Low-power-consumption Bluetooth time synchronization method realized by software layer

The low-power Bluetooth time synchronization method implemented through the software layer uses connection establishment and message reception events to solve the problems of instability in data transmission and hardware dependence in the prior art, and realizes high-precision and low-cost time synchronization, which is suitable for physiological signal monitoring.

CN120302407APending Publication Date: 2025-07-11SOUTH CHINA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510393397.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The existing low-power Bluetooth time synchronization method is difficult to transmit data stably in physiological signal monitoring, relying on additional hardware to increase costs or relying on specific protocol stacks to be insufficient in universality, and it is unable to effectively eliminate the cumulative error caused by clock drift.

Method used

The low-power Bluetooth time synchronization method implemented by the software layer is based on Bluetooth connection event driving, through connection establishment and message reception events, the initial time offset and periodic synchronization are eliminated, and the system complexity and cost are reduced, and it is suitable for different protocol stacks.

Benefits of technology

It realizes high-precision and low-cost time synchronization, and is suitable for distributed physiological signal monitoring, eliminating the accumulated error caused by initial time offset and clock drift, and reducing power consumption and system complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120302407A_ABST
    Figure CN120302407A_ABST
Patent Text Reader

Abstract

The invention relates to a physiological signal monitoring and time synchronization technology, in particular to a low-power-consumption Bluetooth time synchronization method realized by a software layer, which comprises the following steps that: central equipment scans to find target peripheral equipment and initiates connection, the central equipment and the peripheral equipment trigger a connection establishment event, and performs one time of timestamp exchange; the initial time offset is eliminated using a synchronization step based on a connection setup event. The method further comprises the following steps: the central equipment subscribes to the sending characteristics of the peripheral equipment time synchronization service; after the sending feature is subscribed, the peripheral device starts a timer to execute a periodic synchronization task; and after timing of the timer is finished, the peripheral equipment sends a synchronization request to the central equipment, and the two parties complete time synchronization according to a time synchronization step based on a message receiving event so as to eliminate an accumulated error caused by time drift. The method does not need to depend on external hardware and a specific protocol stack, errors caused by initial time migration and time drift can be eliminated, and a technical basis is provided for distributed physiological signal monitoring and data fusion analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to physiological signal monitoring and time synchronization technologies, and specifically to a low-power Bluetooth time synchronization method implemented at the software layer. Background Art

[0002] In the field of distributed physiological signal monitoring, achieving precise time synchronization is crucial. For example, in blood pressure monitoring applications, photoplethysmogram (PPG) and electrocardiogram (ECG) signals must be on the same time coordinate to accurately calculate key physiological parameters such as pulse transit time (PTT) and use them for blood pressure regression estimation. This requires two devices to achieve high-precision time synchronization.

[0003] Although there are currently time synchronization protocols based on BLE broadcasts, such as BlueSync, which can achieve precise time synchronization, they are limited to broadcasting time information and cannot stably and reliably transmit actual data, which limits their use in scenarios for physiological data transmission.

[0004] In the BLE connection mode, due to the low-power characteristic, the chip turns on the radio frequency module only once every connection interval for wireless data transmission. This discontinuous data transmission makes the transmission delay of BLE random, and the traditional NTP protocol is difficult to effectively apply in this scenario because the NTP protocol relies on predictable network delays.

[0005] Currently, there is already a time synchronization method based on current monitoring. The principle is that when the connection event occurs simultaneously on both devices, since the radio frequency module is turned on, the current increases simultaneously in both devices. By setting a threshold to trigger an interrupt, and then recording the local timestamp when the current change occurs, and then exchanging this pair of timestamps, the time offset between the two devices can be calculated, thus achieving time synchronization. Although this method can provide high-precision time synchronization, it requires additional hardware support, increasing the complexity and cost of the system.

[0006] Another time synchronization method based on Nordic's SoftDevice protocol stack uses the radio notification function of the protocol stack. Without an external current monitor, it can also know when the radio frequency module is turned on and inform the software layer through a software interrupt to obtain the connection event occurrence time. Its essence is also that the connection event occurs simultaneously on both devices. However, this method depends on the protocol stack, and only Nordic's protocol stack provides this function, so its generality is not strong.

[0007] Some terms involved in the BLE communication process and time synchronization are introduced as follows: Connection establishment event: An event triggered after the master device scans and discovers a slave device that is broadcasting, then initiates a connection request, and both parties enter the connected state.

