An intelligent sensing terminal device and method based on LoRa self-organizing network

Through the intelligent sensing terminal device based on LORA communication technology, the dynamic network network and functional reconstruction of the terminal network are used to use the LORA self -formulation method, solving the problem of low error rate and low robustness in the existing Internet of Things system, and realized it. More efficient network management and data transmission.

CN114866976BActive Publication Date: 2025-01-28CHONGQING UNIV +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210429158.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-22
Publication Date
2025-01-28
Estimated Expiration
2042-04-22

AI Technical Summary

Technical Problem

The existing Internet of Things systems have low fault tolerance and low robustness, making it difficult to realize dynamic networking and functional reconstruction of terminal networks.

Method used

Using intelligent perception terminal devices based on LORA communication technology, dynamic networking and functional reconstruction of the terminal network through the LoRa self -networking method. This method includes Mac layer communication protocol design, link selection strategy and system program architecture to ensure that the communication process between the terminal nodes and the gateway is standardized and efficient.

Benefits of technology

Realize the dynamic networking and functional restructuring of the terminal network, improve the fault tolerance rate and robustness of the Internet of Things system, and solve the problem of low error tolerance rate and low robustness in the existing system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114866976B_ABST
    Figure CN114866976B_ABST
Patent Text Reader

Abstract

The present invention discloses an intelligent sensing terminal device and method based on LoRa self-organizing network. The device comprises a terminal node and a communication gateway. The terminal node collects information and sends it to the communication gateway, which uploads data to a cloud platform to realize remote monitoring. The terminal node comprises a power module, an information collection and processing module, an STM32 controller and a LoRa communication module. The communication gateway comprises a power module, an STM32 controller, a LoRa communication module and an NB‑IoT / 4G communication module. The present invention is based on LoRa communication technology and takes the intelligent sensing terminal as a physical carrier. It can realize dynamic networking and functional reconstruction of the terminal network, and solves the problems of low fault tolerance and low robustness of the existing Internet of Things system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of communications, and in particular relates to an intelligent sensing terminal device and method based on a LoRa self-organizing network. Background Art

[0002] In recent years, with the increasing demand for node networking in IoT application scenarios, many short-range communication protocols such as Zigbee and BLE have emerged. With the development of LPWAN technology, communication technologies such as LoRa and NB-IoT have developed rapidly. Among them, LoRa communication technology has advantages over other LPWAN technologies such as low power consumption and wide coverage. At the same time, as a new type of self-organizing and decentralized communication network, ad hoc networking can adapt to the dynamic changes of network topology and has great advantages over traditional star networking.

[0003] For example, patent application 201921961306.8 discloses a LoRa self-organizing network communication system for an intelligent ring network cabinet, including N detection modules, N LoRa units, LoRa network cards, and communication terminals; the N detection modules and N LoRa units are respectively arranged in N ring network cabinets. The utility model collects temperature, humidity, air pressure and other data in the ring network cabinet through the detection modules arranged in each ring network cabinet, and the corresponding LoRa units respectively receive the data obtained by each detection module. The LoRa wireless sensor network composed of the LoRa network card establishes a connection with the communication terminal, which can issue instructions and view the ring network cabinet data.

[0004] Therefore, it is very important to design a new type of intelligent sensing terminal device and method based on the LoRa self-organizing network on the basis of the existing Internet of Things communication technology. Summary of the invention

[0005] To solve the above problems, the primary purpose of the present invention is to provide an intelligent sensing terminal device and method based on LoRa self-organizing network. The device and method are based on LoRa communication technology and take the intelligent sensing terminal as the physical carrier. They can realize dynamic networking and functional reconstruction of the terminal network, and solve the problems of low fault tolerance and low robustness of the existing Internet of Things system.

[0006] To achieve the above objectives, the technical solution of the present invention is as follows.

[0007] An intelligent sensing terminal device based on a LoRa self-organizing network includes a terminal node and a communication gateway. The terminal node collects information and sends it to the communication gateway, which uploads the data to a cloud platform to achieve remote monitoring. The terminal node includes a power module, an information collection and processing module, an STM32 controller and a LoRa communication module, and the communication gateway includes a power module, an STM32 controller, a LoRa communication module and an NB-IoT / 4G communication module.

[0008] The present invention includes several terminal nodes and several gateways at the physical level. Among them, the terminal nodes are used to collect and process multi-dimensional information and upload it to the gateway, and receive communication instructions from the gateway. The gateway is used to receive and process the information of the terminal nodes and upload it to the host computer, and on the other hand, transmit and execute communication instructions from the host computer or the gateway itself.

[0009] The power module consists of a rechargeable power supply, a voltage regulator chip, a power protection device and a rectifier and filter module. It can stably provide +5V and +3.3V level voltages to ensure that the terminal is always in a stable working state.

[0010] The information acquisition and processing module is composed of multi-dimensional sensors, including temperature and humidity sensors, air quality sensors, smoke sensors, etc. The temperature and humidity sensors are responsible for collecting temperature and humidity data in the monitoring environment; the air quality sensors and smoke sensors are responsible for collecting atmospheric quality indicators and smoke concentrations in the monitoring environment. The above information acquisition and processing module can collect multi-dimensional information in the environment and convert it into analog / digital signals for transmission to the microcontroller. This module is composed of multi-dimensional sensors, including SHT31 temperature and humidity sensors, MQ-2 smoke sensors, and MQ-135 air quality sensors. Among them, the SHT31 temperature and humidity sensor uses IIC to communicate with the microcontroller, and the MQ-2 sensor and MQ-135 sensor directly transmit analog / digital quantities to the microcontroller.

[0011] The STM32 controller consists of STM32F103ZET6 / STM32F407ZGT6 (terminal node / gateway) and its supporting circuits. It has strong information collection and processing capabilities and works stably and reliably. It can collect, process and upload data for a long time, with low power consumption and high speed, while realizing control over the entire terminal node, effectively supporting the intelligent perception of the terminal node and communication gateway.

[0012] The LoRa communication module uses the SX1278 low-power long-distance transceiver, which assumes the wireless serial port function of the microcontroller and can realize point-to-point and point-to-multiple transparent transmission and directional transmission in the communication network. The above-mentioned LoRa communication module includes the SX1278 chip, RF antenna and its auxiliary driving circuit, which can receive the serial port data of the microprocessor and transmit it to the receiving antenna to realize wireless information interaction.

[0013] The NB-IoT / 4G communication module, wherein the 4G module adopts the ATK-GM510 LTE mobile network communication module of Gosuncn IoT, and the NB-IoT module adopts the BC28 communication module based on the MediaTek MT2625 chip. The 4G / NB-IoT communication module can transmit the collected data of the terminal node from the MAC layer to the network layer, thereby realizing dual-path access to the gateway.

[0014] A LoRa self-organizing network method, which mainly involves three parts: MAC layer communication protocol design, link selection strategy and system program architecture, to achieve dynamic networking and functional reconstruction of intelligent sensing terminals, wherein:

[0015] The MAC layer communication protocol can realize the networking and communication between nodes, nodes and gateways, and gateways and gateways. It includes three parts: data frame design, device table data structure design, and node time slice management. The data frame is used for data analysis and function implementation of LoRa self-organizing network communication, the device table is used to record the properties and status of the node and store it in the gateway, and the node time slice management is used to avoid the same frequency interference in the slave node response mechanism. The MAC layer communication protocol uses data frames and their control codes and check code management to standardize the communication process between terminal nodes and gateways. The link selection strategy determines the topological structure of the node network based on the communication test results. The system program architecture stipulates the specific processes such as node access, data collection, dynamic networking, and function reconstruction.

[0016] The link selection strategy comprehensively considers multiple different communication link indicators, and can select new communication links for terminal nodes in the subnet when the communication network topology changes, realizing dynamic networking. The link selection strategy includes two parts: link communication indicator determination and optimal link solution, ensuring the normal operation of the communication network when the network topology and functional structure change.

