Adaptive multi-level wireless networking method and communication method for terminal device management system

WO2026179191A1PCT designated stage Publication Date: 2026-09-03HANGZHOU FANGQIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/129359
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-02-26
Filing Date
2025-10-22
Publication Date
2026-09-03

Smart Images

  • Figure CN2025129359_03092026_PF_FP_ABST
    Figure CN2025129359_03092026_PF_FP_ABST
Patent Text Reader

Abstract

The present invention relates to the field of wireless networking. Disclosed are an adaptive multi-level wireless networking method and communication method for a terminal device management system. A gateway in the terminal device management system first preconfigures one terminal device as a level-1 master-slave device, and issues a target networking request; the master-slave device broadcasts query information on the basis of the request, calculates the communication quality of responding devices, selects slave devices managed by the master-slave device and a next-level master-slave device, and returns information to the gateway, wherein the slave devices form a device group of a corresponding level; and the gateway then updates the request level and the ID number of a target master-slave device, and continues sending a networking request to the next master-slave device until the construction of the entire network is completed. Such an adaptive mechanism ensures that stable communication performance can be maintained even when network topology changes or a failure occurs, thereby significantly improving the efficiency and reliability of large-scale terminal device management.
Need to check novelty before this filing date? Find Prior Art

Description

Adaptive Multilevel Wireless Networking Method and Communication Method for Terminal Equipment Management System Technical Field

[0001] This invention relates to the field of wireless networking, and more particularly to an adaptive multi-level wireless networking method and communication method for a terminal equipment management system. Background Technology

[0002] In traditional wireless communication architectures, the number of terminals and geographical coverage that a single gateway node can directly manage are limited due to the limitations of wireless transmission range. To overcome this challenge, two methods are typically employed: First, as shown in Figure 4, multiple gateway nodes are deployed to extend network coverage, and interconnection and data synchronization between these gateways are ensured through wired or wireless networks; second, as shown in Figure 5, fixed routing nodes are added to the network as relay stations to extend the signal transmission distance. However, the first approach not only increases hardware costs and reliance on stable power supplies and network connections but also raises system complexity and maintenance requirements; while the second approach can achieve long-distance communication, the relay nodes are independent and require external power, and a failure could cause a communication outage across the entire network, thus affecting the overall reliability and stability of the system. Technical issues

[0003] To achieve cascading of multiple levels of terminal devices under a single gateway node, thereby overcoming transmission distance limitations, while reducing overall costs and simplifying installation and maintenance, this invention proposes an adaptive multi-level wireless networking method for a terminal device management system. Technical solutions

[0004] This invention proposes an adaptive multi-level wireless networking method for a terminal device management system, wherein the terminal device management system includes a gateway and multiple terminal devices; the adaptive multi-level wireless networking method includes the following steps:

[0005] S1: In the terminal device management system, a terminal device is preset as a first-level master-slave device;

[0006] S2: The gateway sends a target networking request to the first-level master-slave device. This request is an i-level networking request; i is a positive integer greater than or equal to 1; the target networking request includes the ID number of the target master-slave device.

[0007] S3: The primary master and slave devices determine whether the target networking request is a Level 1 networking request. If yes, proceed to the next step; otherwise, jump to step S7.

[0008] S4: The primary master and slave devices proceed to step S5 to execute the networking process based on the target networking request;

[0009] S5: Broadcast query information, and calculate the communication quality of each responding device based on the received response information. Use the communication quality to select the next-level master / slave device and / or the responding device to be managed by the current master / slave device, i.e., the slave device. The selected slave devices form a device group of the corresponding level, and return the formed device group and the device information of the selected next-level master / slave device to the gateway. The responding device refers to the terminal device that received the query information.

[0010] S6: After receiving the return information corresponding to the current target networking request, the gateway increments the level i of the target networking request by 1, updates the ID number of the target master-slave device in the request to the ID number of the next-level master-slave device in the return information, and returns to step S2.

[0011] S7: The first-level master-slave device forwards the target network request to the next-level master-slave device based on the ID number of the target master-slave device in the target network request; when the next-level master-slave device determines that it is not the target master-slave device in the target network request, the master-slave device continues to forward the target network request to the next-level master-slave device until the target master-slave device is reached; the target master-slave device returns to step S5 to execute the network process based on the target network request.

[0012] Furthermore, step S5 specifically includes:

[0013] Broadcast query information and determine if the number of responding devices is 0. If it is, the network is complete. If not, calculate the communication quality of each responding device based on the received response information. Based on the relationship between the communication quality of the responding device and the upper and lower limits of the preset standard range, select the next-level master / slave device and / or the responding device to be managed by the current master / slave device. The selected slave devices form a device group of the corresponding level. The formed device group and the device information of the selected next-level master / slave device are returned to the gateway.

[0014] Furthermore, the formula for calculating the communication quality is as follows:

[0015] ;

[0016] In the formula, RSSI represents the signal strength of the response information corresponding to the response device. max and RSSI min These are the maximum and minimum signal strength values ​​among all terminal devices. SNR represents the signal-to-noise ratio of the response information from the responding device. max and SNR min W1 and W2 represent the maximum and minimum signal-to-noise ratios among all terminal devices, respectively. W1 and W2 represent the weights of signal strength and signal-to-noise ratio, respectively. Score represents the communication quality.

[0017] Furthermore, after the selected equipment forms a corresponding level of equipment group, it also includes:

[0018] The current master-slave device sends the group information of the device group to each slave device in the device group; the group information includes the level of the device group and the ID number of the corresponding master-slave device; the current master-slave device is a first-level master-slave device or a target master-slave device.

