Data communication method and system, electronic equipment and storage medium
By broadcasting election multicast information in the local area network to determine the target central node and synchronize scene mode data, the dependence of smart home systems on the cloud is resolved, enabling normal operation in the event of network failure or cloud downtime, and improving the stability and applicability of the system.
Patent Information
- Application Number
- CN202511406983.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2026-01-06
AI Technical Summary
In current smart home scenarios, the control of home devices relies heavily on the cloud, which leads to the paralysis of smart home systems when there is a network failure or the cloud server goes down, resulting in poor applicability.
By broadcasting election multicast information in the local area network, the target central node is determined, and scene mode data is synchronized within the local area network, reducing dependence on the cloud and realizing autonomous control between nodes.
Even in the event of network failure or cloud server downtime, the smart home system can still operate normally, improving the system's stability and applicability.
Smart Images

Figure CN121283791A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart homes, and in particular to a data communication method, system, electronic device, and storage medium. Background Technology
[0002] Smart home is a system that uses a residence as a platform and integrates facilities related to home life through technologies such as integrated wiring, network communication, automatic control, and audio-visual technology to build an efficient management system for residential facilities and daily household affairs.
[0003] In existing technologies, when switching scene modes in a smart home scenario, the main method is to send a scene switching command from the terminal to the cloud, and then the cloud sends relevant control commands to each smart home device.
[0004] It can be seen that the existing methods for controlling home devices in smart home scenarios rely heavily on the cloud. Therefore, when there is a network failure or the cloud server goes down, the smart home system will be paralyzed, resulting in poor applicability of the smart home system. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing a data communication method, system, electronic device, and storage medium that can reduce the dependence of smart home scenarios on the cloud and improve the stability and applicability of smart home systems.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows:
[0007] In a first aspect, the present invention provides a data communication method applied to a target central node in a data communication system. The data communication system includes a router and multiple central nodes mounted on the router. The multiple central nodes are located in the same local area network (LAN). At least some of the central nodes are equipped with at least one first sub-device. The multiple central nodes include at least one of the following: a gateway device, a Wi-Fi device, and a wired device. The method includes:
[0008] The target central node broadcasts a first election multicast message in the local area network and receives a second election multicast message broadcast by other central nodes in the local area network. The first election multicast message carries the central capability information of the target central node, and the second election multicast message carries the central capability information of the other central nodes.
[0009] The target central node determines whether it is the target main central node based on the first election multicast information and the second election multicast information;
[0010] If the target central node is determined to be the target primary central node and the other central nodes are target backup central nodes, then the target central node receives the first unicast join information sent by each of the target backup central nodes, and synchronizes the first scene mode data to at least some of the target backup central nodes according to the first unicast join information and the first scene mode instruction, so that at least some of the target backup central nodes can switch states according to the first scene mode data.
[0011] In an optional implementation, the method further includes:
[0012] If the target central node is determined to be the target backup central node and the first central node among the other central nodes is the target primary central node, then the target central node sends a second unicast join information to the target primary central node, so that the target primary central node synchronizes the second scene mode data to the target central node according to the second unicast join information and the second scene mode instruction, and the target central node performs a state switch according to the second scene mode data.
[0013] In an optional implementation, determining whether the target central node is the target primary central node based on the first election multicast information and the second election multicast information includes:
[0014] Based on the first election multicast information and the second election multicast information, determine whether the target central node is a candidate main central node;
[0015] If the target central node is determined to be a candidate primary central node and the other central nodes are candidate backup central nodes, then the target central node broadcasts a challenge multicast message in the local area network so that each of the candidate backup central nodes challenges the candidate primary central node according to the challenge multicast message.
[0016] Wherein, if the target candidate backup central node among the candidate backup central nodes is successfully challenged, then the target candidate backup central node becomes the target main central node, and the target central node and other candidate backup central nodes become the target backup central node; if all the candidate backup central nodes fail to be challenged, then the candidate backup central node becomes the target backup central node, and the target central node becomes the target main central node.
[0017] In an optional implementation, if the target candidate hub node among the candidate backup hub nodes is successfully challenged, the method further includes:
[0018] The target central node scans and discovers the target primary central node, sends a third unicast join information to the target primary central node, and broadcasts central node switching information to the local area network, so that other candidate backup central nodes scan and discover the target primary central node based on the central node switching information, and send a third unicast join information to the target primary central node.
[0019] In an optional implementation, the data communication system further includes a cloud, and each of the central nodes communicates with the cloud through the router;
[0020] If the target central node is determined to be the primary target central node and the other central nodes are backup target central nodes, the method further includes:
[0021] The target main central node sends communication topology information to the cloud, so that the cloud sends the first scene mode data to the target main central node based on the communication topology information according to the first scene mode instruction sent by the terminal device.
[0022] The communication topology information includes: node information of the target primary hub node, node information of each target backup hub node, device information of each first sub-device mounted on the target primary hub node, and device information of each first sub-device mounted on each target backup hub node.
[0023] In an optional implementation, the router is further equipped with at least one slave device and / or at least one slave gateway, each slave device and / or each slave gateway having a communication connection with each of the central nodes, and each slave gateway having at least one second sub-device.
[0024] Each slave device and / or each slave gateway is configured to run a master node discovery service upon startup. The master node discovery service is used to receive challenge multicast information broadcast by the target master node, and send a fourth unicast join information to the target master node according to the challenge multicast information. The fourth unicast join information includes: device information of each slave device and / or gateway information of each slave gateway.
[0025] In an optional implementation, the target primary hub node is configured to communicate with each of the target backup hub nodes based on a heartbeat mechanism. If it is determined that the communication connection of the target primary hub node has timed out, the multiple target backup hub nodes are configured to re-elect a new target primary hub node according to a preset election mechanism and a preset challenge mechanism.
[0026] In an optional implementation, the target master hub node is further configured to communicate with each slave device and / or each slave gateway based on a heartbeat mechanism. After synchronizing the first scene mode data to the target backup hub node according to the first unicast join information, so that the target backup hub node controls the working status of each attached first sub-device according to the first scene mode data, the method further includes:
[0027] If the target slave device and / or target slave gateway connection timeout is determined, the target master central node deletes the target device information of the target slave device and / or the target gateway information of the target slave gateway.
[0028] In a second aspect, the present invention provides a data communication system, comprising: a router, and a plurality of central nodes mounted on the router, wherein the plurality of central nodes are located in the same local area network, and at least some of the central nodes are mounted with at least one first sub-device, wherein each of the central nodes is used to execute the data communication method described in any of the foregoing embodiments.
[0029] Thirdly, the present invention provides an electronic device, comprising: a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of any of the data communication methods described in the foregoing embodiments.
[0030] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of any of the data communication methods described in the foregoing embodiments.
[0031] The beneficial effects of this application are:
[0032] The data communication method provided in this application is applied to a target central node in a data communication system. The data communication system includes a router and multiple central nodes mounted on the router. The multiple central nodes are located in the same local area network (LAN). At least some of the central nodes are equipped with at least one first sub-device. The multiple central nodes include at least one of the following: a gateway device, a Wi-Fi device, and a wired device. The method includes: the target central node broadcasting first election multicast information in the LAN and receiving second election multicast information broadcast by other central nodes in the LAN. The first election multicast information carries the central capability information of the target central node, and the second election multicast information carries the central capability information of the other central nodes. The target central node then adjusts its configuration according to the first election multicast information. The second election multicast information is used to determine whether the target central node is the target primary central node. If the target central node is determined to be the target primary central node and the other central nodes are target backup central nodes, the target central node receives the first unicast join information sent by each target backup central node, and synchronizes the first scene mode data to the target backup central nodes according to the first unicast join information and the first scene mode instruction, so that the target backup central nodes can switch states according to the first scene mode data. This can reduce the dependence of smart home scenarios on the cloud, and ensure the normal operation of the smart home system even if there is a network failure or the cloud server crashes, which can improve the stability of the smart home system. In addition, this application does not limit the type of central node, which can improve the applicability and applicability of the method of this application. Attached Figure Description
[0033] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A schematic diagram of a data communication system provided in an embodiment of this application;
[0035] Figure 2 A flowchart illustrating a data communication method provided in an embodiment of this application;
[0036] Figure 3 A flowchart illustrating another data communication method provided in an embodiment of this application;
[0037] Figure 4 A flowchart illustrating another data communication method provided in an embodiment of this application;
[0038] Figure 5A timing diagram illustrating a data communication method provided in an embodiment of this application;
[0039] Figure 6 A flowchart illustrating another data communication method provided in an embodiment of this application;
[0040] Figure 7 A schematic diagram of a heartbeat mechanism provided in an embodiment of this application;
[0041] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0043] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0044] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0045] In related technologies, when switching scene modes in a smart home scenario, the main method involves the terminal sending a scene switching command to the cloud, which then sends relevant control commands to each smart home device. Therefore, existing smart home device control methods heavily rely on the cloud, and network failures or cloud server outages can lead to system paralysis, resulting in poor system applicability.
[0046] In view of this, embodiments of this application provide a data communication method that can be applied to smart home systems. This method can reduce the dependence of smart home scenarios on the cloud and ensure the normal operation of the smart home system even in the event of network failure or cloud server downtime, thereby improving the stability of the smart home system. Furthermore, this application does not limit the type of central node, which can improve the applicability and applicability of the method.
[0047] Figure 1This is a schematic diagram of a data communication system provided in an embodiment of this application, such as... Figure 1 As shown, the data communication system may include a router and multiple central nodes mounted on the router. The multiple central nodes are located in the same local area network. At least some of the central nodes are mounted with at least one first sub-device. For example, the current main central node may be mounted with a first sub-device A1. The multiple central nodes include at least one of the following: a gateway device, a WIFI device, or a wired device. That is, the central node can be a gateway device, or a WIFI device, or a wired device, which is not limited here.
[0048] Among them, reference Figure 1 As shown, each central node can communicate with the router via Wi-Fi or Ethernet cable, and the central nodes can communicate with each other via a local area network. Optionally, each central node can mount one or more first sub-devices. Of course, this application does not limit the number of mounted first sub-devices. In some embodiments, the type of the first sub-device can be a Zigbee device, a KNX device, a Bluetooth device, etc., which is not limited here.
[0049] Figure 2 This is a flowchart illustrating a data communication method provided in an embodiment of this application. This method can be applied to... Figure 1 In a data communication system, the target central node can optionally be any one of multiple central nodes; for example, it can be... Figure 1 The central node, which houses the first sub-device A1, can be elected as the target primary central node through the following process: Figure 2 As shown, the method may include:
[0050] S101, the target central node broadcasts the first election multicast information in the local area network and receives the second election multicast information broadcast by other central nodes in the local area network.
[0051] The first election multicast message carries the central capability information of the target central node, while the second election multicast message carries the central capability information of all other central nodes. Optionally, each central node may run a central capability calculation service to calculate its own central capability information. That is, the target central node and each of the other central nodes can determine their own central capability information through their own running central capability calculation service.
[0052] Optionally, the central capability information can characterize the central capability of the central node. In some embodiments, the central capability calculation service can specifically calculate the central capability information of the central node based on signal strength, the type and number of first sub-devices that can be mounted, storage capacity, CPU performance, computing power, operational stability, software type, etc., combined with a preset algorithm. This is not limited here.
[0053] In addition, in some implementations, the first election multicast information may also include: the node identifier of the target central node, the device identifier, etc., which are not limited here.
[0054] Optionally, after each power-on startup, the target central node can broadcast and send the first election multicast information in its local area network. In addition to the target central node, other central nodes among the multiple central nodes can broadcast and send the second election multicast information in their local area networks after each power-on startup.
[0055] Understandably, at this point, each central node can receive election multicast information sent by other central nodes.
[0056] S102. The target central node determines whether it is the target main central node based on the first election multicast information and the second election multicast information.
[0057] After receiving the second election multicast information from other central nodes, the target central node can determine its own central capability based on the second and first election multicast information. If it is the strongest, the target central node becomes the target primary central node, and other central nodes with weaker capabilities become target backup central nodes. Figure 1 The communication topology shown is shown.
[0058] S103. If the target central node is determined to be the target primary central node and the other central nodes are target backup central nodes, the target central node receives the first unicast join information sent by each target backup central node, and synchronizes the first scene mode data to at least some target backup central nodes according to the first unicast join information and the first scene mode instruction, so that at least some target backup central nodes can switch states according to the first scene mode data.
[0059] Optionally, the first scene mode instruction can be used to indicate the scene mode in a smart home scenario, such as home mode, work mode, entertainment mode, sleep mode, etc. In some embodiments, the first scene mode instruction can be sent by the user to the target main hub node through a mobile device (such as a mobile phone, computer, or smartwatch), or the first scene mode instruction can be sent to the target main hub node by a wireless switch, wherein the mobile device and the wireless switch can be on the same local area network as the target main hub device.
[0060] The first scene mode data is the scene data corresponding to the first scene mode, which may include the control instruction set of the scene mode. The control instruction set may include the control instructions of each smart home device in the scene mode.
[0061] If the target central node is determined to be the target primary central node and the other central nodes are target backup central nodes, then each target backup central node can send a first unicast join message to the target primary central node (i.e. the target central node) to request to join the target primary central node. Optionally, the first unicast join message can carry the device identifier, IP address and other identity information of the target backup central node.
[0062] After receiving the first unicast join information, the target primary hub node can synchronize the first scene mode data to at least some target backup hub nodes according to the first unicast join information and the first scene mode instruction. After receiving the first scene mode data, at least some target backup hub nodes can switch states accordingly.
[0063] It should be noted that at least some of the target backup hub nodes switch states based on the first scenario mode data. Specifically, this could be controlling the target backup hub node itself to switch states, or controlling at least some of the first sub-devices attached to the target backup hub node to switch states. This is not limited here and may vary depending on the actual application scenario.
[0064] By applying the embodiments of this application, it is possible to control home devices in a smart home scenario through a target central node mounted on a router. This reduces the smart home scenario's dependence on the cloud and ensures the normal operation of the smart home system even in the event of network failure or cloud server downtime, thereby improving the stability of the smart home system. Furthermore, this application does not limit the type of central node, which can improve the applicability and suitability of the method. For example, the method can be applied to more complex smart home environments, such as large apartments, multi-story villas, and houses with a large number of devices.
[0065] In summary, this application provides a data communication method applied to a target central node in a data communication system. The data communication system includes a router and multiple central nodes mounted on the router. The multiple central nodes are located in the same local area network (LAN), and at least some of the central nodes are equipped with at least one first sub-device. The multiple central nodes include at least one of the following: a gateway device, a Wi-Fi device, and a wired device. The method includes: the target central node broadcasting first election multicast information in the LAN and receiving second election multicast information broadcast by other central nodes in the LAN. The first election multicast information carries the central capability information of the target central node, and the second election multicast information carries the central capability information of the other central nodes. The target central node then performs the following actions according to the first election multicast information: Information and second election multicast information are used to determine whether the target central node is the target primary central node. If the target central node is determined to be the target primary central node and other central nodes are target backup central nodes, the target central node receives the first unicast join information sent by each target backup central node, and synchronizes the first scene mode data to the target backup central nodes according to the first unicast join information and the first scene mode instruction, so that the target backup central nodes can switch states according to the first scene mode data. This can reduce the dependence of smart home scenarios on the cloud, and ensure the normal operation of the smart home system even if there is a network failure or the cloud server crashes, which can improve the stability of the smart home system. In addition, this application does not limit the type of central node, which can improve the applicability and applicability of the method of this application.
[0066] In an optional implementation, the method further includes:
[0067] If the target central node is determined to be the target backup central node and the first central node among the other central nodes is the target primary central node, then the target central node sends a second unicast join information to the target primary central node, so that the target primary central node synchronizes the second scenario mode data with the target central node according to the second unicast join information and the second scenario mode instruction, and the target central node performs state switching according to the second scenario mode data.
[0068] In some embodiments, there may be cases where the central capability of the target central node is weaker than that of other central nodes. In such cases, the target central node will become the target backup central node, and the first central node with the strongest central capability among the other central nodes will become the target primary central node. In this case, the target central node can send a second unicast join information to the currently determined target primary central node via unicast. This second unicast join information can carry the target central node's device identifier, IP address, and other identity information.
[0069] After receiving the second unicast join information sent by the target central node, the currently determined target central node can synchronize the second scenario mode data with the target central node according to the second scenario mode command and the second unicast join information. Furthermore, the target central node can switch states according to the second scenario mode data.
[0070] Optionally, the second scene mode instruction may be the same as or different from the first scene mode instruction described above. No limitation is made here. For an explanation of the second scene mode instruction, please refer to the relevant content of the first scene mode instruction described above. It will not be repeated here.
[0071] In addition, it should be noted that the target central node switches states based on the second scenario mode data. Specifically, it may be controlling the target central node itself to switch states, or it may be controlling at least some of the first sub-devices attached to the target central node to switch states. This is not limited here and may vary depending on the actual application scenario.
[0072] By applying the embodiments of this application, the method provided in this application can be applied to the case where the target central node is the target primary central node, and also to the case where the target central node is the target backup central node. In other words, the method of this application can be applied to all central nodes in the data communication system, which can improve the flexibility and applicability of the method of this application.
[0073] Figure 3 This is a flowchart illustrating another data communication method provided in an embodiment of this application. In optional implementations, such as... Figure 3 As shown, the determination of whether the target central node is the target primary central node based on the first election multicast information and the second election multicast information includes:
[0074] S201. Based on the first election multicast information and the second election multicast information, determine whether the target central node is a candidate main central node.
[0075] Optionally, the process of determining whether a target central node is a target main central node can be divided into a preliminary selection process and a challenge process. In the preliminary selection process, the target central node can determine whether it is a candidate main central node based on the first election multicast information and the second election multicast information within a preset election time.
[0076] In some implementations, the target central node can start a timer while broadcasting the first election multicast information. During the timer, the target central node can receive the second election multicast information broadcast by other central nodes in the local area network. If the timer reaches the preset election time, the preliminary election process is completed. At this time, the central node with the greatest central capability will become the candidate master central node, and other central nodes with weaker central capabilities will become candidate backup central nodes. If the target central node has the greatest central capability at this time, the target central node will become the candidate master central node.
[0077] The preset election time can be any value between 20s and 40s, and is not limited here.
[0078] S202. If the target central node is determined to be a candidate primary central node and the other central nodes are candidate backup central nodes, the target central node broadcasts challenge multicast information in the local area network so that each candidate backup central node challenges the candidate primary central node according to the challenge multicast information.
[0079] If the target candidate backup central node is successfully challenged among the candidate backup central nodes, then the target candidate backup central node becomes the target main central node, and the target central node and other candidate backup central nodes become the target backup central node; if all candidate backup central nodes fail to be challenged, then the candidate backup central node becomes the target backup central node, and the target central node becomes the target main central node.
[0080] Based on the above explanation, in order to avoid election errors during the central node election process, once the target central node is a candidate primary central node, a challenge multicast message can be broadcast in the local area network. This challenge multicast message can carry the central capability information of the target central node.
[0081] After receiving the challenge multicast information, each candidate backup hub node can compare the hub capability information indicated by the challenge multicast information with its own hub capability information. If the hub capability of the target candidate backup hub node is greater than the hub capability of the candidate master hub node, then the target candidate backup hub node has successfully challenged and becomes the target master hub node. The target hub node and other candidate backup hub nodes become target backup hub nodes.
[0082] Optionally, if the central capacity of each candidate backup central node is less than that of the candidate primary central node, then each candidate backup central node fails to challenge, the candidate backup central node becomes the target backup central node, and the target central node becomes the target primary central node.
[0083] By applying the embodiments of this application, a target main central node can be determined from multiple central nodes through a combination of preliminary selection and challenge processes, which can improve the reliability of the determined target main central node.
[0084] Figure 4 This is a flowchart illustrating another data communication method provided in an embodiment of this application. Optionally, as... Figure 4 As shown, the method includes:
[0085] S401, the target central node broadcasts and sends the first election multicast information in the local area network and receives the second election multicast information broadcast and sent by other central nodes in the local area network. The target central node starts timing when broadcasting and sending the first election multicast information in the local area network.
[0086] S402. Based on the preset election time, the target central node determines whether it is a candidate main central node according to the first election multicast information and the second election multicast information. If yes, proceed to step S403; otherwise, proceed to step S404.
[0087] If the current timeout has not reached the preset election time, the target central node will continuously broadcast the first election multicast information in the local area network; if the target central node is determined to be the target main central node based on the first election multicast information and the second election multicast information, and the current timeout has reached the preset election time, the election process will be closed.
[0088] S403. If the target central node is determined to be a candidate primary central node and other central nodes are candidate backup central nodes, then the target central node broadcasts and sends challenge multicast information.
[0089] S404. If the target central node is determined to be a candidate backup central node and the first central node among the other central nodes is a candidate primary central node, the target central node obtains the current time and stops broadcasting the first election multicast information.
[0090] If the target central node is determined to be a candidate backup central node and the first central node is determined to be a candidate primary central node, it means that the current preliminary election process has been completed. At this time, the target central node can obtain the current time and stop broadcasting the first election multicast information, and wait to start the preset receiving service.
[0091] S405. Calculate the time difference between the preset election time and the current timing time, and determine the target start time of the preset reception service based on the time difference and the preset waiting time.
[0092] Optionally, if the current timeout is less than the preset election time, the time difference between the preset election time and the current timeout can be calculated, and the time difference plus the preset waiting time can be used as the target start time.
[0093] Optionally, the preset waiting time may be the same as or different from the preset election time mentioned above, and is not limited here. In some embodiments, the value of the preset waiting time may be any value between 20s and 40s, and is not limited here.
[0094] S406. If it is determined that the current time has reached the target start time, the target central node starts the preset receiving service to receive the challenge multicast information broadcast by the candidate main central node.
[0095] S407. The target central node challenges the candidate main central node according to the challenge multicast information. If the challenge is successful, proceed to step S408. If the challenge fails, proceed to step S409.
[0096] If the current time reaches the target start time, the target central node starts the preset receiving service to receive the challenge multicast information broadcast by the candidate main central node, thereby realizing the search for the candidate main central node; furthermore, based on the challenge multicast information, a challenge can be launched against the candidate main central node to challenge and become the target central node.
[0097] S408. If the challenge is successful, the target candidate backup central node becomes the target main central node, and the target central node and other candidate backup central nodes become the target backup central nodes.
[0098] S409. If the challenge fails, the target central node becomes the target backup central node, and the candidate primary central node becomes the target primary central node.
[0099] Based on the challenge results of the target central node, different identities will be assigned. Depending on the actual application scenario, the target central node can be the target primary central node or the target backup central node.
[0100] By applying the embodiments of this application, a preliminary election process can be implemented to initially screen the central node with the strongest central capabilities as a candidate primary central node, while candidate backup central nodes with weaker central capabilities enter the challenge process. Each candidate backup central node further starts a preset receiving service based on its own target start time to receive the challenge multicast information broadcast by the candidate primary central node, and challenges the candidate primary central node according to the challenge multicast information. This allows for the dynamic setting of the target start time of each candidate backup central node, thereby ensuring that the challenge time of each candidate backup central node is staggered, which can reduce the communication pressure on the communication system and ensure the stability of the communication system.
[0101] Figure 5This is a timing diagram illustrating a data communication method provided in an embodiment of this application. In an optional implementation, if the target candidate backup hub node among the candidate backup hub nodes successfully challenges the target candidate backup hub node, the above method further includes:
[0102] The target central node scans and discovers the target primary central node, sends a third unicast join message to the target primary central node, and broadcasts a central node switching message to the local area network, so that other candidate backup central nodes can scan and discover the target primary central node based on the central node switching message, and send a third unicast join message to the target primary central node.
[0103] Among them, reference Figure 5 As shown, the target central node discovers the target primary central node through scanning and can promptly send a third unicast join message to the target central node to request the establishment of a communication connection with the target primary central node and join the current data communication system. In addition, the target central node can also broadcast central node switching information to the local area network to inform other candidate backup central nodes that a new target primary central node has been generated in the current challenge. After receiving the central node switching information, other target primary central nodes can scan to discover the target primary central node and send a third unicast join message to the target primary central node to request the establishment of a communication connection with the target central node.
[0104] By applying the embodiments of this application, when a target candidate backup hub node successfully challenges a candidate master hub node during the challenge phase, each target backup hub node can promptly establish a communication connection with the target master hub node, thus ensuring the reliability of the method of this application.
[0105] Optionally, the target central node can discover the target primary central node by scanning as follows: the target central node runs a primary central node discovery service, which is used to receive challenge multicast information broadcast by the target primary central node. The target central node determines the target primary central node based on the sender of the challenge multicast information. Other candidate backup central nodes can discover the target primary central node by scanning in the same way as the target central node, and are not limited here.
[0106] In addition, it should be noted that if a new central node is added to the data communication system, the newly added central node can be configured to scan for the target primary central node after it starts. If the target central node is found, the execution process of the target candidate backup central node can be referred to, which will not be elaborated here.
[0107] Specifically, if no target central node is found during the scan within a preset time period, the newly added central node can broadcast a third election multicast message, which can carry the central capability information of the newly added central node.
[0108] In alternative implementations, such as Figure 1 As shown, the aforementioned data communication system also includes a cloud platform, and each central node communicates with the cloud platform via a router. Optionally, after determining that the target central node is the primary target central node and the other central nodes are backup target central nodes, the method further includes:
[0109] The target main central node sends communication topology information to the cloud, so that the cloud can send first scene mode data to the target main central node based on the communication topology information according to the first scene mode command sent by the terminal device.
[0110] The communication topology information includes: node information of the target main hub node, node information of each target backup hub node, device information of each first sub-device mounted on the target main hub node, and device information of each first sub-device mounted on each target backup hub node.
[0111] It should be noted that, for communication topology information, the above-mentioned node information may include: basic node information (e.g., node identifier, node IP address) and node status information; the device information of the first sub-device may include: basic information of the first sub-device (e.g., device identifier, device IP address) and status information.
[0112] Once the target primary hub node and target backup hub node are determined in the data communication system, the target primary hub node can obtain the current communication topology information and send it to the cloud. This communication topology information can characterize the type and status of each target backup hub node connected to the target primary hub node, the type and status of each first sub-device attached to the target primary hub node, and the type and status of each first sub-device attached to each target backup hub node.
[0113] Optionally, if the cloud receives a first scene mode instruction sent by the terminal device, it can determine the target scene mode data based on the first scene mode instruction. In some embodiments, considering that the target scene data may also include other devices (e.g., Figure 1 The scenario data of the second sub-device B1 connected to the gateway is required. Therefore, it is necessary to filter the first scenario mode data related to the communication topology information in the target scenario mode data based on the communication topology information. Furthermore, the filtered first scenario mode data can be sent to the target main hub node for further forwarding.
[0114] By applying the embodiments of this application, the cloud can forward the first scene mode data related to the target main hub node according to the communication topology information, which can improve the applicability of the method of this application.
[0115] Figure 6This is a flowchart illustrating another data communication method provided in an embodiment of this application. In optional implementations, such as... Figure 1 As shown, the router is also equipped with at least one slave device and / or at least one slave gateway. Each slave device and / or each slave gateway communicates with each central node, and each slave gateway is equipped with at least one second sub-device.
[0116] Each slave device and / or each slave gateway is configured to run a master node discovery service upon startup. The master node discovery service is used to receive challenge multicast information broadcast by the target master node and send a fourth unicast join information to the target master node based on the challenge multicast information. The fourth unicast join information includes: device information of each slave device and / or gateway information of each slave gateway.
[0117] Reference Figure 1 As shown, in some implementations, one or more slave devices or slave gateways can be connected to the router via Wi-Fi or Ethernet cable. Each slave device or slave gateway can join a local area network composed of multiple central nodes. During data communication, the target main central node can send scene mode data to each slave gateway or slave device, and each slave gateway or slave device can perform status control accordingly.
[0118] In addition, it should be noted that in order for each gateway and slave device to be aware of the target master node, such as Figure 6 As shown, taking a slave gateway as an example, each slave gateway can run a master node discovery service after startup. This master node discovery service is used to receive challenge multicast information broadcast by the target master node. Understandably, the slave gateway can determine the target master node's device information, IP address, etc., based on this challenge multicast information, and establish a communication connection with the target master node accordingly. It then sends a fourth unicast join message to the target master node, allowing the target master node to know the slave gateway's gateway information, i.e., the relevant devices that can currently send scenario-specific data. Optionally, this gateway information may include: gateway identifier, gateway IP, etc., which are not limited here.
[0119] For details regarding the communication process between the slave device and the target master node, please refer to the relevant description of the slave gateway mentioned above, which will not be repeated here. It should be noted that this application does not limit the type of slave device; it can be any smart home device depending on the actual application scenario, such as printers, refrigerators, range hoods, water dispensers, etc., without further limitation.
[0120] Figure 7This is a schematic diagram of a heartbeat mechanism provided in an embodiment of this application. In an optional implementation, the target primary central node is configured to communicate with each target backup central node based on the heartbeat mechanism. If it is determined that the communication connection of the target primary central node has timed out, the multiple target backup central nodes are configured to re-elect a new target primary central node according to a preset election mechanism and a preset challenge mechanism.
[0121] In an optional implementation, the target master hub node is further configured to communicate with each slave device and / or each slave gateway based on a heartbeat mechanism, and to synchronize first scene mode data to the target backup hub node according to the first unicast join information. After the target backup hub node controls the working status of each first sub-device it is connected to according to the first scene mode data, the configuration further includes:
[0122] If the target slave device and / or target slave gateway connection timeout is determined, the target master central node deletes the target device information of the target slave device and / or the target gateway information of the target slave gateway.
[0123] In some implementations, such as Figure 8 As shown, to ensure stable communication connections between the target master hub node, the target backup hub node, slave devices, and slave gateways, the target master hub node and the target backup hub node can communicate via heartbeat authentication based on clock 2; the target master hub node and the slave gateway can communicate via heartbeat authentication based on clock 3; and the target master hub node and the slave devices can communicate via heartbeat authentication based on clock 4. Furthermore, the target master hub node can update the currently maintained communication topology information based on clock 1.
[0124] In the heartbeat-based communication mechanism, if the current target master node's connection times out, other target backup nodes will re-elect a new target master node according to a preset election mechanism and a preset challenge mechanism. The preset election mechanism and the preset challenge mechanism are explained in step S201 above and will not be repeated here. If any of the target backup nodes, slave devices, or slave gateways times out, the target master node can delete its relevant information, effectively removing it from the current data communication network.
[0125] Optionally, the values of clocks 2, 3, and 4 can be any value between 20s and 60s. Furthermore, the values of the three can be the same or different. The value of clock 1 can be greater than the values of clocks 2, 3, and 4; for example, the value of clock 1 can be any value between 90s and 120s. In some embodiments, specifically, the values of clocks 2, 3, and 4 can be 30s, and the value of clock 1 can be 90s; this is not limited.
[0126] In summary, by applying the embodiments of this application, a stable communication connection can be achieved between the target primary central node, the target backup central node, the slave device, and the slave gateway, thereby improving the stability of the communication network of this application.
[0127] In some implementations, if the status information of any first sub-device mounted on the target backup hub node changes, the above method further includes:
[0128] The target primary hub node receives and stores the updated status information of any first sub-device sent by the target backup hub node.
[0129] Of course, it should be noted that, in addition to the target backup hub node, when any device, such as the gateway, any second sub-device attached to the gateway, or any slave device, sends an update to its status, it should also send the updated status information to the target master hub node.
[0130] Understandably, after receiving the updated status information sent by each device, the target backup hub node can update the communication topology information accordingly, thereby ensuring the real-time nature of the communication topology information.
[0131] In summary, by applying the embodiments of this application and using multicast technology, all central nodes within the local area network (LAN) can achieve self-discovery capabilities. This allows them to discover all active central nodes within the LAN, quickly and stably elect a target primary central node, and the target backup central node can serve as a standby central node, resulting in extremely stable and optimal communication. Furthermore, the target primary central node can simultaneously synchronize offline scenario data to the backup central node, enabling rapid data synchronization between the primary and backup central nodes. If the target primary central node fails, a new primary central node can be re-elected, enhancing network stability. Moreover, this application supports various devices, such as gateways, WiFi devices, Zigbee devices, Bluetooth devices, KNX devices, and wired devices, improving the end-to-end LAN off-network control capabilities and the flexibility of the method described in this application.
[0132] Optionally, embodiments of this application provide a data communication system, including: a router, multiple central nodes mounted on the router, the multiple central nodes being located in the same local area network, and at least some of the central nodes being mounted with at least one first sub-device, wherein each central node is used for the data communication method described in the foregoing embodiments.
[0133] By applying the data communication system of this application, the dependence of smart home scenarios on the cloud can be reduced, and the normal operation of the smart home system can be guaranteed even if there is a network failure or the cloud server goes down, which can improve the stability of the smart home system. In addition, this application does not limit the type of central node, which can improve the applicability and applicability of the method of this application.
[0134] The above-described device is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0135] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0136] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. This electronic device can be integrated into any of the aforementioned central nodes. For example... Figure 8 As shown, the electronic device may include a processor 210, a storage medium 220, and a bus 230. The storage medium 220 stores machine-readable instructions executable by the processor 210. When the electronic device is running, the processor 210 communicates with the storage medium 220 via the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation and technical effects are similar and will not be described in detail here.
[0137] Optionally, this application also provides a storage medium storing a computer program, which, when run by a processor, executes the steps of the above-described method embodiments. The specific implementation and technical effects are similar and will not be repeated here.
[0138] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0139] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0140] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0141] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0142] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0143] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need further definition and explanation in subsequent figures. The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method of data communication, characterized by, The application discloses a target hub node applied to a data communication system, the data communication system comprising a router, a plurality of hub nodes mounted on the router, the plurality of hub nodes being in a same local area network, at least part of the hub nodes being mounted with at least one first sub-device, and the plurality of hub nodes comprising at least one of the following: a gateway device, a WIFI device and a wired device, and the method comprises the following steps: The target hub node broadcasts first election multicast information in the local area network, and receives second election multicast information broadcasted by other hub nodes in the local area network, the first election multicast information carrying hub capability information of the target hub node, and the second election multicast information carrying hub capability information of other hub nodes; The target hub node determines whether the target hub node is a target master hub node according to the first election multicast information and the second election multicast information; If it is determined that the target hub node is a target master hub node and other hub nodes are target backup hub nodes, the target hub node receives first unicast join information sent by the target backup hub nodes, and synchronizes first scene mode data to at least part of the target backup hub nodes according to the first unicast join information and a first scene mode instruction, so that at least part of the target backup hub nodes perform state switching according to the first scene mode data.
2. The method of claim 1, wherein, The method further comprises the following steps: If it is determined that the target hub node is a target backup hub node and a first hub node in other hub nodes is a target master hub node, the target hub node sends second unicast join information to the target master hub node, so that the target master hub node synchronizes second scene mode data to the target hub node according to the second unicast join information and a second scene mode instruction, and the target hub node performs state switching according to the second scene mode data.
3. The method of claim 1, wherein, The determination of whether the target hub node is a target master hub node according to the first election multicast information and the second election multicast information comprises the following steps: It is determined whether the target hub node is a candidate master hub node according to the first election multicast information and the second election multicast information; If it is determined that the target hub node is a candidate master hub node and other hub nodes are candidate backup hub nodes, the target hub node broadcasts challenge multicast information in the local area network, so that each candidate backup hub node challenges the candidate master hub node according to the challenge multicast information; If a target candidate backup hub node in the candidate backup hub nodes succeeds in the challenge, the target candidate backup hub node is a target master hub node, and the target hub node and other candidate backup hub nodes are target backup hub nodes; if each candidate backup hub node fails in the challenge, the candidate backup hub nodes are target backup hub nodes, and the target hub node is a target master hub node.
4. The method of claim 3, wherein, If the target candidate backup hub node succeeds in the challenge, the method further comprises the following steps: The target central node scans to find a target master central node, sends third unicast join information to the target master central node, and broadcasts central switching information to the local area network, so that other candidate backup central nodes scan to find the target master central node according to the central switching information, and send third unicast join information to the target master central node.
5. The method of claim 1, wherein, The data communication system further comprises a cloud, and each central node is in communication connection with the cloud through the router; After determining that the target central node is a target master central node and other central nodes are target backup central nodes, the method further comprises: The target master central node sends communication topology information to the cloud, so that the cloud sends the first scene mode data to the target master central node based on the communication topology information according to the first scene mode instruction sent by the terminal device. The communication topology information comprises node information of the target master central node, node information of each target backup central node, device information of each first sub-device mounted on the target master central node, and device information of each first sub-device mounted on each target backup central node.
6. The method of claim 1, wherein, The router further mounts at least one slave device and / or at least one slave gateway, each slave device and / or each slave gateway is in communication connection with each central node, and the slave gateway mounts at least one second sub-device; Each slave device and / or each slave gateway is configured to start a master central node discovery service after being started, the master central node discovery service is used to receive challenge groupcast information broadcasted by the target master central node, and fourth unicast join information is sent to the target master central node according to the challenge groupcast information, the fourth unicast join information comprising device information of each slave device and / or gateway information of each slave gateway.
7. The method of claim 1, wherein, The target master central node is configured to communicate with each target backup central node based on a heartbeat mechanism, and if it is determined that the target master central node communication connection is timed out, a plurality of target backup central nodes are configured to re-elect a new target master central node according to a preset election mechanism and a preset challenge mechanism.
8. The method of claim 6, wherein, The target master central node is further configured to communicate with each slave device and / or each slave gateway based on a heartbeat mechanism, and after synchronizing the first scene mode data to the target backup central node according to the first unicast join information, so that the target backup central node controls the working state of each mounted first sub-device according to the first scene mode data. If it is determined that the target slave device and / or the target slave gateway connection is timed out, the target master central node deletes the target device information of the target slave device and / or the target gateway information of the target slave gateway.
9. A data communication system, characterized by Comprise: A router, a plurality of central nodes mounted on the router, and a plurality of central nodes in the same local area network, at least part of the central nodes mounting at least one first sub-device, wherein each central node is used to execute the data communication method of any one of claims 1-8.
10. An electronic device, comprising: Comprise: A processor, a storage medium storing machine readable instructions executable by the processor, and a bus for communication between the processor and the storage medium when the electronic device is running, the processor executing the machine readable instructions to perform the steps of the data communication method of any one of claims 1-8.
11. A computer readable storage medium, characterized in that, A computer readable storage medium storing a computer program, the computer program being executed by a processor to perform the steps of the data communication method of any one of claims 1-8.