[0008] Connection event: A feature of Bluetooth Low Energy where the RF module is not always on but is turned on at regular intervals to send air data packets. The process of turning on the RF module and sending messages is called a connection event. Due to this mechanism, the send function called by the application layer is not immediately sent to the other party but is cached in the protocol stack queue and waits for the connection event to occur before actual transmission, resulting in transmission delay, and it is a random delay.

[0009] Connection interval: connection interval, CI, refers to the interval at which connection events occur and can be set through program code. The larger the CI, the more power-saving, but the greater the transmission delay.

[0010] The current Bluetooth Low Energy time synchronization algorithms have the following limitations: Time synchronization methods based on broadcast mode are difficult to stably transmit data; Methods based on monitoring current changes rely on additional hardware, increasing the power consumption and cost of the device; Although the radio notification-based scheme can achieve high-precision synchronization, it depends on a specific protocol stack and has insufficient generality. Summary of the Invention

[0011] To solve the problems existing in the prior art, the present invention proposes a Bluetooth Low Energy time synchronization method implemented at the software layer. This method is based on Bluetooth connection and event-driven, without relying on external hardware and specific protocol stacks, reducing the complexity and cost of the system. It can eliminate the initial time offset and eliminate the influence of clock drift through periodic synchronization, achieving high-precision and low-cost time synchronization, providing a technical basis for distributed physiological signal monitoring and data fusion analysis.

[0012] The technical solution adopted in the embodiments of the present invention is: A Bluetooth Low Energy time synchronization method implemented at the software layer, applied in the physiological signal monitoring scenario. The synchronization method includes the steps: S1. The central device scans and discovers the target peripheral device and initiates a connection. The central device and the peripheral device trigger a connection establishment event and perform a timestamp exchange, using the synchronization step based on the connection establishment event to eliminate the initial time offset; Among them, the steps of the timestamp exchange include: The peripheral device starts broadcasting; At the same time, the central device scans. When the device name or mac address of the peripheral device is matched, a connection is initiated; The central device and the peripheral device simultaneously enter the connection establishment event and obtain the local timestamp TA of the central device and the local timestamp TB of the peripheral device in the event callback function; The central device takes the local timestamp TA as a message and sends it to the peripheral device through the Write function; The peripheral device calculates the time offset relative to the central device based on the assumption that the event occurrence interval ΔT is 0, according to the following formula: offset = TB –TA; where offset is the time offset.

[0013] Preferably, the synchronization method further includes the steps of: S2. The central device subscribes to the sending characteristics of the time synchronization service of the peripheral device; after the sending characteristics are subscribed, the peripheral device starts a timer to execute a periodic synchronization task; S3. After the timing of the timer ends, the peripheral device sends a synchronization request to the central device, and the two parties complete time synchronization according to the time synchronization steps based on the message reception event to eliminate the cumulative error caused by time drift; after the time synchronization is completed, the timer is reset for the next synchronization.

[0014] More preferably, the time synchronization steps based on the message reception event include: The peripheral device sends a synchronization request to the central device through the Notify function. When the central device receives the message of the synchronization request, it will trigger a message reception event and record the local timestamp TA of the current moment in the callback function, and then send the local timestamp TA of the central device to the peripheral device through the Write function; After receiving the local timestamp TA of the central device, the peripheral device triggers a message reception event, records the local timestamp TB of the peripheral device in the callback function, obtains the value of the connection interval CI, and then calculates the time offset relative to the central device according to the following formula: offset = TB – (TA + CI).

[0015] Compared with the prior art, the technical effects achieved by the present invention include: 1. Based on the event mechanism of the BLE core specification, the present invention realizes the time synchronization method at the software layer. Compared with the hardware-dependent current monitoring method, the present invention does not require additional hardware, reducing costs and power consumption; compared with the Nordic solution, the present invention does not rely on a specific protocol stack and has a wider applicability.

[0016] 2. The present invention also solves the problem of clock drift, and the synchronization accuracy meets the requirements of distributed physiological signal acquisition. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a timing diagram of the time synchronization method based on the connection establishment event in the embodiment of the present invention; Figure 2 It is a timing diagram of the time synchronization method based on the message reception event in the embodiment of the present invention; Figure 3This is a flowchart of the time synchronization method that combines connection establishment events and message reception events during long-term data collection in an embodiment of the present invention. Detailed implementation manners

