Channel switching method of zigbee device, gateway device and storage medium
By configuring master-slave modules in the gateway device, using the master module to create the network and the slave module to configure the second channel, the problem of device offline during channel switching of ZigBee devices is solved, achieving seamless device switching and load balancing, and improving communication quality.
Patent Information
- Application Number
- CN202310194399.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-01
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-03-01
AI Technical Summary
Existing ZigBee devices may go offline or fail to receive the handover command during channel switching, resulting in device loss in the network.
By configuring a master module and a slave module in the gateway device, the master module creates the first channel network and generates network information. If the packet loss rate is higher than the threshold, the slave module is used to configure the second channel to ensure that the ZigBee device can access the network. The master module sends a channel switching command to achieve seamless switching of the device.
Ensure that ZigBee devices remain connected to the network during channel switching to avoid network loss due to devices being offline or not receiving switching commands, thereby achieving load balancing and improved communication quality.
Smart Images

Figure CN116249170B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of Internet of Things (IoT) technology, and in particular to a channel switching method, gateway device, and storage medium for a ZigBee device. Background Technology
[0002] ZigBee, WiFi, and Bluetooth all operate in the 2.4GHz ISM band. The ZigBee underlying standard divides the ISM band into 16 channels, allowing the device to choose any one of them for communication to avoid interference from WiFi or Bluetooth signals operating on the same frequency. In actual communication, the channel a ZigBee device is using may no longer be the optimal channel. In this case, the ZigBee device needs to switch channels to improve communication quality. Although the ZigBee protocol supports channel switching, single-channel switching cannot guarantee that offline ZigBee devices or those that have not received a switching command are still in the network, leading to potential device loss during channel switching in the ZigBee network. Summary of the Invention
[0003] This specification aims to at least partially address one of the technical problems in the related art. To this end, one objective of this specification is to propose a channel switching method for ZigBee devices that ensures the ZigBee device remains in a network-connected state during channel switching.
[0004] The second objective of this specification is to propose a gateway device.
[0005] The third objective of this specification is to provide a computer-readable storage medium.
[0006] To achieve the above objectives, a channel switching method for a ZigBee device is proposed in a first aspect of this specification. The channel switching method is applied to a gateway device, which is configured with a master module and at least one slave module. The method includes: the master module creating a network through a first channel; wherein the first channel is used to connect the ZigBee device to the network; if the packet loss rate of the ZigBee device in the first channel is higher than a packet loss threshold, the slave module configures a second channel as the channel for accessing the network according to network information corresponding to the network; wherein the operating frequency band of the first channel is different from the operating frequency band of the second channel; and the master module sending a channel switching command to the ZigBee device to enable the ZigBee device to access the network through the second channel.
[0007] In some embodiments of this specification, the main module creates a network through a first channel, including: the main module scanning all channels corresponding to the operating frequency band of the ZigBee device and determining a first channel that meets preset channel conditions; the main module generating a personal area network address and a key based on the first channel to create the network; wherein the personal area network address and the key constitute the network information corresponding to the network.
[0008] In some embodiments of this specification, the network information includes a personal area network address and a key generated based on the first channel; the slave module configures the second channel as a channel for accessing the network according to the network information corresponding to the network, including: the slave module scanning other channels in the ZigBee device's operating frequency band besides the first channel, and determining a second channel that meets preset channel conditions among the other channels; the slave module configuring the second channel as a channel for accessing the network according to the personal area network address and the key.
[0009] In some embodiments of this specification, after the master module sends a channel switching command to the ZigBee device, the method further includes: if the slave module detects that the ZigBee device has not accessed the network through the second channel, then the master module resends the channel switching command to the ZigBee device; or if the slave module detects that the number of times the ZigBee device has not accessed the network through the second channel within the current inspection cycle of the gateway device reaches a preset threshold, then the master module waits for the next inspection cycle of the gateway device to send the channel switching command to the ZigBee device in the next inspection cycle.
[0010] In some embodiments of this specification, both the first channel and the second channel are loaded with ZigBee devices; the method further includes: the gateway device periodically checking the packet loss status of the ZigBee devices loaded on the first channel and the second channel; if the packet loss rate of a ZigBee device is higher than the packet loss threshold, the gateway device determines a first target channel with a higher channel rating than the channel loaded with the ZigBee device among the other channels besides the channel loaded with the ZigBee device; wherein the channel rating is determined based on the packet loss status of all ZigBee devices loaded on the channel; the first target channel is one of the first channel or the second channel; the master module or slave module corresponding to the channel loaded with the ZigBee device sends a channel switching command to the ZigBee device, so that the ZigBee device accesses the network through the first target channel.
[0011] In some embodiments of this specification, the method further includes: when all ZigBee devices loaded by the first channel switch to the second channel to access the network, the main module determines a third channel that meets the preset channel conditions from among the other channels in the ZigBee device operating frequency band besides the second channel; the main module configures the third channel as a channel for accessing the network according to the network information; wherein the operating frequency band of the third channel is different from the operating frequency band of the second channel.
[0012] In some embodiments of this specification, the method further includes: when the channel ratings of both the first channel and the second channel are lower than a preset rating standard, the gateway device determines the target module corresponding to the channel with the lowest communication density among the first channel and the second channel; wherein, the channel rating is determined based on the packet loss of all ZigBee devices loaded on the channel; the communication density is determined by the number of ZigBee devices loaded on the channel; the target module is either the master module or the slave module; the target module scans other channels in the operating frequency band of the ZigBee devices besides the first channel and the second channel; the target module determines a second target channel among the other channels that meets the preset channel conditions based on the scanning results; if there are no unused target slave modules in the gateway device, the target module configures the second target channel as a channel that can access the network based on the network information, so that all ZigBee devices loaded on the first channel and the second channel can access the network through the second target channel.
[0013] In some embodiments of this specification, the target module configures the second target channel as a channel that can access the network according to the network information, including: the target module sending a channel switching command to the ZigBee device loaded in its corresponding channel to clear the channel corresponding to the target module; the target module configuring the second target channel as a channel that can access the network according to the network information.
[0014] In some embodiments of this specification, after the target module determines a second target channel among the other channels that meets the preset channel conditions based on the scanning results of the scan, the method further includes: if there is an unused target slave module in the gateway device, the target slave module configures the second target channel as a channel that can access the network based on the network information.
[0015] To achieve the above objectives, a gateway device is provided in a second aspect of this specification. The gateway device is configured with a master module and at least one slave module; the master module is used to create a network through a first channel; wherein the first channel is used to connect the ZigBee device to the network; if the packet loss rate of the ZigBee device in the first channel exceeds a packet loss threshold, the slave module is used to configure a second channel as the channel for accessing the network according to network information corresponding to the network; wherein the operating frequency band of the first channel is different from the operating frequency band of the second channel; the master module is also used to send a channel switching command to the ZigBee device so that the ZigBee device accesses the network through the second channel.
[0016] To achieve the above objectives, a third aspect of this specification provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the method described in any of the embodiments of the first aspect.
[0017] Through the above embodiments, a master module and at least one slave module are configured in the gateway device. After the master module creates a network based on the first channel, if the ZigBee device has a high packet loss rate, the slave module can configure a second channel as the access channel based on the network information generated by creating the network based on the first channel. Both channels can simultaneously support the ZigBee device. When the ZigBee device performs channel switching, if it does not receive a channel switching command or is not powered on, it can still access the network through the original channel to maintain its network access status.
[0018] Additional aspects and advantages of this specification will be set forth in part in the description which follows, and in part will be obvious from the description or may be learned by practice of this specification. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the gateway device in an embodiment of this specification.
[0020] Figure 2 This is a flowchart of a channel switching method for a ZigBee device according to an embodiment of this specification.
[0021] Figure 3 This is a schematic block diagram of a gateway device according to one embodiment of this specification.
[0022] Figure 4 This is a flowchart of a channel switching method for a ZigBee device according to one embodiment of this specification.
[0023] Figure 5 This is a block diagram illustrating the principle of a master-slave module according to one embodiment of this specification.
[0024] Figure 6 This is a flowchart of a channel switching method for a ZigBee device according to one embodiment of this specification.
[0025] Figure 7 This is a flowchart of a channel switching method for a ZigBee device according to one embodiment of this specification. Detailed Implementation
[0026] The embodiments of this specification are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this specification, and should not be construed as limiting this specification.
[0027] ZigBee, WiFi, and Bluetooth all operate in the 2.4GHz ISM band. The underlying ZigBee standard divides this 2.4GHz ISM band into 16 channels, each with a bandwidth of 2MHz. A gateway can arbitrarily select one of these 16 channels for communication between ZigBee devices, thus avoiding signal interference from WiFi and Bluetooth operating on the same frequency band.
[0028] However, in actual communication between ZigBee devices, due to the constantly changing wireless environment, the channel on which the ZigBee device operates is likely to be interfered with by WiFi or Bluetooth signals, causing the channel to no longer be the optimal one. Although the ZigBee protocol supports channel switching commands, the single-channel operating mode and single-channel switching method encounter the following two situations: first, when the gateway sends a channel switching command, the ZigBee devices in the network are not powered on; second, when the gateway sends a channel switching command, some ZigBee devices do not receive the channel switching command. This results in the unpowered ZigBee devices being unable to reconnect after being powered on, and the ZigBee devices that did not receive the channel switching command remaining offline.
[0029] The channel switching methods in related technologies cannot guarantee that offline ZigBee devices or ZigBee devices that have not received a switching command are in a network-connected state, which may lead to the risk of device loss during channel switching in the ZigBee network. Therefore, to address the above problems, this specification proposes a channel switching method for ZigBee devices, a gateway device, and a computer-readable storage medium that can ensure that ZigBee devices always maintain a network-connected state during channel switching.
[0030] Please refer to Figure 1This specification provides an embodiment of a gateway device. The gateway device 100 is configured with a master module 110 and at least one slave module 120. The master module 110 is used to create a network via a first channel. The first channel is used to connect ZigBee devices to the network. If the packet loss rate of the ZigBee devices exceeds a packet loss threshold in the first channel, the slave module 120 is used to configure a second channel as the access channel based on the network information corresponding to the network. The operating frequency bands of the first and second channels are different. The master module is also used to send channel switching commands to the ZigBee devices so that the ZigBee devices can access the network via the second channel.
[0031] Specifically, gateway device 100 can be configured with multiple ZigBee modules. These multiple ZigBee modules share unique ZigBee network information. The ZigBee modules in the gateway device are divided into master modules 110 and slave modules 120. The multiple ZigBee modules include one master module 110 and at least one slave module 120. Gateway device 100 uses the master module 110 and slave modules 120 to achieve multi-channel load balancing for the ZigBee devices, thereby enabling ZigBee devices to access the ZigBee network.
[0032] For example, consider a gateway device 100 configured with a master module 110 and a slave module 120. After the gateway device 100 is initially started, the master module 100 connects to the first channel (…). Figure 1 In the first channel: A) Create a network, which is a ZigBee network. After creating the network through the first channel, the main module 110 generates the network information corresponding to the network, including the Personal Area Network Address (PAN ID) and the Transport Key. Taking a smart home scenario as an example, ZigBee devices can be smart devices such as lighting devices, control panels, and refrigerators. When a ZigBee device needs to access the network, it can access the network through the main module 110 in the gateway device 100 via the first channel. The gateway device 100 can periodically detect the communication status of the ZigBee devices loaded in the channel. If the packet loss rate of ZigBee devices in the first channel is detected to be higher than the packet loss threshold, the slave module 120 will connect to the second channel (…) according to the network information corresponding to the network. Figure 1 Channel B) is configured as the channel for network access. The operating frequency band of the first channel is different from that of the second channel. Both the first and second channels are among the 16 channels in the ISN band. Subsequently, the main module sends a channel switching command to ZigBee devices with packet loss rates exceeding the packet loss threshold, enabling the ZigBee devices to access the network through the second channel.
[0033] It is understandable that the first channel can support multiple ZigBee devices, and the second channel can also support multiple ZigBee devices. The first and second channels can simultaneously support ZigBee devices, enabling the ZigBee devices to be in the network-connected state.
[0034] Figure 2 This is a flowchart illustrating a channel switching method for a ZigBee device according to an embodiment of this specification. This channel switching method is applied to a gateway device. Please refer to... Figure 2 The channel switching method includes:
[0035] S210, the main module creates a network through the first channel.
[0036] The first channel is used to connect ZigBee devices to the network.
[0037] S220, if the packet loss rate of ZigBee devices in the first channel is higher than the packet loss threshold, the module configures the second channel as the access channel for the network based on the network information corresponding to the network.
[0038] The operating frequency band of the first channel is different from that of the second channel.
[0039] S230, the main module sends a channel switching command to the ZigBee device so that the ZigBee device can access the network through the second channel.
[0040] The ZigBee underlying standard divides its 2.4GHz ISM band into 16 channels, each with a bandwidth of 2MHz. The first channel and the second channel are any one of the 16 channels, and the operating frequency bands of the first channel and the second channel are different.
[0041] Specifically, upon initial startup of the gateway device, the main module first creates a network via the first channel, generating corresponding network information. This network information includes the network's identifier to determine if it belongs to the same network. After creating the network via the first channel, the main module can add ZigBee devices, similar to the standard ZigBee device network entry process, allowing these devices to access the network via the first channel. At this point, all ZigBee devices operate within the network defined by the first channel.
[0042] The gateway device can periodically analyze the communication status of each ZigBee device in the channel to determine the packet loss rate during communication. During a periodic analysis by the gateway device, if it detects that the packet loss rate of a ZigBee device in the first channel exceeds the packet loss threshold, it can trigger a channel switch for the ZigBee device. The slave module can configure the second channel as the access channel for the network based on the network information generated when creating the network based on the first channel.
[0043] Subsequently, the master module sends a channel switching command to the ZigBee devices in the first channel whose packet loss rate is higher than the packet loss threshold, causing the ZigBee devices with packet loss rates higher than the packet loss threshold to switch to the slave module and access the network through the second channel.
[0044] In the above embodiments, among the ZigBee devices with a packet loss rate higher than the packet loss threshold in the first channel, if there is a ZigBee device that is not powered on when the main module sends a channel switching command to it, the ZigBee device that is not powered on will still access the network through the first channel after being powered on again. However, the ZigBee devices that are communicating normally among the ZigBee devices with a packet loss rate higher than the packet loss threshold will switch to the second channel to access the network after receiving the channel switching command.
[0045] In other cases, when the main module sends a channel switching command to a ZigBee device in the first channel whose packet loss rate is higher than the packet loss threshold, if any ZigBee device does not receive the channel switching command, these ZigBee devices that do not receive the channel switching command will still access the network through the first channel.
[0046] Through the above embodiments, a master module and at least one slave module are configured in the gateway device. After the master module creates a network based on the first channel, if the ZigBee device has a high packet loss rate, the slave module can configure a second channel as the access channel based on the network information generated by creating the network based on the first channel. Both channels can simultaneously support the ZigBee device. When the ZigBee device performs channel switching, if it does not receive a channel switching command or is not powered on, it can still access the network through the original channel to maintain its network access status.
[0047] In some embodiments of this specification, the main module creates a network through a first channel, including: the main module scanning all channels corresponding to the operating frequency band of the ZigBee device and determining a first channel that meets preset channel conditions. The main module generates a personal area network address and a key based on the first channel to create the network. The personal area network address and key constitute the network information corresponding to the network.
[0048] Specifically, upon initial startup of the gateway device, the main module creates a network through the first channel to complete ZigBee network initialization. To ensure communication quality for ZigBee devices, the main module can scan all channels in the ZigBee device's operating frequency band (i.e., the ISM band) before creating the network and select the first channel that meets preset channel conditions. These preset channel conditions can be the channel least affected by WiFi and Bluetooth signal interference or the channel with the lowest signal-to-noise ratio.
[0049] Please see Figure 3 After determining the first channel, the main module can create a ZigBee network based on the first channel. Along with determining the first channel, a Personal Area Network ID (PAN ID) and a Key-transport key corresponding to the ZigBee network can be generated. The PAN ID is the network's ID, or network identifier. The key, derived from the link key, is used to protect key transmission information carrying a non-master key. The PAN ID and key uniquely identify a ZigBee network. The PAN ID and key constitute the network information corresponding to the network created based on the first channel. This network information may also include the channel (CH).
[0050] Please see Figure 5 As shown in Figure (a), after the main module creates a network based on the first channel, the process is the same as that of a regular ZigBee device joining the network. The main module adds ZigBee devices so that the ZigBee devices can access the network through the first channel.
[0051] In some embodiments of this specification, network information includes a personal area network address and key generated based on the first channel. The slave module configures the second channel as the access channel for the network according to the network information corresponding to the network, including: scanning other channels in the ZigBee device's operating frequency band besides the first channel, and determining the second channel that meets preset channel conditions from the other channels. The slave module configures the second channel as the access channel for the network according to the personal area network address and key.
[0052] In the embodiments of this specification, after detecting that the packet loss rate of a ZigBee device in the first channel exceeds the packet loss threshold, triggering a channel switching action for the ZigBee device, the slave module scans all channels in the ZigBee device's operating frequency band, i.e., the ISM band, except for the first channel. A second channel that meets preset channel conditions is determined from these other channels. The preset channel conditions are the same as described above, and can be selecting the channel with the lowest interference from WiFi and Bluetooth signals or a channel with a low signal-to-noise ratio. Then, based on the personal area network information and the key, the second channel is configured as the channel for accessing the network.
[0053] In another embodiment, after the master module creates the network, the slave module can periodically scan other channels in the frequency band besides the first channel during normal communication by enabling ZigBee devices to access the network through the first channel, and record the interference situation of each channel after each scan. If the slave module detects that the packet loss rate of a ZigBee device in the first channel is higher than the packet loss threshold, it determines a second channel that meets the preset channel conditions based on the interference situation of other channels recorded over several periods. Then, based on the personal area network information and the key, the second channel is configured as the channel for accessing the network.
[0054] It is understandable that when the module configures the second channel as the access network channel, it uses the personal area network information and key generated based on the network created using the first channel. Therefore, regardless of whether the ZigBee device accesses the network through the first channel or the second channel, the ZigBee device is always in a single network environment.
[0055] In some embodiments of this specification, after the master module sends a channel switching command to the ZigBee device, the channel switching method further includes: if the slave module detects that the ZigBee device has not accessed the network through the second channel, the master module resends the channel switching command to the ZigBee device; or, if the slave module detects that the number of times the ZigBee device has not accessed the network through the second channel reaches a preset threshold within the current inspection cycle of the gateway device, the master module waits for the next inspection cycle of the gateway device in order to send a channel switching command to the ZigBee device in the next inspection cycle.
[0056] Specifically, after the master module sends a channel switching command to a ZigBee device with a packet loss rate exceeding the packet loss threshold, the ZigBee device switches from the master module to the slave module specified in the channel switching command to access the network through the second channel configured on that slave module. However, after the master module sends the channel switching command, there may be situations where the ZigBee device is not powered on or has not received the command, resulting in the ZigBee device not performing a channel switch. To determine whether the ZigBee device has executed the channel switching command, the slave module checks the ZigBee device to determine whether the ZigBee device is currently accessing the network through the second channel.
[0057] If the module detects that the ZigBee device is not accessing the network through the second channel, it indicates that the ZigBee device has not executed the channel switching command or has failed to switch channels successfully. In this case, the main module can send the same channel switching command to the ZigBee device again to induce it to switch channels again.
[0058] In other embodiments, if, during the current inspection cycle of the gateway device, the number of times the slave module detects that the ZigBee device has failed to access the network through the second channel reaches a preset threshold, it indicates that the ZigBee device has performed a preset number of channel switches, but all have failed. The master module then waits for the next inspection cycle of the gateway device to send a channel switch command to the ZigBee device in the next inspection cycle.
[0059] Understandably, when the master module sends a channel switching command to the ZigBee device, the slave module will perform a detection on the ZigBee device.
[0060] Please see Figure 4 In one specific embodiment, a preset threshold number of attempts can be set to 3. The channel switching process of a ZigBee device may include the following steps:
[0061] S410, the main module sends a channel switching command to the ZigBee device.
[0062] S420 detects whether a ZigBee device is accessing the network through the second channel.
[0063] S430: If the module detects that the ZigBee device is accessing the network through the second channel, then the channel switching is considered successful.
[0064] S440: If the module detects that the ZigBee device has not accessed the network through the second channel, determine the number of times the main module sends a channel switching command to the ZigBee device and determine whether it exceeds 3 times.
[0065] S450: If the current master module sends channel switching commands to the ZigBee device more than 3 times, then ignore this channel switching task. Wait for the next inspection cycle of the gateway device, and then execute steps S410, S420, S430, S440 and S450 in the next inspection cycle.
[0066] If the current master module sends channel switching commands to the ZigBee device no more than 3 times, then repeat steps S410, S420, S430 and S440.
[0067] In some embodiments of this specification, both the first channel and the second channel are loaded with ZigBee devices. The channel switching method further includes: the gateway device periodically checking the packet loss status of the ZigBee devices loaded on the first and second channels. If the packet loss rate of a ZigBee device is higher than the packet loss threshold, the gateway device determines a first target channel with a higher channel rating than the channel loaded with the ZigBee device among the other channels besides those loaded with the ZigBee device. The master module or slave module corresponding to the channel loaded with the ZigBee device sends a channel switching command to the ZigBee device, so that the ZigBee device accesses the network through the first target channel.
[0068] The channel rating is determined based on the packet loss situation of all ZigBee devices on the channel; the first target channel is either the first channel or the second channel.
[0069] In the embodiments of this specification, after the main module creates the network, it can support multiple ZigBee devices to access the network through a first channel. However, as the wireless environment changes during communication, the first channel may receive various interferences, leading to a deterioration in the communication performance of the ZigBee devices supported on the first channel, i.e., a gradual increase in the packet loss rate of the ZigBee devices. If the packet loss rate of a ZigBee device in the first channel exceeds the packet loss threshold, a channel switching command will be issued to that ZigBee device, causing it to access the network through a second channel configured by the module. Figure 5 As shown in Figure (b), devices 1 to 6 represent ZigBee devices, with channel A being the first channel and channel B being the second channel. Devices 1 to 5 access the network via the master module on the first channel, while device 6 accesses the network via the slave module on the second channel.
[0070] Taking a gateway device configured with a master module and a slave module as an example, the master module creates a network through a first channel, and the slave module configures a second channel as the access channel based on the network information of the first channel. Currently, both the master and slave modules are loaded with ZigBee devices. The gateway device periodically checks the communication status, i.e., packet loss, of the ZigBee devices loaded on both channels. If, in either channel, the packet loss rate of a ZigBee device exceeds the packet loss threshold, the gateway device determines a first target channel from among the other channels (excluding those loaded with ZigBee devices) with a higher channel rating. The master or slave module corresponding to the channel loaded with ZigBee devices sends a channel switching command to the ZigBee device, enabling the ZigBee device to access the network through the first target channel.
[0071] For example, please refer to Figure 5As shown in Figure (b), the gateway device periodically checks the packet loss status of ZigBee devices 1-6 on channels A and B. If the packet loss rate of device 3 in channel A is higher than the packet loss threshold, the gateway device determines whether the channel rating of channel B is higher than that of channel A. If it is higher, channel B becomes the first target channel. The main module sends a channel switching command to device 3, enabling device 3 to access the network through channel B.
[0072] The channel rating is determined by the packet loss data of all ZigBee devices connected to the gateway device through the channel, and can be determined by the average packet loss value of all ZigBee devices. The first target channel is either the first channel or the second channel, that is, one of the channels available for network access.
[0073] It is understandable that when a gateway device is configured with multiple slave modules, the second channel can include multiple channels, each corresponding to a slave module.
[0074] Through the above embodiments, the gateway device periodically checks the packet loss status of ZigBee devices loaded in the first and second channels, and can also periodically determine the channel ratings of the first and second channels. When both channels corresponding to the master and slave modules are loaded with ZigBee devices, if a packet loss rate of a ZigBee device is detected to be higher than the packet loss threshold, channel switching will only be performed on the ZigBee device if a better channel is available, in order to improve the communication quality of the ZigBee device. This method also enables load balancing between the master and slave modules of the gateway device.
[0075] In some embodiments of this specification, the channel switching method further includes: when all ZigBee devices powered by the first channel switch to the second channel to access the network, the main module determines a third channel that meets preset channel conditions from among the other channels in the ZigBee device's operating frequency band besides the second channel. The main module configures the third channel as the access channel for the network based on network information. The operating frequency band of the third channel is different from that of the second channel.
[0076] In some cases, during continuous operation, the first channel may be affected by other communication protocols in the same frequency band, leading to a deterioration in the communication quality of the ZigBee devices it carries. This may cause all ZigBee devices in the first channel to switch channels. Please refer to [link to relevant documentation]. Figure 5In Figure (c), when all ZigBee devices loaded in the first channel have switched to the second channel to access the network, the first channel corresponding to the master module is no longer loaded with any ZigBee devices. To prevent the master module from being idle and to maintain load balance between the master and slave modules, the master module can select another channel with better quality in the ISM band, configure this channel as a network-accessible channel, and continue to load ZigBee devices simultaneously with the second channel of the slave module.
[0077] Specifically, the main module scans all channels in the ZigBee device's operating frequency band except for the second channel, and determines the third channel that meets the preset channel conditions. Figure 5 In diagram (c), channel A' is used. Then, the main module configures the third channel based on the network information generated when the network is initially created using the first channel, making it a channel accessible to the network. The third channel operates in a different frequency band than the second channel, but the third channel can be the first channel.
[0078] In some embodiments of this specification, such as Figure 6 As shown, the channel switching method also includes:
[0079] S610, if the channel ratings of both the first channel and the second channel are lower than the preset rating standard, the gateway device determines the target module corresponding to the channel with the lowest communication density among the first channel and the second channel.
[0080] Among them, the channel rating is determined based on the packet loss of all ZigBee devices on the channel; the communication density is determined by the number of ZigBee devices on the channel; the target module is either a master module or a slave module.
[0081] S620, the target module scans all channels in the ZigBee device's operating frequency band except for the first and second channels.
[0082] S630, the target module determines the second target channel that meets the preset channel conditions among other channels based on the scanning results.
[0083] S640, if there are no unused target slave modules in the gateway device, the target module configures the second target channel as a network-accessible channel according to the network information, so that all ZigBee devices loaded in the first and second channels can access the network through the second target channel.
[0084] Specifically, during a check cycle, if the gateway device determines that both the channel ratings of the first channel and the second channel are below a preset rating standard, that is, if the overall network quality of both the master and slave modules is poor, then it identifies the target module with the fewest ZigBee devices under load. For example, if the first channel has 10 ZigBee devices under load and the second channel has 5 ZigBee devices under load, then the slave module corresponding to the second channel is the target module.
[0085] During the idle period of the gateway device, the target module periodically scans the channels in the ISM band other than the first and second channels, and determines whether there are any unused better channels among the other channels based on the scan results. If the scan results determine that there is a second target channel among the other channels that meets the preset channel conditions, the second target channel can be configured as the channel for accessing the network, so that the ZigBee devices in the first and second channels can be transferred to the second target channel to access the network.
[0086] The configuration of the second target channel can be in the following two cases:
[0087] First, there are no unused target slave modules in the gateway device, meaning there are no slave modules configured with channels to load balance ZigBee devices. Second, there are unused target slave modules in the gateway device.
[0088] In the first scenario, if there are no unused target slave modules in the gateway device, the target module configures the second target channel as a network-accessible channel based on network information, so that all ZigBee devices loaded in the first and second channels can access the network through the second target channel.
[0089] Since the target module is currently loaded with ZigBee devices, the ZigBee devices loaded on the target module can be cleared first, and then the target module can configure the second target channel.
[0090] Specifically, the target module sends a channel switching command to the ZigBee device loaded in its corresponding channel. For example, if the target module is the master module, it can first switch its loaded ZigBee device to the second channel configured by the slave module to access the network. After the channel corresponding to the target module is cleared, the second channel is configured as a network-accessible channel based on the aforementioned network information.
[0091] Subsequently, other modules besides the target module can send channel switching commands to the ZigBee devices they support, so that all ZigBee devices are transferred to the second target channel to access the network.
[0092] For example, when configuring a second target channel using the main module, please refer to... Figure 7The channel switching method for ZigBee devices may also include:
[0093] S710, the master module sends a channel switching command to all ZigBee devices loaded on the first channel to clear the first channel; the slave module sends a channel switching command to all ZigBee devices loaded on the corresponding second channel to enable all ZigBee devices to switch to the second target channel to access the network.
[0094] In the S720, the main module configures the second target channel as a network-accessible channel based on network information.
[0095] S730, the main module checks the number of ZigBee devices on the load of the second target channel.
[0096] S740, the main module determines whether there are ZigBee devices that failed to switch channels successfully.
[0097] S750: If there is a ZigBee device whose channel failed to switch, the module switches to the channel of the lost ZigBee device and sends a channel switching command to the ZigBee device in that channel.
[0098] S760: If all ZigBee devices switch to the second target channel to access the network, the module enters standby mode.
[0099] In the second scenario, if there is an unused target slave module in the gateway device, the target slave module will configure the second target channel as a channel that can access the network based on the network information.
[0100] Corresponding to the above embodiments, this specification also proposes a computer-readable storage medium, which includes a stored computer program, wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to perform the method as described in any of the embodiments of the first aspect.
[0101] According to the computer-readable storage medium described in this specification, when the computer program is running, after the main module creates a network based on the first channel, if the ZigBee device has a high packet loss rate, the slave module can configure the second channel as the access channel based on the network information generated by creating the network based on the first channel. Both channels can simultaneously support the ZigBee device. When the ZigBee device performs channel switching, if it does not receive a channel switching command or is not powered on, it can still maintain its network access status by accessing the network through the original channel.
[0102] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0103] It should be understood that various parts of this specification can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0104] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0105] In the description of this specification, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this specification and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this specification.
[0106] Furthermore, the terms "first," "second," etc., used in the embodiments of this specification are for descriptive purposes only and should not be construed as indicating or implying relative importance, or implicitly specifying the number of technical features indicated in this embodiment. Therefore, features defined with terms such as "first" and "second" in the embodiments of this specification can explicitly or implicitly indicate that the embodiment includes at least one of those features. In the description of this specification, the word "multiple" means at least two or more, such as two, three, four, etc., unless otherwise explicitly specified in the embodiments.
[0107] In this specification, unless otherwise explicitly specified or limited in the embodiments, the terms "installation," "connection," "joining," and "fixing," etc., appearing in the embodiments, should be interpreted broadly. For example, a connection can be a fixed connection, a detachable connection, or an integral part; it can also be a mechanical connection, an electrical connection, etc. Of course, it can also be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal communication between two components, or the interaction between two components. Those skilled in the art will be able to understand the specific meaning of the above terms in this specification based on the specific implementation.
[0108] In this specification, unless otherwise expressly specified and limited, "above" or "below" the second feature can mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0109] Although embodiments of this specification have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting this specification. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this specification.
Claims
1. A channel switching method for a ZigBee device, characterized in that, Applied to a gateway device, the gateway device being configured with a master module and at least one slave module; the method includes: The main module creates a network through a first channel; wherein, the first channel is used to connect the ZigBee device to the network; If a ZigBee device experiences a packet loss rate exceeding a packet loss threshold in the first channel, the slave module configures the second channel as the access channel for the network based on the network information corresponding to the network; wherein the operating frequency band of the first channel is different from that of the second channel; The main module sends a channel switching command to the ZigBee device so that the ZigBee device can access the network through the second channel; The first channel and the second channel can simultaneously load the ZigBee device, enabling the ZigBee device to be in a network-connected state.
2. The method according to claim 1, characterized in that, The main module creates a network through the first channel, including: The main module scans all channels corresponding to the operating frequency band of the ZigBee device and determines the first channel that meets the preset channel conditions. The main module generates a personal area network address and a key based on the first channel to create the network; wherein the personal area network address and the key constitute the network information corresponding to the network.
3. The method according to claim 1, characterized in that, The network information includes a personal area network address and key generated based on the first channel; The slave module configures the second channel as a channel for accessing the network based on the network information corresponding to the network, including: The module scans other channels in the ZigBee device's operating frequency band besides the first channel, and determines a second channel that meets the preset channel conditions from among the other channels. The slave module configures the second channel as a channel for accessing the network based on the domain network address and the key.
4. The method according to claim 1, characterized in that, After the main module sends a channel switching command to the ZigBee device, the method further includes: If the slave module detects that the ZigBee device is not accessing the network through the second channel, the master module resends the channel switching command to the ZigBee device; or If the slave module detects that the number of times the ZigBee device has failed to access the network through the second channel reaches a preset threshold during the current inspection cycle of the gateway device, the master module waits for the next inspection cycle of the gateway device to send the channel switching command to the ZigBee device in the next inspection cycle.
5. The method according to any one of claims 1 to 4, characterized in that, Both the first channel and the second channel are loaded with ZigBee devices; the method further includes: The gateway device periodically checks the packet loss status of the ZigBee devices carried by the first channel and the second channel; If the packet loss rate of a ZigBee device exceeds the packet loss threshold, the gateway device determines a first target channel with a higher channel rating than the channel carrying the ZigBee device, among the channels other than those carrying the ZigBee device; wherein the channel rating is determined based on the packet loss situation of all ZigBee devices carried by the channel; the first target channel is one of the first channel or the second channel; The master module or slave module corresponding to the channel of the ZigBee device sends a channel switching command to the ZigBee device so that the ZigBee device can access the network through the first target channel.
6. The method according to any one of claims 1 to 4, characterized in that, The method further includes: When all ZigBee devices loaded by the first channel switch to the second channel to access the network, the main module determines a third channel that meets the preset channel conditions from the other channels in the ZigBee device's operating frequency band besides the second channel. The main module configures the third channel as a channel for accessing the network based on the network information; wherein the operating frequency band of the third channel is different from that of the second channel.
7. The method according to any one of claims 1 to 4, characterized in that, The method further includes: If the channel ratings of both the first channel and the second channel are lower than a preset rating standard, the gateway device determines the target module corresponding to the channel with the lowest communication density among the first channel and the second channel; wherein, the channel rating is determined based on the packet loss situation of all ZigBee devices loaded on the channel; the communication density is determined by the number of ZigBee devices loaded on the channel; and the target module is either the master module or the slave module. The target module scans all channels in the ZigBee device's operating frequency band except for the first channel and the second channel; The target module determines a second target channel among the other channels that meets the preset channel conditions based on the scanning results of the scan; If there are no unused target slave modules in the gateway device, the target module configures the second target channel as a channel that can access the network according to the network information, so that all ZigBee devices loaded in the first channel and the second channel can access the network through the second target channel.
8. The method according to claim 7, characterized in that, The target module configures the second target channel as a channel that can access the network based on the network information, including: The target module sends a channel switching command to the ZigBee device loaded in its corresponding channel to clear the channel corresponding to the target module; The target module configures the second target channel as a channel that can access the network based on the network information.
9. The method according to claim 7, characterized in that, After the target module determines a second target channel among the other channels that meets the preset channel conditions based on the scanning results, the method further includes: If there is an unused target slave module in the gateway device, the target slave module configures the second target channel as a channel that can access the network according to the network information.
10. A gateway device, characterized in that, The gateway device is configured with a master module and at least one slave module; The main module is used to create a network through a first channel; wherein, the first channel is used to connect ZigBee devices to the network; If a ZigBee device experiences a packet loss rate exceeding a packet loss threshold in the first channel, the slave module configures the second channel as the access channel for the network based on the network information corresponding to the network; wherein the operating frequency band of the first channel is different from that of the second channel. The main module is also used to send a channel switching command to the ZigBee device so that the ZigBee device can access the network through the second channel; The first channel and the second channel can simultaneously load the ZigBee device, enabling the ZigBee device to be in a network-connected state.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Anti-interference method and equipment of ZigBee network
CN103517293A
ZigBee terminal node network management method and ZigBee terminal node network management system
CN110972163A
Anti-interference method, device and system of Zigbee network
CN114071433A