[0017] The system program architecture includes four parts: node access process, data collection process, dynamic networking process, and function reconstruction process, ensuring standardized and efficient communication.

[0018] Furthermore, data frames are divided into unicast frames and broadcast frames. The unicast frame consists of a frame header, network ID, source address, destination address, channel, control code, length, data, check code, and frame tail. It is used for point-to-point communication and is sent to the target node of the specified address and channel. The broadcast frame consists of a frame header, network ID, broadcast address, channel, control code, length, data, check code, and frame tail. It is used for broadcast monitoring and is sent to all terminal nodes in the same channel.

[0019] Furthermore, in the above unicast frame design, the unicast frame is composed of a frame header, a network ID, a source address, a destination address, a channel, a control code, a length, data, a check bit, and a frame tail from front to back.

[0020] a. The frame header is represented by 0xAA, which is the start flag of a frame of information;

[0021] b. The network ID is the number of the terminal node, which is used to identify the subnet to which the terminal node belongs;

[0022] c. The source address and destination address are two 2-byte hexadecimal identifiers, which represent the sending device address and receiving device address of the data frame respectively. The upper 8 bits represent the network ID number, and the lower 8 bits represent the subnet address number.

[0023] d. Channel is used to indicate the working frequency band of the LoRa communication module. The default value 0x17 represents the 433MHZ frequency band of the terminal node, and 0x18 represents the 434MHZ frequency band of the gateway. This protocol supports a total of 32 channels from 410 to 441MHZ.

[0024] e. The control code represents the communication instruction carried by the data frame. Different control codes represent different functional instructions;

[0025] f. Length indicates the byte length of the entire data frame;

[0026] g. Data is the content actually transmitted by the frame information. The data frame can be filled with different contents according to actual needs and transmitted bit by bit in the form of ASCII code to complete specific instructions;

[0027] h. The check bit uses CRC16 check to detect whether the data is wrong, and the bit error rate is 2^16 / 1;

[0028] i. The end of the frame is represented by 0XFF, which is the end mark of a frame of data.

[0029] Furthermore, in the above-mentioned unicast frame design, the control code part of the data frame can transmit the specified communication instruction, and the specific content of the instruction is related to the sending device.

[0030] a. When the control code is 0x00, the data frames sent by the terminal node and the gateway are only used for data transmission;

[0031] b. When the control code is 0x01, the terminal node applies for direct connection to the network, and the gateway sends a direct connection response after receiving the request;

[0032] c. When the control code is 0x02, the terminal node sends a relay access request and determines the relay node according to the link strategy, and then receives a relay access response from the gateway;

[0033] d. When the control code is 0x03, the gateway sends a communication test request. After receiving the request, the terminal node broadcasts a communication test response and collects the communication link vector of the node through time slice management;

[0034] e. When the control code is 0x04, the gateway sends a communication indicator request, and the terminal node sends the corresponding communication indicator after receiving the request;

[0035] f. When the control code is 0x05, the gateway sends a data collection request, and the terminal node sends the sensor's collection information after receiving the request;

[0036] g. When the control code is 0x06, the terminal node sends a time synchronization broadcast, and the gateway that receives the corresponding broadcast sends a time synchronization response;

[0037] h. When the control code is 0x07, the terminal node that receives the corresponding broadcast sends a time synchronization response, and the gateway sends a topology reconstruction instruction to adjust the communication link of the terminal node;

[0038] In the broadcast frame design, the structure of the broadcast frame is similar to that of the unicast frame, but the broadcast frame has no destination address, and the default value of the broadcast address is 0xFFFF. The broadcast frame will be sent to all nodes in the same channel.

[0039] Furthermore, the data structure of the device table includes node address, destination address, node type, node status, node load, channel, time slice number, etc. Its data structure includes recording the network ID, node address, destination address, node type, node status, node load, channel, time slice number, etc. of the node.

[0040] a. Node type indicates whether the node is a terminal node or a relay node. The default value is 0x00, indicating a general node, and 0x01, indicating a relay node.

[0041] b. Node status indicates whether the node is working properly. The default value 0x01 indicates normal operation, and 0x00 indicates damage.

[0042] c. Node load indicates the number of child nodes connected to the relay node. The default value 0x00 means the number of child nodes is zero.

[0043] Furthermore, the node time slice management adopts the method of regularly sending time synchronization messages (Ts_brd) to obtain the time synchronization response (Ts_rep) of the slave node corresponding to the time slice number in each synchronization cycle, and the time slice number is incremented once per synchronization cycle.

[0044] In the above node time slice management, when the terminal node (master node) applies to join the subnet or completes the communication test, the receiving device (slave node, gateway or terminal node) needs to send a corresponding response instruction to the master node. The process design is as follows:

[0045] Step 1: When the master node needs to receive responses from the slave nodes in turn, it sends a time synchronization broadcast Ts_brd to unify the node time.

[0046] Step 2: Every other cycle, the master node broadcasts the current time slice number starting from 0x0000 through the Ts_brd message, and the time slice number increases by 1 per cycle.

[0047] Step 3: If the master node does not receive a response within a certain synchronization cycle, it will repeat broadcasting the time slice number of the current cycle once. If it still does not receive a response, it is determined that the node with the current time slice number cannot be used as a slave node.

[0048] Step 4: After the master node has broadcast all the time slice numbers in the network, it exits the broadcast mode and the time slice numbers are reset to zero.

[0049] Furthermore, in the above-mentioned node time slice management, each slave node needs a specific time slice number. According to the network ID and the node address, the present invention designs the time slice number Node_time as follows:

[0050] Node_time=(0x00FF&Node_src)*Net_num+Net_id

[0051] Furthermore, in the above-mentioned node time slice management, the node time slice number is equal to the product of the subnet address (the lower 8 bits of the node address, i.e. 0x00FF & Node_src) and the number of subnets (Net_num) and the node network ID (Net_id). The node time slice numbering design of the present invention can, on the one hand, allow each subnet node to have an independent time slice number; on the other hand, it can process the node responses of each subnet in parallel, saving time.

[0052] The link selection strategy includes two parts: link communication indicator determination and optimal link solution, which ensures the normal operation of the communication network when the network topology and functional structure change.

[0053] Furthermore, in the above link selection strategy, three indicators, namely packet loss rate, communication delay, and node load, are selected to analyze the communication quality of the link, and all three indicators can be obtained through the communication test of the terminal node. The packet loss rate refers to the ratio of the number of lost data packets to the total number of sent data packets in the link communication test, the communication delay refers to the time required for a data block to be transmitted from one end of the link or network to the other end, and the node load refers to the number of terminal nodes managed by the relay node or gateway.

[0054] a. Packet loss rate (PL) refers to the ratio of the number of lost data packets (p_loss) to the total number of sent data packets (p_total) in link communication. The calculation formula is:

[0055]

[0056] b. Communication delay (TD) refers to the time required for a data frame to be transmitted from one end of a link or network to the other end. The calculation formula is:

[0057] TD=std+ptd+ftd;

[0058] c. Node load (NL) refers to the number of terminal nodes that a relay node or gateway manages. If the node does not assume the relay function or the gateway does not manage the terminal nodes, the node load is 0x00.

[0059] In the above link selection strategy, the communication test between the master and slave nodes is carried out as follows:

[0060] Step 1: The gateway sends a communication test message Ct_ask to the master node, or the master node actively applies for a communication test;

[0061] Step 2, start the test, within a period of time, the master node continuously broadcasts the Ct_rep communication test response message;

[0062] Step 3, the slave node calculates the number of data packets lost during the broadcast reception process and the average communication delay;