[0019] Further, in step S5, based on the relationship between the communication quality of the responding device and the upper and lower limits of the preset standard range, the next-level master / slave device and / or the responding device to be managed by the current master / slave device are selected using the communication quality; the selected slave devices form a device group of the corresponding level, and the formed device group and the device information of the selected next-level master / slave device are returned to the gateway, specifically as follows:

[0020] S51: Determine if the number of responding devices is greater than 1. If yes, proceed to the next step; otherwise, jump to step S56.

[0021] S52: Determine whether the communication quality of any responding device is within the preset standard range. If yes, proceed to the next step; otherwise, jump to step S54.

[0022] S53: Determine whether the number of responding devices within the preset standard range is greater than 1. If yes, select one of the multiple responding devices whose communication quality is the median value or the smallest difference from the median value as the next-level master-slave device, and jump to step S55. If no, set the only responding device within the preset standard range as the next-level master-slave device, and jump to step S55.

[0023] S54: Determine whether the communication quality of the responding devices is greater than the upper limit of the preset standard range. If yes, proceed to step S56; otherwise, select the responding device that is closest to the preset standard range as the next level master-slave device.

[0024] S55: Determine whether there is a response device among the remaining response devices with a communication quality greater than a preset value. If yes, set the response device with a communication quality greater than the preset value as a slave device of the corresponding master-slave device, form a device group of the corresponding level, and return the device group and the device information of the next level master-slave device to the gateway, and jump to step S6. If no, return the device information of the next level master-slave device to the gateway, and jump to step S6.

[0025] S56: Set the responding device as a slave device of the corresponding master-slave device, the set slave devices form a device group of the corresponding level, and return the device information of the device group to the gateway, and the network formation ends.

[0026] Furthermore, the terminal device management system also includes:

[0027] A network server connected to the gateway is used to display wireless networking information; the wireless networking information includes: device information of master and slave devices at each level, and device information of slave devices included in the device groups corresponding to master and slave devices at each level.

[0028] This invention also proposes an adaptive multi-level wireless communication method for a terminal device management system, comprising the following steps:

[0029] S01: Wireless networking is achieved for terminal devices in the terminal device management system using the adaptive multi-level wireless networking method described above;

[0030] S02: The gateway sends data packets to the primary master and slave devices;

[0031] S03: After receiving the data packet, the first-level master and slave device sends the data packet to each slave device in the corresponding level device group and the next-level master and slave device, and returns the sending result to the gateway;

[0032] S04: After receiving the transmission result, the gateway generates a data packet forwarding request containing the target master / slave device ID number and sends it to the first-level master / slave device; the target master / slave device is the next-level master / slave device of the master / slave device corresponding to the currently received transmission result;

[0033] S05: After receiving a data packet forwarding request, the first-level master-slave device forwards the data packet forwarding request to the next-level master-slave device. The next-level master-slave device determines whether it is the target master-slave device in the data packet forwarding request. If it is, it proceeds to the next step. If not, it continues to forward the data packet forwarding request to the next-level master-slave device until the request is forwarded to the target master-slave device.

[0034] S06: The target master-slave device determines whether it is the last-level master-slave device. If not, it sends the data packet to each slave device in the corresponding level device group and the next-level master-slave device, and returns the sending result to the gateway, while returning to step S04. If yes, the target master-slave device determines whether it manages slave devices. If yes, it sends the data packet to each slave device in the corresponding level device group and returns the sending result to the gateway. If not, it directly returns the sending result to the gateway.

[0035] S07: The gateway terminates communication after receiving the transmission result returned by the last-level master and slave devices.

[0036] Furthermore, the adaptive multi-level wireless communication method further includes:

[0037] The fault detection process includes the following steps:

[0038] S001: The gateway sends a query request to the primary master-slave device; the query request contains the ID number of the target master-slave device; in the first query request sent by the gateway, the ID number of the target master-slave device is the ID number of the primary master-slave device;

[0039] S002: After receiving a query request, the first-level master-slave device determines whether it is the target master-slave device in the query request. If so, it returns the query result to the gateway; if not, it continues to forward the query request to the next lower-level master-slave device until the request is forwarded to the target master-slave device. After receiving the query request, the target master-slave device returns the query result to the gateway.

[0040] S003: The gateway determines whether it has received the query result corresponding to the current query request within a preset time period. If yes, it proceeds to the next step; if no, it indicates that the corresponding target master-slave device is faulty. The gateway switches the master-slave device corresponding to the query request and proceeds to the next step after the switch is completed.

[0041] S004: Determine whether the master-slave device corresponding to the current query result is the highest level master-slave device. If yes, it means that the fault detection is complete; otherwise, update the ID number in the query request to the ID number of the next level master-slave device corresponding to the current query result and return S001.

[0042] Furthermore, the switching of the master / slave device corresponding to the query request specifically involves:

[0043] The gateway selects the slave device with the best communication quality from the device group corresponding to the faulty master and slave devices based on the communication quality data calculated during network setup, and replaces the current faulty master and slave devices.

[0044] Furthermore, in step S06, returning the sending result to the gateway specifically involves the target master-slave device returning the sending result to the gateway level by level through the master-slave devices at each preceding level. Beneficial effects

[0045] Compared with the prior art, the present invention has at least the following beneficial effects:

[0046] (1) The adaptive multi-level wireless networking method proposed in this invention aims to achieve automatic cascading of multi-level terminal devices through a single gateway node, thereby breaking through the transmission distance limitation, reducing the overall cost, and simplifying installation and maintenance. It avoids the high cost and complexity caused by adding multiple gateways or fixed relay nodes. Its core technology is to allow terminal devices to dynamically switch master-slave modes according to the actual communication quality. It can act as a regular terminal or a relay, reducing the strict requirements on the device arrangement order and enhancing the flexibility and adaptability of the network. Specifically, the gateway first presets a terminal device as a first-level master-slave device and sends a target networking request. The master-slave device broadcasts query information according to the request, calculates the communication quality of the responding device, selects the slave device it manages and the next-level master-slave device, and the slave device forms a device group of the corresponding level and returns the information to the gateway. The gateway then updates the request level and the target master-slave device ID number and continues to send networking requests to the next master-slave device until the construction of the entire network is completed. This adaptive mechanism ensures that stable communication performance can be maintained even when the network topology changes or a fault occurs, which significantly improves the efficiency and reliability of large-scale terminal device management.

[0047] (2) The present invention reduces the strict requirements on the installation location and sequence of the equipment by automatically selecting the master and slave devices through a dynamic adjustment mechanism, making the installation more flexible and convenient; at the same time, once a master or slave device fails, the system can automatically select a new master or slave device to replace it, reducing the maintenance difficulty and downtime, thereby significantly reducing the overall operation and maintenance cost.

[0048] (3) In the networking process, the present invention selects the most suitable next-level master and slave devices and their managed slave devices by calculating the communication quality of the response device, thus ensuring the optimal allocation of resources; in addition, the fault detection process and master and slave device switching mechanism further optimize the efficiency of resource utilization, ensuring that the network always maintains a high-efficiency operating state.

[0049] (4) This invention is particularly suitable for scenarios such as traffic lighting, such as the large-scale deployment of tunnel lighting equipment. It can quickly complete data synchronization without sacrificing communication quality. Attached Figure Description

[0050] Figure 1 is a flowchart of an adaptive multi-level wireless networking method for a terminal device management system in an embodiment of the present invention;

[0051] Figure 2 is a flowchart of an adaptive multi-level wireless communication method for a terminal device management system in an embodiment of the present invention;

[0052] Figure 3 is a wireless network structure diagram of the terminal device management system in an embodiment of the present invention;

[0053] Figure 4 is a network structure diagram of extending network coverage through multiple gateway nodes in the prior art;

[0054] Figure 5 shows a network structure diagram of extending network coverage through multiple relay nodes in the prior art. Embodiments of the present invention

[0055] The following are specific embodiments of the present invention, which are described in conjunction with the accompanying drawings. However, the present invention is not limited to these embodiments.

[0056] Example 1

[0057] To achieve cascading of multiple levels of terminal devices under a single gateway node, thereby overcoming transmission distance limitations, reducing overall costs, and simplifying installation and maintenance, as shown in Figure 1, this invention proposes an adaptive multi-level wireless networking method for a terminal device management system. The terminal device management system includes a gateway and multiple terminal devices. The adaptive multi-level wireless networking method includes the following steps:

[0058] S1: In the terminal device management system, a terminal device is preset as a first-level master-slave device;

[0059] S2: The gateway sends a target networking request to the first-level master and slave devices. This request is a level i networking request; i is a positive integer greater than or equal to 1; the target networking request includes the ID number of the target master and slave devices; the level of the master and slave devices corresponds one-to-one with the level of the target networking request; the first target networking request sent by the gateway is a level 1 networking request.

[0060] S3: The primary master and slave devices determine whether the target networking request is a Level 1 networking request. If yes, proceed to the next step; otherwise, jump to step S7.

[0061] S4: The primary master and slave devices proceed to step S5 to execute the networking process based on the target networking request;

[0062] S5: Broadcast query information, and calculate the communication quality of each responding device based on the received response information. Use the communication quality to select the next-level master / slave device and / or the responding device to be managed by the current master / slave device, i.e., the slave device. The selected slave devices form a device group of the corresponding level, and return the formed device group and the device information of the selected next-level master / slave device to the gateway. The responding device refers to the terminal device that received the query information.

[0063] It should be noted that in the wireless networking scheme of this invention, the master and slave devices are actually the same type of terminal devices; the only difference between them is their logical roles. Each terminal designated as a master or slave device is not only responsible for managing a group of subordinate slave devices, but it is also managed by the master or slave device at the next higher level as a slave device itself. For example, a second-level master or slave device manages the slave devices in a second-level device group, while it itself is managed and communicates with a first-level master or slave device. The top-level first-level master or slave device directly receives management and instructions from the gateway. This hierarchical management structure allows the network to automatically cascade multiple levels of terminal devices through a single gateway node, thereby breaking through the transmission distance limitations of traditional schemes and simplifying installation and maintenance. By dynamically adjusting the master-slave mode, these devices can switch roles when necessary, acting as ordinary terminals or repeaters, enhancing the flexibility and adaptability of the network and ensuring stable communication performance even when the network topology changes or failures occur.

[0064] The S5 step is specifically as follows:

[0065] Broadcast query information and determine if the number of responding devices is 0. If it is, the network is complete. If not, calculate the communication quality of each responding device based on the received response information. Based on the relationship between the communication quality of the responding device and the upper and lower limits of the preset standard range, select the next-level master / slave device and / or the responding device to be managed by the current master / slave device. The selected slave devices form a device group of the corresponding level. The formed device group and the device information of the selected next-level master / slave device are returned to the gateway.

[0066] The formula for calculating the communication quality is:

[0067] ;

