Search

CN-115987440-B - Clock synchronization method, device, equipment and storage medium

CN115987440BCN 115987440 BCN115987440 BCN 115987440BCN-115987440-B

Abstract

The embodiment of the application discloses a clock synchronization method, a device, equipment and a storage medium, wherein the method is applied to first Bluetooth equipment of a first terminal, the method comprises the steps of receiving a first data packet of second Bluetooth equipment of the first terminal, determining a first offset between a clock of the first Bluetooth equipment and a clock of the second Bluetooth equipment based on the time when the first data packet is received by the first Bluetooth equipment and the time when the first data packet is received by the first Bluetooth equipment specified by a protocol, and sending the first offset to third Bluetooth equipment of the second terminal, wherein the first offset is used for clock synchronization of the first Bluetooth equipment, the second Bluetooth equipment and the third Bluetooth equipment, the clock sources of the first Bluetooth equipment and the second Bluetooth equipment are different, and the third Bluetooth equipment is the Bluetooth equipment communicated with the first Bluetooth equipment. In the method, the Bluetooth device can perform clock synchronization with other Bluetooth devices at the time of receiving the data packet, so that the Bluetooth system can stably operate for a long time.

Inventors

  • QIN YUJIAN

Assignees

  • 哲库科技(上海)有限公司

Dates

Publication Date
20260505
Application Date
20221228

Claims (11)

  1. 1. A method of clock synchronization, applied to a first bluetooth device of a first terminal, the method comprising: Receiving a first data packet from a second Bluetooth device of the first terminal through Bluetooth connection between the first Bluetooth device and the second Bluetooth device; Determining a first offset between a clock of the first Bluetooth device and a clock of the second Bluetooth device based on a time when the first Bluetooth device receives the first data packet and a time when the first Bluetooth device receives the first data packet specified by a protocol; transmitting the first offset to a third Bluetooth device of a second terminal, wherein the first offset is used for clock synchronization of the first Bluetooth device, the second Bluetooth device and the third Bluetooth device; Wherein the first bluetooth device is different from the clock source of the second bluetooth device, and the third bluetooth device is a bluetooth device in communication with the first bluetooth device.
  2. 2. The method of claim 1, wherein the determining a first offset between the clock of the first bluetooth device and the clock of the second bluetooth device based on the time of receipt of the first data packet by the first bluetooth device and the time of receipt of the first data packet by the first bluetooth device specified by a protocol comprises: determining a time of receiving the first data packet by the first Bluetooth device specified by a protocol; And determining the offset between the moment of receiving the first data packet by the first Bluetooth device and the moment of receiving the first data packet by the first Bluetooth device specified by a protocol as the first offset.
  3. 3. The method according to claim 1, wherein the method further comprises: And based on the first offset, performing clock synchronization with the second Bluetooth device to obtain a first synchronous clock.
  4. 4. A method according to claim 3, characterized in that the method further comprises: And the third Bluetooth device realizes the synchronization of the clock of the third Bluetooth device and the first synchronization clock based on the moment of receiving the second data packet.
  5. 5. A method of clock synchronization, applied to a second bluetooth device of a first terminal, the method comprising: Transmitting a first data packet to a first Bluetooth device of the first terminal through Bluetooth connection between the first Bluetooth device and the second Bluetooth device, wherein the time when the first Bluetooth device receives the first data packet and the time when the first Bluetooth device receives the first data packet specified by a protocol are used for determining a first offset between a clock of the first Bluetooth device and a clock of the second Bluetooth device, and the first offset is used for synchronizing clocks of the first Bluetooth device, the second Bluetooth device and a third Bluetooth device of the second terminal; Wherein the first bluetooth device is different from the clock source of the second bluetooth device, and the third bluetooth device is a bluetooth device in communication with the first bluetooth device.
  6. 6. A method of clock synchronization, applied to a third bluetooth device of a second terminal, the method comprising: Receiving a first offset of a first Bluetooth device from a first terminal, wherein the first offset is an offset between a clock of the first Bluetooth device and a clock of a second Bluetooth device of the first terminal; Wherein the first Bluetooth device is different from the clock source of the second Bluetooth device, and the third Bluetooth device is a Bluetooth device in communication with the first Bluetooth device; the first offset is used for clock synchronization between the first Bluetooth device and the second Bluetooth device to obtain a first synchronization clock, and the method further comprises: receiving a second data packet from the first bluetooth device; Determining a second offset between the clock of the first Bluetooth device and the clock of the third Bluetooth device based on the time when the second data packet is received by the third Bluetooth device and the time when the second data packet is received by the third Bluetooth device specified by a protocol; and based on the addition result of the first offset and the second offset, performing clock synchronization with the first synchronous clock to obtain a second synchronous clock.
  7. 7. An apparatus for clock synchronization, the apparatus deployed at a first terminal, the apparatus comprising: the receiving module is used for receiving a first data packet from a second Bluetooth device of the first terminal through Bluetooth connection between the device and the second Bluetooth device; a determining module, configured to determine a first offset between a clock of the apparatus and a clock of the second bluetooth device based on a time when the apparatus receives the first data packet and a time when the apparatus receives the first data packet specified by a protocol; The first transmitting module is used for transmitting the first offset to a third Bluetooth device of the second terminal, wherein the first offset is used for clock synchronization of the device, the second Bluetooth device and the third Bluetooth device; Wherein the apparatus is different from a clock source of the second bluetooth device, and the third bluetooth device is a bluetooth device in communication with the apparatus.
  8. 8. An apparatus for clock synchronization, the apparatus deployed at a first terminal, the apparatus comprising: a sending module, configured to send a first data packet to a first bluetooth device of the first terminal through a bluetooth connection between the first bluetooth device and the apparatus, where a time when the first bluetooth device receives the first data packet and a time when the first bluetooth device specified by a protocol receives the first data packet are used to determine a first offset between a clock of the first bluetooth device and a clock of the apparatus, where the first offset is used to perform clock synchronization on a third bluetooth device of the first bluetooth device, the apparatus, and the second terminal; Wherein the first bluetooth device is different from a clock source of the apparatus, and the third bluetooth device is a bluetooth device in communication with the first bluetooth device.
  9. 9. An apparatus for clock synchronization, the apparatus deployed at a second terminal, the apparatus comprising: The first receiving module is used for receiving a first offset of a first Bluetooth device from a first terminal, wherein the first offset is an offset between a clock of the first Bluetooth device and a clock of a second Bluetooth device of the first terminal; Wherein the first bluetooth device is different from the clock source of the second bluetooth device, and the apparatus is a bluetooth device in communication with the first bluetooth device; The first offset is used for clock synchronization between the first Bluetooth device and the second Bluetooth device to obtain a first synchronization clock, and the device further comprises: A second receiving module, configured to receive a second data packet from the first bluetooth device; A determining module, configured to determine a second offset between a clock of the first bluetooth device and a clock of the apparatus based on a time when the apparatus receives the second data packet and a time when the apparatus receives the second data packet specified by a protocol; and the synchronization module is used for carrying out clock synchronization with the first synchronization clock based on the addition result of the first offset and the second offset to obtain a second synchronization clock.
  10. 10. A communication device, the communication device comprising: A memory for storing computer executable instructions; A processor, coupled to the memory, for implementing the method of any one of claims 1 to 4, or the method of claim 5, or the method of claim 6, by executing the computer-executable instructions.
  11. 11. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by at least one processor, implements the method according to any one of claims 1 to 4, or implements the method according to claim 5, or implements the method according to claim 6.