[0063] Step 4: After the broadcast of the Ct_rep message is completed, the master node obtains the packet loss rate, communication delay and node load of each slave node in turn through time slice management, and updates the communication link vector (R_vector) of the n column;

[0064] Step 5, according to the slave node type, obtain the corresponding communication test result;

[0065] Step 5.1, if the slave node is a terminal node (channel 0x17), then n represents the number of terminal nodes, R_vector(i) represents the communication link index between the master node and terminal node i, the gateway sends a communication index request message Ci_ask to the terminal node, merges the R_vector of each terminal node one by one, and obtains a communication link matrix (R_matrix) with n rows and n columns, where R_matrix(i,j) represents the communication link index between terminal node i and terminal node j;

[0066] Step 5.2, if the slave node is a gateway (channel 0x18), then n represents the number of gateways, and R_vector(i) represents the communication link indicator between the master node and gateway i.

[0067] In the above link selection strategy, the link indicators in the communication test result R_vector need to be further preprocessed.

[0068] a. Regarding the packet loss rate, the packet loss rate of the uplink between the slave node and the gateway is considered. PL(i) represents the packet loss rate from the node to be connected to the slave node i. PL'(i) is the theoretical packet loss rate of the node to be connected to the gateway through the slave node i. PL(i)j is the packet loss rate of the jth uplink of the slave node i. n is the number of uplinks between the slave node i and the gateway (if the slave node i is the gateway, then n = 0). The correction formula is as follows:

[0069]

[0070] b. For communication delay, the communication delay of the uplink between the slave node and the gateway is considered. TD(i) represents the communication delay from the node to be connected to the slave node i. TD'(i) is the communication delay from the node to be connected to the gateway through the slave node i. TD(i)j is the communication delay of the jth uplink from the slave node i. The correction formula is as follows:

[0071]

[0072] c. For the node load, the node load itself and the maximum node load on the entire link are considered. NL(i) represents the node load of the slave node i, NL'(i) is the node load level of the communication link where the slave node i is located, and NLmax is the maximum node load of the communication link where the slave node i is located. The correction formula is as follows:

[0073]

[0074] In the above link selection strategy, in order to simplify the calculation of link communication quality LQ and eliminate the dimension effect, the obtained PL', TD', and NL' data are normalized to obtain the link reliability index PL*, link rapidity index TD*, and link risk resistance index NL*, so that the maximum value of each index is 1 and the minimum value is 0.

[0075] In the above link selection strategy, in order to comprehensively evaluate the reliability, risk resistance and rapidity of the communication between the terminal node and each gateway, a, b, c are PL*, NL*, TD* weights, and the link communication quality LQ is defined as follows:

[0076] LQ=a×PL * +((PL * ! =0)?∞:1)×b×NL * +(((PL*!=0)|(NL * ! =0))? ∞:1)×c×TD *

[0077] In the above-mentioned link selection strategy, the smaller the LQ, the better the communication quality of the link, and the node will select the link with a small LQ to enter the network. In order to give priority to reliability and risk resistance, the present invention sets the priority of the link selection strategy to PL*, NL*, and TD* from large to small. Combined with the above formula, it can be seen that if the PL* or NL* of the communication link is not 0, the LQ is infinite, and the link is not in the terminal node selection range. That is, if there is no PL* minimum in the selectable link, the LQ is only determined by the reliability indicator PL*; if there is PL* minimum in the link, but there is no NL* minimum at the same time, then LQ is jointly determined by PL* and NL*; if PL* and NL* are both minimum in the link, then LQ is jointly determined by PL*, NL*, and TD*.

[0078] In the above link selection strategy, when the terminal node applies for network access or communication failure occurs, the topology of the communication network changes. The gateway can determine the communication link of the node to be networked / communication failure based on the optimal link solution. The process is as follows:

[0079] a. The terminal node applies for network access.

[0080] Step 1: Take the node to be connected as the master node, broadcast the Ct_rep message, complete the communication test, and obtain R_vector;

[0081] Step 2, preprocessing the communication link index in the communication test result R_vector of the node to be connected to the network;

[0082] Step 3, based on the PL*, TD*, and NL* obtained by preprocessing, the link communication quality LQ is calculated;

[0083] Step 4: Select the communication link with the smallest LQ to access the network.

[0084] b. Terminal node communication failure,

[0085] Step 1: The gateway polls and issues a Ct_ask command to obtain the communication link matrix R_matrix of the terminal node;

[0086] Step 2: Determine the fault type of the communication fault node A. There are three situations:

[0087] Step 2.1: If node A cannot communicate with any terminal node, the fault type is node damage;

[0088] Step 2.2: If node A can communicate with other nodes in its subnet, the fault type is communication obstruction;

[0089] Step 2.3, if node A can only communicate with nodes in another subnet, the fault type is communication loss;

[0090] Step 3: Take corresponding actions according to the fault type of node A in step 2; (Step 3.1 corresponds to the follow-up of step 2.1, and the same applies to the following)

[0091] Step 3.1, remove node A from the current subnet and determine a relay node for its child nodes based on link quality evaluation;

[0092] Step 3.2, re-determine the relay node for node A based on the link quality evaluation;

[0093] Step 3.3: Node A and its child nodes are removed from the current subnet and added to the new subnet based on link quality evaluation.

[0094] The optimal link solution determines the topology of the communication network through link indicator preprocessing and link quality evaluation, where the priorities of link selection are packet loss rate, node load, and communication delay from large to small.

[0095] The beneficial effects of the present invention are:

[0096] The present invention is based on LoRa communication technology and uses intelligent sensing terminals as physical carriers, which can realize dynamic networking and functional reconstruction of terminal networks, and solve the problems of low fault tolerance and low robustness of existing Internet of Things systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0097] Figure 1 This is a diagram of the terminal node system architecture of the present invention.

[0098] Figure 2 It is a schematic diagram of the information acquisition and processing module and the LoRa communication module structure of the present invention.

[0099] Figure 3 This is a schematic diagram of a gateway using two-way communication in the present invention.

[0100] Figure 4 This is a schematic diagram of the unicast frame format of the present invention.

[0101] Figure 5 This is a schematic diagram of the broadcast frame format of the present invention.

[0102] Figure 6 This is a schematic diagram of the control code format of the present invention.

[0103] Figure 7 The diagram shows a schematic diagram of a node device of the present invention.

[0104] Figure 8 This is a flow chart of time slice management of the present invention.

[0105] Fig. 9 Schematic diagram of the link selection strategy of the present invention.

[0106] Fig.10This is a flow chart of node access to the network according to the present invention.

[0107] Fig.11 The data collection flow chart of the present invention.

[0108] Fig.12 This is a dynamic networking flow chart of the present invention.

[0109] Fig.13 Reconstruct the flow chart for the function of the present invention.

[0110] Fig.14 It is a schematic diagram of the Fun_rec message structure of the present invention.

[0111] Fig.15 This is a schematic diagram of the control code format of the present invention. DETAILED DESCRIPTION

[0112] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0113] Reference Figure 1 As shown, refer to Figure 1 ,This system architecture includes terminal nodes and gateways.

[0114] The terminal node mainly includes information collection and processing module, STM32 controller, LoRa communication module and power module. The information collection and processing module includes temperature and humidity detection, air quality detection and smoke detection. The STM32 controller uses STM32F103ZET6. The LoRa module includes SX1278 chip, RF antenna and its auxiliary circuit. The power module includes rechargeable power supply, voltage regulator chip, power protection device and rectifier filter module.

[0115] Combination Figure 2 , 3 The gateway mainly includes LoRa module, STM32 controller, 4G / NB-IoT module and power module. The LoRa module includes SX1278 chip, RF antenna and its auxiliary circuit; STM32 microcontroller uses STM32F407ZGT6 chip; 4G communication module uses ATK-GM510 LE mobile network communication module; NB-IoT module uses BC28 communication module based on MediaTek MT2625 chip; power module includes rechargeable power supply, voltage regulator chip, power protection device and rectifier filter module.

