A time synchronization method, device, system and computer storage medium
Through the time synchronization packet interaction between the network server and the gateway, the problem of high cost and complexity of time synchronization between Class B terminal and gateway in LoRaWAN is solved, and efficient time synchronization is achieved, reducing deployment costs and increasing the gateway's Utilization.
Patent Information
- Application Number
- CN201911047047.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-30
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2039-10-30
AI Technical Summary
The existing LoRaWAN solution for maintaining time synchronization between Class B terminals and gateways is expensive, has increased complexity and is not effective.
Receive IP uplink data through the network server, determine the type and terminal identification of the forwarding gateway, send a time synchronization request to the indoor gateway, the indoor gateway sends the first time synchronization message to the outdoor gateway, and the outdoor gateway sends the second time synchronization message to the network server, and the outdoor gateway sends the second time synchronization message to the network server. , the network server obtains the current GPS time and synchronizes the downlink to the forwarding gateway.
Time synchronization between Class B terminal and gateway is realized, reducing the complexity of LoRaWAN topology and deployment costs, and improving the effective utilization rate of gateways.
Smart Images

Figure CN110677212B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a long range radio (LoRa) technology in the field of communications, and in particular to a time synchronization method, device, system and computer storage medium. Background Art
[0002] In the Long Range Radio Wide Area Network (LoRaWAN), communication terminals are mainly divided into three types: Class A two-way communication terminals, also known as Class A terminals, Class B two-way communication terminals, also known as Class B terminals, and Class C two-way communication terminals, also known as Class C terminals. Among these three types of communication terminals, due to the characteristics of Class B terminals, Class B terminals need to maintain time synchronization with the gateway to ensure normal data transmission and reception. However, the currently commonly used solution of maintaining time synchronization between Class B terminals and gateways has the disadvantages of high cost, increased complexity of LoRaWAN, and poor effect. Summary of the invention
[0003] To solve the existing technical problems, the embodiments of the present invention provide a time synchronization method, device, system and computer storage medium.
[0004] To achieve the above object, the technical solution of the embodiment of the present invention is implemented as follows:
[0005] In a first aspect, an embodiment of the present invention provides a time synchronization method, which is applied to a network server, and the method includes:
[0006] Receiving Internet Protocol (IP) uplink data; determining the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data;
[0007] When the type of the forwarding gateway is an indoor gateway, sending a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server;
[0008] receiving at least one of the second time synchronization messages, and obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway;
[0009] Sending downlink data including at least current GPS time and terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0010] In the above technical solution, determining the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data includes:
[0011] Performing a first analysis on the IP uplink data according to the IP address to obtain a first analysis result;
[0012] Based on the first parsing result, obtaining the time field included in the long-distance radio wide area network LoRaWAN uplink data and the IP uplink data;
[0013] Determining the type of the forwarding gateway according to the time field;
[0014] Perform a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; and determine the terminal identification of the communication terminal based on the second analysis result.
[0015] In the above technical solution, the obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway includes:
[0016] Sorting the at least one second time synchronization message according to a set condition;
[0017] Based on the sorting result, determining a current GPS time corresponding to a first local time of the forwarding gateway;
[0018] or,
[0019] The obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway comprises:
[0020] Based on the at least one second time synchronization message, determining a first received second time synchronization message;
[0021] Performing a third analysis on the first received second time synchronization message to obtain a third analysis result;
[0022] Based on the third analysis result, the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message are obtained; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway;
[0023] Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is obtained.
[0024] In the above technical solution, the step of sorting the at least one second time synchronization message according to a set condition includes:
[0025] Sorting the at least one second time synchronization message in descending order of signal strength in each second time synchronization message;
[0026] Correspondingly, determining the current GPS time corresponding to the first local time of the forwarding gateway based on the sorting result includes:
[0027] Based on the sorting result, obtain a second time synchronization message corresponding to the signal strength ranked first;
[0028] Performing a fourth analysis on the second time synchronization message to obtain a fourth analysis result;
[0029] Based on the four analysis results, the GPS time, transmission time and the first local time corresponding to the second local time are obtained; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway;
[0030] Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is determined.
[0031] In the above technical solution, the sending of the time synchronization request to the forwarding gateway includes:
[0032] The time synchronization request is sent to the forwarding gateway according to a first set period.
[0033] In the above technical solution, determining the type of the forwarding gateway according to the time field includes:
[0034] Determine whether the time field is non-zero and non-empty;
[0035] When it is determined that the time field is non-zero and non-empty, determining that the type of the forwarding gateway is an outdoor gateway;
[0036] When it is determined that the time field is zero or empty, it is determined that the type of the forwarding gateway is an indoor gateway.
[0037] In the above technical solution, the method further includes:
[0038] When the forwarding gateway is an outdoor gateway, the current GPS time corresponding to the first local time of the forwarding gateway is obtained based on the IP uplink data.
[0039] In a second aspect, an embodiment of the present invention further provides a time synchronization method, which is applied to an indoor gateway, and the method includes:
[0040] receiving a time synchronization request, performing a fifth analysis on the time synchronization request, and obtaining a fifth analysis result;
[0041] Generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0042] Sending the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0043] Receive downlink data including at least current global positioning system GPS time and terminal identification; the current global positioning system GPS time is the GPS time corresponding to the first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identification is determined by the network server based on the received Internet Protocol IP uplink data;
[0044] Time synchronization is performed on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0045] In the above technical solution, the time synchronization of the communication terminal corresponding to the downlink data and the terminal identifier includes:
[0046] Based on the downlink data, obtain the current GPS time and terminal identification corresponding to the first local time of the indoor gateway;
[0047] Generate a beacon message based on the current GPS time corresponding to the first local time;
[0048] The Beacon message is sent to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0049] In the above technical solution, obtaining the current GPS time corresponding to the first local time of the indoor gateway based on the downlink data includes:
[0050] Performing a sixth analysis on the downlink data according to the IP address to obtain a sixth analysis result;
[0051] Based on the sixth parsing result, a current GPS time corresponding to the first local time of the indoor gateway is obtained.
[0052] In the above technical solution, the sending of the Beacon message to the communication terminal corresponding to the terminal identifier includes:
[0053] The Beacon message is sent to the communication terminal corresponding to the terminal identifier according to a second set period.
[0054] In the above technical solution, the generating of the first time synchronization message based on the first synchronization identifier in the fifth parsing result includes:
[0055] Based on the fifth parsing result, obtaining a first synchronization identifier;
[0056] Based on the first synchronization identifier, a first time synchronization message is encapsulated according to the LoRaWAN protocol.
[0057] In the above technical solution, the gateway control parameters at least include a message sending period. Correspondingly, sending the first time synchronization message according to the gateway control parameters in the fifth analysis result includes: sending the first synchronization time message according to the message sending period.
[0058] In a third aspect, an embodiment of the present invention provides a time synchronization device, which is applied to a network server, and the device includes: a first receiving unit, a first determining unit, a first sending unit, a second receiving unit, a first obtaining unit, and a second sending unit, wherein:
[0059] The first receiving unit is used to receive Internet Protocol IP uplink data;
[0060] The first determining unit is used to determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data;
[0061] The first sending unit is used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server;
[0062] The second receiving unit is used to receive at least one second time synchronization message;
[0063] The first obtaining unit is used to obtain a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message;
[0064] The second sending unit is used to send downlink data including at least current GPS time and terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0065] In the above technical solution, the first determining unit includes: a first parsing subunit, a first obtaining subunit, a first determining subunit, a second parsing subunit and a second determining subunit, wherein:
[0066] The first parsing subunit is used to perform a first parsing on the IP uplink data according to the IP to obtain a first parsing result;
[0067] The first obtaining subunit is used to obtain the time field included in the long-range radio wide area network LoRaWAN uplink data and the IP uplink data based on the first parsing result;
[0068] The first determining subunit is used to determine the type of the forwarding gateway according to the time field;
[0069] The second parsing subunit is used to perform a second parsing on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second parsing result;
[0070] The second determining subunit is used to determine the terminal identification of the communication terminal based on the second parsing result.
[0071] In the above technical solution, the first obtaining unit includes a sorting subunit and a third determining subunit, wherein:
[0072] The sorting subunit is used to sort the at least one second time synchronization message according to a set condition;
[0073] The third determining subunit is used to determine the current GPS time corresponding to the first local time of the forwarding gateway based on the sorting result;
[0074] or,
[0075] The first obtaining unit is specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message; perform a third analysis on the first received second time synchronization message to obtain a third analysis result; based on the third analysis result, obtain the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, obtain the current GPS time corresponding to the first local time of the forwarding gateway.
[0076] In the above technical solution, the sorting subunit is specifically used to: sort the at least one second time synchronization message in descending order of the signal strength in each second time synchronization message;
[0077] The third determination subunit is specifically used to: obtain a second time synchronization message corresponding to the signal strength ranked first based on the sorting result; perform a fourth analysis on the second time synchronization message to obtain a fourth analysis result; based on the four analysis results, obtain the GPS time, transmission time and the first local time corresponding to the second local time; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, determine the current GPS time corresponding to the first local time of the forwarding gateway.
[0078] In the above technical solution, the first sending unit is specifically used to: send the time synchronization request to the forwarding gateway according to a first set period.
[0079] In the above technical solution, the first determination subunit is specifically used to: determine whether the time field is non-zero and non-empty; when it is determined that the time field is non-zero and non-empty, determine that the type of the forwarding gateway is an outdoor gateway; when it is determined that the time field is zero or empty, determine that the type of the forwarding gateway is an indoor gateway.
[0080] In the above technical solution, the device further includes: a second obtaining unit, which is used to obtain a current GPS time corresponding to a first local time of the forwarding gateway based on the IP uplink data when the forwarding gateway is an outdoor gateway.
[0081] In a fourth aspect, an embodiment of the present invention further provides a time synchronization device, which is applied to an indoor gateway. The device includes: a third receiving unit, a parsing unit, a generating unit, a third sending unit, a fourth receiving unit and a time synchronization unit, wherein:
[0082] The third receiving unit is used to receive a time synchronization request;
[0083] The parsing unit is used to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result;
[0084] The generating unit is configured to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0085] The third sending unit is used to send the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0086] The fourth receiving unit is used to receive downlink data including at least a current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on the received Internet Protocol IP uplink data;
[0087] The time synchronization unit is used to perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0088] In the above technical solution, the time synchronization unit includes: a second obtaining subunit, a generating subunit and a sending subunit, wherein:
[0089] The second obtaining subunit is used to obtain the current GPS time and the terminal identification corresponding to the first local time of the indoor gateway based on the downlink data;
[0090] The generating subunit is configured to generate a beacon message based on the current GPS time corresponding to the first local time;
[0091] The sending subunit is used to send the Beacon message to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0092] In the above technical solution, the second obtaining subunit is specifically used to: perform a sixth analysis on the downlink data according to IP to obtain a sixth analysis result; and obtain a current GPS time corresponding to the first local time of the indoor gateway based on the sixth analysis result.
[0093] In the above technical solution, the sending subunit is specifically used to: send the Beacon message to the communication terminal corresponding to the terminal identifier according to a second set period.
[0094] In the above technical solution, the generating unit is specifically used to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
[0095] In the above technical solution, the gateway control parameter at least includes a message sending period, and correspondingly, the third sending unit is used to send the first synchronization time message according to the message sending period.
[0096] In a fifth aspect, an embodiment of the present invention provides a computer storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0097] In a sixth aspect, an embodiment of the present invention provides a time synchronization device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor, when used to run the computer program, executes the steps of the method described in any one of the above claims.
[0098] In a seventh aspect, an embodiment of the present invention further provides a time synchronization system, the system comprising: a network server, an indoor gateway and at least one outdoor gateway, wherein:
[0099] The network server is used for the IP uplink data, and based on the IP uplink data, determines the type of the forwarding gateway and the terminal identification of the communication terminal; when the type of the forwarding gateway is an indoor gateway, sends a time synchronization request to the forwarding gateway; receives at least one second time synchronization message, and based on the at least one second time synchronization message, obtains the current global positioning system GPS time corresponding to the first local time of the forwarding gateway; sends downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the second time synchronization message is obtained by the outdoor gateway based on the first time synchronization message, and the first time synchronization message is obtained by the indoor gateway based on the time synchronization request;
[0100] The indoor gateway is used to receive a time synchronization request, perform a fifth analysis on the time synchronization request, and obtain a fifth analysis result; generate the first time synchronization message based on the first synchronization identifier in the fifth analysis result; send the first time synchronization message according to the gateway control parameter in the fifth analysis result; receive downlink data including at least the current GPS time and the terminal identifier; perform time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier;
[0101] Each of the at least one outdoor gateway is configured to receive the first time synchronization message, obtain a second time synchronization message based on the first time synchronization message, and send the second time synchronization message to the network server.
[0102] In the above technical solution, the network server includes:
[0103] A first receiving component, configured to receive the IP uplink data;
[0104] A first determination component, configured to determine a type of a forwarding gateway and a terminal identifier of a communication terminal based on the IP uplink data;
[0105] A first sending component, used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server;
[0106] A second receiving component, configured to receive at least one of the second time synchronization messages;
[0107] A first obtaining component, configured to obtain a current global positioning system GPS time corresponding to a first local time of the forwarding gateway based on the at least one second time synchronization message;
[0108] The second sending component is used to send downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0109] In the above technical solution, the indoor gateway includes:
[0110] A third receiving component, configured to receive a time synchronization request;
[0111] A parsing component, configured to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result;
[0112] A generating component, configured to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0113] A third sending component, configured to send the first time synchronization message according to the gateway control parameter in the fifth parsing result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0114] a fourth receiving component, configured to receive downlink data including at least a current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by a network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on received Internet Protocol IP uplink data;
[0115] A time synchronization component is used to perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0116] In the above technical solution, each of the at least one outdoor gateway includes:
[0117] A fifth receiving component, configured to receive the first time synchronization message;
[0118] A third obtaining component, configured to obtain a second time synchronization message based on the first time synchronization message;
[0119] A fourth sending component is used to send the second time synchronization message to the network server.
[0120] In the above technical solution, the first determination component is specifically used to: perform a first analysis on the IP uplink data according to the IP to obtain a first analysis result; based on the first analysis result, obtain the time field included in the long-range radio wide area network LoRaWAN uplink data and the IP uplink data; determine the type of the forwarding gateway according to the time field; perform a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; based on the second analysis result, determine the terminal identification of the communication terminal.
[0121] In the above technical solution, the first obtaining component is specifically used to: sort the at least one second time synchronization message according to the set condition; based on the sorting result, determine the current GPS time corresponding to the first local time of the forwarding gateway, or, specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message;
[0122] Performing a third analysis on the first received second time synchronization message to obtain a third analysis result;
[0123] Based on the third analysis result, the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message are obtained; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway;
[0124] Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is obtained.
[0125] In the above technical solution, the time synchronization component is specifically used to: obtain the current GPS time and terminal identification corresponding to the first local time of the indoor gateway based on the downlink data; generate a beacon Beacon message based on the current GPS time corresponding to the first local time; send the Beacon message to the communication terminal corresponding to the terminal identification; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0126] In the above technical solution, the generating component is specifically used to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
[0127] In the above technical solution, the gateway control parameters at least include a message sending period, and correspondingly, the third sending component is used to send the first synchronization time message according to the message sending period.
[0128] In the above technical solution, the network server is further used to obtain the current GPS time corresponding to the first local time of the forwarding gateway based on the IP uplink data.
[0129] The embodiment of the present invention provides a time synchronization method, device, system and computer storage medium, wherein the method applied to a network server comprises: receiving Internet Protocol IP uplink data; determining the type of a forwarding gateway and a terminal identifier of a communication terminal based on the IP uplink data; sending a time synchronization request to the forwarding gateway when the type of the forwarding gateway is an indoor gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to an outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server; receiving at least one of the second time synchronization messages, and obtaining a current global positioning system GPS time corresponding to a first local time of the forwarding gateway based on the at least one second time synchronization message; sending downlink data including at least the current GPS time and the terminal identifier to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data. By adopting the method provided in the embodiment of the present invention, a gateway in LoRaWAN that cannot obtain GPS time can obtain the current GPS time by interacting with a gateway that can obtain GPS time, and then based on the current GPS time, the Class B terminal keeps the time synchronized with the gateway. In this way, not only will the complexity and deployment cost of the LoRaWAN topology not be increased, but the effective utilization rate of the gateway can also be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0130] Figure 1 A schematic diagram of a system structure of LoRaWAN in related technology;
[0131] Figure 2 A schematic diagram of a time synchronization method provided by an embodiment of the present invention;
[0132] Figure 3 A schematic diagram of another time synchronization method provided by an embodiment of the present invention;
[0133] Figure 4A schematic diagram of an interactive process of a time synchronization method provided by an embodiment of the present invention;
[0134] Figure 5 A schematic diagram of an application scenario of the time synchronization method provided by an embodiment of the present invention;
[0135] Figure 6 A schematic diagram of the structure of a time synchronization device provided by an embodiment of the present invention;
[0136] Figure 7 A schematic diagram of the structure of another time synchronization device provided by an embodiment of the present invention;
[0137] Figure 8 A schematic diagram of the structure of a time synchronization system provided by an embodiment of the present invention;
[0138] Fig. 9 A schematic diagram of the hardware structure of a time synchronization device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0139] To make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the specific technical solution of the invention will be further described in detail below in conjunction with the drawings in the embodiments of the present invention. The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0140] In order to facilitate the understanding of the present invention, the related technologies of LoRaWAN are briefly introduced first.
[0141] LoRaWAN is a system architecture designed based on the long-range (LoRa, Long Range) communication protocol and is widely used in the Internet of Things. Figure 1As shown, the communication terminal is connected to the gateway through the LoRa wireless communication mode; the gateway is connected to the network server through the Internet Protocol (IP) network, wherein the IP network can be: a mobile cellular network, such as the third generation mobile communication technology, also known as 3G, or the fourth generation mobile communication technology, also known as 4G, etc., wireless fidelity (WIFI, Wireless Fidelity), Ethernet, etc. In this network structure, the gateway plays the role of connecting the network server and the communication terminal in LoRaWAN. Specifically, the communication terminal can send data to the network server through the gateway. This process is called the uplink process, and the data sent by the communication terminal is called uplink data; the network server can send data to the communication terminal through the gateway. This process is called the downlink process, and the data sent by the network server is called downlink data. It should be noted that the functional module that can send data according to the LoRaWAN protocol is also installed on the gateway in LoRaWAN. Therefore, data interaction can also be carried out between gateways according to the LoRaWAN protocol.
[0142] In LoRaWAN, communication terminals can be roughly divided into: Class A two-way communication terminals, Class B two-way communication terminals and Class C two-way communication terminals. Among them, Class A two-way communication terminals can also be called Class A terminals. This type of communication terminal uses the ALOHA protocol to send uplink data to the network server through the gateway as needed, and two short downlink windows are followed after each uplink data is sent to receive the response sent by the network server to the Class A terminal through the gateway in the downlink window. The application scenarios of this type of communication terminal can be: garbage can monitoring, smoke alarms, gas monitoring, etc.
[0143] C-level two-way communication terminal, also known as Class C terminal, has a downlink window that is always open, and is closed briefly only when it is sending uplink data. Since the downlink window of this type of communication terminal is always open, it can be said that this type of communication terminal is always in a receiving state. The network server can send downlink data to the Class C terminal at any time. The application scenario of the Class C terminal can be street light control, etc.
[0144] For Class B two-way communication terminals, also called Class B terminals, the application scenarios of this type of communication terminals can be valve-controlled water, gas and electricity meters, etc. In addition to the characteristics of Class A terminals, Class B terminals also have some unique characteristics, specifically: Class B terminals will open the downlink window at the specified time and receive the downlink data sent by the network server through the gateway. However, in order to enable the Class B terminal to open the downlink window at the specified time, the Class B terminal needs to obtain the Global Positioning System (GPS) time from the gateway and adjust its own time based on the obtained GPS time to keep time synchronized with the gateway, so as to ensure the normal sending and receiving of data. At present, there are two commonly used ways to keep the Class B terminal and the gateway time synchronized:
[0145] One is to set a GPS module on each gateway in LoRaWAN. The gateway uses the GPS module to obtain the current GPS time, and then sends a beacon message carrying the current GPS time to the Class B terminal. The Class B terminal receives the Beacon message, obtains the current GPS time based on the Beacon message, and adjusts its own time based on the current GPS time to keep time synchronization with the gateway. However, using this method requires each gateway in LoRaWAN to set a GPS module on the hardware, which increases the hardware volume and cost of each gateway; and because the GPS microwave signal has weak penetration ability, the GPS microwave signal cannot be obtained indoors, resulting in the GPS module being unavailable indoors, reducing the effective utilization of the gateway, which is also a disguised waste of resources.
[0146] Another method is to add an additional third-party time synchronization server to LoRaWAN. The gateway obtains the current GPS time from the third-party time synchronization server at a certain period, and then sends a Beacon message carrying the current GPS time to the Class B terminal. The Class B terminal receives the Beacon message, obtains the current GPS time based on the Beacon message, and adjusts its own time based on the current GPS time to keep time synchronization with the gateway. However, this method requires the addition of an additional third-party time synchronization server, which increases the complexity and deployment cost of the LoRaWAN topology. The third-party time synchronization server is a server specifically used to obtain accurate time, which can provide reliable time for millions of users. The commonly used third-party time server is the Network Time Protocol (NTP) server.
[0147] Based on this, an embodiment of the present invention provides a time synchronization method. When LoRaWAN is deployed, only the gateway located outdoors is installed with a GPS module. Therefore, the gateway installed with a GPS module can be called an outdoor gateway, and the gateway located indoors is not installed with a GPS module. Therefore, the gateway without a GPS module can be called an indoor gateway. In this way, the outdoor gateway can obtain the current GPS time through the GPS module installed on itself, and send a Beacon message carrying the current GPS time to the Class B terminal. The Class B terminal receives the Beacon message, obtains the current GPS time based on the Beacon message, and adjusts its own time based on the current GPS time to keep time synchronization with the outdoor gateway; and the indoor gateway can obtain the current GPS time through interaction with the outdoor gateway with a GPS module, and send a Beacon message carrying the current GPS time to the Class B terminal. The Class B terminal receives the Beacon message, obtains the current GPS time based on the Beacon message, and adjusts its own time based on the current GPS time, so that the Class B terminal maintains accurate GPS time. Since the way in which the outdoor gateway maintains time synchronization with the Class B terminal is the same as the way in which time synchronization is used in the related art, the embodiment of the present invention focuses on studying how to make the indoor gateway maintain time synchronization with the Class B terminal.
[0148] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0149] like Figure 2 As shown, it shows a schematic flow chart of a time synchronization method, which is applied to a network server, and the method includes:
[0150] S201: Receive Internet Protocol IP uplink data; determine the type of forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data.
[0151] It should be noted that IP uplink data is data sent by the forwarding gateway to the network server. In actual application, the process of obtaining IP uplink data can be as follows:
[0152] The communication terminal sends LoRaWAN uplink data to the forwarding gateway;
[0153] The forwarding gateway receives the LoRaWAN uplink data, processes the LoRaWAN uplink data according to IP, obtains IP uplink data, and sends the IP uplink data to a network server.
[0154] It should be noted that the communication terminal encapsulates the data to be sent according to the LoRaWAN protocol to obtain the LoRaWAN uplink data, and then sends the LoRaWAN uplink data to the forwarding gateway according to the LoRaWAN protocol, wherein the LoRaWAN uplink data at least includes the terminal identification of the communication terminal, and the terminal identification is a unique identification. In other words, the terminal identification is like an identity identification to identify the uniqueness of the communication terminal. In the subsequent data transmission process, the data related to the communication terminal are all accompanied by its terminal identification, for example, the IP uplink data also contains the terminal identification of the communication terminal.
[0155] In some embodiments, the forwarding gateway processes the LoRaWAN uplink data according to IP, including: adding a gateway related information field to the LoRaWAN uplink data, wherein the gateway related information field may include a time field, a gateway identification field, a channel identification field, a signal strength field, a transmission time field, etc.; the time field at least includes the GPS time when the forwarding gateway receives the LoRaWAN uplink data; the gateway identification field may at least include a gateway identification code, for example, the gateway identification code may use the gateway's identification number; the channel identification field at least includes the channel identification of the channel used by the forwarding gateway to send IP uplink data to the network server; the signal strength field at least includes the signal strength used by the forwarding gateway to send IP uplink data to the network server; the transmission time field at least includes the transmission time required for the LoRaWAN uplink data from the communication terminal to the forwarding gateway. After the forwarding gateway adds the gateway related information field to the LoRaWAN uplink data according to IP, it obtains the IP uplink data and sends the IP uplink data to the network server.
[0156] It should be noted that according to the LoRaWAN protocol, the LoRaWAN uplink data sent by the communication terminal can be received by one or more gateways, so the forwarding gateway here can be an indoor gateway or an outdoor gateway. On this basis, the forwarding gateway processes the LoRaWAN uplink data according to the IP in two ways: adding an indoor gateway related information field to the LoRaWAN uplink data; or adding an outdoor gateway related information field to the LoRaWAN uplink data; wherein the indoor gateway related information field contains the same fields as the outdoor gateway related information field, only the contents contained in the fields are different, in other words, the time field in the indoor gateway related information field can be empty or zero, while the time field in the outdoor gateway related information field can be non-empty and non-zero; the gateway identification field in the indoor gateway related information field is the indoor gateway identification, while the gateway identification field in the outdoor gateway related information field is the outdoor gateway identification, etc.
[0157] Based on this, the process in which the network server determines the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data is the reverse process of the aforementioned process of obtaining the IP uplink data.
[0158] In some embodiments, determining the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data includes:
[0159] Performing a first analysis on the IP uplink data according to the IP address to obtain a first analysis result;
[0160] Based on the first parsing result, obtaining the time field included in the long-distance radio wide area network LoRaWAN uplink data and the IP uplink data;
[0161] Determining the type of the forwarding gateway according to the time field;
[0162] Perform a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; and determine the terminal identification of the communication terminal based on the second analysis result.
[0163] It should be noted that the "first" in the first analysis here, and the "second", "third", "fourth", "fifth" and "sixth" in the subsequent second analysis, third analysis, fourth analysis, fifth analysis and sixth analysis are only distinctions between different analysis processes and are not used to limit the present invention.
[0164] It should be noted that the types of forwarding gateways include: indoor gateways and outdoor gateways. Specifically, a gateway with a GPS module installed is called an outdoor gateway; a gateway without a GPS module installed is called an indoor gateway. The outdoor gateway has a GPS module and can obtain GPS time; the indoor gateway does not have a GPS module and cannot obtain GPS time. Based on this, when the forwarding gateway is an indoor gateway, after the indoor gateway encapsulates the LoRaWAN uplink data according to IP, the time field in the obtained IP uplink data does not contain GPS time. In this case, the time field of the IP uplink data is empty or zero; and when the outdoor gateway encapsulates the LoRaWAN uplink data according to IP, the time field of the IP uplink data has GPS time. In this case, the time field of the IP uplink data is empty or zero.
[0165] In actual application, determining the type of the forwarding gateway according to the time field includes:
[0166] Determine whether the time field is non-zero and non-empty;
[0167] When it is determined that the time field is non-zero and non-empty, determining that the type of the forwarding gateway is an outdoor gateway;
[0168] When it is determined that the time field is zero or empty, it is determined that the type of the forwarding gateway is an indoor gateway.
[0169] S202: When the type of the forwarding gateway is an indoor gateway, send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server.
[0170] It should be noted that the time synchronization request includes at least a first synchronization identifier and a gateway control parameter, wherein the first synchronization identifier is an identifier that triggers the forwarding gateway to obtain GPS time when the network server determines that the forwarding gateway is an indoor gateway. In some embodiments, the first synchronization identifier may be included in a field of the time synchronization request, such as a sync field. Specifically, when the network server determines that the type of the forwarding gateway is an indoor gateway, the network server determines that the forwarding gateway needs to obtain GPS time. At this time, the network server sets the sync field of the time synchronization request to true, and this true is the first synchronization identifier.
[0171] In the actual application process, the gateway control parameters may be the relevant parameters set by the network server for the forwarding gateway to send the first time synchronization message. For example, the gateway control parameters may include the message sending frequency, the message sending period, etc., wherein the message sending frequency refers to the frequency required for the forwarding gateway to send the first time synchronization message; the message sending period refers to the period for the forwarding gateway to send the first time synchronization message. In other words, the forwarding gateway sends the first time synchronization message according to what period. Among them, the message sending frequency is determined according to the model of the forwarding gateway used in LoRaWAN and the deployment area of LoRaWAN. The message sending period can be set by the user, for example, the message sending period can be 120 seconds (s). It should be noted that the forwarding gateway can periodically send the first time synchronization message through the message sending period, so that the forwarding gateway can periodically obtain the current GPS time corresponding to the first local time, thereby ensuring the time synchronization between the communication terminal and the forwarding gateway.
[0172] It should be noted that the first time synchronization message is a message based on the LoRaWAN protocol, which is generated by the forwarding gateway based on the time synchronization request, and its specific generation process can be as follows: after the forwarding gateway receives the time synchronization request, parses the time synchronization request and obtains the first synchronization identifier, the forwarding gateway encapsulates the first time synchronization message based on the first synchronization identifier and in accordance with the LoRaWAN protocol, wherein the first time synchronization message contains at least a second synchronization identifier, a gateway identification code and a first local time; the second synchronization identifier is used to identify that the forwarding gateway needs to obtain GPS time; the role played by the gateway identification code is the same as that played by the terminal identification of the communication terminal; the first local time is the time when the forwarding gateway sends the first time synchronization message.
[0173] In actual application, the first time synchronization message sent by the forwarding gateway can be received by at least one outdoor gateway. Each outdoor gateway receives the first time synchronization message and processes the received first time synchronization message to obtain a second time synchronization message to send the second time synchronization message to the network server. In some embodiments, the process of the outdoor gateway obtaining the second time synchronization message can be as follows:
[0174] Based on the first time synchronization message, obtaining the transmission time of the first time synchronization message;
[0175] Determine a second local time at which the first time synchronization message is received;
[0176] Based on the second local time, determining a GPS time corresponding to the second local time;
[0177] A second time synchronization message is obtained based on the GPS time corresponding to the second local time, the transmission time and the first time synchronization message.
[0178] It should be noted that, since the outdoor gateway also has the general characteristics of a gateway, the outdoor gateway will encapsulate the GPS time corresponding to the second local time, the transmission time and the first time synchronization message according to IP to obtain the second time synchronization message, that is, the outdoor gateway encapsulates the second time synchronization message according to IP, and the second time synchronization message also includes the outdoor gateway related information field. Specifically, the outdoor gateway related information field may also include a time field, a gateway identification field, a channel identification field, a signal strength field, a transmission time field, etc. Among them, in the second time synchronization message, the time field at least includes the second local time and the GPS time corresponding to the second local time, and the second local time is the time when the outdoor gateway receives the first time synchronization message; the gateway identification field is used to include at least the outdoor gateway identification code, for example, the outdoor gateway identification code can adopt the identity (Identification) identification number of the outdoor gateway; the channel identification field at least includes the channel identification of the channel used by the second time synchronization message sent by the outdoor gateway to the network server; the signal strength field at least includes the signal strength used by the second time synchronization message sent by the outdoor gateway to the network server; the transmission time field at least includes the transmission time, and the transmission time is the time required for the first time synchronization message to be transmitted from the forwarding gateway to the outdoor gateway.
[0179] In order to ensure that the current GPS time can be obtained at the forwarding gateway, in some embodiments, sending a time synchronization request to the forwarding gateway includes:
[0180] The time synchronization request is sent to the forwarding gateway according to a first set period.
[0181] It should be noted that the first setting period can be set by the user, for example, the first setting period is set to 5 minutes / time. In this way, if the forwarding gateway still fails to obtain the current GPS time after the first setting period, the network server can resend the time synchronization request to the forwarding gateway, and the forwarding gateway can re-receive the time synchronization request and obtain the current GPS time based on the time synchronization request. This setting can increase the success rate of the indoor gateway obtaining the current GPS time, greatly ensuring the success rate of data transmission between the communication terminal and the forwarding gateway.
[0182] S203: Receive at least one of the second time synchronization messages, and obtain a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message.
[0183] It should be noted that in LoRaWAN, multiple gateways are usually deployed, including indoor gateways and outdoor gateways. Then, when the forwarding gateway broadcasts the first time synchronization message, more than one outdoor gateway can receive the first time synchronization message. Therefore, when each outdoor gateway receives the first time synchronization message, it will process the first time synchronization message to obtain the second time synchronization message corresponding to each outdoor gateway, and each outdoor gateway will send the corresponding second time synchronization message to the network server, and the network server will receive at least one second time synchronization message. In this case, there are various ways for the network server to obtain the current GPS time corresponding to the first local time of the forwarding gateway.
[0184] As an implementation manner, obtaining a current GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message includes:
[0185] Sorting the at least one second time synchronization message according to a set condition;
[0186] Based on the sorting result, determining a current GPS time corresponding to a first local time of the forwarding gateway;
[0187] or,
[0188] As another implementation manner, obtaining a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message includes:
[0189] Based on the at least one second time synchronization message, determining a first received second time synchronization message;
[0190] Performing a third analysis on the first received second time synchronization message to obtain a third analysis result;
[0191] Based on the third analysis result, obtaining the GPS time, transmission time and first local time corresponding to the second local time in the first received second time synchronization message,
[0192] Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is obtained.
[0193] It should be noted that the setting condition may be the signal strength in the second time synchronization message, the sequence of the second local time, the sequence of the GPS corresponding to the second local time, and the like.
[0194] In some embodiments, before sorting the at least one second time synchronization message according to a set condition, the method further includes: parsing all received second time synchronization messages to obtain a signal strength of each second time synchronization message.
[0195] In some embodiments, when the set condition is the magnitude of the signal strength in the second time synchronization message, it is necessary to obtain the signal strength of each second time synchronization message; in this case, sorting the at least one second time synchronization message according to the set condition may include:
[0196] Sorting the at least one second time synchronization message in descending order according to the signal strength in each second time synchronization message;
[0197] Correspondingly, based on the sorting result, determining the current GPS time corresponding to the first local time of the gateway includes:
[0198] Based on the sorting result, obtain a second time synchronization message corresponding to the signal strength ranked first;
[0199] Performing a fourth analysis on the second time synchronization message to obtain a fourth analysis result;
[0200] Based on the fourth analysis result, the GPS time, transmission time and first local time corresponding to the second local time are obtained; the transmission time is the time required for the forwarding gateway to send the first time synchronization message to the outdoor gateway;
[0201] A current GPS time corresponding to a first local time of the forwarding gateway is determined based on the GPS time corresponding to the second local time, the transmission time, and the first local time.
[0202] Specifically, based on the GPS time corresponding to the second local time and the transmission time, the current GPS time corresponding to the first local time of the forwarding gateway is determined, including: subtracting the transmission time from the GPS time corresponding to the second local time to obtain the difference, and using the difference as the current GPS time corresponding to the first local time of the forwarding gateway.
[0203] In other embodiments, the ordering of the at least one second time synchronization message according to the set conditions may also include: ordering the at least one second time synchronization message in order from small to large according to the signal strength in each second time synchronization message; correspondingly, determining the current GPS time corresponding to the first local time of the forwarding gateway based on the ordering result may also include: obtaining the second time synchronization message corresponding to the signal strength at the end of the ordering based on the ordering result, and obtaining the GPS time, transmission time and first local time corresponding to the second local time in the second time synchronization message, and determining the current GPS time corresponding to the first local time of the forwarding gateway based on the GPS time corresponding to the second local time, the transmission time and the first local time. The specific calculation process is similar to the above and will not be repeated here.
[0204] Exemplarily, when the at least one second time synchronization message is three second time synchronization messages, which are respectively recorded as second time synchronization message 1, second time synchronization message 2, and second time synchronization message 3, and the signal strengths contained therein are 60 dB, 70 dB, and 80 dB, respectively, then, they are sorted from large to small according to the aforementioned signal strengths as second time synchronization message 3, second time synchronization message 2, and second time synchronization message 1. In this case, based on the sorting result, determining the current GPS time corresponding to the first local time of the gateway includes: obtaining the GPS time corresponding to the second local time in the second time synchronization message 3, the transmission time of the first time synchronization message, and the first local time, subtracting the transmission time of the first time synchronization message from the GPS time corresponding to the second local time, and obtaining the current GPS time corresponding to the first local time of the forwarding gateway.
[0205] It should be noted that the network server calculates the current GPS time corresponding to the first local time of the gateway according to the signal strength in the second time synchronization message sorted from large to small. This can be understood based on the calculation of the current GPS time corresponding to the first local time of the gateway according to the signal strength in the second time synchronization message sorted from small to large, and will not be repeated here.
[0206] It should be noted that, in actual application, sorting according to the order of the second local time and the order of the GPS corresponding to the second local time, and then obtaining the current GPS time corresponding to the first local time of the forwarding gateway is similar to the process of sorting according to signal strength to obtain the current GPS time, and the detailed process will not be repeated here.
[0207] It should be noted that the network server can determine the first received second time synchronization message according to its own timer. For details on how to calculate and obtain the current GPS time corresponding to the first local time of the gateway, please refer to the above description.
[0208] S204: Send downlink data including at least the current GPS time and the terminal identifier to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0209] It should be noted that the network server encapsulates the data including at least the current GPS time and the terminal identification according to the IP, obtains the downlink data, and sends the downlink data to the forwarding gateway. The forwarding gateway receives the downlink data and performs time synchronization with the communication terminal based on the downlink data.
[0210] In some embodiments, the process of the forwarding gateway performing time synchronization with the communication terminal based on the downlink data can be as follows: based on the downlink data, obtaining the current GPS time corresponding to the first local time of the forwarding gateway and the terminal identification of the communication terminal, generating a Beacon message based on the current GPS time corresponding to the first local time, and sending the Beacon message to the communication terminal corresponding to the terminal identification; the Beacon message is used to instruct the communication terminal to perform time synchronization with the forwarding gateway based on the Beacon message.
[0211] It should be noted that the Beacon message at least includes a third local time and a GPS time corresponding to the third local time. The third local time is the time when the forwarding gateway sends the Beacon message. In actual application, the third local time of the Beacon message can be Coordinated Universal Time (UTC). The GPS time corresponding to the third local time is equal to the third local time minus the first local time, and then plus the current GPS time corresponding to the first local time.
[0212] In actual application, the communication terminal receives the Beacon message, obtains the GPS time corresponding to the third local time, the third local time and the transmission time of the Beacon message based on the Beacon message, and maintains synchronization with the forwarding gateway time based on the GPS time corresponding to the third local time, the third local time, the fourth local time and the transmission time of the Beacon message. It should be noted that the fourth local time is the time when the communication terminal receives the Beacon message.
[0213] In actual application, the communication terminal maintains time synchronization with the forwarding gateway based on the GPS time corresponding to the third local time, the third local time, the fourth local time and the transmission time of the Beacon message, including:
[0214] Acquire a clock deviation between the communication terminal and the forwarding gateway based on the third local time, the fourth local time and the transmission time of the Beacon message;
[0215] Based on the clock deviation, the transmission time of the Beacon message and the GPS time corresponding to the third local time, time synchronization with the forwarding gateway is maintained.
[0216] Specifically, the clock deviation is equal to the fourth local time minus the third local time minus the transmission time of the Beacon message.
[0217] In some embodiments, the communication terminal maintains time synchronization with the forwarding gateway based on the clock deviation, the transmission time of the Beacon message and the GPS time corresponding to the third local time, including: adding the GPS time corresponding to the third local time to the transmission time of the Beacon message to obtain the GPS time corresponding to the fourth local time; and subtracting the clock deviation from the GPS time corresponding to the fourth local time and the fourth local time at the same time to maintain time synchronization with the forwarding gateway.
[0218] In some embodiments, between two Beacon message time intervals, the communication terminal will randomly open some downlink windows. It should be noted that the user can change the timing and number of downlink windows opened by the communication terminal between two Beacon message time intervals through the network server. Among them, each downlink window can also be called a ping slot. During the period when a downlink window remains open, if the communication terminal receives downlink data sent by the gateway, the downlink window will not be closed until the communication terminal receives the complete downlink data. If no data is received during the period when a downlink window remains open, the duration of a downlink window is approximately 30-40 microseconds (μs).
[0219] In some embodiments, when the network server determines that the type of the forwarding gateway is an outdoor gateway, the method further includes: obtaining a current GPS time corresponding to a first local time of the forwarding gateway based on the IP uplink data.
[0220] It should be noted that, since the IP uplink data sent by the outdoor gateway includes the GPS time corresponding to the local time, that is, the network server can directly obtain the current GPS time corresponding to the first local time of the forwarding gateway based on the received IP uplink data. Then, the network server sends downlink data including at least the current GPS time corresponding to the first local time of the forwarding gateway and the terminal identifier of the communication terminal to the forwarding gateway. Then, the forwarding gateway receives the downlink data, and performs time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier. The specific synchronization method can be understood based on the above description and will not be repeated here.
[0221] The time synchronization method applied to the network server provided by the embodiment of the present invention only needs to deploy some gateways equipped with GPS modules (called outdoor gateways) in LoRaWAN. The gateways without GPS modules (called indoor gateways) can obtain the GPS time corresponding to the local time based on the assistance of the network server and the outdoor gateway, and then synchronize the time with the communication terminal through the Beacon message, so as to ensure the normal transmission and reception of data. This will not only not increase the topological complexity of LoRaWAN, but also prevent the indoor gateway from being abandoned because it cannot obtain accurate GPS time and cannot transmit and receive data normally with the communication terminal. This indirectly improves the utilization rate of each gateway in LoRaWAN.
[0222] Based on the same inventive concept, the embodiment of the present invention also provides another time synchronization method, which is applied to the indoor gateway side, such as Figure 3 As shown, another time synchronization method process of an embodiment of the present invention is shown, and the method includes:
[0223] S301: receiving a time synchronization request, performing a fifth analysis on the time synchronization request, and obtaining a fifth analysis result;
[0224] S302: Generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0225] S303: Send the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0226] S304: receiving downlink data including at least current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on the received Internet Protocol IP uplink data;
[0227] S305: Perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0228] It should be noted that the fifth parsing process here is the aforementioned parsing process for the time synchronization request, and this process is that the forwarding gateway performs the fifth parsing of the time synchronization request according to the LoRaWAN protocol.
[0229] In some embodiments, for S305, it includes:
[0230] Based on the downlink data, obtain the current GPS time and terminal identification corresponding to the first local time of the indoor gateway;
[0231] Generate a beacon message based on the current GPS time corresponding to the first local time;
[0232] The Beacon message is sent to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0233] In some embodiments, obtaining the current GPS time corresponding to the first local time of the indoor gateway based on the downlink data includes:
[0234] Performing a sixth analysis on the downlink data according to the IP address to obtain a sixth analysis result;
[0235] Based on the sixth parsing result, a current GPS time corresponding to the first local time of the indoor gateway is obtained.
[0236] In some embodiments, the sending the Beacon message to the communication terminal corresponding to the terminal identifier includes:
[0237] The Beacon message is sent to the communication terminal corresponding to the terminal identifier according to a second set period.
[0238] It should be noted that the second set period can be set to 128s, that is, the forwarding gateway will send a Beacon message to the communication terminal every 128s, and the communication terminal will receive the Beacon message broadcast by the gateway every 128s, so that the communication terminal calibrates its own clock based on the GPS time corresponding to the third local time in the Beacon message to maintain time synchronization with the forwarding gateway.
[0239] In some embodiments, generating a first time synchronization message based on the first synchronization identifier in the fifth parsing result includes:
[0240] Based on the fifth parsing result, obtaining a first synchronization identifier;
[0241] Based on the first synchronization identifier, a first time synchronization message is encapsulated according to the LoRaWAN protocol.
[0242] In some embodiments, the gateway control parameters include at least a message sending period. Correspondingly, sending the first time synchronization message according to the gateway control parameters in the fifth analysis result includes: sending the first synchronization time message according to the message sending period.
[0243] It should be noted that the embodiment of the present invention is another side description of the previous embodiment. Various nouns herein can be understood based on the previous embodiment and will not be repeated here.
[0244] The time synchronization method for indoor gateways provided by the embodiments of the present invention not only does not increase the topological complexity of LoRaWAN, but also the indoor gateway will not be abandoned because it cannot obtain accurate GPS time and cannot perform normal data transmission and reception with the communication terminal, thereby indirectly improving the utilization rate of each gateway in LoRaWAN.
[0245] In order to better understand the present invention, the embodiment of the present invention provides a complete process of time synchronization between a Class B terminal and an indoor gateway, such as Figure 4 As shown, the process includes:
[0246] S401: The Class B terminal sends LoRaWAN uplink data to the forwarding gateway according to the LoRaWAN protocol;
[0247] S402: The forwarding gateway receives the LoRaWAN uplink data, processes the LoRaWAN uplink data according to IP, obtains IP uplink data, and sends the IP uplink data to a network server.
[0248] In actual application, the Class B terminal encapsulates the data to be sent according to the LoRaWAN protocol, obtains the LoRaWAN uplink data, and then sends the LoRaWAN uplink data to the gateway according to the LoRaWAN protocol.
[0249] In some embodiments, the forwarding gateway processes the LoRaWAN uplink data according to IP, including: adding a gateway related information field of the forwarding gateway to the LoRaWAN uplink data, wherein the gateway related information field may include a time field, a gateway identification field, a channel identification field, a signal strength field, a transmission time field, etc.; wherein the content contained in each field is similar to the above, and here, the transmission time field at least includes the transmission time required for the LoRaWAN uplink data from the Class B terminal to the forwarding gateway. After the forwarding gateway adds the gateway related information field of the forwarding gateway to the LoRaWAN uplink data according to IP, it obtains the IP uplink data and sends the IP uplink data to the network server.
[0250] S403: The network server receives the IP uplink data, and determines the type of the forwarding gateway and the terminal identifier of the Class B terminal based on the IP uplink data;
[0251] It should be noted that the types of forwarding gateways include: indoor gateways and outdoor gateways as mentioned above.
[0252] In some embodiments, determining the type of the forwarding gateway based on the IP uplink data in S403 includes: performing a first analysis on the IP uplink data according to the IP to obtain a first analysis result; obtaining a time field included in the IP uplink data based on the first analysis result; and determining the type of the forwarding gateway based on the time field. Specifically, when it is determined that the time field is non-zero and non-empty, the type of the forwarding gateway is determined to be an outdoor gateway; when it is determined that the time field is zero or empty, the type of the forwarding gateway is determined to be an indoor gateway.
[0253] In some embodiments, the first parsing result also includes LoRaWAN uplink data, based on which, the terminal identification of the Class B terminal is determined based on the IP uplink data, including: performing a second parsing of the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second parsing result; based on the second parsing result, determining the terminal identification of the Class B terminal.
[0254] S404: When the type of the forwarding gateway is an indoor gateway, the network server sends a time synchronization request to the forwarding gateway.
[0255] It should be noted that the time synchronization request here has the same meaning as mentioned above and will not be repeated here.
[0256] S405: The forwarding gateway receives the time synchronization request, performs a fifth analysis on the time synchronization request to obtain a fifth analysis result, generates a first time synchronization message based on a first synchronization identifier in the fifth analysis result, and sends the first time synchronization message according to a gateway control parameter in the fifth analysis result.
[0257] It should be noted that the forwarding gateway here is actually an indoor gateway. The gateway control parameter and the first time synchronization message have the same meaning as above.
[0258] S406: The outdoor gateway receives the first time synchronization message, processes the first time synchronization message, obtains a second time synchronization message, and sends the second time synchronization message to the network server.
[0259] It should be noted that the processing of the outdoor gateway is the same as that described above, and based on the above understanding, it will not be repeated here.
[0260] S407: The network server receives at least one of the second time synchronization messages, obtains the current GPS time corresponding to the first local time of the forwarding gateway based on the at least one of the second time synchronization messages, and sends downlink data including at least the current GPS time and the terminal identifier to the forwarding gateway.
[0261] S408: The forwarding gateway receives the downlink data, and performs time synchronization based on the downlink data and the Class B terminal corresponding to the terminal identifier.
[0262] In some embodiments, the forwarding gateway performs time synchronization with the Class B terminal corresponding to the terminal identifier based on the downlink data, including: based on the downlink data, obtaining the current GPS time corresponding to the first local time of the forwarding gateway and the terminal identifier of the Class B terminal, generating a Beacon message based on the current GPS time corresponding to the first local time, and sending the Beacon message to the Class B terminal corresponding to the terminal identifier; the Beacon message is used to instruct the Class B terminal to perform time synchronization with the forwarding gateway based on the Beacon message.
[0263] In some embodiments, the sending the Beacon message to the Class B terminal corresponding to the terminal identifier includes: sending the Beacon message to the Class B terminal corresponding to the terminal identifier according to a second set period.
[0264] S409: The Class B terminal receives the Beacon message, obtains the GPS time corresponding to the third local time, the third local time and the transmission time of the Beacon message based on the Beacon message, and maintains time synchronization with the forwarding gateway based on the GPS time corresponding to the third local time, the third local time, the fourth local time and the transmission time of the Beacon message.
[0265] It should be noted that the fourth local time is the time when the Class B terminal receives the Beacon message. Since the Class B terminal is a specific form of a communication terminal, the process of the Class B terminal using the Beacon message to synchronize time with the forwarding gateway is similar to the process of the communication terminal using the Beacon message to synchronize time with the forwarding gateway, which can be understood based on the foregoing and will not be repeated here.
[0266] In order to better understand the present invention, an embodiment of the present invention provides an application scenario, such as Figure 5 As shown, the application scenario includes a Class B terminal, an indoor gateway, an outdoor gateway, and a network server. In this application scenario, the specific steps to achieve time synchronization between the Class B terminal and the indoor gateway are as follows:
[0267] Step 1: The Class B terminal sends LoRaWAN uplink data to the indoor gateway according to the LoRaWAN protocol;
[0268] Step 2: The Class B terminal sends LoRaWAN uplink data to the outdoor gateway according to the LoRaWAN protocol.
[0269] It should be noted that since the Class B terminal sends the LoRaWAN uplink data through Lora wireless broadcast, both the indoor gateway and the outdoor gateway within a certain range can receive the LoRaWAN uplink data. Therefore, step 1 and step 2 occur at the same time, and the only difference is that the indoor gateway and the outdoor gateway receive the LoRaWAN uplink data at different times.
[0270] Step 3: The indoor gateway receives the LoRaWAN uplink data, processes the LoRaWAN uplink data, and obtains the first IP uplink data;
[0271] Step 4: The outdoor gateway receives the LoRaWAN uplink data, processes the LoRaWAN uplink data, and obtains second IP uplink data;
[0272] Step 5: The indoor gateway sends the first IP uplink data to the network server and the outdoor gateway sends the second IP uplink data to the network server.
[0273] It should be noted that there is no order between step 3 and step 4, and the processing of these two steps is similar, which has been described in detail in the previous S402 and will not be repeated here. The first IP uplink data and the second IP uplink data are a specific form of the aforementioned IP uplink data, which is only used to illustrate forwarding to the network server through different gateways, and is not used to limit the present invention.
[0274] Step 6: The network server receives the first IP uplink data and the second IP uplink data, and based on the time field of the first IP uplink data, determines that the gateway sending the first IP uplink data is an indoor gateway; sends a time synchronization request to the indoor gateway; the time synchronization request at least includes a first synchronization identifier and a gateway control parameter; based on the time field of the second IP uplink data, determines that the gateway sending the second IP uplink data is an outdoor gateway, obtains the current GPS time corresponding to the first local time of the outdoor gateway and the terminal identifier of the Class B terminal, and sends downlink data including at least the GPS time corresponding to the local time of the outdoor gateway and the terminal identifier of the Class B terminal to the outdoor gateway; the outdoor gateway receives the downlink data, and maintains time synchronization with the Class B terminal based on the downlink data.
[0275] Step 7: The indoor gateway receives the time synchronization request, performs a fifth analysis on the time synchronization request to obtain a fifth analysis result, generates a first time synchronization message based on the first synchronization identifier in the fifth analysis result, and sends the first time synchronization message according to the gateway control parameter in the fifth analysis result;
[0276] Step 8: The outdoor gateway receives the first time synchronization message, processes the first time synchronization message, obtains a second time synchronization message, and sends the second time synchronization message to the network server;
[0277] Step 9: The network server receives the second time synchronization message, obtains the current GPS time corresponding to the first local time of the indoor gateway based on the second time synchronization message, and sends downlink data including at least the current GPS time and the terminal identifier to the indoor gateway. The indoor gateway receives the downlink data and performs time synchronization with the Class B terminal based on the downlink data.
[0278] It should be noted that how to keep time synchronization with the indoor gateway has been described in detail above and will not be repeated here. When the gateway is an outdoor gateway, the way in which the Class B terminal keeps time synchronization with the outdoor gateway has been described in detail above and will not be repeated here.
[0279] Based on the same inventive concept, the embodiment of the present invention also provides a time synchronization device, such as Figure 6 As shown, a time synchronization device is shown, which is applied to a network server. The time synchronization device 60 includes:
[0280] A first receiving unit 601, a first determining unit 602, a first sending unit 603, a second receiving unit 604, a first obtaining unit 605 and a second sending unit 606, wherein:
[0281] The first receiving unit 601 is used to receive Internet Protocol IP uplink data;
[0282] The first determining unit 602 is used to determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data;
[0283] The first sending unit 603 is used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server;
[0284] The second receiving unit 604 is used to receive at least one second time synchronization message;
[0285] The first obtaining unit 605 is used to obtain a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message;
[0286] The second sending unit 606 is used to send downlink data including at least current GPS time and terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0287] In some embodiments, the first determining unit 602 includes: a first parsing subunit, a first obtaining subunit, a first determining subunit, a second parsing subunit, and a second determining subunit, wherein:
[0288] The first parsing subunit is used to perform a first parsing on the IP uplink data according to the IP to obtain a first parsing result;
[0289] The first obtaining subunit is used to obtain the time field included in the long-range radio wide area network LoRaWAN uplink data and the IP uplink data based on the first parsing result;
[0290] The first determining subunit is used to determine the type of the forwarding gateway according to the time field;
[0291] The second parsing subunit is used to perform a second parsing on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second parsing result;
[0292] The second determining subunit is used to determine the terminal identification of the communication terminal based on the second parsing result.
[0293] In some embodiments, the first obtaining unit 605 includes a sorting subunit and a third determining subunit, wherein:
[0294] The sorting subunit is used to sort the at least one second time synchronization message according to a set condition;
[0295] The third determining subunit is used to determine the current GPS time corresponding to the first local time of the forwarding gateway based on the sorting result;
[0296] or,
[0297] The first obtaining unit 605 is specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message; perform a third analysis on the first received second time synchronization message to obtain a third analysis result; based on the third analysis result, obtain the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, obtain the current GPS time corresponding to the first local time of the forwarding gateway.
[0298] In some embodiments, the sorting subunit is specifically used to: sort the at least one second time synchronization message in descending order of the signal strength in each second time synchronization message;
[0299] The third determination subunit is specifically used to: obtain a second time synchronization message corresponding to the signal strength ranked first based on the sorting result; perform a fourth analysis on the second time synchronization message to obtain a fourth analysis result; based on the four analysis results, obtain the GPS time, transmission time and the first local time corresponding to the second local time; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, determine the current GPS time corresponding to the first local time of the forwarding gateway.
[0300] In some embodiments, the first sending unit 603 is specifically used to: send the time synchronization request to the forwarding gateway according to a first set period.
[0301] In some embodiments, the first determination subunit is specifically used to: determine whether the time field is non-zero and non-empty; when it is determined that the time field is non-zero and non-empty, determine that the type of the forwarding gateway is an outdoor gateway; when it is determined that the time field is zero or empty, determine that the type of the forwarding gateway is an indoor gateway.
[0302] In some embodiments, the time synchronization device 60 further includes: a second obtaining unit, configured to obtain, when the forwarding gateway is an outdoor gateway, a current GPS time corresponding to the first local time of the forwarding gateway based on the IP uplink data.
[0303] The time synchronization device for a network server provided by the embodiment of the present invention not only does not increase the topological complexity of LoRaWAN, but also prevents the indoor gateway from being abandoned due to failure to obtain accurate GPS time and unable to perform normal data transmission and reception with the communication terminal, thereby indirectly improving the utilization rate of each gateway in LoRaWAN.
[0304] The embodiment of the present invention also provides another time synchronization device, such as Figure 7 As shown, another time synchronization device is shown, which is applied to an indoor gateway. The time synchronization device 70 includes: a third receiving unit 701, a parsing unit 702, a generating unit 703, a third sending unit 704, a fourth receiving unit 705 and a time synchronization unit 706, wherein,
[0305] The third receiving unit 701 is used to receive a time synchronization request;
[0306] The parsing unit 702 is used to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result;
[0307] The generating unit 703 is configured to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0308] The third sending unit 704 is used to send the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0309] The fourth receiving unit 705 is used to receive downlink data including at least a current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on the received Internet Protocol IP uplink data;
[0310] The time synchronization unit 706 is configured to perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0311] In some embodiments, the time synchronization unit 706 includes: a second obtaining subunit, a generating subunit and a sending subunit, wherein:
[0312] The second obtaining subunit is used to obtain the current GPS time and the terminal identification corresponding to the first local time of the indoor gateway based on the downlink data;
[0313] The generating subunit is configured to generate a beacon message based on the current GPS time corresponding to the first local time;
[0314] The sending subunit is used to send the Beacon message to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0315] In some embodiments, the second obtaining subunit is specifically used to: perform a sixth analysis on the downlink data according to the IP to obtain a sixth analysis result; and obtain a current GPS time corresponding to the first local time of the indoor gateway based on the sixth analysis result.
[0316] In some embodiments, the sending subunit is specifically used to: send the Beacon message to the communication terminal corresponding to the terminal identifier according to a second set period.
[0317] In some embodiments, the generating unit 703 is specifically used to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
[0318] In some embodiments, the gateway control parameter includes at least a message sending period, and correspondingly, the third sending unit 704 is used to send the first synchronization time message according to the message sending period.
[0319] Based on the same concept, the embodiment of the present invention also provides another time synchronization system, such as Figure 8 As shown, the time synchronization system 80 includes: a network server 801, an indoor gateway 802 and at least one outdoor gateway 803, wherein:
[0320] The network server 801 is used to receive Internet Protocol IP uplink data, and determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data; when the type of the forwarding gateway is an indoor gateway, send a time synchronization request to the forwarding gateway; receive at least one second time synchronization message, and obtain the current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message; send downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the second time synchronization message is obtained by the outdoor gateway based on the first time synchronization message, and the first time synchronization message is obtained by the indoor gateway based on the time synchronization request;
[0321] The indoor gateway 802 is used to receive a time synchronization request, perform a fifth analysis on the time synchronization request, and obtain a fifth analysis result; generate the first time synchronization message based on the first synchronization identifier in the fifth analysis result; send the first time synchronization message according to the gateway control parameter in the fifth analysis result; receive downlink data including at least the current GPS time and the terminal identifier; perform time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier;
[0322] Each outdoor gateway in the at least one outdoor gateway 803 is configured to receive the first time synchronization message, obtain a second time synchronization message based on the first time synchronization message, and send the second time synchronization message to the network server.
[0323] In some embodiments, the network server 801 includes: the first receiving component, configured to receive the IP uplink data;
[0324] The first determination component is used to determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data;
[0325] The first sending component is used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server;
[0326] The second receiving component is used to receive at least one second time synchronization message;
[0327] The first obtaining component is used to obtain a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message;
[0328] The second sending component is used to send downlink data including at least current GPS time and terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data.
[0329] In some embodiments, the indoor gateway 802 includes: the third receiving component, configured to receive a time synchronization request;
[0330] The parsing component is used to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result;
[0331] The generating component is used to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result;
[0332] The third sending component is used to send the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server;
[0333] The fourth receiving component is used to receive downlink data including at least current global positioning system GPS time and terminal identification; the current global positioning system GPS time is the GPS time corresponding to the first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identification is determined by the network server based on the received Internet Protocol IP uplink data;
[0334] The time synchronization component is used to perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
[0335] In some embodiments, each of the at least one outdoor gateway 803 includes:
[0336] The fifth receiving component is used to receive the first time synchronization message;
[0337] The third obtaining component is used to obtain a second time synchronization message based on the first time synchronization message;
[0338] The fourth sending component is used to send the second time synchronization message to the network server.
[0339] In some embodiments, the first determination component is specifically used to: perform a first analysis on the IP uplink data according to the IP to obtain a first analysis result; based on the first analysis result, obtain the long-range radio wide area network LoRaWAN uplink data and the time field included in the IP uplink data; determine the type of the forwarding gateway according to the time field; perform a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; and determine the terminal identification of the communication terminal based on the second analysis result.
[0340] In some embodiments, the first acquisition component is specifically used to: sort the at least one second time synchronization message according to set conditions; based on the sorting result, determine the current GPS time corresponding to the first local time of the forwarding gateway, or, specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message; perform a third analysis on the first received second time synchronization message to obtain a third analysis result; based on the third analysis result, obtain the GPS time, transmission time and first local time corresponding to the second local time in the first received second time synchronization message; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, obtain the current GPS time corresponding to the first local time of the forwarding gateway.
[0341] In some embodiments, the time synchronization component is specifically used to: obtain the current GPS time and terminal identification corresponding to the first local time of the forwarding gateway based on the downlink data; generate a beacon Beacon message based on the current GPS time corresponding to the first local time; send the Beacon message to the communication terminal corresponding to the terminal identification; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
[0342] In some embodiments, the generating component is specifically used to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
[0343] In some embodiments, the gateway control parameter includes at least a message sending period, and correspondingly, the third sending unit is used to send the first synchronization time message according to the message sending period.
[0344] In some embodiments, the network server 801 is further configured to obtain, based on the IP uplink data, a current GPS time corresponding to the first local time of the forwarding gateway.
[0345] The time synchronization system applied to the indoor gateway provided by the embodiment of the present invention not only does not increase the topological complexity of LoRaWAN, but also the indoor gateway will not be abandoned due to the inability to obtain accurate GPS time and unable to perform normal data transmission and reception with the communication terminal, thereby indirectly improving the utilization rate of each gateway in LoRaWAN.
[0346] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the above-mentioned method embodiment are implemented. The aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0347] An embodiment of the present invention further provides a time synchronization device, comprising: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor executes the steps of the above method embodiment stored in the memory when running the computer program.
[0348] Fig. 9 This is a schematic diagram of the hardware structure of the time synchronization device of an embodiment of the present invention. The time synchronization device 90 includes: at least one processor 901, a memory 902, and optionally, the time synchronization device 90 may further include at least one communication interface 903. The various components in the time synchronization device 90 are coupled together through a bus system 904. It can be understood that the bus system 904 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Fig. 9 Various buses are labeled as bus system 904.
[0349] It can be understood that the memory 902 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 902 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memories.
[0350] The memory 902 in the embodiment of the present invention is used to store various types of data to support the operation of the time synchronization device 90. Examples of such data include: any computer program used to operate on the time synchronization device 90, such as a network server calculating the current GPS time corresponding to the first local time, etc. The program for implementing the method of the embodiment of the present invention may be included in the memory 902.
[0351] The method disclosed in the above embodiment of the present invention can be applied to the processor 901, or implemented by the processor 901. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0352] In an exemplary embodiment, the time synchronization device 90 can be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the above method.
[0353] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms. The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, the functional units in the embodiments of the present invention may be all integrated in one processing unit, or each unit may be a separate unit, or two or more units may be integrated in one unit; the above integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0354] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A time synchronization method, characterized in that: Applied to a network server, the method comprises: Receiving Internet Protocol (IP) uplink data; determining the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data; When the type of the forwarding gateway is an indoor gateway, sending a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server; receiving at least one of the second time synchronization messages, and obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway; Sending downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data; Wherein, determining the type of the forwarding gateway and the terminal identifier of the communication terminal based on the IP uplink data includes: Performing a first analysis on the IP uplink data according to the IP address to obtain a first analysis result; Based on the first parsing result, obtaining the time field included in the long-distance radio wide area network LoRaWAN uplink data and the IP uplink data; Determining the type of the forwarding gateway according to the time field; Performing a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; and determining a terminal identification of the communication terminal based on the second analysis result; The obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway includes: Sorting the at least one second time synchronization message according to a set condition; Based on the sorting result, determining a current GPS time corresponding to a first local time of the forwarding gateway; or, The obtaining, based on the at least one second time synchronization message, a current global positioning system GPS time corresponding to the first local time of the forwarding gateway comprises: Based on the at least one second time synchronization message, determining a first received second time synchronization message; Performing a third analysis on the first received second time synchronization message to obtain a third analysis result; Based on the third analysis result, the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message are obtained; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is obtained.
2. The method according to claim 1, characterized in that The sorting of the at least one second time synchronization message according to the set condition includes: Sorting the at least one second time synchronization message in descending order of signal strength in each second time synchronization message; Correspondingly, determining the current GPS time corresponding to the first local time of the forwarding gateway based on the sorting result includes: Based on the sorting result, obtain a second time synchronization message corresponding to the signal strength ranked first; Performing a fourth analysis on the second time synchronization message to obtain a fourth analysis result; Based on the four analysis results, the GPS time, transmission time and the first local time corresponding to the second local time are obtained; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is determined.
3. The method according to claim 1, characterized in that The sending a time synchronization request to the forwarding gateway includes: The time synchronization request is sent to the forwarding gateway according to a first set period.
4. The method according to claim 1, characterized in that: Determining the type of the forwarding gateway according to the time field includes: Determine whether the time field is non-zero and non-empty; When it is determined that the time field is non-zero and non-empty, determining that the type of the forwarding gateway is an outdoor gateway; When it is determined that the time field is zero or empty, it is determined that the type of the forwarding gateway is an indoor gateway.
5. The method according to claim 1, characterized in that The method further comprises: When the forwarding gateway is an outdoor gateway, the current GPS time corresponding to the first local time of the forwarding gateway is obtained based on the IP uplink data.
6. A time synchronization method, characterized in that: Applied to an indoor gateway, the method includes: receiving a time synchronization request, performing a fifth analysis on the time synchronization request, and obtaining a fifth analysis result; Generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result; Sending the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server; Receive downlink data including at least current global positioning system GPS time and terminal identification; the current global positioning system GPS time is the GPS time corresponding to the first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identification is determined by the network server based on the received Internet Protocol IP uplink data; Performing time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier; The performing time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier includes: Based on the downlink data, obtain the current GPS time and terminal identification corresponding to the first local time of the indoor gateway; Generate a beacon message based on the current GPS time corresponding to the first local time; The Beacon message is sent to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
7. The method according to claim 6, characterized in that The obtaining, based on the downlink data, a current GPS time corresponding to the first local time of the indoor gateway includes: Performing a sixth analysis on the downlink data according to the IP address to obtain a sixth analysis result; Based on the sixth parsing result, a current GPS time corresponding to the first local time of the indoor gateway is obtained.
8. The method according to claim 6, characterized in that The sending the Beacon message to the communication terminal corresponding to the terminal identifier includes: The Beacon message is sent to the communication terminal corresponding to the terminal identifier according to a second set period.
9. The method according to claim 6, characterized in that The generating a first time synchronization message based on the first synchronization identifier in the fifth parsing result includes: Based on the fifth parsing result, obtaining a first synchronization identifier; Based on the first synchronization identifier, a first time synchronization message is encapsulated according to the LoRaWAN protocol.
10. The method according to claim 6, characterized in that The gateway control parameters at least include a message sending period. Correspondingly, sending the first time synchronization message according to the gateway control parameters in the fifth analysis result includes: sending the first time synchronization message according to the message sending period.
11. A time synchronization device, characterized in that: Applied to a network server, the device comprises: a first receiving unit, a first determining unit, a first sending unit, a second receiving unit, a first obtaining unit and a second sending unit, wherein: The first receiving unit is used to receive Internet Protocol IP uplink data; The first determining unit is used to determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data; The first sending unit is used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server; The second receiving unit is used to receive at least one second time synchronization message; The first obtaining unit is used to obtain a current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message; The second sending unit is used to send downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data; The first determination unit includes: a first parsing subunit, a first obtaining subunit, a first determination subunit, a second parsing subunit and a second determination subunit, wherein: The first parsing subunit is used to perform a first parsing on the IP uplink data according to the IP to obtain a first parsing result; The first obtaining subunit is used to obtain the time field included in the long-range radio wide area network LoRaWAN uplink data and the IP uplink data based on the first parsing result; The first determining subunit is used to determine the type of the forwarding gateway according to the time field; The second parsing subunit is used to perform a second parsing on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second parsing result; The second determining subunit is used to determine the terminal identification of the communication terminal based on the second parsing result; The first obtaining unit includes a sorting subunit and a third determining subunit, wherein: The sorting subunit is used to sort the at least one second time synchronization message according to a set condition; The third determining subunit is used to determine the current GPS time corresponding to the first local time of the forwarding gateway based on the sorting result; or, The first obtaining unit is specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message; perform a fourth analysis on the first received second time synchronization message to obtain a third analysis result; based on the third analysis result, obtain the GPS time, transmission time and the first local time corresponding to the second local time in the first received second time synchronization message; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, obtain the current GPS time corresponding to the first local time of the forwarding gateway.
12. The device according to claim 11, characterized in that The sorting subunit is specifically used to: sort the at least one second time synchronization message in descending order of the signal strength in each second time synchronization message; The third determining subunit is specifically used to: obtain, based on the sorting result, a second time synchronization message corresponding to the signal strength ranked first; Perform a fourth analysis on the second time synchronization message to obtain a fourth analysis result; based on the fourth analysis result, obtain the GPS time, transmission time and the first local time corresponding to the second local time; The transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; Based on the GPS time, the transmission time and the first local time, a current GPS time corresponding to the first local time of the forwarding gateway is determined.
13. The device according to claim 11, characterized in that The first sending unit is specifically configured to send the time synchronization request to the forwarding gateway according to a first set period.
14. The device according to claim 11, characterized in that The first determination subunit is specifically used to: determine whether the time field is non-zero and non-empty; when it is determined that the time field is non-zero and non-empty, determine that the type of the forwarding gateway is an outdoor gateway; when it is determined that the time field is zero or empty, determine that the type of the forwarding gateway is an indoor gateway.
15. The device according to claim 11, characterized in that The device further includes: a second obtaining unit, configured to obtain, when the forwarding gateway is an outdoor gateway, a current GPS time corresponding to a first local time of the forwarding gateway based on the IP uplink data.
16. A time synchronization device, characterized in that: Applied to an indoor gateway, the device comprises: a third receiving unit, a parsing unit, a generating unit, a third sending unit, a fourth receiving unit and a time synchronization unit, wherein: The third receiving unit is used to receive a time synchronization request; The parsing unit is used to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result; The generating unit is configured to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result; The third sending unit is used to send the first time synchronization message according to the gateway control parameter in the fifth analysis result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server; The fourth receiving unit is used to receive downlink data including at least a current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by the network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on the received Internet Protocol IP uplink data; The time synchronization unit is used to perform time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier; The time synchronization unit includes: a second obtaining subunit, a generating subunit and a sending subunit, wherein: The second obtaining subunit is used to obtain the current GPS time and the terminal identification corresponding to the first local time of the indoor gateway based on the downlink data; The generating subunit is configured to generate a beacon message based on the current GPS time corresponding to the first local time; The sending subunit is used to send the Beacon message to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
17. The device according to claim 16, characterized in that The second obtaining subunit is specifically used to: perform a sixth analysis on the downlink data according to the IP to obtain a sixth analysis result; and obtain a current GPS time corresponding to the first local time of the indoor gateway based on the sixth analysis result.
18. The device according to claim 16, characterized in that The sending subunit is specifically used to: send the Beacon message to the communication terminal corresponding to the terminal identifier according to a second set period.
19. The device according to claim 16, characterized in that: The generating unit is specifically configured to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
20. The device according to claim 16, characterized in that The gateway control parameter at least includes a message sending period, and correspondingly, the third sending unit is used to send the first time synchronization message according to the message sending period.
21. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 or 6 to 10 are implemented.
22. A time synchronization device, characterized in that: The time synchronization device comprises: a processor and a memory for storing a computer program that can be run on the processor, wherein the processor executes the steps of the method according to any one of claims 1 to 5 or 6 to 10 when running the computer program.
23. A time synchronization system, characterized in that: The system comprises: a network server, an indoor gateway and at least one outdoor gateway, wherein: The network server is used to receive Internet Protocol IP uplink data, and determine the type of the forwarding gateway and the terminal identification of the communication terminal based on the IP uplink data; when the type of the forwarding gateway is an indoor gateway, send a time synchronization request to the forwarding gateway; receive at least one second time synchronization message, and obtain the current global positioning system GPS time corresponding to the first local time of the forwarding gateway based on the at least one second time synchronization message; send downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the second time synchronization message is obtained by the outdoor gateway based on the first time synchronization message, and the first time synchronization message is obtained by the indoor gateway based on the time synchronization request; The indoor gateway is used to receive a time synchronization request, perform a fifth analysis on the time synchronization request, and obtain a fifth analysis result; generate the first time synchronization message based on the first synchronization identifier in the fifth analysis result; send the first time synchronization message according to the gateway control parameter in the fifth analysis result; receive downlink data including at least the current GPS time and the terminal identifier; perform time synchronization based on the downlink data and the communication terminal corresponding to the terminal identifier; Each of the at least one outdoor gateway is configured to receive the first time synchronization message, obtain a second time synchronization message based on the first time synchronization message, and send the second time synchronization message to the network server; Wherein, the network server comprises: A first receiving component, configured to receive the IP uplink data; A first determination component, configured to determine a type of a forwarding gateway and a terminal identifier of a communication terminal based on the IP uplink data; A first sending component, used to send a time synchronization request to the forwarding gateway; the time synchronization request is used to instruct the forwarding gateway to send a first time synchronization message to the outdoor gateway; the first time synchronization message is used to instruct the outdoor gateway to send a second time synchronization message to the network server; A second receiving component, configured to receive at least one of the second time synchronization messages; A first obtaining component, configured to obtain a current global positioning system GPS time corresponding to a first local time of the forwarding gateway based on the at least one second time synchronization message; A second sending component is used to send downlink data including at least the current GPS time and the terminal identification to the forwarding gateway; the downlink data is used to instruct the forwarding gateway to perform time synchronization with the communication terminal based on the downlink data; The first determination component is specifically used to: perform a first analysis on the IP uplink data according to the IP to obtain a first analysis result; based on the first analysis result, obtain the long-range radio wide area network LoRaWAN uplink data and the time field included in the IP uplink data; determine the type of the forwarding gateway according to the time field; perform a second analysis on the LoRaWAN uplink data according to the LoRaWAN protocol to obtain a second analysis result; and determine the terminal identification of the communication terminal based on the second analysis result; The first acquisition component is specifically used to: sort the at least one second time synchronization message according to the set conditions; based on the sorting result, determine the current GPS time corresponding to the first local time of the forwarding gateway, or, specifically used to: determine the first received second time synchronization message based on the at least one second time synchronization message; perform a third analysis on the first received second time synchronization message to obtain a third analysis result; based on the third analysis result, obtain the GPS time, transmission time and first local time corresponding to the second local time in the first received second time synchronization message; the transmission time is the time required for the first time synchronization message to travel from the forwarding gateway to the outdoor gateway; based on the GPS time, the transmission time and the first local time, obtain the current GPS time corresponding to the first local time of the forwarding gateway.
24. The system according to claim 23, characterized in that The indoor gateway comprises: A third receiving component, configured to receive a time synchronization request; A parsing component, configured to perform a fifth parsing on the time synchronization request to obtain a fifth parsing result; A generating component, configured to generate a first time synchronization message based on the first synchronization identifier in the fifth parsing result; A third sending component, configured to send the first time synchronization message according to the gateway control parameter in the fifth parsing result; the first time synchronization message is used to instruct at least one outdoor gateway to send a second time synchronization message to the network server; a fourth receiving component, configured to receive downlink data including at least a current global positioning system GPS time and a terminal identifier; the current global positioning system GPS time is a GPS time corresponding to a first local time of the indoor gateway obtained by a network server based on at least one of the second time synchronization messages; the terminal identifier is determined by the network server based on received Internet Protocol IP uplink data; A time synchronization component is used to perform time synchronization on the communication terminal corresponding to the terminal identifier based on the downlink data.
25. The system according to claim 23, characterized in that Each of the at least one outdoor gateway comprises: A fifth receiving component, configured to receive the first time synchronization message; A third obtaining component, configured to obtain a second time synchronization message based on the first time synchronization message; A fourth sending component is used to send the second time synchronization message to the network server.
26. The system according to claim 24, characterized in that The time synchronization component is specifically used to: obtain the current GPS time and terminal identification corresponding to the first local time of the indoor gateway based on the downlink data; generate a beacon Beacon message based on the current GPS time corresponding to the first local time; The Beacon message is sent to the communication terminal corresponding to the terminal identifier; the Beacon message is used to instruct the communication terminal to perform time synchronization with the indoor gateway based on the Beacon message.
27. The system according to claim 26, characterized in that The generating component is specifically used to: obtain a first synchronization identifier based on the fifth parsing result; and encapsulate a first time synchronization message according to the LoRaWAN protocol based on the first synchronization identifier.
28. The system according to claim 26, characterized in that The gateway control parameter at least includes a message sending period, and correspondingly, the third sending component is used to send the first time synchronization message according to the message sending period.
29. The system according to claim 23, characterized in that The network server is further configured to obtain, based on the IP uplink data, a current GPS time corresponding to the first local time of the forwarding gateway.
Citation Information
Patent Citations
Time synchronization system
CN211239861U