[0018] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention. Embodiment

[0019] The low-power Bluetooth time synchronization method implemented at the software layer provided in this embodiment is applied to the physiological signal monitoring scenario. The general idea is as follows: select that there is a specific occurrence interval when an event occurs on both devices. Assume that this occurrence interval is ΔT. By recording the time TA when an event occurs on device A and the time TB when the event occurs on device B, then the time offset offset of device B relative to device A is: offset = TB – (TA + ΔT); The essence of time synchronization is to eliminate the time offset. After obtaining the time offset, device B can eliminate the time offset through the following formula to obtain the synchronized time TB': TB' = TB – offset; In this embodiment, the slave device does not modify the value of the local timer based on the time offset, that is, it does not use the calculated TB' to modify the local clock, but saves the time offset offset in the memory. Whenever the time needs to be obtained, first obtain the local clock value, and then subtract offset to obtain the synchronized time.

[0020] In this embodiment, relative time synchronization is implemented. The device timestamp starts from 0 when the device is powered on. The central device is selected as the time reference, and each peripheral device synchronizes with it as the target. If absolute time synchronization needs to be implemented, the central device needs to be aligned with UTC first, which requires additional means, such as connecting to WiFi for a network time service system. In the physiological signal monitoring scenario, the purpose of synchronization is to achieve the alignment and fusion of the collected data, and relative synchronization can be achieved.

[0021] BLE devices organize data through services and characteristics. This embodiment requires the peripheral device (i.e., the slave device) to have a time synchronization service, including two characteristics: one is the receive characteristic (RX_CHR), which has a write attribute and is used to receive messages from the central device (i.e., the master device); the other is the transmit characteristic (TX_CHR), which has a read attribute and a subscription attribute and is used to send messages to the central device.

[0022] The time synchronization method described in this embodiment has two sub-methods: Method 1: A time synchronization method based on connection establishment events, as Figure 1 shown. Device A is the central device, and Device B is the peripheral device. The peripheral device starts broadcasting, and at the same time, the central device performs scanning. When the device name or MAC address of the peripheral device is matched, a connection is initiated. The central device and the peripheral device almost simultaneously enter the connection establishment event (event name: BLE_GAP_EVENT_CONNECT), and in the event callback function, the local timestamps of the central device and the peripheral device are obtained through the gettimeofday function, denoted as TA and TB respectively. Subsequently, the central device takes the local timestamp TA of the central device as a message and sends it to the peripheral device through the Write function. Based on the assumption that the event occurrence interval ΔT is 0, the peripheral device calculates the time offset relative to the central device based on the following formula: offset = TB – TA.

[0023] After experimental tests, when the connection intervals CI are 10ms, 50ms, and 100ms respectively, the calculated time offset offset and the actual time offset offset differ by about 20 microseconds, that is, the synchronization error is 20 microseconds, and the error is independent of the connection interval CI. The disadvantage of the time synchronization method based on connection establishment events is that the connection establishment event only occurs once in the entire communication cycle and can only be used for initial offset correction and cannot eliminate the cumulative error caused by clock drift.

[0024] Method 2: A time synchronization method based on message reception events, as Figure 2 shown. After the message connection is established, the central device A needs to subscribe to the send characteristics of the peripheral device B.

[0025] This method requires the peripheral device to initiate actively. First, the peripheral device uses the Notify function to send a synchronization request to the central device through the send characteristics. When the central device receives the message of the synchronization request, it will trigger the message reception event (event name: BLE_GAP_EVENT_NOTIFY_RX) and record the local timestamp TA of the current moment in the callback function. Immediately, it sends the local timestamp TA of the central device to the peripheral device through the Write function. After receiving the local timestamp TA of the central device, the peripheral device triggers the message reception event (event name: BLE_GATT_ACCESS_OP_WRITE_CHR), and records the local timestamp TB of the peripheral device in the callback function. Assuming that ΔT is the size of a connection interval CI, the value of the connection interval CI can be obtained through the relevant API, and then the time offset relative to the central device is calculated according to the following formula: offset = TB – (TA + CI).