[0116] The workflow between the main modules is as follows: the power module supplies power to each part of the terminal node and the gateway, the information collection and processing module collects relevant information (such as temperature and humidity values, smoke concentration) from the environment, and transmits it to the STM32F103ZET6 microprocessor after circuit preprocessing. The signal is processed by the microprocessor and transmitted to the LoRa communication module through USART3, and then sent to other terminal nodes or gateways via the RF antenna. After receiving the information sent by the node, the LoRa communication module of the gateway transmits the information to the STM32F407ZGT6 microprocessor through USART3. The processor compresses the information and dynamically selects the network access channel. It selects the network with lower congestion in the 4G and NB-IoT modules to access the network and transmits the information to the host computer.

[0117] The LoRa self-organizing network method implemented by the present invention mainly involves three parts: MAC layer communication protocol design, link selection strategy and system program architecture, to achieve dynamic networking and functional reconstruction of intelligent sensing terminals, wherein:

[0118] The MAC layer communication protocol can realize the networking and communication between nodes, nodes and gateways, and gateways and gateways. It includes three parts: data frame design, device table data structure design, and node time slice management. The data frame is used for data analysis and function implementation of LoRa self-organizing network communication, the device table is used to record the properties and status of the node and store it in the gateway, and the node time slice management is used to avoid the same frequency interference in the slave node response mechanism. The MAC layer communication protocol uses data frames and their control codes and check code management to standardize the communication process between terminal nodes and gateways. The link selection strategy determines the topological structure of the node network based on the communication test results. The system program architecture stipulates the specific processes such as node access, data collection, dynamic networking, and function reconstruction.

[0119] The link selection strategy comprehensively considers multiple different communication link indicators, and can select new communication links for terminal nodes in the subnet when the communication network topology changes, realizing dynamic networking. The link selection strategy includes two parts: link communication indicator determination and optimal link solution, ensuring the normal operation of the communication network when the network topology and functional structure change.

[0120] The system program architecture includes four parts: node access process, data collection process, dynamic networking process, and function reconstruction process, ensuring standardized and efficient communication.

[0121] Specifically, data frames are divided into unicast frames and broadcast frames. Unicast frames are composed of a frame header, network ID, source address, destination address, channel, control code, length, data, check code, and frame trailer. They are used for point-to-point communication and are sent to the target node of the specified address and channel. Broadcast frames are composed of a frame header, network ID, broadcast address, channel, control code, length, data, check code, and frame trailer. They are used for broadcast monitoring and are sent to all terminal nodes in the same channel.

[0122] The data frame can realize functions such as data transmission, gateway direct connection, relay access, communication testing, data collection, synchronous broadcast, topology reconstruction, etc. through control codes, and the data frame uses check codes to realize CRC16 check.

[0123] In the above unicast frame design, the unicast frame is composed of frame header, network ID, source address, destination address, channel, control code, length, data, check bit, and frame tail from front to back. Among them:

[0124] a. The frame header is represented by 0xAA, which is the start flag of a frame of information;

[0125] b. The network ID is the number of the terminal node, which is used to identify the subnet to which the terminal node belongs;

[0126] c. The source address and destination address are two 2-byte hexadecimal identifiers, which represent the sending device address and receiving device address of the data frame respectively. The upper 8 bits represent the network ID number, and the lower 8 bits represent the subnet address number.

[0127] d. Channel is used to indicate the working frequency band of the LoRa communication module. The default value 0x17 represents the 433MHZ frequency band of the terminal node, and 0x18 represents the 434MHZ frequency band of the gateway. This protocol supports a total of 32 channels from 410 to 441MHZ.

[0128] e. The control code represents the communication instruction carried by the data frame. Different control codes represent different functional instructions;

[0129] f. Length indicates the byte length of the entire data frame;

[0130] g. Data is the content actually transmitted by the frame information. The data frame can be filled with different contents according to actual needs and transmitted bit by bit in the form of ASCII code to complete specific instructions;

[0131] h. The check bit uses CRC16 check to detect whether the data is wrong, and the bit error rate is 2^16 / 1;

[0132] i. The end of the frame is represented by 0XFF, which is the end mark of a frame of data.

[0133] Furthermore, in the above unicast frame design, the control code part of the data frame can transmit the specified communication instruction, and the specific content of the instruction is related to the sending device, as follows:

[0134] a. When the control code is 0x00, the data frames sent by the terminal node and the gateway are only used for data transmission;

[0135] b. When the control code is 0x01, the terminal node applies for direct connection to the network, and the gateway sends a direct connection response after receiving the request;

[0136] c. When the control code is 0x02, the terminal node sends a relay access request and determines the relay node according to the link strategy, and then receives a relay access response from the gateway;

[0137] d. When the control code is 0x03, the gateway sends a communication test request. After receiving the request, the terminal node broadcasts a communication test response and collects the communication link vector of the node through time slice management;

[0138] e. When the control code is 0x04, the gateway sends a communication indicator request, and the terminal node sends the corresponding communication indicator after receiving the request;

[0139] f. When the control code is 0x05, the gateway sends a data collection request, and the terminal node sends the sensor's collection information after receiving the request;

[0140] g. When the control code is 0x06, the terminal node sends a time synchronization broadcast, and the gateway that receives the corresponding broadcast sends a time synchronization response;

[0141] h. When the control code is 0x07, the terminal node that receives the corresponding broadcast sends a time synchronization response, and the gateway sends a topology reconstruction instruction to adjust the communication link of the terminal node.

[0142] In the broadcast frame design, the structure of the broadcast frame is similar to that of the unicast frame, but the broadcast frame has no destination address, and the default value of the broadcast address is 0xFFFF. The broadcast frame will be sent to all nodes in the same channel.

[0143] The data structure of the device table includes node address, destination address, node type, node status, node load, channel, and time slice number. In the design of the device table data structure, the device table is used to record the attributes and status of the terminal node and is stored in the corresponding gateway. Its data structure includes recording the node's network ID, node address, destination address, node type, node status, node load, channel, time slice number and other information. Among them,

[0144] a. Node type indicates whether the node is a terminal node or a relay node. The default value is 0x00, indicating a general node, and 0x01, indicating a relay node.

[0145] b. Node status indicates whether the node is working properly. The default value 0x01 indicates normal operation, and 0x00 indicates damage.

[0146] c. Node load indicates the number of child nodes connected to the relay node. The default value 0x00 means the number of child nodes is zero.

[0147] Node time slice management uses the method of regularly sending time synchronization messages (Ts_brd) to obtain the time synchronization response (Ts_rep) from the slave node corresponding to the time slice number in each synchronization cycle. The time slice number increases once per synchronization cycle.

[0148] In the above node time slice management, when the terminal node (master node) applies to join the subnet or completes the communication test, the receiving device (slave node, gateway or terminal node) needs to send a corresponding response command to the master node. However, considering that the SX1278 communication module can only receive a group of data from the same frequency band at a time, in order to avoid co-frequency interference, the slave node needs to apply the time slice management mode, that is, each slave node can only reply to the master node within the corresponding time slice. The process design is as follows:

[0149] Step 1: When the master node needs to receive responses from the slave nodes in turn, it sends a time synchronization broadcast Ts_brd to unify the node time.

[0150] Step 2: Every other cycle, the master node broadcasts the current time slice number starting from 0x0000 through the Ts_brd message, and the time slice number increases by 1 per cycle.

[0151] Step 3: If the master node does not receive a response within a certain synchronization cycle, it will repeat broadcasting the time slice number of the current cycle once. If it still does not receive a response, it is determined that the node with the current time slice number cannot be used as a slave node.

[0152] Step 4: After the master node has broadcast all the time slice numbers in the network, it exits the broadcast mode and the time slice numbers are reset to zero.

