Time synchronization method and network system
By obtaining the transmission and dwell time of Bluetooth broadcasts between nodes' Bluetooth protocol stacks and generating response times, the problem of poor time synchronization accuracy of Bluetooth broadcasts is solved, and high-precision time synchronization is achieved.
Patent Information
- Application Number
- CN202410955871.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2026-01-20
AI Technical Summary
In existing technologies, when Bluetooth broadcasting is used for time synchronization, there is an error of tens of milliseconds, resulting in poor time synchronization accuracy between recording devices.
By obtaining the transmission time and dwell time of Bluetooth broadcasts between the Bluetooth protocol stacks of the nodes, a response time is generated, and time synchronization is performed based on this response time to reduce errors.
It significantly reduces time synchronization errors between nodes, improves the accuracy of time synchronization, and reduces the error to tens of microseconds.
Smart Images

Figure CN121367559A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of time synchronization, in particular to a time synchronization method and a network system. BACKGROUND
[0002] In the related art, in the process of time synchronization among multiple recording devices, Bluetooth broadcast is usually used for time synchronization. However, there is a tens of milliseconds error between the actual time sent by the recording device and the time sent by the application layer, which finally leads to a large error in time synchronization of the recording device. SUMMARY
[0003] In view of the deficiencies in the prior art, the present application provides a time synchronization method and a network system, aiming at solving the technical problem of poor accuracy of time synchronization by using Bluetooth broadcast in the prior art.
[0004] To solve the above problems, in a first aspect, the present application provides a time synchronization method applied to a first node, the method comprising:
[0005] responding to a preset Bluetooth broadcast of a second node; wherein Bluetooth broadcast communication is used between the first node and the second node;
[0006] obtaining a first transmission time between a Bluetooth protocol stack of the first node and a Bluetooth protocol stack of the second node, and obtaining a first residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node or / and a second residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node;
[0007] generating a response time for responding to the Bluetooth broadcast based on the first residence time or / and the second residence time according to the first transmission time;
[0008] performing time synchronization with the second node according to the response time.
[0009] Further, in the time synchronization method, the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node is obtained, and the first residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node or / and the second residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node is obtained, comprising:
[0010] obtaining the second residence time and the first transmission time according to the broadcast packet of the Bluetooth broadcast.
[0011] Still further, in the time synchronization method, the second residence time and the first transmission time are obtained according to the broadcast packet of the Bluetooth broadcast, comprising:
[0012] parsing the broadcast packet to obtain a first timestamp of an application layer request of the second node to the Bluetooth protocol stack broadcast of the second node, a second timestamp of the Bluetooth protocol stack broadcast of the second node, and the first transmission time;
[0013] generating the first residence time according to the first timestamp and the second timestamp.
[0014] Further, in the time synchronization method, the obtaining of the first residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node and / or the second residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node comprises:
[0015] obtaining the first residence time according to the time axis of the first node.
[0016] Further, in the time synchronization method, the obtaining of the first residence time according to the time axis of the first node comprises:
[0017] parsing the broadcast packet of the Bluetooth broadcast to obtain a third timestamp of the Bluetooth protocol stack of the first node sending the broadcast packet to the application layer of the first node;
[0018] obtaining a fourth timestamp of the application layer of the first node receiving the broadcast packet from the time axis of the first node;
[0019] generating the first residence time according to the third timestamp and the fourth timestamp.
[0020] Further, in the time synchronization method, the time synchronization with the second node according to the response time comprises:
[0021] obtaining a standard time of the second node requesting the Bluetooth broadcast to the first node;
[0022] time synchronizing with the second node according to the standard time and the response time.
[0023] Further, in the time synchronization method, the obtaining of the standard time of the second node requesting the Bluetooth broadcast to the first node comprises:
[0024] parsing the broadcast packet of the Bluetooth broadcast to obtain the standard time of the second node requesting the Bluetooth broadcast to the first node.
[0025] In a second aspect, the application further provides a network system comprising at least a first node and a second node for Bluetooth broadcast communication, and the first node is configured to execute the time synchronization method of the first aspect.
[0026] Further, in the network system, the second node is configured to execute a time generation method, the time generation method comprising the steps of:
[0027] generating a broadcast packet of a Bluetooth broadcast in response to an application layer of the second node;
[0028] determining a Bluetooth broadcast mode between the first node and the second node and a bit number of the broadcast packet;
[0029] generating a first transmission time between a Bluetooth protocol stack of the first node and a Bluetooth protocol stack of the second node according to the Bluetooth broadcast mode and the bit number.
[0030] Further, in the network system, the generating the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node according to the Bluetooth broadcast mode and the bit number comprises:
[0031] determining a second transmission time of each bit data of the broadcast packet according to the Bluetooth broadcast mode;
[0032] generating the first transmission time according to the bit number and the second transmission time.
[0033] The time synchronization method provided by the embodiments of the present application can generate a response time of an application layer of a first node in response to a Bluetooth broadcast sent by an application layer of a second node by obtaining a first transmission time between a Bluetooth protocol stack of the two nodes, a first residence time on the Bluetooth protocol stack of the first node or / and a second residence time on the Bluetooth protocol stack of the second node when the second node uses the Bluetooth broadcast to synchronize the time of the first node, so that the time synchronization of the first node and the second node can be realized through the response time, and the technical problem of poor accuracy of time synchronization using the Bluetooth broadcast is solved, and the time synchronization error between the nodes is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0035] Figure 1 a framework diagram of the network system provided by the embodiments of the present application;
[0036] Figure 2 A flowchart of a time synchronization method provided by an embodiment of the present application is shown in FIG. 1.
[0037] Figure 3 A flowchart of a time generation method provided by an embodiment of the present application is shown in FIG. 2. DETAILED DESCRIPTION
[0038] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort belong to the scope of protection of the present application.
[0039] It should be understood that, when used in the specification and the appended claims, the terms "comprise" and "include" indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0040] It should also be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and the appended claims of the present application, the singular forms "a", "an" and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0041] It should be further understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0042] Embodiments of the present application provide a time synchronization method and a network system.
[0043] For ease of understanding, the network system is first introduced, and the time synchronization method is described in detail based on the system.
[0044] Please refer to Figure 1 , Figure 1 A framework diagram of the network system provided by an embodiment of the present application is shown in FIG. 3. The network system includes a first node A and a second node B, and the first node A and the second node B communicate with each other by using Bluetooth broadcast. The first node A and the second node B each can correspond to a device with a time code generator. The device can have the function of generating a time code and synchronizing its own time code to other devices in the network system. Meanwhile, the software application layers in the device can communicate with each other by using Bluetooth broadcast.
[0045] It is understood that the network system provided in this application includes not only the first node A and the second node B, but also other nodes. When time synchronization of the network system is required, one of the nodes can broadcast via Bluetooth to other nodes in the network system to achieve time synchronization of all nodes in the network system. Furthermore, the first node A and the second node B can be the same node, and both nodes can perform the same function.
[0046] It should be noted that the first node and the second node mentioned in this application can be devices such as recorders, microphones, cameras, and video cameras that contain timecoders, and the timecoders also have Bluetooth functionality. In other words, as long as a device has both Bluetooth functionality and a timecoder, it can serve as a node in the network system.
[0047] It should also be noted that the application scenarios described in the following embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0048] The time synchronization method described below will be explained in detail.
[0049] like Figure 2 As shown, the method includes the following steps S210 to S240.
[0050] S210, responding to a preset Bluetooth broadcast from a second node; wherein the first node and the second node communicate via Bluetooth broadcast.
[0051] In this embodiment, the time synchronization method is applied to the first node of the network system. The network system includes at least the first node and the second node. Both the first node and the second node are equipped with Bluetooth protocol stacks, namely the first Bluetooth protocol stack and the second Bluetooth protocol stack. Both the first Bluetooth protocol stack and the second Bluetooth protocol stack can be BLE (Bluetooth Low Energy) protocol. Both the first Bluetooth protocol stack and the second Bluetooth protocol stack include an application layer, a host layer and a controller layer.
[0052] Specifically, when it is necessary to synchronize the time between the first node and the second node, the second node can send a Bluetooth broadcast to the first node. After receiving the Bluetooth broadcast sent by the second node, the application layer of the first node can respond to the Bluetooth broadcast sent by the second node.
[0053] S220, acquire the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node, and acquire the first residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node or / and the second residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node.
[0054] Specifically, when the second node performs time synchronization with the first node by using the Bluetooth broadcast, the Bluetooth broadcast will reside on the Bluetooth protocol stack for a period of time, and this residence time will cause an error of tens of milliseconds when the two nodes in the network system perform time synchronization, thereby leading to poor accuracy of time synchronization between the nodes in the network system.
[0055] Therefore, when the second node performs Bluetooth broadcast to the first node, the first residence time, the second residence time of the broadcast packet on the respective corresponding nodes, and the first transmission time between the two nodes of the Bluetooth protocol stack can be acquired, and then the first residence time, the second residence time, and the first transmission time can be compensated, so as to avoid a large time synchronization error, and greatly improve the accuracy of time synchronization.
[0056] The broadcast packet is a protocol data unit in a broadcast message when the second node performs Bluetooth broadcast to the first node, the broadcast message includes preamble data, access address, protocol data unit (PDU), and check data, and the broadcast packet includes broadcast header, broadcast length, and broadcast data.
[0057] It can be understood that the above is only time synchronization during Bluetooth broadcast of the second node to the first node, and the application can also perform time synchronization during Bluetooth broadcast of the first node to the second node.
[0058] In some embodiments, step S220 includes the step of acquiring the second residence time and the first transmission time according to the broadcast packet.
[0059] In this embodiment, during the process of Bluetooth broadcast of the second node to the first node, the time of the broadcast packet residing on the Bluetooth protocol stack of the second node, i.e. the second residence time, is written into the broadcast packet, and then when the broadcast packet is transmitted to the Bluetooth protocol stack of the first node, the transmission time between the two Bluetooth protocol stacks, i.e. the first transmission time, is written into the broadcast packet, so that after the broadcast packet is received by the application layer of the first node, the second residence time and the first transmission time can be acquired from the broadcast packet.
[0060] In some embodiments, the first residence time and the first transmission time are obtained according to the broadcast packet, including the following steps: parsing the broadcast packet to obtain a first timestamp of a request of an application layer of the second node to the Bluetooth protocol stack of the second node to broadcast, a second timestamp of the Bluetooth protocol stack of the second node to broadcast, and the first transmission time; and generating a second residence time according to the first timestamp and the second timestamp.
[0061] Specifically, the application layer of the second node is a software application layer of the second node, which can communicate with the outside world through the Bluetooth protocol stack of the second node. That is, the application layer of the second node mentioned in the present application is not the application layer in the Bluetooth protocol stack of the second node.
[0062] In the present embodiment, the first timestamp is used to represent the time when the application layer of the second node requests the Bluetooth protocol stack of the second node to broadcast to the first node, and the second timestamp is used to represent the time when the Bluetooth protocol stack of the second node sends the broadcast packet to the Bluetooth protocol stack of the first node. When the second node broadcasts to the first node, the application layer of the second node will request the Bluetooth protocol stack of the second node to broadcast to the first node, at this time the first timestamp in the time axis of the application layer of the second node can be written into the broadcast packet, and at the same time when the Bluetooth protocol stack of the second node sends the broadcast packet to the Bluetooth protocol stack of the first node, that is, at the time when the second node actually sends the broadcast packet to the outside world, the second timestamp in the time axis of the application layer of the second node can be written into the broadcast packet and transmitted to the Bluetooth protocol stack of the first node together with the broadcast packet. After the Bluetooth protocol stack of the first node receives the broadcast packet, it needs to send the broadcast packet to the application layer of the first node, at this time the third timestamp in the time axis of the application layer of the first node is also written into the broadcast packet and transmitted to the application layer of the first node together with the broadcast packet. The application layer of the first node can obtain the fourth timestamp at the time when it receives the broadcast packet sent by the Bluetooth protocol stack of the first node, and then it can parse the broadcast packet to obtain the first timestamp, the second timestamp and the third timestamp from the broadcast packet.
[0063] Further, the second residence time of the broadcast packet in the Bluetooth protocol stack of the second node can be generated by the time difference between the first timestamp and the second timestamp, and the first transmission time can be generated by the time difference between the second timestamp and the third timestamp. At the same time, the first residence time of the broadcast packet in the Bluetooth protocol stack of the first node can be generated by the third timestamp and the fourth timestamp, which can be obtained from the time axis of the application layer of the first node at the time when the application layer of the first node receives the broadcast packet sent by the Bluetooth protocol stack of the first node. The calculation formula of the second residence time can be:
[0064] Ts=T2-T1
[0065] wherein Ts is the second residence time, T1 is the first timestamp, and T2 is the second timestamp.
[0066] In some embodiments, step S220 further comprises the step of: obtaining the second residence time according to the timeline of the second node.
[0067] In this embodiment, when obtaining the first residence time of the broadcast packet in the Bluetooth protocol stack of the first node, the third timestamp of the Bluetooth protocol stack of the first node responding to the Bluetooth broadcast and the fourth timestamp of the application layer of the first node responding to the Bluetooth broadcast can be obtained respectively through the timeline of the first node, and then the first residence time of the broadcast packet in the Bluetooth protocol stack of the first node can be generated through the third timestamp and the fourth timestamp.
[0068] The calculation formula of the first residence time can be:
[0069] Tr=T4-T3
[0070] wherein Tr is the first residence time, T3 is the third timestamp, and T4 is the fourth timestamp.
[0071] In some embodiments, obtaining the first residence time according to the timeline of the first node comprises the following steps: parsing the broadcast packet to obtain the third timestamp of the Bluetooth protocol stack of the first node sending the broadcast packet to the application layer of the first node; obtaining the fourth timestamp of the application layer of the first node receiving the broadcast packet from the timeline of the first node; and generating the first residence time according to the third timestamp and the fourth timestamp.
[0072] In this embodiment, the third timestamp is used to represent the time when the Bluetooth protocol stack of the first node transmits the broadcast packet sent by the Bluetooth protocol stack of the second node to the application layer of the first node, and the fourth timestamp is used to represent the time when the application layer of the first node receives the broadcast packet. The third timestamp can be written into the broadcast packet before the Bluetooth protocol stack of the first node transmits the broadcast packet sent by the Bluetooth protocol stack of the second node to the application of the first node, and then can be transmitted to the application layer of the first node together with the broadcast packet. After receiving the broadcast packet, the application layer of the first node can obtain the third timestamp from the broadcast packet, and obtain the fourth timestamp from the timeline of the application layer of the first node, and then can generate the first residence time of the broadcast packet in the Bluetooth protocol stack of the first node through the third timestamp and the fourth timestamp.
[0073] Similarly, the application layer of the first node is the software application layer of the first node, which can communicate with the outside world through the Bluetooth protocol stack of the first node. That is, the application layer of the first node mentioned in the present application is not the application layer in the Bluetooth protocol stack of the first node.
[0074] It should be noted that the time between the first node's Bluetooth protocol stack receiving the broadcast packet sent by the second node and the first node's Bluetooth protocol stack sending the broadcast packet to the first node's application layer can be negligible, so the third time stamp can also be understood as the time when the first node's Bluetooth protocol stack receives the broadcast packet sent by the second node.
[0075] S230, based on the first transmission time, generating a response time of the response Bluetooth broadcast according to the first residence time or / and the second residence time.
[0076] Specifically, the response time is the time when the application layer of the second node requests the Bluetooth broadcast to the application layer of the first node to receive the Bluetooth broadcast, which can be obtained by accumulating and superimposing the first transmission time and one or more of the first residence time and the second residence time. The first transmission time, the first residence time and the second residence time are preferably accumulated and superimposed to obtain the response time.
[0077] In this embodiment, the calculation formula of the response time can be:
[0078] Td=Ts+Tf+Tr
[0079] Wherein, Td is the response time, Ts is the second residence time, Tr is the first residence time, and Tf is the first transmission time.
[0080] S240, according to the response time, time synchronization is performed with the second node.
[0081] Specifically, after obtaining the first residence time, the second residence time and the first transmission time, the first residence time, the second residence time and the first transmission time can be accumulated and superimposed to obtain the response time, and finally the response time can be compensated for the time code of the first node, so that the time synchronization between the first node and the second node can be completed.
[0082] In some embodiments, step S240 includes the following steps: obtaining a standard time when the second node requests to perform Bluetooth broadcast to the first node; and according to the standard time and the response time, time synchronization is performed with the second node.
[0083] In the embodiment, the standard time is the time when the second node requests the first node to broadcast via Bluetooth, and the standard time can be Universal Time Coordinated (UTC). Specifically, after the response time and the standard time are obtained, the time code of the first node can be updated according to the response time and the standard time, so as to realize the time synchronization between the first node and the second node, and the time synchronization error between the first node and the second node can be reduced by 1000 times, or even reduced to tens of microseconds.
[0084] It can be understood that, in the process of updating the time code of the first node by using the response time and the standard time, the standard time of the first node can be updated according to the standard time, and then the time code of the first node is updated again by using the response time, so as to realize the time synchronization between the first node and the second node.
[0085] In other embodiments, the standard time when the second node requests the first node to broadcast via Bluetooth is obtained, including the following steps: the broadcast packet is parsed to obtain the standard time when the second node requests the first node to broadcast via Bluetooth.
[0086] Specifically, in order to obtain the standard time more quickly, when the second node requests the first node to broadcast via Bluetooth, the standard time of the second node can be written into the broadcast packet, so that the standard time can be broadcast to the application layer of the first node along with the broadcast packet, so that when the first node is time-synchronized, the broadcast packet in the application layer of the first node can be parsed to obtain the standard time of the second node, and the time synchronization between the first node and the second node can be realized quickly.
[0087] In the time synchronization method provided in the embodiment, when the second node time-synchronizes the first node by using Bluetooth broadcast, the first transmission time between the Bluetooth protocol stacks of the two nodes, the first residence time on the Bluetooth protocol stack of the first node, or / and the second residence time on the Bluetooth protocol stack of the second node are obtained, and then the response time of the application layer of the first node responding to the Bluetooth broadcast sent by the application layer of the second node is generated, so as to realize the time synchronization between the first node and the second node by using the response time, and the technical problem that the accuracy of time synchronization by using Bluetooth broadcast is poor is solved, and the time synchronization error between nodes is reduced.
[0088] In some embodiments, as shown in Figure 3 The application further provides a time generation method, which is applied to a second node of a network system, and the method includes steps S310, S320 and S330.
[0089] S310, in response to the broadcast packet of the Bluetooth broadcast generated by the application layer of the second node; wherein the Bluetooth broadcast communication is used between the first node and the second node;
[0090] S320, determining the Bluetooth broadcast mode between the first node and the second node and the bit number of the broadcast packet.
[0091] S330, generating the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node according to the Bluetooth broadcast mode and the bit number.
[0092] In the embodiment, the Bluetooth protocol stack of the second node can also directly determine the first transmission time of the broadcast packet between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node according to the bit number of the broadcast packet and the Bluetooth broadcast mode between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node before the broadcast packet is sent to the Bluetooth protocol stack of the first node, and then the first transmission time can be directly written into the broadcast packet when the Bluetooth protocol stack of the second node sends the broadcast packet to the Bluetooth protocol stack of the first node, so that the first transmission time can be directly parsed from the broadcast packet when the time synchronization of the first node is performed.
[0093] Specifically, when the second node performs the Bluetooth broadcast to the first node, the second node first generates the broadcast packet of the Bluetooth broadcast at the application layer of the second node, and after the Bluetooth broadcast packet is generated by the application layer of the second node, the second node can determine the Bluetooth broadcast mode between the first node and the second node and the bit number of the broadcast packet, and then the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node can be generated according to the Bluetooth broadcast mode and the bit number.
[0094] In some embodiments, the step S330 includes the following steps: determining the second transmission time of each bit data of the broadcast packet according to the Bluetooth broadcast mode; and generating the first transmission time according to the bit number and the second transmission time.
[0095] Specifically, the time for each bit of data in the broadcast packet to be transmitted between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node is determined by the Bluetooth broadcast mode between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node. Therefore, when determining the first transmission time, the Bluetooth broadcast mode between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node needs to be determined in advance, and then the transmission time of each bit of data in the broadcast packet, i.e., the second transmission time, is determined according to the Bluetooth broadcast mode. Then, the first transmission time of the broadcast packet between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node can be generated according to the number of bits and the second transmission time. The second transmission time is the time for 1 bit of data to be transmitted between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node under different Bluetooth broadcast modes. For example, when the Bluetooth broadcast mode is PHY 1M mode, if the time for 1 bit of data to be transmitted between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node is 1 us, the second transmission time can be 1 us. At the same time, since the speed of electromagnetic waves in the air is the speed of light, the time for electromagnetic waves to fly in the air can be ignored.
[0096] In this embodiment, the calculation formula for generating the first transmission time can be:
[0097] Tf=N*1us
[0098] Wherein, Tf is the first transmission time, and N is the number of bits of the broadcast packet.
[0099] It should be noted that when calculating the first transmission time, the number of bits before the first timestamp is written into the broadcast packet can be used for calculation, or the number of bits before the second timestamp is written into the broadcast packet can be used for calculation, or the number of bits before the third timestamp is written into the broadcast packet can be used for calculation. In order to more accurately calculate the first transmission time, the number of bits before the third timestamp is written into the broadcast packet is preferred.
[0100] In some embodiments, the present application provides a network system, the network system comprising a first node and a second node, the first node and the second node communicate by Bluetooth broadcast, the first node is used to execute a time synchronization method, specifically comprising: the first node responds to the Bluetooth broadcast of the second node; the first node acquires the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node, and acquires the first residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node or / and the second residence time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node; the first node generates a response time of responding to the Bluetooth broadcast based on the first transmission time according to the first residence time or / and the second residence time; the first node performs time synchronization with the second node according to the response time.
[0101] In some embodiments, the application provides a network system, the network system comprising a first node and a second node, the first node and the second node communicate by Bluetooth broadcast, the second node is configured to perform the time generation method in any of the above embodiments. For example: the second node generates a broadcast packet of the Bluetooth broadcast in response to an application layer of the second node; the second node determines a Bluetooth broadcast mode between the first node and the second node and a bit number of the broadcast packet; the second node generates a first transmission time between a Bluetooth protocol stack of the first node and a Bluetooth protocol stack of the second node according to the Bluetooth broadcast mode and the bit number.
[0102] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the detailed description of other embodiments above, which will not be repeated here.
[0103] In the implementation, each unit or structure above can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each unit or structure can refer to the method embodiments above, which will not be repeated here.
[0104] The time code synchronization method and the network system provided by the embodiments of the application are described in detail above, the principle and the embodiments of the application are described by applying specific examples in this paper, the above embodiment is only used to help understand the method of the application and its core idea; at the same time, for those skilled in the art, according to the idea of the application, the specific embodiments and the application range will be changed, and the above description should not be understood as the limitation of the application.
Claims
1. A time synchronization method, characterized in that, Applied to the first node, the method includes: Responding to a preset Bluetooth broadcast from a second node; wherein the first node and the second node communicate via Bluetooth broadcast. Obtain the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node, and obtain the first dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node and / or the second dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node; Based on the first transmission time, and according to the first dwell time and / or the second dwell time, a response time for responding to the Bluetooth broadcast is generated; Based on the response time, time synchronization is performed with the second node.
2. The time synchronization method according to claim 1, characterized in that, The step of obtaining the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node, and obtaining the first dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node and / or the second dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node, includes: The second dwell time and the first transmission time are obtained based on the broadcast packet of the Bluetooth broadcast.
3. The time synchronization method according to claim 2, characterized in that, The step of obtaining the second dwell time and the first transmission time based on the broadcast packet broadcast by Bluetooth includes: The broadcast packet is parsed to obtain the first timestamp of the application layer request of the second node to broadcast the Bluetooth protocol stack, the second timestamp of the Bluetooth protocol stack broadcast by the second node, and the first transmission time. The second dwell time is generated based on the first timestamp and the second timestamp.
4. The time synchronization method according to claim 1, characterized in that, The step of obtaining the first dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the first node and / or the second dwell time of the Bluetooth broadcast on the Bluetooth protocol stack of the second node includes: The first dwell time is obtained based on the timeline of the first node.
5. The time synchronization method according to claim 4, characterized in that, The step of obtaining the first dwell time based on the timeline of the first node includes: The broadcast packet of the Bluetooth broadcast is parsed to obtain the third timestamp of the broadcast packet sent by the Bluetooth protocol stack of the first node to the application layer of the first node; Obtain the fourth timestamp of the application layer receiving the broadcast packet from the timeline of the first node; The first dwell time is generated based on the third timestamp and the fourth timestamp.
6. The time synchronization method according to claim 1, characterized in that, The step of synchronizing time with the second node based on the response time includes: Obtain the standard time at which the second node requests to broadcast Bluetooth to the first node; Synchronize time with the second node based on the standard time and the response time.
7. The time synchronization method according to claim 6, characterized in that, The step of obtaining the standard time for the second node to request a Bluetooth broadcast to the first node includes: The broadcast packets of the Bluetooth broadcast are parsed to obtain the standard time when the second node requests to broadcast Bluetooth to the first node.
8. A network system, characterized in that, It includes at least a first node and a second node that use Bluetooth broadcast communication, wherein the first node is used to perform the time synchronization method according to any one of claims 1-7.
9. The network system according to claim 8, characterized in that, The second node is used to execute a time generation method, which includes the following steps: A broadcast packet generated by the application layer in response to the second node; wherein the second node and the preset first node communicate via Bluetooth broadcast. Determine the Bluetooth broadcast mode between the first node and the second node, as well as the number of bits in the broadcast packet; Based on the Bluetooth broadcast mode and the number of bits, a first transmission time is generated between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node.
10. The network system according to claim 9, characterized in that, The step of generating the first transmission time between the Bluetooth protocol stack of the first node and the Bluetooth protocol stack of the second node based on the Bluetooth broadcast mode and the number of bits includes: Based on the Bluetooth broadcast mode, a second transmission time for transmitting each bit of data in the broadcast packet is determined; The first transmission time is generated based on the number of bits and the second transmission time.
Citation Information
Patent Citations
System and method for realizing time synchronization between Internet-of-Things equipment
CN106254021A
Time synchronization method, electronic equipment and storage medium
CN117715171A
Technique for determining radio device residence time and scheduling
US20230171014A1