A loRa system time synchronization method and system
Patent Information
- Application Number
- CN202310823363.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-05
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-07-05
AI Technical Summary
如果网关使用环境在室内的话,则无法获取GPS信号,所以无法同步信标帧,无法使用LoRaWAN Class B从而无法进行
[0028]本发明采用如上技术方案,解决了loRaWAN室内网关时间授时问题,从而解决了loRaWAN class b信标同步和class b模式下的应用场景。
Smart Images

Figure CN116782362B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of LoRa communication technology, and in particular to a LoRa system time synchronization method and system. Background Technology
[0002] LoRa is a new type of wireless network spread spectrum modulation communication technology. LoRa boasts advantages such as long transmission distance, low power consumption, low cost, and large-scale networking capabilities. With the development of the Internet of Things (IoT) industry, LoRaWAN is attracting increasing attention. LoRaWAN is a communication protocol and system architecture based on LoRa radio frequency communication, designed to realize long-distance communication networks. A LoRaWAN communication system typically consists of three parts: terminals, gateways, and network servers (NS).
[0003] In a LoRaWAN communication system, terminals are classified into three categories: Class A, Class B, and Class C. Class A terminals use the ALOHA protocol to report data on demand. Each uplink is followed by two brief downlink receive windows, enabling bidirectional transmission. This operation is the most power-efficient. Class A terminals must wait for data reports before sending data to other terminals; their applications typically include trash can monitoring, smoke detectors, and gas monitoring. Class B terminals, in addition to the random receive window of Class A, also open receive windows at specified times. To allow the terminal to open its receive window at these times, it needs to receive time synchronization beacons from the gateway. Class B terminals can send data within their fixed receive window, resulting in slightly higher latency; their applications typically include valve-controlled water, gas, and electricity meters. Class C terminals essentially keep their receive windows open continuously, only briefly closing them when sending data. Because Class C terminals are in a continuous receiving state, data can be sent to other terminals at any time. Their applications typically include street light control. Class C terminals consume more power than Class A and Class B terminals.
[0004] Existing LoRaWAN gateways rely on GPS modules for time synchronization and then use GPS PPS to send LoRa beacon frames to LoRaWAN nodes for LoRaWAN Class B processing. If the gateway is used indoors, it cannot obtain GPS signals, thus failing to synchronize beacon frames and use LoRaWAN Class B, preventing the necessary processing. Summary of the Invention
[0005] To address the aforementioned issues, this invention proposes a LoRa system time synchronization method and system.
[0006] The specific plan is as follows:
[0007] A LoRa system time synchronization method, comprising:
[0008] The gateway executes the following process:
[0009] S101: Obtain the network time and set the obtained network time as the system time;
[0010] S102: Convert the system time to the calibration time;
[0011] S103: Based on the calibration time, beacon transmission is performed at fixed time intervals;
[0012] The terminal node executes the following process:
[0013] S201: Obtain the time via the LoRaWAN standard protocol and set the obtained time as the system time of the terminal node;
[0014] S202: Receive beacons at fixed time intervals, determine whether a beacon has been received, if yes, proceed to S204, otherwise proceed to S203;
[0015] S203: Determine whether the number of missed beacons is less than a preset threshold. If yes, return to S202; otherwise, return to S201.
[0016] S204: Calculate the current time based on the time carried in the received beacon, and set the calculated current time as the terminal node's system time;
[0017] S205: Report the beacon synchronization success information to the network server and return S202.
[0018] Furthermore, in step S101, the gateway obtains the network time via NTP.
[0019] Furthermore, the method for converting the system time to the calibration time in step S102 is as follows: the calibration time of each gateway is obtained by using the time offset between different gateways.
[0020] Furthermore, the method for obtaining the calibration time of each gateway by the time offset between different gateways is as follows: number all gateways, and subtract the time difference based on the number from the system time to obtain the calibration time.
[0021] Furthermore, the process of the terminal node obtaining the time through the LoRaWAN standard protocol in step S201 includes the following steps:
[0022] The terminal node sends a DeviceTimeReq packet;
[0023] After receiving the DeviceTimeReq packet, the gateway obtains the corresponding calibration time based on the system time at the time the DeviceTimeReq packet was received, and reports the obtained calibration time to the network server.
[0024] The network server calculates the packet with the best signal based on all the packets reported by the gateways it receives, and calculates the current calibration time using the calibration time in the packet with the best signal. Based on the calculated current calibration time, it generates a DeviceTimeAns packet and returns it to the gateway.
[0025] After receiving the DeviceTimeAns packet, the gateway forwards it to the corresponding terminal node.
[0026] Furthermore, the network server also includes binding the gateway and node corresponding to the packet with the best signal.
[0027] A LoRa system time synchronization system includes a network server, a gateway, and terminal nodes, wherein the system implements the steps of the method described in the embodiments of the present invention.
[0028] The present invention adopts the above technical solution to solve the time synchronization problem of loRaWAN indoor gateway, thereby solving the application scenarios of loRaWAN class b beacon synchronization and class b mode. Attached Figure Description
[0029] Figure 1 The diagram shown is a flowchart of gateway execution in Embodiment 1 of the present invention.
[0030] Figure 2 The diagram shown is a flowchart of the execution of the terminal node in Embodiment 1 of the present invention. Detailed Implementation
[0031] To further illustrate the various embodiments, the present invention provides accompanying drawings. These drawings are part of the disclosure of the present invention, primarily used to illustrate the embodiments, and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementations and the advantages of the present invention.
[0032] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments.
[0033] Example 1:
[0034] This invention provides a time synchronization method for a LoRa system, wherein:
[0035] like Figure 1 As shown, the gateway executes the following process:
[0036] S101: Obtain the network time and set the obtained network time as the system time.
[0037] In this embodiment, the gateway obtains the network time through NTP (Network Time Protocol).
[0038] S102: Convert system time to calibration time.
[0039] Because the acquired network time has a certain network latency, direct beacon transmission from different gateways may cause interference. To avoid this interference, this embodiment uses the time offset between different gateways to obtain the calibration time of each gateway, thus avoiding interference from beacon transmission. The specific method is as follows: First, all gateways are numbered (0-127 in this embodiment, up to 128 devices). The calibration time is obtained by subtracting the time difference based on the number from the system time. For example, if the number is X, the calibration time is the system time - X.
[0040] S103: Based on the calibration time, beacon is sent at fixed time intervals.
[0041] Both beacon transmission and reception require the use of a gateway chip. In this embodiment, the gateway chip used is SX1302. When transmitting the beacon, the calibration time needs to be mapped to the time of the gateway chip.
[0042] In this embodiment, the beacon is set to be sent every 128 seconds. The gateway immediately proceeds to steps S101 to S103 upon startup.
[0043] like Figure 2 As shown, the terminal node executes the following process:
[0044] S201: Obtain the time via the LoRaWAN standard protocol and set the obtained time as the system time of the terminal node.
[0045] S202: Receive beacons at fixed time intervals, determine whether a beacon has been received, if yes, proceed to S204, otherwise proceed to S203.
[0046] S203: Determine whether the number of beacon misses is less than a preset threshold. If yes, return to S202; otherwise, return to S201. The number of beacon misses can be recorded using a variable initially set to 0. In this embodiment, the threshold is set to 10 times. In other embodiments, those skilled in the art can set it according to their needs, and no restrictions are imposed here.
[0047] S204: Calculate the current time based on the time carried in the received beacon, and set the calculated current time as the terminal node's system time.
[0048] In this embodiment, the beacon reception time is set to beacon carrying time + air time. The air time calculation method can refer to the LoRa transmission time calculation.
[0049] S205: Report the beacon synchronization success information to the network server and return S202.
[0050] The terminal node receives a beacon every 128 seconds. After joining the network via OTAA, the terminal node immediately executes steps S201 to S205.
[0051] The LoRaWAN standard protocol used in this embodiment is V1.0.3. The process by which the terminal node obtains the time through the LoRaWAN standard protocol includes the following steps:
[0052] S301: The terminal node sends a DeviceTimeReq packet.
[0053] S302: After receiving the DeviceTimeReq packet, the gateway obtains the corresponding calibration time based on the system time when the DeviceTimeReq packet was received, and reports the obtained calibration time to the network server.
[0054] Multiple gateways around the terminal node can receive DeviceTimeReq packets to perform the operation in step S302.
[0055] S303: The network server calculates the packet with the best signal based on all packets reported by the gateways it receives, and calculates the current calibration time using the calibration time in the packet with the best signal. Based on the calculated current calibration time, it generates a DeviceTimeAns packet and returns it to the gateway.
[0056] The network server receives packets reported by multiple gateways and selects the optimal gateway based on the best signal principle.
[0057] Furthermore, since different gateways have different calibration times, each terminal node (the terminal node that sends the DeviceTimeReq packet) corresponds to a gateway, that is, the gateway from which the packet with the best signal comes. In this case, the two need to be bound together.
[0058] The current calibration time of the network server is calculated by adding the calibration time to the receiving window time.
[0059] S304: After receiving the DeviceTimeAns packet, the gateway forwards it to the corresponding terminal node.
[0060] After receiving the beacon synchronization success message, the network server marks the terminal node as having completed the beacon synchronization function.
[0061] Example 2:
[0062] The present invention also provides a LoRa system time synchronization system, including a network server, a gateway, and terminal nodes, wherein the system implements the steps in the above-described method embodiments of Embodiment 1 of the present invention.
[0063] Although the invention has been specifically shown and described in conjunction with preferred embodiments, those skilled in the art should understand that various changes in form and detail may be made to the invention without departing from the spirit and scope of the invention as defined in the appended claims, all of which shall be within the scope of protection of the invention.
Claims
1. A time synchronization method for a LoRa system, characterized in that, include: The gateway executes the following process: S101: Obtain the network time and set the obtained network time as the system time; S102: Convert the system time to the calibration time. The method for converting the system time to the calibration time is as follows: obtain the calibration time of each gateway by using the time offset between different gateways. The method for obtaining the calibration time of each gateway by using the time offset between different gateways is as follows: number all gateways and subtract the time difference based on the number from the system time as the calibration time. S103: Based on the calibration time, beacon transmission is performed at fixed time intervals; The terminal node executes the following process: S201: Obtain the time via the LoRaWAN standard protocol and set the obtained time as the system time of the terminal node; S202: Receive beacons at fixed time intervals, determine whether a beacon has been received, if yes, proceed to S204, otherwise proceed to S203; S203: Determine whether the number of missed beacons is less than a preset threshold. If yes, return to S202; otherwise, return to S201. S204: Calculate the current time based on the time carried in the received beacon, and set the calculated current time as the terminal node's system time; S205: Report the beacon synchronization success information to the network server and return S202.
2. The LoRa system time synchronization method according to claim 1, characterized in that: In step S101, the gateway obtains the network time via NTP.
3. The LoRa system time synchronization method according to claim 1, characterized in that: The process of the terminal node obtaining the time through the LoRaWAN standard protocol in step S201 includes the following steps: The terminal node sends a DeviceTimeReq packet; After receiving the DeviceTimeReq packet, the gateway obtains the corresponding calibration time based on the system time at the time the DeviceTimeReq packet was received, and reports the obtained calibration time to the network server. The network server calculates the packet with the best signal based on all the packets reported by the gateways it receives, and calculates the current calibration time using the calibration time in the packet with the best signal. Based on the calculated current calibration time, it generates a DeviceTimeAns packet and returns it to the gateway. After receiving the DeviceTimeAns packet, the gateway forwards it to the corresponding terminal node.
4. The LoRa system time synchronization method according to claim 1, characterized in that: The network server also includes binding the gateway and node corresponding to the packet with the best signal.
5. A LoRa system time synchronization system, characterized in that: The system includes a network server, a gateway, and terminal nodes, and implements the steps of the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Communication system, first node, gateway, network server and time synchronization method
CN111641937A
Gateway, synchronization system, synchronization method, and synchronization program
JP7034345B1