[0068] In the formula, RSSI represents the signal strength of the response information corresponding to the response device. max and RSSI min These are the maximum and minimum signal strength values ​​among all terminal devices. SNR represents the signal-to-noise ratio of the response information from the responding device. max and SNR min W1 and W2 represent the maximum and minimum signal-to-noise ratios among all terminal devices, respectively. W1 and W2 represent the weights of signal strength and signal-to-noise ratio, respectively. Score represents the communication quality.

[0069] It's important to note that when building a wireless network, master and slave devices need to maintain a certain distance to optimize communication efficiency, but they cannot be too far apart to ensure reliable and stable communication. However, in actual deployments, since terminal devices may not be installed in the preset ID number order, the master and slave devices cannot know in advance the specific ID numbers of subsequent slave devices and their relative distances. Furthermore, the propagation characteristics of radio waves mean that all devices within the receiving range will receive the sent message almost simultaneously, and their responses will arrive at the sending device almost simultaneously as well. For example, in the scenario shown in Figure 3, when master / slave device 2 broadcasts a message, its managed slave devices 2-1, 2-2, through 2-N, etc., will receive this information almost simultaneously, and their responses will be returned to master / slave device 2 almost synchronously.

[0070] Therefore, in such an environment, the selection of suitable master / slave devices cannot be directly based on physical distance relationships. Instead, the system must rely on other indicators to determine the optimal master / slave devices and their corresponding slave devices. Specifically, this invention employs a communication quality-based selection strategy. The communication quality of each responding device is calculated by measuring signal strength index (RSSI) and signal-to-noise ratio (SNR) and combining them with weighting parameters w1 and w2. This allows the system to dynamically adjust according to the actual wireless environment without prior knowledge of the physical location or distance between devices. Ultimately, devices with higher communication quality are selected as the next-level master / slave device or as the slave device of the current master / slave device, thus ensuring good communication performance even when the network topology changes. This adaptive approach enhances network flexibility and reliability, reduces the requirements for device arrangement order, simplifies the installation process, and lowers maintenance difficulty.

[0071] It should be noted that, considering the generally negative correlation between the signal strength (RSSI) and signal-to-noise ratio (SNR) of a wireless module and communication distance—meaning these parameters typically decrease with increasing distance—this embodiment evaluates the communication quality between devices by comprehensively calculating these two parameters. Since the relationship between signal strength and SNR and distance is not strictly linear, relying solely on either parameter to calculate communication quality is inappropriate. Therefore, this solution employs a comprehensive scoring mechanism, dynamically selecting the slave device to be managed and the next master / slave device based on real-time communication quality. This method not only effectively ensures communication reliability but also reduces the stringent requirements on installation location and sequence, enhancing the system's flexibility and adaptability. It ensures that the network can automatically adjust according to actual environmental conditions after deployment, maintaining optimal performance and a stable communication link.

[0072] In step S5, based on the relationship between the communication quality of the responding device and the upper and lower limits of the preset standard range, the next-level master / slave device and / or the responding device to be managed by the current master / slave device are selected using communication quality. The selected slave devices form a device group of the corresponding level, and the formed device group and the device information of the selected next-level master / slave device are returned to the gateway. Specifically:

[0073] S51: Determine if the number of responding devices is greater than 1. If yes, proceed to the next step; otherwise, jump to step S56.

[0074] S52: Determine whether the communication quality of any responding device is within the preset standard range. If yes, proceed to the next step; otherwise, jump to step S54.

[0075] S53: Determine whether the number of responding devices within the preset standard range is greater than 1. If yes, select one of the multiple responding devices whose communication quality is the median value or the smallest difference from the median value as the next-level master-slave device, and jump to step S55. If no, set the only responding device within the preset standard range as the next-level master-slave device, and jump to step S55.

[0076] S54: Determine whether the communication quality of the responding devices is greater than the upper limit of the preset standard range. If yes, proceed to step S56; otherwise, select the responding device that is closest to the preset standard range as the next level master-slave device.

[0077] S55: Determine whether there is a response device among the remaining response devices with a communication quality greater than a preset value. If yes, set the response device with a communication quality greater than the preset value as a slave device of the corresponding master-slave device, form a device group of the corresponding level, and return the device group and the device information of the next level master-slave device to the gateway, and jump to step S6. If no, return the device information of the next level master-slave device to the gateway, and jump to step S6.

[0078] S56: Set the responding device as a slave device of the corresponding master-slave device, the set slave devices form a device group of the corresponding level, and return the device information of the device group to the gateway, and the network formation ends.

[0079] It should be noted that the preset value is less than the lower limit of the preset standard range.

[0080] After the selected devices form the corresponding level of device group, it also includes:

[0081] The current master-slave device sends the group information of the device group to each slave device in the device group; the group information includes the level of the device group and the ID number of the corresponding master-slave device; the current master-slave device is a first-level master-slave device or a target master-slave device.

[0082] S6: After receiving the return information corresponding to the current target networking request, the gateway increments the level i of the target networking request by 1, updates the ID number of the target master-slave device in the request to the ID number of the next-level master-slave device in the return information, and returns to step S2.

[0083] S7: The first-level master-slave device forwards the target network request to the next-level master-slave device based on the ID number of the target master-slave device in the target network request; when the next-level master-slave device determines that it is not the target master-slave device in the target network request, the master-slave device continues to forward the target network request to the next-level master-slave device until the target master-slave device is reached; the target master-slave device returns to step S5 to execute the network process based on the target network request.

