The more work is done, the better it will be done , First of all, we must improve our tools . The prerequisite for a good project is to prepare the preliminary work well .
Create a database , After the project is configured , We need to know how to accomplish the five functions we need ?
Because of the complexity of the communication module used in the hardware WIFI modular , Therefore, the communication protocol on the web page must be well-known TCP perhaps UDP It's agreed , So what kind of protocol is used ?
What I'm using here is UDP agreement , because udp It belongs to connectionless transmission protocol , Faster transmission speed , It will not consume too many resources in the process of high-speed refresh request on the web page .
When you click start in the web page , Stop or auto mode button , Will pass udp The protocol is like the specified address and port number OPEN、STOP、AUTO Information about . The hardware determines the rotation mode of the fan based on this information .
Hardware end pass WiFi The module will change the temperature 、 Speed and other information are sent to django backstage , The background writes this information to the database , When a high-speed refresh web page requests to receive the information sent by the hardware , When our web page changes information every two seconds , It is equivalent to storing a set of data every two seconds , It won't take long , The database will not be able to support , So we need to limit the amount of data stored .