[0026] After experimental testing, when the connection interval CI is 10 ms, 50 ms, and 100 ms respectively, the mean value of the synchronization error is independent of the connection interval CI. However, as CI increases, the variance of the error distribution increases, changing from 11 ms to 22 ms. This deviation is also related to the length of the sent message. When in use, it should be ensured that the length of the synchronization request sent by the peripheral device to the central device is the same as the length of the timestamp sent by the central device to the peripheral device. In this embodiment, the timestamp length is 8 bytes.

[0027] The event names described above come from the NimBLE open source protocol stack, and the error values are measured based on the ESP32-C3 and the NimBLE protocol stack. In fact, each protocol stack has these events, and they will all be notified to the application layer through the callback function mechanism, which is universal. Although the specific scheduling implementation methods of different protocol stacks are different, the underlying layer still meets the requirements of the BLE core specification. Therefore, even if the actual error may deviate from the description of this embodiment, it can still meet the physiological signal acquisition scenario.

[0028] In actual use, the above two sub-methods can be used according to requirements.

[0029] (1) When only short-term data acquisition is performed, a synchronization can be performed based on Method 1, which has a lower synchronization error and is more stable.

[0030] (2) When long-term data acquisition is required, in order to eliminate time drift, after using Method 1 to eliminate the initial offset, the peripheral device can initiate a synchronization request at regular intervals and use Method 2 for periodic synchronization, as Figure 3 , which specifically includes the following steps: S1. The central device scans and discovers the target peripheral device and initiates a connection. Both devices trigger a connection establishment event, perform a timestamp exchange once according to Method 1, and use the synchronization method based on the connection establishment event to eliminate the initial time offset.

[0031] S2. The central device subscribes to the transmit characteristic (TX_CHR) of the peripheral device's time synchronization service. After this transmit characteristic is subscribed, the peripheral device starts a timer to execute the periodic synchronization task.

[0032] S3. After the timer expires, the peripheral device sends a synchronization request to the central device, and both parties complete the time synchronization according to the steps of Method 2 to eliminate the cumulative error caused by time drift. After the time synchronization is completed, the timer is reset for the next synchronization.

[0033] Among them, the interval of cycle synchronization can be calculated according to the following formula: Tsync = Tdrift / (2 * ppm * 10^(-6)). The time unit in the formula is seconds, Tdrift is the time offset range that needs to be controlled, and in the physiological signal monitoring scenario, it is recommended to be between 500 us and 1 ms; ppm is the drift coefficient of the crystal oscillator used in the device; Tsync is the calculated synchronization period.

[0034] The above calculation formula is derived under the worst-case scenario; for example, the frequency offset of the device crystal oscillator is ±10 ppm, and the above formula assumes one frequency offset of +10 ppm and one of -10 ppm. In fact, the synchronization period can be slightly extended, such as using 1.5 * Tsync as the synchronization period to save energy consumption. In implementation, a timing task can be designed in the RTOS, and approximate timing can be achieved through the vTaskDelay function during this period, thereby achieving cycle synchronization.

[0035] The above description is carried out between a central device and a peripheral device and is applicable to the scenario of one master and multiple slaves. For Method 1, connections need to be established for the peripheral devices (i.e., slaves) in sequence, and synchronization is completed according to the same process. For Method 2, it uses the sending and receiving of messages for synchronization, and the process of message sending and receiving is scheduled by the underlying protocol stack according to the time-division multiplexing method. The application layer does not need to pay attention to the details, and the synchronization process can be carried out one-on-one, but the connection intervals of each peripheral device (i.e., slave) and the central device (i.e., master) need to be controlled to avoid conflicts in communication time slots. This embodiment recommends that the connection intervals CI of N peripheral devices be set to be the same and relatively large, so that the central device will have CI / N time for message exchange and processing of connection events.

[0036] In actual application, there are specifically the following two ways for time synchronization between the central device and the peripheral device: (1) When the Bluetooth connection between the central device and the peripheral device is only used for time synchronization, the connection interval CI is set to be greater than or equal to 100 ms to save energy consumption; when the Bluetooth between the central device and the peripheral device is used for time synchronization and data transmission, the collected data is packed and sent, and the interference to synchronization is reduced by reducing the transmission initiation frequency. The central device and the peripheral device first establish a connection and perform time synchronization, then both start the data collection task, and record the collection timestamp when collecting data. The data is sent to the PC for data analysis through local storage or through the serial port.