Description

Clock synchronization method, device, equipment and storage medium Technical Field The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, a device, and a storage medium for clock synchronization. Background With the development of bluetooth technology, at present, there may be two or more bluetooth devices in the same terminal. For example, two bluetooth devices with different clock sources working simultaneously exist in a certain terminal, including bluetooth device #1 and bluetooth device #2, where service exchange needs to be performed between bluetooth device #1 and bluetooth devices (such as bluetooth device # 3) of other terminals. In this scenario, in order to enable bluetooth device #1, bluetooth device #2, and bluetooth device #3 to perform traffic normally, collision between traffic is avoided, clock synchronization needs to be performed on bluetooth device #1, bluetooth device #2, and bluetooth device # 3. Disclosure of Invention The embodiment of the application at least provides a method, a device, equipment and a storage medium for clock synchronization. The technical scheme of the embodiment of the application is realized as follows: In a first aspect, an embodiment of the application provides a clock synchronization method applied to a first Bluetooth device of a first terminal, the method comprises the steps of receiving a first data packet of a second Bluetooth device of the first terminal, determining a first offset between a clock of the first Bluetooth device and a clock of the second Bluetooth device based on the time when the first Bluetooth device receives the first data packet and the time when the first Bluetooth device receives the first data packet specified by a protocol, sending the first offset to a third Bluetooth device of the second terminal, wherein the first offset is used for clock synchronization of the first Bluetooth device, the second Bluetooth device and the third Bluetooth device, the clock sources of the first Bluetooth device and the second Bluetooth device are different, and the third Bluetooth device is a Bluetooth device in communication with the first Bluetooth device. In a second aspect, the embodiment of the application provides a clock synchronization method applied to a second Bluetooth device of a first terminal, the method comprises the steps of sending a first data packet to the first Bluetooth device of the first terminal, wherein the first data packet is used for determining a first offset between a clock of the first Bluetooth device and a clock of the second Bluetooth device, the first offset is used for clock synchronization of the first Bluetooth device, the second Bluetooth device and a third Bluetooth device of the second terminal, the clock sources of the first Bluetooth device and the second Bluetooth device are different, and the third Bluetooth device is a Bluetooth device in communication with the first Bluetooth device. In a third aspect, the embodiment of the application provides a clock synchronization method applied to a third Bluetooth device of a second terminal, the method comprises the steps of receiving a first offset of a first Bluetooth device from a first terminal, wherein the first offset is an offset between a clock of the first Bluetooth device and a clock of a second Bluetooth device of the first terminal, the first offset is used for clock synchronization of the first Bluetooth device, the second Bluetooth device and the third Bluetooth device, the clock sources of the first Bluetooth device and the second Bluetooth device are different, and the third Bluetooth device is a Bluetooth device in communication with the first Bluetooth device. In a fourth aspect, an embodiment of the present application provides an apparatus for clock synchronization, where the apparatus is disposed in a first terminal, and the apparatus includes a receiving module configured to receive a first data packet from a second bluetooth device of the first terminal, a determining module configured to determine a first offset between a clock of the apparatus and a clock of the second bluetooth device based on a time when the apparatus receives the first data packet and a time when the apparatus receives the first data packet specified by a protocol, and a first transmitting module configured to transmit the first offset to a third bluetooth device of the second terminal, where the first offset is used for clock synchronization of the apparatus, the second bluetooth device, and the third bluetooth device, where the apparatus is different from a clock source of the second bluetooth device, and the third bluetooth device is a bluetooth device that communicates with the apparatus. In a fifth aspect, an embodiment of the present application provides an apparatus for clock synchronization, where the apparatus is disposed in a first terminal, and the apparatus includes a sending module, conf