[0153] In the above-mentioned node time slice management, each slave node needs a specific time slice number. According to the network ID and the node address, the present invention designs the time slice number Node_time as follows:

[0154] Node_time=(0x00FF&Node_src)*Net_num+Net_id

[0155] In the above-mentioned node time slice management, the node time slice number is equal to the product of the subnet address (the lower 8 bits of the node address, i.e. 0x00FF & Node_src) and the number of subnets (Net_num) and the node network ID (Net_id). The node time slice numbering design of the present invention can, on the one hand, allow each subnet node to have an independent time slice number; on the other hand, it can process the node responses of each subnet in parallel, saving time.

[0156] The link selection strategy includes two parts: link communication indicator determination and optimal link solution, which ensures the normal operation of the communication network when the network topology and functional structure change.

[0157] In the above link selection strategy, three indicators, namely packet loss rate, communication delay, and node load, are selected to analyze the communication quality of the link, and all three indicators can be obtained through the communication test of the terminal node. The packet loss rate refers to the ratio of the number of lost data packets to the total number of sent data packets in the link communication test, the communication delay refers to the time required for a data block to be transmitted from one end of the link or network to the other end, and the node load refers to the number of terminal nodes in charge of the relay node or gateway. The specific algorithm is as follows:

[0158] a. Packet loss rate (PL) refers to the ratio of the number of lost data packets (p_loss) to the total number of sent data packets (p_total) in link communication. The calculation formula is:

[0159]

[0160] b. Communication delay (TD) refers to the time required for a data frame to be transmitted from one end of a link or network to the other end. The calculation formula is:

[0161] TD=std+ptd+ftd;

[0162] c. Node load (NL) refers to the number of terminal nodes that a relay node or gateway manages. If the node does not assume the relay function or the gateway does not manage the terminal nodes, the node load is 0x00.

[0163] In the above link selection strategy, the communication test between the master and slave nodes is carried out as follows:

[0164] Step 1: The gateway sends a communication test message Ct_ask to the master node, or the master node actively applies for a communication test;

[0165] Step 2, start the test, within a period of time, the master node continuously broadcasts the Ct_rep communication test response message;

[0166] Step 3, the slave node calculates the number of data packets lost during the broadcast reception process and the average communication delay;

[0167] Step 4: After the broadcast of the Ct_rep message is completed, the master node obtains the packet loss rate, communication delay and node load of each slave node in turn through time slice management, and updates the communication link vector (R_vector) of the n column;

[0168] Step 5, according to the slave node type, obtain the corresponding communication test result;

[0169] Step 5.1, if the slave node is a terminal node (channel 0x17), then n represents the number of terminal nodes, R_vector(i) represents the communication link index between the master node and terminal node i, the gateway sends a communication index request message Ci_ask to the terminal node, merges the R_vector of each terminal node one by one, and obtains a communication link matrix (R_matrix) with n rows and n columns, where R_matrix(i,j) represents the communication link index between terminal node i and terminal node j;

[0170] Step 5.2, if the slave node is a gateway (channel 0x18), then n represents the number of gateways, and R_vector(i) represents the communication link indicator between the master node and gateway i.

[0171] In the above link selection strategy, the link indicators in the communication test result R_vector need to be further preprocessed. Among them:

[0172] a. Regarding the packet loss rate, the packet loss rate of the uplink between the slave node and the gateway is considered. PL(i) represents the packet loss rate from the node to be connected to the slave node i. PL'(i) is the theoretical packet loss rate of the node to be connected to the gateway through the slave node i. PL(i)j is the packet loss rate of the jth uplink of the slave node i. n is the number of uplinks between the slave node i and the gateway (if the slave node i is the gateway, then n = 0). The correction formula is as follows:

[0173]

[0174] b. For communication delay, the communication delay of the uplink between the slave node and the gateway is considered. TD(i) represents the communication delay from the node to be connected to the slave node i. TD'(i) is the communication delay from the node to be connected to the gateway through the slave node i. TD(i)j is the communication delay of the jth uplink from the slave node i. The correction formula is as follows:

[0175]

[0176] c. For the node load, the node load itself and the maximum node load on the entire link are considered. NL(i) represents the node load of the slave node i, NL'(i) is the node load level of the communication link where the slave node i is located, and NLmax is the maximum node load of the communication link where the slave node i is located. The correction formula is as follows:

[0177]

[0178] In the above link selection strategy, in order to simplify the calculation of link communication quality LQ and eliminate the dimension effect, the obtained PL', TD', and NL' data are normalized to obtain the link reliability index PL*, link rapidity index TD*, and link risk resistance index NL*, so that the maximum value of each index is 1 and the minimum value is 0.

[0179] In the above link selection strategy, in order to comprehensively evaluate the reliability, risk resistance and rapidity of the communication between the terminal node and each gateway, a, b, c are PL*, NL*, TD* weights, and the link communication quality LQ is defined as follows:

[0180] LQ=a×PL * +((PL * ! =0)?∞:1)×b×NL * +(((PL*!=0)|(NL * ! =0))? ∞:1)×c×TD *

[0181] In the above-mentioned link selection strategy, the smaller the LQ, the better the communication quality of the link, and the node will select the link with a small LQ to enter the network. In order to give priority to reliability and risk resistance, the present invention sets the priority of the link selection strategy to PL*, NL*, and TD* from large to small. Combined with the above formula, it can be seen that if the PL* or NL* of the communication link is not 0, the LQ is infinite, and the link is not in the terminal node selection range. That is, if there is no PL* minimum in the selectable link, the LQ is only determined by the reliability indicator PL*; if there is PL* minimum in the link, but there is no NL* minimum at the same time, then LQ is jointly determined by PL* and NL*; if PL* and NL* are both minimum in the link, then LQ is jointly determined by PL*, NL*, and TD*.

[0182] In the above link selection strategy, when the terminal node applies for network access or communication failure occurs, the topology of the communication network changes. The gateway can determine the communication link of the node to be networked / communication failure based on the optimal link solution. The process is as follows:

[0183] a. The terminal node applies for network access.

[0184] Step 1: Take the node to be connected as the master node, broadcast the Ct_rep message, complete the communication test, and obtain R_vector;

[0185] Step 2, preprocessing the communication link index in the communication test result R_vector of the node to be connected to the network;

[0186] Step 3, based on the PL*, TD*, and NL* obtained by preprocessing, the link communication quality LQ is calculated;

[0187] Step 4: Select the communication link with the smallest LQ to access the network.

[0188] b. Terminal node communication failure,

[0189] Step 1: The gateway polls and issues a Ct_ask command to obtain the communication link matrix R_matrix of the terminal node;

[0190] Step 2: Determine the fault type of the communication fault node A. There are three situations:

[0191] Step 2.1: If node A cannot communicate with any terminal node, the fault type is node damage;

[0192] Step 2.2: If node A can communicate with other nodes in its subnet, the fault type is communication obstruction;

[0193] Step 2.3, if node A can only communicate with nodes in another subnet, the fault type is communication loss;

[0194] Step 3: Take corresponding actions according to the fault type of node A in step 2; (Step 3.1 corresponds to the follow-up of step 2.1, and the same applies to the following)

[0195] Step 3.1, remove node A from the current subnet and determine a relay node for its child nodes based on link quality evaluation;

[0196] Step 3.2, re-determine the relay node for node A based on the link quality evaluation;

[0197] Step 3.3: Node A and its child nodes are removed from the current subnet and added to the new subnet based on link quality evaluation.

[0198] The optimal link solution determines the topology of the communication network through link indicator preprocessing and link quality evaluation, where the priorities of link selection are packet loss rate, node load, and communication delay from large to small.

