Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The existing home control system mostly depends on a home intelligent gateway, the home intelligent gateway is connected with an internal network and an external network of a home, all home devices are connected with the home intelligent gateway in a wired or wireless mode, the home intelligent gateway carries out centralized management and decentralized control on all home devices through the internal network, and a user can realize remote control and view information of the home devices through the external network.
However, the above manner requires additional setting of the home intelligent gateway, and the setting cost of the home control system is high.
In order to solve the above problems, the present inventors propose a home control system, a home control method, an electronic device, and a storage medium, the home control system including: a plurality of home devices and servers; wherein at least one of the plurality of home devices belongs to a sensing type, and at least one of the plurality of home devices belongs to a controlled type; at least one home device in the plurality of home devices is used as gateway equipment; the home equipment belonging to the perception type is used for acquiring environment data, determining initial transmission data according to the environment data and sending the initial transmission data to the gateway equipment; the gateway equipment is used for receiving the initial transmission data, generating target transmission data according to the initial transmission data, determining whether the gateway equipment is a main gateway equipment according to the gateway ordering relation, and processing the target transmission data according to the determination result; the server is used for receiving the target transmission data and determining target control equipment and control instructions according to the target transmission data and preset control rules; the server is also used for sending a control instruction to the target control equipment so that the target control equipment executes the control instruction; the target control equipment belongs to controlled household equipment. According to the method and the device, the home equipment can be used as gateway equipment to send target transmission data to the server, the cost of additionally arranging the intelligent gateway is saved, the gateway equipment receives initial transmission data and then uniformly sends the initial transmission data to the server by the main gateway equipment, the number of repeated data received by the server is reduced, operation resources are saved, the occupation of bandwidth is reduced, and the data processing efficiency is greatly improved.
Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a home control system according to an embodiment of the present application. As shown in fig. 1, the home control system 100 in fig. 1 includes: a plurality of home devices 110 and a server 120.
In some implementations, at least one of the plurality of home devices 110 is of a perception type; and at least one home device of the plurality of home devices 110 is of a controlled type; at least one of the plurality of home devices 110 acts as a gateway device 112.
In some embodiments, the home device 111 belonging to the sensing type is used for acquiring environmental data and for determining initial transmission data according to the environmental data; and is used to send initial transmission data to gateway device 112.
In some embodiments, the environmental data is home environmental information acquired by the sensing type home device 111, such as humidity information, etc. in the home environment.
In other embodiments, the environmental data may also be work environment information acquired by the sensing type home device 111, for example, whether the work environment is abnormal, whether the workflow fails, etc.
In some embodiments, the awareness-type home device 111 sends the initial transmission data to the gateway device 112 via short-range communication.
The short-range communication modes include ZigBee, bluetooth, NFC and the like. Alternatively, in the embodiment of the present application, the sensing type home device 111 sends the initial transmission data to the gateway device 112 through the bluetooth communication method is described as an example.
Further, when the sensing-type home device 111 transmits the initial transmission data to the gateway device 112 through the bluetooth communication, the sensing-type home device 111 may perform bluetooth broadcasting at a high frequency, that is, fast broadcasting, in a short time, and the sensing-type home device 111 may broadcast 200 times in 1.5S, for example.
It will be appreciated that many applications of the device require stringent power consumption and will require the device to be in a broadcast mode at all times, when the broadcast frequency is reduced to reduce power consumption, which may be referred to as the device being broadcasting slowly.
The faster the broadcast frequency, the more advantageous the connection, so for quick discovery and connection, preferably, the perceived type of home device 111 can employ quick broadcasting to improve the interference immunity of the broadcast.
In some implementations, the awareness-type home device 111 is also used to: when the environment data accords with the preset sending condition, the initial transmission data is determined according to the environment data, the protocol identification and the equipment identification.
The gateway device 112 is further configured to determine whether the device identifier is a master gateway device corresponding to the device identifier according to the gateway ordering relationship when the protocol identifier belongs to a preset identifier and the device identifier is different from the cached device identifier.
The gateway device 112 is further configured to filter the initial transmission data when the protocol identifier does not belong to a preset identifier, or when the device identifier is the same as the cached device identifier.
In some embodiments, when the protocol identifier does not belong to the preset identifier, the initial transmission data is characterized as not being sent out because the home environment is changed, that is, the environment data meets the preset sending condition, and the gateway device 112 directly filters the initial transmission data.
In some embodiments, when receiving the initial transmission data, the gateway device 112 may determine whether the same initial transmission data is received according to whether the device identifier is the same as the cached device identifier, and it may be understood that the sensing type home device 111 may broadcast multiple times within a period of time, so that the gateway device 112 receives multiple pieces of the same initial transmission data, and thus the same initial transmission data may be filtered according to the above manner, so as to improve data transmission efficiency.
In some embodiments, after receiving the data, the gateway device 112 stores the data in the buffer pool for a period of time, and the time for storing the data in the buffer pool is called as buffer data, and the time for storing the buffer data in the buffer pool can be set according to needs, which is not limited in this application. Thus, if there is cached data in the cache pool of the gateway device 112 with the same device identification as the initial transmission data, i.e., the device identification is the same as the device information of the cached data, the gateway device 112 is characterized as having received the same data, at which point the repeated initial transmission data may be filtered out.
In some embodiments, the protocol identifies a data type used to identify the initial transmission data.
For example, the home device 111 of the sensing type may also send data to the gateway device 112 when accessing the home control system 100, for example, when the home device 111 of the sensing type is paired with the gateway device 112, but the protocol identification in the data is different from the protocol identification in the initially transmitted data.
Illustratively, some of the functions of the gateway device 112 itself also require the use of data sent by the awareness-type home device 111, which is not required to be uploaded to a server, and thus the protocol identification in such data is also different from the protocol identification in the initially transmitted data.
Optionally, the protocol identification is defined as a specific number of two bytes.
In some implementations, the device identification includes one or more of a universally unique identification code (Universally Unique Identifier, UUID), a media access control (Media Access Control, MAC) address, and a device runtime of the home device 110.
Optionally, the device runtime is the system time of the perceived type of home device 111 that sent the initial transmission data.
Optionally, the UUID has a byte length < device runtime a byte length < MAC address. Illustratively, the UUID is two bytes in length, the device runtime is four bytes in length, and the MAC address is six bytes in length, thereby reducing the bluetooth broadcast data space occupied by the device identification at the time of broadcast.
In some embodiments, the environmental data in the initial transmission data is encrypted data, where the sensing-type home device 111 is further configured to obtain the environmental data, encrypt the environmental data according to the device running time, and determine the initial environmental data according to the encrypted environmental data.
Illustratively, the perceived type of home device 111 may encrypt the environmental data by an advanced encryption standard (Advanced Encryption Standard, AES) in a symmetric encryption algorithm, where both encryption and decryption use the same key, which may be 128, 192 or 256 bits in length. AES includes: codebook mode, cipher block chaining mode, calculator mode, cipher feedback mode, output feedback mode.
In some embodiments, the device running time is used as the key of the AES, because the device running time changes in real time, the key also changes in real time, so that encryption security is improved, the byte length of the device running time is far smaller than the required byte length of the key, and the byte length of the bluetooth broadcast is limited, for example, 37 bytes at most, so that the device running time is used as the key of the AES, the data space of the bluetooth broadcast is saved, and the bluetooth broadcast can carry more information.
Further, when the byte length of the device runtime is insufficient, 0 may be appended after the device runtime until the length meets the encryption or encryption requirement.
Referring to fig. 2 again, fig. 2 is a schematic diagram of an encryption flow provided in an embodiment of the present application. As shown in fig. 2, fig. 2 illustrates encryption in the codebook mode, and the encryption flow 200 includes: plaintext block 210, key 220, encryptor 230, and ciphertext block 240.
Specifically, plaintext block 210 includes environmental data, and in some embodiments, plaintext block 210 may further include a cyclic redundancy check (Cyclic Redundancy Check, CRC) corresponding to the environmental data; key 320 is the device runtime of the perceived type of home device; the encryptor 230 is configured to encrypt the plaintext block 210 according to the key 220 to obtain the ciphertext block 240, and it is understood that the ciphertext block 240 may include encrypted environmental data, and may also include encrypted environmental data and an encrypted CRC check code.
Further, when ciphertext block 240 includes encrypted environment data and an encrypted CRC check code, sensing-type home device 111 is further configured to determine initial transmission data based on the encrypted environment data, the protocol identification, the device identification, and the encrypted CRC check code.
In some embodiments, the gateway device 112 is configured to receive the initial transmission data, generate target transmission data according to the initial transmission data, determine whether the gateway device is a primary gateway device according to the gateway ordering relationship, and process the target transmission data according to the determination result.
In some embodiments, the home device 110 with the capability of receiving the initial transmission data may be used as the gateway device 112, and the user may freely set whether the home device that meets the condition is used as the gateway device 112 through the terminal device 130.
In some embodiments, each gateway device 112 maintains a gateway ordering relationship from which each gateway device 112 may determine whether itself is the primary gateway device 1121 when receiving the initial transmission data.
Alternatively, if the gateway device 112 is not the primary gateway device 1121, the gateway device 112 is a normal gateway device 1122, and in the case that the primary gateway device 1121 works normally, the normal gateway device 1122 indirectly communicates with the server through the primary gateway device 1121, so as to reduce the amount of duplicate data received by the server.
In some embodiments, the gateway devices 112 may be wirelessly networked to form a distributed network system through which the gateway devices 112 may communicate with each other to enable the generic gateway device 1122 to send targeted transmission data to the primary gateway device 1121.
Optionally, the gateway device 112 performs wireless networking communication protocols including, but not limited to, transmission control protocol (Transmission Control Protocol, TCP), user datagram protocol (User Datagram Protocol, UDP), bluetooth low energy (Bluetooth Low Energy, BLE).
In some implementations, gateway device 112 is further configured to:
(1) Upon determining itself to be the primary gateway device 1121 from the gateway ordering relationship, the target transmission data is sent to the server 130.
(2) When it is determined that the gateway is not itself the primary gateway device 1121 according to the gateway ranking relationship, the target transmission data is transmitted to the primary gateway device 1121.
Specifically, in the embodiment of the present application, all gateway devices 112 may generate target transmission data according to initial transmission data, and send the target transmission data to the server 130, but if each gateway device 112 receives the initial transmission data and sends the target transmission data to the server 130, the server 130 receives excessive repeated data, resulting in shortage of operation resources of the server 130, and the repeated data sending may occupy bandwidth and affect transmission of other effective data, so in the present application, one or more main gateway devices 1121 are determined according to the gateway ordering relationship, only the main gateway device 1121 sends the target transmission data to the server, thereby reducing the number of the repeated data received by the server 130, saving operation resources, reducing occupation of bandwidth, and greatly improving the efficiency of data processing.
Preferably, the number of primary gateway devices 1121 is one.
In some implementations, gateway device 112 is further configured to:
(1) When determining that the slave gateway device is not the master gateway device 1121 according to the gateway ordering relation, if the success information sent by the master gateway device 1121 is not received within the first preset time period from the initial transmission data is received, determining the slave gateway device according to the gateway ordering relation, and sending the target transmission data to the slave gateway device.
(2) When determining that the gateway ordering relation is not the main gateway equipment 1121, if the success information sent by the main gateway equipment 1121 is received within the first preset time from the initial transmission data is received, destroying the target transmission data after the second preset time from the initial transmission data is received; the second preset time length is greater than or equal to the first preset time length.
In some embodiments, when the primary gateway device 1121 sends the target transmission data to the server 130, it sends success information to all the ordinary gateway devices 1122, or sends success information to the ordinary gateway devices 1122 that sent the target transmission data separately, so as to notify the ordinary gateway devices 1122 that the target transmission data has been sent successfully, without repeated sending.
Therefore, if the normal gateway device 1122 does not receive the success information sent by the main gateway device 1121 within the first preset duration from the initial transmission data reception, it represents that the main gateway device 1121 fails to send the target transmission data, and the target transmission data needs to be sent to the server 130 by the slave gateway device to avoid the transmission omission of the target transmission data, and after the slave gateway device receives the target transmission data, the slave gateway device sends the target transmission data to the server 130, that is, after the transmission failure of the main gateway device 1121, the slave gateway device performs the function of the main gateway device 1121, so as to prevent the server 130 from not timely controlling the home system due to the transmission failure of the target transmission data, so that the home system has a potential safety hazard.
In some implementations, gateway device 112 is further configured to:
(1) When determining that the gateway ordering relation is not the master gateway device 1121, if the success information sent by the master gateway device 1121 is not received within a first preset time period from the initial transmission data reception, and the gateway ordering relation determines that the gateway ordering relation is the slave gateway device, the target transmission data is sent to the server 130.
Specifically, if the master gateway device 1121 fails to transmit and is itself a slave gateway device, it transmits the target transmission data to the server 130.
It is understood that the slave gateway devices are one or more of the common gateway devices 1122.
Further, the slave gateway device may also be determined according to a gateway ordering relationship.
Alternatively, the success information includes configuration information of the home device 111 of the perceived type that transmitted the initial transmission data and valid data in the initial transmission data, so that the ordinary gateway device 1122 can determine whether or not it needs to transmit the target transmission data to the slave gateway device itself based on the success information.
Optionally, the configuration information of the sensing-type home device 111 includes a MAC address and a device type of the sensing-type home device 111.
Optionally, the valid data in the initial transmission data includes at least the environment data.
In some embodiments, the server 120 is configured to receive the target transmission data, and the server 120 is further configured to determine the target control device 113 and the control instruction according to the target transmission data and the preset control rule; the server is further configured to send a control instruction to the target control device 113, so that the target control device 113 executes the control instruction; the target control device 113 belongs to a controlled home device.
Further, although the target control device 113 is illustrated as a separate module in fig. 1, the target control device 113 may be the sensing type home device 111 or the gateway device 112 at the same time.
In some implementations, the server 120 may send control instructions to the target control device 113 via an internet of things protocol. Optionally, the internet of things protocol includes a message queue telemetry transport protocol (Message Queuing Telemetry Transport, MQTT), a transmission control protocol (Transmission Control Protocol, TCP), and the like.
Illustratively, the internet of things protocol is illustrated as the MQTT protocol, which is a "lightweight" communication protocol based on a publish/subscribe mode. In the communication process, three identities exist in the MQTT protocol: publishers (publishes), brokers (Broker), subscribers (subscribers).
In one embodiment of the present application, both the publisher and the subscriber are home devices, and the publisher may be both subscribers and the proxy is a server. The messages transmitted by the MQTT are divided into: topic (Topic) and load (payload), the Topic is the type of the message, and after subscribing, the subscriber receives the message of the Topic; the load, i.e. the content of the message, contains a certain load.
Further, the target control device 113 subscribes to a unique topic, which may be issued by the server 120 when configuring the network for the target control device 113, and when the server 120 issues a control instruction to the topic, the target control device subscribed to the topic receives the control instruction to perform a corresponding operation.
In some embodiments, if the sensing-type home device 110 encrypts the initial transmission data, the server 130 needs to decrypt the initial transmission data, where the server 130 is further configured to:
(1) Environmental data and device runtime are determined from the initial transmission data.
(2) Decrypting the environmental data based on the device runtime, and determining the decrypted environmental data.
(3) And determining target control equipment and control instructions according to the decrypted environment data and preset control rules.
Referring to fig. 3 again, fig. 3 is a schematic diagram of a decryption flow provided in an embodiment of the present application. As shown in fig. 3, fig. 3 illustrates decryption in the codebook mode, and the decryption flow 300 includes: ciphertext block 310, key 320, decryptor 330, and plaintext block 340.
Specifically, ciphertext block 310 may include initial environmental data, the initial transmission data may include encrypted environmental data, and in some embodiments, ciphertext block 310 may further include an encrypted cyclic redundancy check (Cyclic Redundancy Check, CRC) corresponding to the encrypted environmental data; key 320 is the device runtime of the perceived type of home device; decryptor 330 is configured to decrypt ciphertext block 310 based on key 320 to obtain plaintext block 340.
Further, when the plaintext block 340 includes a CRC check code and decrypted environmental data, the server is further configured to determine whether the environmental data is complete according to the CRC check code, and when the environmental data is complete, the re-executing step determines the target control device and the control command according to the decrypted environmental data and a preset control rule, so as to prevent the risk of the server determining the wrong target control device when the environmental data is missing during the transmission process.
For example, when the sensing type home device has a temperature sensing function, the target control device may be a fan heater, and the control instruction may be a temperature raising instruction; when the sensing type household equipment is all switches in the household, the target control equipment can be household equipment linked with the switches, for example, the switches are lamp switches, the target control equipment can be lamps controlled by the switches, and the control instructions can be lamp on instructions; when the sensing type household equipment is a door magnet, the target control equipment can be the household equipment which is working in the area corresponding to the door magnet, and the control instruction can be a stop instruction; when the sensing type household equipment has a human body sensing function, the target control equipment can be a Bluetooth sound box, and the control instruction can be a music playing instruction.
Optionally, in order to enable a user to set up or control the home control system 100, the home control system 100 further includes a terminal device 130.
The terminal device 130 is configured to send the offline information to the gateway device 112.
The gateway device 112 is further configured to send a offline notification to the other gateway devices 112 when receiving the offline information; wherein the offline notification includes a gateway identification of gateway device 112.
The gateway device 112 that received the down notification is configured to determine a gateway identification based on the down notification, and the gateway device 112 corresponding to the gateway identification is deleted from the gateway ordering relationship to update the gateway ordering relationship.
Optionally, the gateway identification includes information of the MAC address, UUID, etc. of the gateway device 112.
Alternatively, the gateway device 112 may send the offline notification to the remaining gateway devices 112 in accordance with a user datagram protocol (User Datagram Protocol, UDP) multicast.
In particular, UDP multicast is a one-to-many communication mode between hosts, a technique that allows one or more multicast sources to send the same message to multiple receivers.
The multicast source in the UDP multicast communication mode sends a message to a specific multicast address, the multicast address does not belong to a specific host, but belongs to a group of hosts, one multicast address represents a group, and receivers needing to receive the multicast message sent by the multicast source all join the group, so that a plurality of receivers all receive the information sent by the multicast source.
Referring to fig. 4 and fig. 5, fig. 4 is another schematic structural diagram of a home control system provided in an embodiment of the present application, and fig. 5 is a schematic diagram of a gateway ordering relationship provided in an embodiment of the present application.
In the home control system shown in fig. 4, the broadcasting range of the sensing type home device a includes gateway device a, gateway device B, gateway device C, and gateway device D, that is, when the sensing type home device a performs bluetooth broadcasting to send initial transmission data, all the four gateway devices can receive the initial transmission data sent by the sensing type home device a.
The broadcasting range of the sensing type home device B includes gateway device D and gateway device E, that is, when the sensing type home device B performs bluetooth broadcasting to send initial transmission data, both the gateway devices can receive the initial transmission data sent by the sensing type home device B.
Optionally, all gateway devices are ranked according to the network factors in the gateway ranking relationship 400, and each gateway device corresponds to a ranking factor, so that the gateway ranking relationship 400 ranks the gateway devices in order from top to bottom in order of the ranking factors from top to bottom; the network factor reflects the network quality of the gateway device, and the ranking factor may be a specific value of the network factor.
Illustratively, when the network factor is network delay, the ordering factor of gateway device a is 20ms.
In fig. 5, therefore, the gateway device with the optimal network factor is gateway device a, so that gateway device a is a master gateway device, and after receiving initial transmission data sent by the sensing type home device a or the sensing type home device B, the rest gateway devices generate target transmission data according to the initial transmission data, and send the initial transmission data to gateway device a.
Further, if the gateway device whose network factor is next to the master gateway device is determined as the slave gateway device, the slave gateway device is gateway device D in fig. 5.
It will be appreciated that gateway device a illustrated in fig. 5 may be represented by a gateway identification of gateway device a, and so on.
Further, if the terminal device controls the gateway device D to be disconnected, the gateway device D sends a disconnection notification to the rest of the gateway devices in a UDP multicast manner, and the gateway device that receives the disconnection notification determines a gateway identifier of the gateway device D according to the disconnection notification, and deletes the gateway device corresponding to the gateway identifier in the gateway ordering relationship, so as to update the gateway ordering relationship.
Finally, referring to fig. 6, fig. 6 is a schematic diagram of another gateway ordering relationship according to an embodiment of the present application. As shown in fig. 6, after the gateway device D sends the offline notification, the gateway ordering relationship stored in each gateway device that receives the offline notification is shown in fig. 6, and in the gateway ordering relationship 500 shown in fig. 6, because the gateway device D is offline, the gateway device D is deleted from the gateway ordering relationship 500 stored in each gateway device that receives the offline notification.
At this time, if the gateway device that still has the network factor inferior to the master gateway device is determined to be the slave gateway device, the slave gateway device is the gateway device E after the gateway device D is disconnected.
In some embodiments, the terminal device 130 is also configured to send the presence information to the gateway device 112.
The gateway device 112 is further configured to send an online notification to the other gateway devices 112 when the online information is received; wherein the online notification includes the first ranking factor of gateway device 112 and the first gateway identification.
The gateway equipment 112 which receives the online notification updates the gateway ordering relation stored by itself according to the first ordering factor and the first gateway identification; and transmits its own second ranking factor and second gateway identification to gateway device 112 which transmitted the online notification.
The gateway device 112 that transmits the online information is further configured to determine a gateway ordering relationship according to the first ordering factor, the first gateway identifier, all the second ordering factors, and the second gateway identifier corresponding to each second ordering factor.
For example, when the gateway device D in fig. 4 is in the down state, it is assumed that the gateway ordering relationship stored by each gateway device 112 is shown in fig. 6, and when the gateway device D in fig. 4 is turned from the down state to the up state, the gateway device D performs a network test to determine its first ordering factor, and sends the first ordering factor and the first gateway identifier to the gateway device a, the gateway device B, the gateway device C and the gateway device E, so that the gateway device updates the gateway ordering relationship stored by itself according to the first ordering factor and the first gateway identifier, and the updated gateway ordering relationship may be shown in fig. 5.
And after receiving the online notification sent by the gateway device D, the gateway device a sends the second ordering factor and the second gateway identifier of the gateway device a to the gateway device D, and the gateway device B sends the second ordering factor and the second gateway identifier of the gateway device B to the gateway device D, and so on, so that the gateway device D determines the gateway ordering relationship according to the first ordering factor, the first gateway identifier, all the second ordering factors and the second gateway identifiers corresponding to each second ordering factor, and the gateway ordering relationship finally determined by the gateway device D can be shown in fig. 5.
Optionally, after the gateway device is turned from the down state to the on state, the gateway device starts a local area network device discovery function, and the local area network device discovery function may be implemented by using a UDP multicast mode, and the gateway device having the same function may discover the gateway device having the same function through the local area network device discovery function, and send an on-line notification to the gateway device having the same function.
The gateway device sending the online notification is defined as an online gateway, the gateway device receiving the online notification is a reply gateway, and if one reply gateway has the capability of analyzing a broadcast packet which is sent by the online gateway and contains a network factor and a gateway identifier of the online gateway and can reply the broadcast packet which contains the network factor and the gateway identifier of the online gateway, the reply gateway and the online gateway are considered to be gateways with the same function.
In some embodiments, each gateway device maintains a terminal network information table, and in the same lan, the terminal network information table maintained by each gateway device is the same, through which the online gateway can know which gateway devices exist in the current lan, and can send an online notification to all gateway devices.
Referring to fig. 7 again, fig. 7 is a flow chart of a home control method according to an embodiment of the present application. As shown in fig. 7, the home control method 600 includes: step 610 to step 640.
Step 610: initial transmission data is received.
Optionally, the initial transmission data includes environmental data acquired by the sensing type home device.
For example, when the sensing type home device has a temperature sensing function, the environmental data may be temperature data; when the sensing type home equipment is each switch in the home, the environment data can be the switch state of each switch.
Step 620: and generating target transmission data according to the initial transmission data.
In some embodiments, after receiving the initial transmission data, the gateway device determines the environment data, the protocol identifier and the device identifier according to the initial transmission data, and then processes the environment data, the protocol identifier and the device identifier according to a target communication protocol used by the gateway device to communicate with the server, so as to generate target transmission data.
Alternatively, the target communication protocol used by the gateway device to communicate with the server may be the hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) or MQTT protocol.
Step 630: and determining whether the gateway is the master gateway device according to the gateway ordering relation.
Optionally, the gateway ordering relationship may include ordering of all gateway devices according to the network factor, or ordering of the gateway devices according to the number of broadcast packets broadcast by the sensing type home devices that can be received by the gateway devices.
Alternatively, the user may also manually set the gateway ordering relationship.
The number of broadcast packets broadcast by the sensing type home devices that can be received by the gateway device depends on how many sensing type home devices the gateway device is located within.
In some embodiments, the gateway ordering relationship includes an ordering condition that orders all gateway devices according to a network factor that characterizes network quality of the gateway devices, step 630 includes the following steps.
(1) And determining whether the network equipment is the network equipment with the optimal network quality in all gateway equipment according to the ordering condition, and if so, determining the network equipment to be the main gateway equipment.
Further, the gateway device with the suboptimal network factor is determined as the slave gateway device, i.e. the slave gateway device is the gateway device with the network quality inferior to that of the master gateway device.
Optionally, when the master gateway device fails to send the target transmission data, that is, the gateway device sending the target transmission data to the master gateway device does not receive the success information sent by the master gateway device within the first preset time period from receiving the initial transmission data, the gateway device sends the target transmission data to the slave gateway device, and the slave gateway device sends the target transmission data to the server.
If the slave gateway device also fails to transmit, the gateway device may transmit the target transmission data to a secondary slave gateway device of the slave gateway device, where the secondary slave gateway device is a gateway device having network quality inferior to that of the slave gateway device.
When the secondary gateway device also transmits a failure, the processing manner is similar to that described above.
In some implementations, the network factors include at least one of packet loss rate, network delay, network connection rate.
Optionally, each gateway device checks the packet loss rate and the network delay between itself and the router or the switch through the ping command (Packet Internet Groper) every preset detection time, which indicates that the better the link between the gateway device and the router or the switch is, the better the network quality is.
Specifically, ping is a procedure for testing network connection quantity, and is also a network quality detection method commonly used in networks, where a gateway device sends a network datagram control protocol (Internet Control Messages Protocol, ICMP) by using a ping command, and a receiving end generates an ICMP echo response after receiving the ICMP, and through this procedure, it can determine whether two network machines are connected, and the packet loss rate and network delay between the two network machines.
Optionally, the gateway device may directly obtain the corresponding hardware parameter from the network card driving layer, and determine the network connection rate of the gateway device according to the hardware parameter. For example, the hardware parameters include a 100Mbps network card, a 1000Mbps network card, wifi6, wifi2.4g, etc., and the better the above hardware parameters, the faster the network connection rate of the gateway device, and therefore, the better the network quality.
Specifically, different network quality scores may be preset for each sub-parameter in the hardware parameters, where the higher the network quality score is, the faster the network connection rate of the gateway device with the sub-parameter is, so as to determine the total network quality score of the hardware parameters according to the network quality score of each sub-parameter, and order each gateway device according to the total network quality score.
Optionally, when ordering the gateway device according to the network factor, the ordering priority of the packet loss rate is higher than the ordering priority of the network delay, and the ordering priority of the network delay is higher than the ordering priority of the network connection rate.
That is, all gateway devices are preferably ordered according to the packet loss rate, network delay is considered when the packet loss rate is the same, and network connection rate is considered when the network delay is the same.
Step 640: and processing the target transmission data according to the determined result.
In some embodiments, step 640 includes the following steps.
(1) And when the gateway ordering relation determines that the gateway is the main gateway equipment, sending target transmission data to the server.
(2) And when the gateway ordering relation determines that the gateway ordering relation is not the main gateway equipment, sending target transmission data to the main gateway equipment.
Specific details are set forth in the foregoing description and are not repeated here.
In some embodiments, step 640 includes the following steps.
(1) When the gateway ordering relation determines that the gateway ordering relation is not the main gateway equipment, if the success information sent by the main gateway equipment is not received within the first preset time period from the initial transmission data receiving, the auxiliary gateway equipment is determined according to the gateway ordering relation, and the target transmission data is sent to the auxiliary gateway equipment.
(2) When the gateway ordering relation determines that the target transmission data is not the main gateway equipment, if the success information sent by the main gateway equipment is received within the first preset time from the initial transmission data is received, destroying the target transmission data after the second preset time from the initial transmission data is received; the second preset time length is greater than or equal to the first preset time length.
Specific details are set forth in the foregoing description and are not repeated here.
Optionally, the gateway device may send the target transmission data to the queue to be destroyed, where the data sent to the queue to be destroyed is automatically destroyed after receiving the second preset time period from the initial transmission data.
Optionally, the first preset duration has a value in the range of 8S,12S, preferably 10S.
Optionally, the second preset duration has a value in the range of [18S,22S ], preferably 20S.
In some implementations, the home control method 600 provided in the embodiments of the present application further includes the following steps.
(1) And when receiving the target transmission data sent by the other gateway equipment, carrying out integrity check and sending detection on the target transmission data.
(2) And when the integrity check result is that the data is complete and the transmission detection result is that the transmission is not performed, transmitting the target transmission data to the server.
Optionally, the gateway device may perform integrity check on the target transmission data by using a CRC check code in the target transmission data.
Optionally, the gateway device may also perform integrity check on the target transmission data by means of accumulation and check.
Optionally, when the gateway device sends the target transmission data to the server, the target transmission data is marked with a sending middle label, after the sending is successful, the target transmission data is marked with a sending success label, and the target transmission data with the sending middle label and the target transmission data with the sending success label are cached in the cache pool at the same time.
Therefore, after the gateway device receives the target transmission data to be sent to the server, it will first determine whether there is the same target transmission data with the sending tag and the sending success tag in the buffer pool, if there is, the sending detection result is sent or is sending, if there is no, the sending detection result is not sending.
Optionally, if the integrity check result is incomplete data or the transmission detection result is transmitted or is being transmitted, the gateway device may send the target transmission data to the queue to be destroyed for destruction.
Optionally, the gateway device only backs up the last successful target transmission data in the buffer pool, and deletes the old target transmission data backed up in the buffer pool after the new target transmission data is successfully transmitted.
By the method, the main gateway equipment can filter the target transmission data, when a plurality of common gateway equipment sends the same target transmission data to the main gateway equipment, the main gateway equipment successfully sends the target transmission data to the server, and the target transmission data is backed up in the cache pool by the successful sending label, so that the main gateway equipment does not send the same target transmission data to the server any more, the data quantity received by the server is reduced, the operation resources of the server are saved, the occupation of bandwidth is reduced, and the data processing efficiency is greatly improved.
In some embodiments, the gateway device also needs to actively send heartbeat information to the rest of the gateway devices to maintain online status.
At this time, the home control method 600 provided in the embodiment of the present application further includes the following steps.
(1) Sending heartbeat information to other gateway equipment in a preset period; wherein the heartbeat information includes its own gateway identification and ranking factor.
(2) And the gateway equipment receiving the heartbeat information updates the gateway ordering relation stored by the gateway equipment according to the gateway identification and the ordering factor in the heartbeat information.
Specifically, in order to ensure real-time update of the gateway ordering relationship, each gateway device sends heartbeat information to the rest of gateway devices in a preset period, wherein the heartbeat information includes own gateway identification and ordering factors so as to enable the rest of gateway devices to update the gateway ordering relationship.
In some embodiments, in order to prevent the gateway device from being passively disconnected due to power outage or the like, the home control method 600 provided in the embodiments of the present application further includes the following steps.
(1) The gateway device that received the heartbeat information records the latest reception time of the heartbeat information.
(2) And deleting gateway equipment corresponding to the gateway identification in the heartbeat information in the gateway ordering relation stored by the gateway ordering relation if the heartbeat information is not received again within a preset time interval from the latest receiving time so as to update the gateway ordering relation.
Specifically, the preset time interval is greater than a preset period in which the gateway device transmits heartbeat information.
Optionally, the preset period has a value of 1min and 2min
By the method, when the main gateway equipment is suddenly disconnected, failure of sending the target transmission data caused by the fact that the main gateway equipment cannot be timely determined again can be prevented, and safety of a home system is guaranteed.
Referring to fig. 8 again, fig. 8 is a flow chart of another home control method according to an embodiment of the present disclosure. As shown in fig. 8, the home control method is applied to the home control system described above, and the home control method 700 includes: steps 710 through 730.
Step 710: the home equipment belonging to the perception type is used for acquiring environment data, determining initial transmission data according to the environment data and sending the initial transmission data to the gateway equipment.
Step 720: the gateway equipment receives the initial transmission data, generates target transmission data according to the initial transmission data, determines whether the gateway equipment is the main gateway equipment according to the gateway ordering relation, and processes the target transmission data according to the determination result.
Step 730: the server receives the target transmission data and determines target control equipment and a control instruction according to the target transmission data and a preset control rule; the server sends a control instruction to the target control equipment so that the target control equipment executes the control instruction; the target control equipment belongs to controlled household equipment.
The details of steps 710 to 730 are described in the above portions of the specification, and are not repeated here.
The application provides a home control system, a home control method, electronic equipment and a storage medium, wherein the home control system comprises: a plurality of home devices and servers; wherein at least one of the plurality of home devices belongs to a sensing type, and at least one of the plurality of home devices belongs to a controlled type; at least one home device in the plurality of home devices is used as gateway equipment; the home equipment belonging to the perception type is used for acquiring environment data, determining initial transmission data according to the environment data and sending the initial transmission data to the gateway equipment; the gateway equipment is used for receiving the initial transmission data, generating target transmission data according to the initial transmission data, determining whether the gateway equipment is a main gateway equipment according to the gateway ordering relation, and processing the target transmission data according to the determination result; the server is used for receiving the target transmission data and determining target control equipment and control instructions according to the target transmission data and preset control rules; the server is also used for sending a control instruction to the target control equipment so that the target control equipment executes the control instruction; the target control equipment belongs to controlled household equipment. According to the method and the device, the home equipment can be used as gateway equipment to send target transmission data to the server, the cost of additionally arranging the intelligent gateway is saved, the gateway equipment receives initial transmission data and then uniformly sends the initial transmission data to the server by the main gateway equipment, the number of repeated data received by the server is reduced, operation resources are saved, the occupation of bandwidth is reduced, and the data processing efficiency is greatly improved.
Referring to fig. 9 again, fig. 9 is a schematic structural diagram of a home control device according to an embodiment of the present disclosure. As shown in fig. 9, the home control device is applied to the gateway apparatus, and the home control device 800 includes: a receiving unit 810, a generating unit 820, a determining unit 830, and a processing unit 840.
A receiving unit 810 for receiving the initial transmission data.
A generating unit 820 for generating target transmission data from the initial transmission data.
A determining unit 830, configured to determine whether the gateway device is a primary gateway device according to the gateway ordering relationship.
And a processing unit 840 for processing the target transmission data according to the determination result.
It should be noted that, for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and the relevant points are referred to in the description of the method embodiment. Any of the described processing manners in the method embodiment may be implemented by a corresponding processing module in the device embodiment, which is not described in detail in the device embodiment.
In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 10, the electronic device 900 includes: one or more processors 910, and a memory 920, one processor 910 being illustrated in fig. 10.
The processor 910 and the memory 920 may be connected by a bus or otherwise, for example in fig. 10.
A processor 910 for receiving initial transmission data; generating target transmission data according to the initial transmission data; determining whether the gateway is a master gateway device according to the gateway ordering relation; and processing the target transmission data according to the determined result.
The memory 920 is used as a non-volatile computer readable storage medium for storing non-volatile software programs, non-volatile computer executable programs, and modules, such as program instructions/modules of the home control method in the embodiments of the present application. The processor 910 executes various functional applications and data processing of the electronic device by running nonvolatile software programs, instructions and modules stored in the memory 920, that is, implements the home control method of the above-described method embodiment.
Memory 920 may include a storage program area that may store an operating system, at least one application required for functionality, and a storage data area; the storage data area may store data created according to the use of the electronic device, etc. In addition, memory 920 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 920 may optionally include memory located remotely from processor 910, which may be connected to the controller via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
One or more modules are stored in memory 920 that, when executed by one or more processors 910, perform the home control method in any of the method embodiments described above, for example, performing method steps 610 through 640 in fig. 7 described above.
Referring to fig. 11, fig. 11 is a block diagram illustrating a computer readable storage medium according to an embodiment of the present application. The computer-readable storage medium 1000 has stored therein program code 1010, the program code 1010 being executable by a processor to perform the home control method described in the above method embodiments.
The computer readable storage medium 1000 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium comprises a non-volatile computer readable medium (non-transitory computer-readable storage medium). The computer readable storage medium 1000 has storage space for program code to perform any of the method steps in the home control method described above. The program code can be read from or written to one or more computer program products. The program code may be compressed, for example, in a suitable form.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the invention, the steps may be implemented in any order, and there are many other variations of the different aspects of the invention as above, which are not provided in details for the sake of brevity; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention. From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, but may also be implemented by means of hardware. Those skilled in the art will appreciate that a program implementing all or part of the above-described embodiment method steps can be implemented by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium, and the program can include the above-described embodiment method steps when executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.