[0084] In actual deployments, the installation of terminal devices does not necessarily follow the order of their ID numbers. The labels in Figure 3, such as 1-1, 1-2, 1-N, etc., are for illustrative purposes only (Master-Slave Device 1, Master-Slave Device 2, and Master-Slave Device 3 represent Level 1, Level 2, and Level 3 master-slave devices, respectively; Master-Slave Device 1's slave devices include slave devices 1-1, 1-2, and 1-N; Master-Slave Device 2's slave devices include slave devices 2-1, 2-2, and 2-N; and Master-Slave Device 3's slave device includes slave device 3-1). These labels do not represent the actual ID numbers of the devices. Therefore, when setting up a network, one cannot rely on fixed distances or intervals to select master-slave devices, nor can one pre-define which slave devices a particular master-slave device should manage. For example, Master-Slave Device 2 in the figure is dynamically selected based on actual communication quality and can be adjusted at any time; the second group of slave devices it manages is also determined based on the on-site installation conditions, rather than being pre-specified.

[0085] At the physical layer, wireless communication uses broadcasting for message transmission. This means that when master / slave device 2 sends a message, all devices within its signal coverage area can receive this information. However, at the software layer, the destination address (ID number) contained in the message determines which devices should process the message, while other irrelevant devices will filter it out. This mechanism enables the system to implement unicast, multicast, and broadcast functions, where unicast and multicast refer to master / slave device 2 being able to multicast or unicast messages to slave devices in its corresponding level of device group.

[0086] The terminal device management system also includes:

[0087] A network server connected to the gateway is used to display wireless networking information; the wireless networking information includes: device information of master and slave devices at each level, and device information of slave devices included in the device groups corresponding to master and slave devices at each level.

[0088] The adaptive multi-level wireless networking method proposed in this invention aims to achieve automatic cascading of multi-level terminal devices through a single gateway node, thereby overcoming transmission distance limitations, reducing overall costs, and simplifying installation and maintenance. It avoids the high costs and complexity associated with adding multiple gateways or fixed relay nodes. Its core technology allows terminal devices to dynamically switch between master-slave modes based on actual communication quality, functioning as both ordinary terminals and repeaters. This reduces the strict requirements on device arrangement order and enhances network flexibility and adaptability. Specifically, the gateway first presets one terminal device as a first-level master-slave device and sends a target networking request. The master-slave device broadcasts query information based on the request, calculates the communication quality of the responding device, selects its managed slave devices and the next-level master-slave devices, forming a device group of the corresponding level, and returns the information to the gateway. The gateway then updates the request level and the target master-slave device ID, continuing to send networking requests to the next master-slave device until the entire network is constructed. This adaptive mechanism ensures stable communication performance even when the network topology changes or failures occur, significantly improving the efficiency and reliability of managing large-scale terminal devices.

[0089] Example 2

[0090] As shown in Figure 2, this embodiment of the invention also proposes an adaptive multi-level wireless communication method for a terminal device management system, including the following steps:

[0091] S01: Wireless networking is achieved for terminal devices in the terminal device management system using the adaptive multi-level wireless networking method described above;

[0092] S02: The gateway sends data packets to the primary master and slave devices;

[0093] S03: After receiving the data packet, the first-level master and slave device sends the data packet to each slave device in the corresponding level device group and the next-level master and slave device, and returns the sending result to the gateway;

[0094] S04: After receiving the transmission result, the gateway generates a data packet forwarding request containing the target master / slave device ID number and sends it to the first-level master / slave device; the target master / slave device is the next-level master / slave device of the master / slave device corresponding to the currently received transmission result;

[0095] S05: After receiving a data packet forwarding request, the first-level master-slave device forwards the data packet forwarding request to the next-level master-slave device. The next-level master-slave device determines whether it is the target master-slave device in the data packet forwarding request. If it is, it proceeds to the next step. If not, it continues to forward the data packet forwarding request to the next-level master-slave device until the request is forwarded to the target master-slave device.

[0096] S06: The target master-slave device determines whether it is the last-level master-slave device. If not, it sends the data packet to each slave device in the corresponding level device group and the next-level master-slave device, and returns the sending result to the gateway, while returning to step S04. If yes, the target master-slave device determines whether it manages slave devices. If yes, it sends the data packet to each slave device in the corresponding level device group and returns the sending result to the gateway. If not, it directly returns the sending result to the gateway.

[0097] S07: The gateway terminates communication after receiving the transmission result returned by the last-level master and slave devices.

[0098] In step S06, returning the sending result to the gateway specifically involves the target master-slave device returning the sending result to the gateway level by level through the master-slave devices at each preceding level.

[0099] In detail, in the normal network communication process, after the gateway completes the wireless network setup according to step S01, it sends data packets to the primary master / slave device (i.e., master / slave device 1) according to step S02. Upon receiving the data packets, master / slave device 1, according to step S03, multicasts the data packets to its managed slave devices and the next master / slave device (master / slave device 2), and simultaneously sends back the reception status (transmission result) of these devices to the gateway. After receiving the transmission result returned by master / slave device 1, the gateway records this information and generates a new data packet forwarding request according to step S04, which includes the ID number of the target master / slave device (i.e., master / slave device 2), and then sends this request again to master / slave device 1. It is important to note that this forwarding request only carries instructions and does not include the actual data packets to be forwarded.

[0100] Next, in steps S05 and S06, after receiving the packet forwarding request from the gateway, master-slave device 1 forwards it to master-slave device 2. Upon receiving the request, master-slave device 2 confirms whether it is the designated target master-slave device. If so, it repeats the operation of master-slave device 1: sending the packet previously sent by master-slave device 1 to its managed slave devices and next-level master-slave devices, and sending the result back to the higher-level master-slave device 1. This process proceeds layer by layer, with each subsequent master-slave device performing the same operation until the data is passed to the last-level master-slave device. If the master-slave device does not manage any more slave devices or next-level master-slave devices, the communication is considered complete. Throughout the process, the results from each level of master-slave device are relayed back to the gateway level by level from the preceding master-slave devices. Finally, the gateway aggregates all results and uploads the data to the network server for users to view. This method ensures efficient and reliable data transmission even in complex network topologies.

[0101] The adaptive multi-level wireless communication method further includes:

[0102] The fault detection process includes the following steps:

[0103] S001: The gateway sends a query request to the primary master-slave device; the query request contains the ID number of the target master-slave device; in the first query request sent by the gateway, the ID number of the target master-slave device is the ID number of the primary master-slave device;

[0104] S002: After receiving a query request, the first-level master-slave device determines whether it is the target master-slave device in the query request. If so, it returns the query result to the gateway; if not, it continues to forward the query request to the next lower-level master-slave device until the request is forwarded to the target master-slave device. After receiving the query request, the target master-slave device returns the query result to the gateway.

[0105] S003: The gateway determines whether it has received the query result corresponding to the current query request within a preset time period. If yes, it proceeds to the next step; if no, it indicates that the corresponding target master-slave device is faulty. The gateway switches the master-slave device corresponding to the query request and proceeds to the next step after the switch is completed.

[0106] The specific steps for switching the master / slave device corresponding to the query request are as follows:

[0107] The gateway selects the slave device with the best communication quality from the device group corresponding to the faulty master and slave devices based on the communication quality data calculated during network setup, and replaces the current faulty master and slave devices.

[0108] It should be noted that when multiple slave devices have communication quality at their maximum value, any slave device with the highest communication quality is selected to replace the current faulty master / slave device. After selecting the new master / slave device, the information of the slave devices previously managed by the faulty master / slave device is sent to the newly selected master / slave device. Upon receiving this information, the new master / slave device will complete a dynamic role switch and officially take over the responsibilities of the original master / slave device. Through this intelligent and dynamic adjustment mechanism, it can be ensured that even if the master / slave device fails, network communication can still maintain a high degree of reliability and stability.

[0109] In addition, since the faulty master and slave devices may automatically resume communication or be manually repaired, there are two master and slave devices of the same level. Therefore, during the communication process, when the original faulty master and slave device also receives the request, it can confirm that there is a new master and slave device in place by matching the ID number in the request, and thus automatically switch back to the slave device mode of the device group, avoiding duplicate management and potential conflicts.

[0110] Since the master and slave devices in this embodiment are identical in hardware, the master and slave devices can be automatically switched when a failure occurs, thereby avoiding network communication failure due to problems with the master and slave devices.

[0111] S004: Determine whether the master-slave device corresponding to the current query result is the highest level master-slave device. If yes, it means that the fault detection is complete; otherwise, update the ID number in the query request to the ID number of the next level master-slave device corresponding to the current query result and return S001.

[0112] It should be noted that the solution of this invention is particularly suitable for traffic lighting scenarios, such as the deployment of tunnel lighting equipment. The distribution range of equipment within a tunnel may exceed 10 kilometers, imposing strict requirements on communication distance. Furthermore, since these devices are primarily used for lighting control, the amount of data they transmit is relatively small, and a certain degree of latency can be tolerated. Therefore, the adaptive multi-level wireless networking method and communication method proposed in this invention can well meet the functional requirements of tunnel lighting systems. This method achieves automatic cascading of multi-level terminal devices through a single gateway node, not only solving the cost and complexity problems caused by the need for multiple gateways or fixed routing nodes in traditional solutions, but also reducing the workload of installation and maintenance. Tests show that a network consisting of 3 master-slave devices and 7 slave devices within a 1-kilometer range can complete data synchronization within 5 seconds, demonstrating the efficiency and reliability of this solution in practical applications.

[0113] Considering the need for large-scale equipment upgrades, this invention also provides an optimized upgrade method to address the firmware update challenges in long-distance, large-scale equipment scenarios such as tunnel lighting. Traditional upgrade methods typically involve a one-to-one master-slave process, where the master must wait for confirmation from the slave after each data packet is sent. Upgrading a 50KB software package for 200 devices distributed over a 10km radius using this method is expected to take at least 11 hours. This invention, however, utilizes its unique communication mechanism, where the master and slave devices manage slave devices in groups, thus significantly reducing the upgrade time. Specifically:

[0114] 1. The gateway first transmits the upgrade package to the first-level master and slave devices. After receiving the complete upgrade package, the master and slave devices will read it and assign a sequential number to each data block in the upgrade package, resulting in multiple data packets with sequential numbers. They will then send these data packets in sequence to the slave devices they manage and the next-level master and slave devices via multicast.

[0115] It's important to note that a complete upgrade package typically contains multiple data packets. This is because firmware or other types of software update files are often quite large and cannot be transmitted in one go over the LoRa network. To ensure reliable transmission, each larger upgrade package is broken down into multiple smaller data packets for transmission. Each such data packet is assigned a unique sequence number (i.e., a sequence number), which helps the receiver correctly assemble and verify the received data. This ensures that even if some data packets are lost or corrupted, it is possible to identify which data needs to be retransmitted.

[0116] 2. Upon receiving a data packet, each slave device writes it to the corresponding location in its memory according to the packet's sequence number. If a data packet fails verification or has encryption / decryption errors, the slave device actively discards it, and its sequence number is recorded as a lost packet. Once the master and slave devices have completed the initial transmission of all data packets, they query each slave device under their management to understand their respective packet loss situation. For any lost data packet, the master and slave devices retransmit it one by one. However, before each retransmission, the master and slave devices check whether the number of retransmissions for that data packet exceeds the preset maximum number of retransmissions. If the number of retransmissions has not exceeded the limit, the retransmission operation is performed, and the retransmission count is incremented by 1; if the number of retransmissions has reached or exceeded the preset value, no further retransmission attempts are made, and this situation is reported to the gateway as the final retransmission result. This mechanism ensures that even under poor network conditions, all slave devices can receive complete upgrade data as much as possible, while avoiding unnecessary duplicate transmissions and improving communication efficiency.

[0117] It should be noted that due to the broadcast nature of LoRa technology, even if data packets are retransmitted in unicast form, other slave devices with the same packet loss can receive the data packets and update their own packet loss records. However, only the slave device that the master or slave device finds has packet loss (the target slave device) needs to respond and confirm. Other devices only need to update their own packet loss records when necessary without responding.

[0118] Specifically, during unicast retransmission, although only the target slave device needs to acknowledge the loss, other slave devices may receive these retransmitted data packets. If other slave devices did indeed lose data packets with the same number previously, they can take this opportunity to receive and store these packets and update their own packet loss records accordingly to reflect the latest status. Therefore, even if these devices did not initially report packet loss, they may still need to update their own packet loss records because new data packets may compensate for previous omissions.

[0119] Additionally, master and slave devices can check for packet loss by querying the status of the slave device. This is typically done by requesting the slave device to report a list of packet numbers it has successfully received. Based on this list, the master and slave devices can compare the packet numbers they sent to identify which packets were not acknowledged, thus determining which packets were lost by the slave device.

[0120] Once this process is complete, the primary master-slave device reports the upgrade result to the gateway. Subsequently, the gateway continues to request the next-level master-slave device to begin upgrading the slave devices it manages, through the primary master-slave device, until all devices have successfully received all data packets.

[0121] After testing, using this upgrade method, the upgrade time for one group of devices is about 200 seconds. Theoretically, the overall upgrade time for 200 devices can be shortened to about 1 hour, which greatly improves efficiency.

[0122] In summary, the adaptive multi-level wireless communication method provided by this invention enables long-distance communication without the need for additional hardware such as gateways. By dynamically searching for ID numbers to establish logical groups, network construction is independent of the specific location of devices and the preset ID number order, simplifying the installation process and avoiding strict requirements on the arrangement order of terminal devices. Furthermore, the dynamic selection of master and slave devices ensures that even if one master or slave device fails, the entire network communication will not be interrupted, enhancing the system's stability and reliability. A practical application based on this principle—the large-scale synchronous communication and upgrade maintenance of tunnel lighting equipment—demonstrates that this solution significantly reduces operation and maintenance costs while improving communication performance, providing an effective solution for similar application scenarios.

Claims

1. An adaptive multi-level wireless networking method for a terminal device management system, characterized in that, The terminal device management system includes a gateway and multiple terminal devices; the adaptive multi-level wireless networking method includes the following steps: S1: In the terminal device management system, a terminal device is preset as a first-level master-slave device; S2: The gateway sends a target networking request to the first-level master-slave device. This request is an i-level networking request; i is a positive integer greater than or equal to 1; the target networking request includes the ID number of the target master-slave device. S3: The primary master and slave devices determine whether the target networking request is a Level 1 networking request. If yes, proceed to the next step; otherwise, jump to step S7. S4: The primary master and slave devices enter step S5 to execute the networking process based on the target networking request; S5: Broadcast query information and calculate the communication quality of each responding device based on the received response information. Use the communication quality to select the next level master / slave device and / or the responding device to be managed by the current master / slave device, i.e., the slave device. The selected slave devices form a device group at the corresponding level, and the device group and the device information of the selected next-level master and slave devices are returned to the gateway; the responding device represents the terminal device that received the query information; step S5 specifically includes: Broadcast query information and determine whether the number of responding devices is 0. If it is, the network is completed; otherwise, calculate the communication quality of each responding device based on the received response information, and select the next level master / slave device and / or the responding device to be managed by the current master / slave device based on the relationship between the communication quality of the responding device and the upper and lower limits in the preset standard range. The selected slave devices form a device group at the corresponding level, and the formed device group and the device information of the selected next-level master and slave devices are returned to the gateway; In step S5, based on the relationship between the communication quality of the responding device and the upper and lower limits of the preset standard range, the next-level master / slave device and / or the responding device to be managed by the current master / slave device are selected using communication quality. The selected slave devices form a device group of the corresponding level, and the formed device group and the device information of the selected next-level master / slave device are returned to the gateway. Specifically: S51: Determine if the number of responding devices is greater than 1. If yes, proceed to the next step; otherwise, jump to step S56. S52: Determine whether the communication quality of the responding device is within the preset standard range. If yes, proceed to the next step; otherwise, jump to step S54. S53: Determine whether the number of responding devices within the preset standard range is greater than 1. If yes, select one of the multiple responding devices whose communication quality is the median value or the smallest difference from the median value as the next-level master-slave device, and jump to step S55. If no, set the only responding device within the preset standard range as the next-level master-slave device, and jump to step S55. S54: Determine whether the communication quality of the responding devices is greater than the upper limit of the preset standard range. If yes, proceed to step S56; otherwise, select the responding device that is closest to the preset standard range as the next level master-slave device. S55: Determine whether there is a response device among the remaining response devices with a communication quality greater than a preset value. If yes, set the response device with a communication quality greater than the preset value as a slave device of the corresponding master-slave device, form a device group of the corresponding level, and return the device group and the device information of the next level master-slave device to the gateway, and jump to step S6. If no, return the device information of the next level master-slave device to the gateway, and jump to step S6. S56: Set the responding device as a slave device of the corresponding master-slave device, the set slave devices form a device group of the corresponding level, and return the device information of the device group to the gateway, and the network configuration ends; S6: After receiving the return information corresponding to the current target networking request, the gateway increments the level i of the target networking request by 1, updates the ID number of the target master-slave device in the request to the ID number of the next-level master-slave device in the return information, and returns to step S2. S7: The first-level master-slave device forwards the target network request to the next-level master-slave device based on the ID number of the target master-slave device in the target network request; when the next-level master-slave device determines that it is not the target master-slave device in the target network request, the master-slave device continues to forward the target network request to the next-level master-slave device until the target master-slave device is reached; the target master-slave device returns to step S5 to execute the network process based on the target network request.

2. The adaptive multi-level wireless networking method for a terminal device management system according to claim 1, characterized in that, The formula for calculating the communication quality is: ; In the formula, RSSI represents the signal strength of the response information corresponding to the response device. max and RSSI min These are the maximum and minimum signal strength values ​​among all terminal devices. SNR represents the signal-to-noise ratio of the response information from the responding device. max and SNR min W1 and W2 represent the maximum and minimum signal-to-noise ratios among all terminal devices, respectively. W1 and W2 represent the weights of signal strength and signal-to-noise ratio, respectively. Score represents the communication quality.

3. The adaptive multi-level wireless networking method for a terminal device management system according to claim 2, characterized in that, After the selected devices form the corresponding level of device group, it also includes: The current master-slave device sends the group information of the device group to each slave device in the device group; the group information includes the level of the device group and the ID number of the corresponding master-slave device; the current master-slave device is a first-level master-slave device or a target master-slave device.

4. The adaptive multi-level wireless networking method for a terminal device management system according to claim 1, characterized in that, The terminal device management system also includes: A network server connected to the gateway is used to display wireless networking information; the wireless networking information includes: device information of master and slave devices at each level, and device information of slave devices included in the device groups corresponding to master and slave devices at each level.

5. An adaptive multi-level wireless communication method for a terminal device management system, characterized in that, Including the following steps: S01: Wireless networking is achieved for terminal devices in the terminal device management system using the adaptive multi-level wireless networking method according to any one of claims 1 to 4; S02: The gateway sends data packets to the primary master and slave devices; S03: After receiving the data packet, the first-level master and slave device sends the data packet to each slave device in the corresponding level device group and the next-level master and slave device, and returns the sending result to the gateway; S04: After receiving the transmission result, the gateway generates a data packet forwarding request containing the target master / slave device ID number and sends it to the first-level master / slave device; the target master / slave device is the next-level master / slave device of the master / slave device corresponding to the currently received transmission result; S05: After receiving a data packet forwarding request, the first-level master-slave device forwards the data packet forwarding request to the next-level master-slave device. The next-level master-slave device determines whether it is the target master-slave device in the data packet forwarding request. If it is, it proceeds to the next step. If not, it continues to forward the data packet forwarding request to the next-level master-slave device until the request is forwarded to the target master-slave device. S06: The target master-slave device determines whether it is the last-level master-slave device. If not, it sends the data packet to each slave device in the corresponding level device group and the next-level master-slave device, and returns the sending result to the gateway, while returning to step S04. If yes, the target master-slave device determines whether it manages slave devices. If yes, it sends the data packet to each slave device in the corresponding level device group and returns the sending result to the gateway. If not, it directly returns the sending result to the gateway. S07: The gateway terminates communication after receiving the transmission result returned by the last-level master and slave devices.

6. An adaptive multi-level wireless communication method for a terminal device management system according to claim 5, characterized in that, The adaptive multi-level wireless communication method further includes: The fault detection process includes the following steps: S001: The gateway sends a query request to the primary master-slave device; the query request contains the ID number of the target master-slave device; in the first query request sent by the gateway, the ID number of the target master-slave device is the ID number of the primary master-slave device; S002: After receiving a query request, the first-level master-slave device determines whether it is the target master-slave device in the query request. If so, it returns the query result to the gateway; if not, it continues to forward the query request to the next lower-level master-slave device until the request is forwarded to the target master-slave device. After receiving the query request, the target master-slave device returns the query result to the gateway. S003: The gateway determines whether it has received the query result corresponding to the current query request within a preset time period. If yes, it proceeds to the next step; if no, it indicates that the corresponding target master-slave device is faulty. The gateway switches the master-slave device corresponding to the query request and proceeds to the next step after the switch is completed. S004: Determine whether the master-slave device corresponding to the current query result is the highest level master-slave device. If yes, it means that the fault detection is complete; otherwise, update the ID number in the query request to the ID number of the next level master-slave device corresponding to the current query result and return S001.

7. An adaptive multi-level wireless communication method for a terminal device management system according to claim 6, characterized in that, The specific steps for switching the master / slave device corresponding to the query request are as follows: The gateway selects the slave device with the best communication quality from the device group corresponding to the faulty master and slave devices based on the communication quality data calculated during network setup, and replaces the current faulty master and slave devices.

8. An adaptive multi-level wireless communication method for a terminal device management system according to claim 5, characterized in that, In step S06, returning the sending result to the gateway specifically involves the target master-slave device returning the sending result to the gateway level by level through the master-slave devices at each preceding level.