[0199] Reference Figure 4It is the unicast frame format in the MAC layer communication protocol. From the beginning to the end, it is the frame header (1 Byte), network ID (1 Byte), source address (2 Byte), destination address (2 Byte), channel (1 Byte), control code (1 Byte), length (1 Byte), data (n Byte), check (2 Byte), and frame tail (1 Byte).

[0200] Reference Figure 5 , is the broadcast frame format in the MAC layer communication protocol, from the beginning to the end, it is the frame header (occupying 1 Byte), network ID (occupying 1 Byte), broadcast address (2 Byte), channel (occupying 1 Byte), control code (occupying 1 Byte), length (occupying 1 Byte), data (occupying n Byte), check (occupying 2 Byte), frame tail (occupying 1 Byte). Compared with unicast frames, broadcast frames have no directional target, so there is no destination address.

[0201] Reference Figure 6 , is a comparison table of control codes in the MAC layer communication protocol. The control codes increase from 0x00 to 0x07. The corresponding terminal node instructions are data transmission, gateway direct connection application, relay network application, communication test response, communication indicator response, data collection response, time synchronization broadcast, and time synchronization response. The corresponding gateway instructions are data transmission instructions, gateway direct connection response, relay network response, communication test request, communication indicator request, data collection request, time synchronization response, and topology reconstruction instructions.

[0202] Reference Figure 7 , which is the data structure of the device table in the MAC layer communication protocol, where the network ID is identified as Net_id, with a default value of 0x01; the node address is identified as Node_src, with a default value of 0x0000; the destination address is identified as Node_des, with a default value of 0x0000; the node type is identified as Node_Type, with a default value of 0x00; the node status is identified as Node_status, with a default value of 0x01; the node load is identified as Node_load, with a default value of 0x00; the channel is identified as Node_Chan, with a default value of 0x17; the time slice number is identified as Node_time, with a default value of 0x00.

[0203] Reference Figure 8, is a timing diagram of node network time slice management in the MAC layer communication protocol. When the master node needs to respond from the nodes in sequence, the master node will broadcast the node message through Ts_brd starting from the time slice number of node 1. When the node receives its own time slice number, it will send a time synchronization response (Ts_rep) to the master node and update the node status at the master node. If the master node cannot receive a response within a certain synchronization cycle, it will repeat broadcasting the time slice number of the current cycle once; if no response is received after repeated broadcasting, it is determined that the node with the current time slice number cannot be used as a slave node. Thus, the time slice number of node 2 is broadcast. And so on, until the master node broadcasts all the time slice numbers in the networking system, it exits the broadcast mode and the time slice number is cleared.

[0204] Reference Fig. 9 , gateway (black node) is the gateway; relay node (brown) is the relay node; new node is the node to be connected to the network; link is the communication link; communication zone is the communication range; PL(i)j represents the packet loss rate of the jth uplink from node i. Due to the limited communication range, the node to be connected to the network cannot be directly connected to the network, so it adopts point-by-point uplink and selects relay to connect to the network. After the system completes the data processing of the communication link indicators, it evaluates the communication quality of each link and selects the one with the highest link quality as the communication link, that is, the optimal link is selected.

[0205] Reference Fig.10 ,The node access to the network process is as follows.

[0206] Step 1: The node to be connected to the network broadcasts a Dc_ask message on the 0x18 channel of the gateway to apply for direct connection to the network;

[0207] Step 2: The node to be connected to the network continuously broadcasts Ct_rep messages on channel 0x18 to complete the communication test;

[0208] Step 3: The node to be connected to the network broadcasts the Ts_brd message on the 0x18 channel regularly, waits for the gateway to reply the communication test result, and obtains the communication link vector R_vector;

[0209] Step 4.1, if the node to be connected receives the Ts_rep response from the gateway, it applies the link selection strategy to determine the gateway to be connected after receiving the response, and registers the node address at the gateway;

[0210] Step 4.2: If the node to be connected to the network does not receive the Ts_rep response from the gateway, it broadcasts the Tc_ask message on the 0x17 channel where the node works to apply for relay access to the network;

[0211] Step 5.1, the node to be connected to the network receives the Dc_rep message from the gateway, updates its own address (originally the default address), and the node is successfully connected to the network; (Step 5.1 follows step 4.1, and so on)

[0212] Step 5.2: The node to be connected to the network repeats steps 2 and 3 on channel 0x17 and waits for the node to respond.

[0213] Step 6.1, the node to be connected to the network is successfully connected to the network;

[0214] Step 6.2.1, if the node to be connected receives the Ts_rep response of the node, it applies the link selection strategy to determine the relay node after receiving the response, and registers the node address at the gateway through the relay node;

[0215] Step 6.2.2: If the node to be connected does not receive the Ts_rep response from the node, the relay connection fails; (Step 6.2.2 is followed by step 6.2.1 followed by step 5.2, and so on)

[0216] Step 7.1, the node to be connected to the network is successfully connected to the network;

[0217] Step 7.2.1, the node to be connected to the network receives the Tc_rep message from the node, updates its own address, and successfully relays to the network;

[0218] Step 7.2.2: The node to be connected to the network fails to relay to the network.

[0219] (Step x.1 is completed in step 5, and the direct connection is successful; step x.2.1 is completed in step 7, and the relay connection is successful; step x.2.2 is completed in step 6, and the relay connection fails)

[0220] Reference Fig.11 , when the terminal node collects data normally and uploads it to the gateway, the specific steps are:

[0221] Step 1: The gateway waits for the data acquisition trigger signal of the TIM3 timer, which arrives once per minute.

[0222] Step 2: After receiving the trigger signal, the gateway sends a Da_ask message to the current destination node. The initial destination node is the terminal node that first enters the network.

[0223] Step 3: After receiving the Da_ask message, the terminal node first determines whether the destination address is itself. If so, it sends a Da_rep message to the gateway; if not, it relays the Da_ask message to the corresponding terminal node and sends a Da_rep message back to the node;

[0224] Step 3.1, if the gateway receives the Da_rep message from the destination node, it decodes the collected data and uploads it to the host computer;

[0225] Step 3.2: If the gateway does not receive the Da_rep message from the destination node, repeat step 2;

[0226] Step 4.1, return to step 1, and poll the new terminal nodes in the order of access to the network;

[0227] Step 4.2, if the gateway receives the Da_rep message from the destination node this time, repeat step 3.1; if the gateway still does not receive the Da_rep message, mark the node and update the topology structure through dynamic networking after the polling is completed;

[0228] Step 5: The node polling is completed and waits for the next round of data collection.

[0229] Reference Fig.12 When the system packet loss rate, communication delay, node load imbalance and all three exceed the warning line, this intelligent monitoring and verification platform automatically identifies that the network is faulty and will automatically start the dynamic networking function to change the network topology to improve the network processing efficiency. The specific process is as follows:

[0230] Step 1: The gateway sends a Ct_ask message to the destination node currently in the network to start the communication test. The order in which the messages are sent is the order in which the nodes enter the network.

[0231] Step 2: After receiving the Ct_ask message, the terminal node first determines whether the destination node is itself, based on whether its own address is the same as the target address sent by the gateway. If so, it broadcasts the Ct_rep command on the 0x17 channel to complete the communication test; if not, it acts as a relay node to send the Ct_ask message to the corresponding terminal node;

[0232] Step 3: The terminal node broadcasts the Ts_brd message regularly on the 0x17 channel, waits for the node to reply with the communication test result, and obtains the communication link vector R_vector corresponding to the node;

[0233] Step 4: After obtaining the communication link vector, the terminal node sends R_vector to the gateway through the Ci_rep message;

[0234] Step 5: After receiving the Ci_rep message from the destination node, the gateway polls the new terminal node in the order of access to the network and merges the R_vector transmitted by each node;

[0235] Step 6: The gateway completes polling, obtains the corresponding communication link matrix R_matrix, and determines the new topology of the subnet through the link selection strategy;