[0037] (2) The central device acts as a gateway and collects data through multiple peripheral devices. When the central device connects to the peripheral devices, it synchronizes them in sequence, and then subscribes to the transmit characteristics of the time synchronization service of the peripheral devices and the transmit characteristics of the data collection service. The peripheral devices start collecting data only after synchronization is completed, and pack multiple data into a data packet and send it to the central device. By reducing the transmission frequency, a larger connection interval can be set, saving energy while avoiding the impact of connection time slot conflicts of multiple devices on the cycle synchronization effect. Specifically, for data with a sampling rate of 100 Hz, one sampling value is 12 bits (calculated as 2 bytes according to the byte alignment method). The best BLE transmission should not exceed the 251-byte limit of the data length enhancement (DLE). Calculated by a 100-byte data packet, 0.5 seconds of collected data can be placed. Therefore, the connection interval CI can be set to 500 ms. In addition, only the collection timestamp of the first data needs to be carried in a data packet, and the collection timestamps of other data sampling points can be deduced through the sampling rate. After receiving the data packet, the central device saves it or sends it to the PC for analysis.

[0038] The above-described embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A low-power Bluetooth time synchronization method implemented at the software layer, characterized in that, Applied in the physiological signal monitoring scenario, the synchronization method includes the following steps: S1. The central device scans to discover the target peripheral device and initiates a connection. The central device and the peripheral device trigger a connection establishment event, perform a timestamp exchange, and use the synchronization steps based on the connection establishment event to eliminate the initial time offset. Among them, the steps of the timestamp exchange include: The peripheral device starts broadcasting; at the same time, the central device scans. When the device name or MAC address of the peripheral device is matched, a connection is initiated. The central device and the peripheral device simultaneously enter the connection establishment event, and obtain the local timestamp TA of the central device and the local timestamp TB of the peripheral device in the event callback function. The central device takes the local timestamp TA as a message and sends it to the peripheral device through the Write function. Based on the assumption that the event occurrence interval ΔT is 0, the peripheral device calculates the time offset relative to the central device based on the following formula: offset = TB –TA; In the formula, offset is the time offset.

2. The time synchronization method according to claim 1, wherein The synchronization method further includes the following steps: S2. The central device subscribes to the sending characteristic of the peripheral device time synchronization service; after the sending characteristic is subscribed, the peripheral device starts a timer to execute the periodic synchronization task. S3. After the timer expires, the peripheral device sends a synchronization request to the central device, and the two parties complete the time synchronization according to the time synchronization steps based on the message reception event to eliminate the cumulative error caused by time drift; after the time synchronization is completed, the timer is reset for the next synchronization.

3. The time synchronization method according to claim 2, characterized in that The time synchronization steps based on the message reception event include: The peripheral device sends a synchronization request to the central device through the Notify function. When the central device receives the message of the synchronization request, it will trigger a message reception event and record the local timestamp TA at the current moment in the callback function, and then send the local timestamp TA of the central device to the peripheral device through the Write function. After receiving the local timestamp TA of the central device, the peripheral device triggers a message reception event, records the local timestamp TB of the peripheral device in the callback function, obtains the value of the connection interval CI, and then calculates the time offset relative to the central device according to the following formula: offset = TB –(TA + CI).

4. The time synchronization method according to claim 2, characterized in that The length of the synchronization request sent by the peripheral device to the central device is the same as the length of the timestamp sent by the central device to the peripheral device.

5. The time synchronization method according to claim 2, wherein The interval of periodic synchronization is calculated according to the following formula: Tsync = Tdrift / (2 * ppm * 10^(-6)); In the formula, Tdrift is the time offset range that needs to be controlled, which is between 500 us and 1 ms in the physiological signal monitoring scenario; ppm is the drift coefficient of the crystal oscillator used in the device; Tsync is the calculated synchronization period.

6. The time synchronization method according to claim 5, characterized in that The synchronization period is extended, and 1.5 * Tsync is taken as the synchronization period.

7. The time synchronization method according to claim 1, wherein When the Bluetooth connection between the central device and the peripheral device is only used for time synchronization, the connection interval CI is set to be greater than or equal to 100 ms; when it is used for time synchronization and data transmission, the collected data is packed and sent.

8. The time synchronization method according to claim 1, characterized in that The central device acts as a gateway and collects data through multiple peripheral devices; when the central device connects to the peripheral devices, synchronization is performed sequentially, and then the sending characteristics of the time synchronization service of the peripheral devices and the sending characteristics of the data collection service are subscribed.