[0236] Step 7: The gateway polls the terminal nodes in the order of access to the network, and sends a Tp_rec message carrying the upper node number in a targeted manner. After receiving the Tp_rec message, the terminal node makes corresponding adjustments to the communication link;

[0237] Step 8: Dynamic networking is completed and the gateway realizes the topology reconstruction of the subnet.

[0238] Reference Fig.13 ,The specific steps of implementing functional reconstruction of this intelligent monitoring verification platform are as follows:

[0239] Step 1: The host computer sends a Fun_rec function reconstruction message to the destination gateway;

[0240] Step 2: The gateway receives the Fun_rec message and forwards it to the destination node;

[0241] Step 3: The destination node decodes the Fun_rec message and completes the function reconstruction.

[0242] In the above system program architecture, the Fun_rec message forwarded by the gateway comes from the network layer, which is different from the message specified by the MAC layer communication protocol. The terminal node can decode the Fun_rec message and implement the corresponding function. The Fun_rec message consists of a frame header, network ID, destination node, control code, length, data, check, and frame tail.

[0243] a. Network ID indicates the gateway number that receives messages from the host computer. The default value is 0x01.

[0244] b. The destination node indicates the device address of the node to be regulated by the host computer. The default value is 0x0000;

[0245] c. The control code can be from 0x01 to 0x04, corresponding to different functional reconstruction instructions.

[0246] Reference Fig.14 , is the Fun_rec control message format sent by the host computer. From the beginning to the end, it is frame header (occupying 1 Byte), network ID (occupying 1 Byte), destination node (occupying 2 Bytes), control code (occupying 1 Byte), length (occupying 1 Byte), data (occupying n Bytes), check (occupying 2 Bytes), frame tail (occupying 1 Byte).

[0247] Reference Fig.15, is the control code format in the Fun_rec control message. The control code increases from 0x01 to 0x04, and the corresponding control functions are to turn on / off a data acquisition function, add / delete a terminal node, wake up / sleep a terminal node, and adjust the node communication link. The control code and data part in the Fun_rec message are designed as follows:

[0248] a. When the control code is 0x01, the host computer turns on or off a data acquisition function of the destination node. At this time, the data part of the Fun_rec message is 2 bytes long. The first byte represents the number of the acquisition function, and the second byte represents the 0-1 variable that controls the acquisition function to be turned on or off;

[0249] b. When the control code is 0x02 (0x03), the host computer adds (wakes up) or deletes (sleeps) the destination node. At this time, the data part is a 0-1 variable that controls the node to add (wake up) or delete (sleep).

[0250] c. When the control code is 0x04, the host computer adjusts the communication link of the destination node. At this time, the data part represents the parent node address of the adjusted destination node.

[0251] In summary, the present invention is based on LoRa communication technology and uses intelligent sensing terminals as physical carriers, which can realize dynamic networking and functional reconstruction of terminal networks, and solve the problems of low fault tolerance and low robustness of existing Internet of Things systems.

[0252] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method based on LoRa self-organizing network, characterized in that This method mainly involves three parts: MAC layer communication protocol design, link selection strategy and system program architecture, to achieve dynamic networking and functional reconstruction of intelligent sensing terminals, including: The MAC layer communication protocol can realize the networking and communication between nodes, nodes and gateways, and gateways and gateways. It includes three parts: data frame design, device table data structure design, and node time slice management. The data frame is used for data analysis and function implementation of LoRa self-organizing network communication, the device table is used to record the properties and status of the node and store them in the gateway, and the node time slice management is used to avoid the same-frequency interference in the slave node response mechanism. The link selection strategy includes two parts: link communication index determination and optimal link solution, which ensures the normal operation of the communication network when the network topology and functional structure change; The system program architecture includes four parts: node access process, data collection process, dynamic networking process, and function reconstruction process, ensuring standardized and efficient communication; Data frames are divided into unicast frames and broadcast frames. Unicast frames consist of a frame header, network ID, source address, destination address, channel, control code, length, data, check code, and frame tail. They are used for point-to-point communication and are sent to the target node of the specified address and channel. Broadcast frames consist of a frame header, network ID, broadcast address, channel, control code, length, data, check code, and frame tail. They are used for broadcast monitoring and are sent to all terminal nodes in the same channel. The data structure of the device table includes node address, destination address, node type, node status, node load, channel, and time slice number; in the design of the device table data structure, the device table is used to record the attributes and status of the terminal node and is stored in the corresponding gateway; its data structure includes recording the node's network ID, node address, destination address, node type, node status, node load, channel, and time slice number information; among them, a. Node type indicates whether the node is a terminal node or a relay node. The default value is 0x00, indicating a general node, and 0x01, indicating a relay node. b. Node status indicates whether the node is working properly. The default value 0x01 indicates normal operation, and 0x00 indicates damage. c. Node load indicates the number of child nodes connected to the relay node. The default value 0x00 indicates that the number of child nodes is zero. The link selection strategy includes two parts: link communication index determination and optimal link solution, to ensure the normal operation of the communication network when the network topology and functional structure change. In the above link selection strategy, three indicators, namely packet loss rate, communication delay and node load, are selected to analyze the communication quality of the link, and all three indicators can be obtained through the communication test of the terminal node. The packet loss rate refers to the ratio of the number of lost data packets to the total number of sent data packets in the link communication test, the communication delay refers to the time required for a data block to be transmitted from one end of the link or network to the other end, and the node load refers to the number of terminal nodes in charge of the relay node or gateway. The node access process is as follows: Step 1: The node to be connected to the network broadcasts a Dc_ask message on the 0x18 channel of the gateway to apply for direct connection to the network; Step 2: The node to be connected to the network continuously broadcasts Ct_rep messages on channel 0x18 to complete the communication test; Step 3: The node to be connected to the network broadcasts the Ts_brd message on the 0x18 channel regularly, waits for the gateway to reply the communication test result, and obtains the communication link vector R_vector; Step 4, determine whether the terminal node receives the Ts_rep response from the gateway, if it receives the Ts_rep response from the gateway, proceed to step 4.1, if it does not receive the Ts_rep response from the gateway, proceed to step 4.2; Step 4.1, apply the link selection strategy to determine the gateway to be connected to the network, and register the node address at the gateway, and proceed to step 5.1; Step 4.2, broadcast the Tc_ask message on the 0x17 channel where the node works, apply for relay access, and then go to step 5.2; Step 5.1, the node to be connected to the network receives the Dc_rep message from the gateway, updates its own address, and the node is successfully directly connected to the network, and the network access process is completed; Step 5.2: The node to be connected repeats steps 2 and 3 on channel 0x17, waits for the node to respond, and proceeds to step 6; Step 6, determine whether the terminal node receives the Ts_rep response of the node. If the node to be connected to the network receives the Ts_rep response of the node, proceed to step 6.2.1, otherwise proceed to step 6.2.2; Step 6.2.1, after receiving the response, apply the link selection strategy to determine the relay node, register the node address at the gateway through the relay node, and enter step 7; Step 6.2.2: The relay fails to access the network, and the access process ends; Step 7: The node to be connected to the network receives the Tc_rep message from the node, updates its own address, successfully relays to the network, and the network connection process ends; The data collection process is as follows: When the terminal node collects data normally and uploads it to the gateway, the specific steps are as follows: Step 11, the gateway waits for the data collection trigger signal of the TIM3 timer, and the trigger signal arrives once per minute; Step 12: After receiving the trigger signal, the gateway sends a Da_ask message to the current destination node. The initial destination node is the terminal node that first enters the network. Step 13, after receiving the Da_ask message, the terminal node first determines whether the destination address is itself; if so, it sends a Da_rep message to the gateway, and enters step 14; if not, it relays the Da_ask message to the corresponding terminal node and returns the Da_rep message to the node, and enters step 16; Step 14, if the gateway receives the Da_rep message from the destination node, it decodes the collected data and uploads it to the host computer; if the gateway does not receive the Da_rep message from the destination node, repeat step 12; Step 15, return to step 11, poll the new terminal nodes in the order of access, until the node polling is completed, and wait for the next round of data collection; Step 16: If the gateway receives the Da_rep message from the destination node this time, repeat step 15; if the gateway still does not receive the Da_rep message, mark the node and update the topology structure through dynamic networking after the polling is completed; Step 17, the node polling is completed and waits for the next round of data collection; The dynamic networking process is as follows: Step 21, the gateway sends a Ct_ask message to the destination node currently in the network to start the communication test. The order in which the messages are sent is the order in which the nodes enter the network; Step 22, after receiving the Ct_ask message, the terminal node first determines whether the destination node is itself, and the judgment basis is whether its own address is the same as the target address sent by the gateway; if so, it broadcasts the Ct_rep command on the 0x17 channel to complete the communication test; if not, it acts as a relay node to send the Ct_ask message to the corresponding terminal node; Step 23, the terminal node broadcasts the Ts_brd message regularly on the 0x17 channel, waits for the node to reply the communication test result, and obtains the communication link vector R_vector corresponding to the node; Step 24, after obtaining the communication link vector, the terminal node sends R_vector to the gateway through the Ci_rep message; Step 25, after receiving the Ci_rep message from the destination node, the gateway polls the new terminal node in the order of access to the network and merges the R_vector transmitted by each node; Step 26, the gateway completes polling, obtains the corresponding communication link matrix R_matrix, and determines the new topology of the subnet through the link selection strategy; Step 27, the gateway polls the terminal node in the order of access to the network, and sends a Tp_rec message carrying the upper node number in a targeted manner. After receiving the Tp_rec message, the terminal node makes corresponding adjustments to the communication link; Step 28, dynamic networking is completed, and the gateway realizes the topology reconstruction of the subnet; The functional reconstruction process is: Step 31, the host computer sends a Fun_rec function reconstruction message to the destination gateway; Step 32: The gateway receives the Fun_rec message and forwards it to the destination node; Step 33: The destination node decodes the Fun_rec message and completes the function reconstruction.

2. The method based on LoRa self-organizing network as claimed in claim 1, characterized in that In the unicast frame design, the unicast frame consists of the frame header, network ID, source address, destination address, channel, control code, length, data, check bit, and frame tail from front to back, where: a. The frame header is represented by 0xAA, which is the start flag of a frame of information; b. The network ID is the number of the terminal node, which is used to identify the subnet to which the terminal node belongs; c. The source address and destination address are two 2-byte hexadecimal identifiers, which represent the sending device address and receiving device address of the data frame respectively. The upper 8 bits represent the network ID number, and the lower 8 bits represent the subnet address number. d. Channel is used to indicate the working frequency band of the LoRa communication module. The default value 0x17 represents the 433MHZ frequency band of the terminal node, and 0x18 represents the 434MHZ frequency band of the gateway. This protocol supports a total of 32 channels from 410 to 441MHZ. e. The control code represents the communication instruction carried by the data frame. Different control codes represent different functional instructions; f. Length indicates the byte length of the entire data frame; g. Data is the content actually transmitted by the frame information. The data frame can be filled with different contents according to actual needs and transmitted bit by bit in the form of ASCII code to complete specific instructions; h. The check bit uses CRC16 check to detect whether the data is wrong; i. The end of the frame is represented by 0XFF, which is the end mark of a frame of data.

3. The method based on LoRa self-organizing network as claimed in claim 1, characterized in that The node time slice management adopts the method of sending the time synchronization message Ts_brd at regular intervals to obtain the time synchronization response Ts_rep of the slave node corresponding to the time slice number in each synchronization cycle. The time slice number is incremented once per synchronization cycle. In the above-mentioned node time slice management, when the terminal node applies to join the subnet or completes the communication test, the receiving device needs to send the corresponding response instruction to the master node. The process design is as follows: Step 1: When the master node needs to receive responses from the slave nodes in turn, it sends a time synchronization broadcast Ts_brd to unify the node time. Step 2: Every other cycle, the master node broadcasts the current time slice number starting from 0x0000 through the Ts_brd message, and the time slice number increases by 1 per cycle; Step 3: If the master node does not receive a response within a synchronization cycle, it will repeatedly broadcast the time slice number of the current cycle once. If it still does not receive a response, it is determined that the node with the current time slice number cannot be used as a slave node. Step 4: After the master node has broadcast all the time slice numbers in the network, it exits the broadcast mode and the time slice numbers are reset to zero.

4. The method based on LoRa self-organizing network as claimed in claim 1, characterized in that In the link selection strategy, three indicators, packet loss rate, communication delay, and node load, are selected as follows: a. Packet loss rate (PL) refers to the ratio of the number of lost data packets (p_loss) to the total number of sent data packets (p_total) in link communication. The calculation formula is: b. Communication delay (TD) refers to the time required for a data frame to be transmitted from one end of a link or network to the other end. The calculation formula is: TD=std+ptd+ftd; c. Node load (NL) refers to the number of terminal nodes that a relay node or gateway manages. If the node does not assume the relay function or the gateway does not manage the terminal nodes, the node load is 0x00.

5. An intelligent sensing terminal device based on the LoRa self-organizing network method as claimed in claim 1, characterized in that The device includes a terminal node and a communication gateway. The terminal node collects information and sends it to the communication gateway, which uploads the data to the cloud platform to achieve remote monitoring. The terminal node includes a power module, an information collection and processing module, an STM32 controller and a LoRa communication module, and the communication gateway includes a power module, an STM32 controller, a LoRa communication module and a NB-IoT / 4G communication module. The power module consists of a rechargeable power supply, a voltage regulator chip, a power protection device and a rectifier filter module, which can stably provide +5V and +3.3V level voltages to ensure that the terminal is always in a stable working state; The information collection and processing module is composed of multi-dimensional sensors, including temperature and humidity sensors, air quality sensors, and smoke sensors. The temperature and humidity sensors are responsible for collecting temperature and humidity data in the monitoring environment; the air quality sensors and smoke sensors are responsible for collecting air quality indicators and smoke concentrations in the monitoring environment; The STM32 controller is composed of STM32F103ZET6 / STM32F407ZGT6 and its supporting circuits. It has strong information collection and processing capabilities and works stably and reliably. It can collect, process and upload data for a long time, with low power consumption and high speed. At the same time, it can control the entire terminal node and effectively support the intelligent perception of the terminal node and communication gateway. The LoRa communication module uses the SX1278 low-power long-distance transceiver, which assumes the wireless serial port function of the microcontroller and can realize point-to-point, point-to-multipoint transparent transmission and directional transmission in the communication network; The NB-IoT / 4G communication module, wherein the 4G module adopts the ATK-GM510 LTE mobile network communication module of Gosuncn IoT, and the NB-IoT module adopts the BC28 communication module based on the MediaTek MT2625 chip. The 4G / NB-IoT communication module can transmit the collected data of the terminal node from the MAC layer to the network layer, thereby realizing dual-path access to the gateway.

6. The intelligent sensing terminal device according to claim 5, characterized in that The above-mentioned information acquisition and processing module collects multi-dimensional information in the environment and converts it into analog / digital signals for transmission to the microcontroller; the module is composed of multi-dimensional sensors, including SHT31 temperature and humidity sensor, MQ-2 smoke sensor, and MQ-135 air quality sensor; among them, the SHT31 temperature and humidity sensor uses IIC to communicate with the microcontroller, and the MQ-2 sensor and MQ-135 sensor directly transmit analog / digital quantities to the microcontroller.

Citation Information

Patent Citations

  • LoRa ad hoc network communication system of intelligent ring main unit

    CN210895799U