A wireless communication method, device, electronic device, and storage medium
Patent Information
- Application Number
- CN202611149606.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-09-15
Smart Images

Figure CN122765679A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of wireless communication technology, and more specifically, to a wireless communication method, apparatus, electronic device, and storage medium. Background Technology
[0002] In Internet of Things (IoT) wireless connectivity systems, point-to-point (Piconet) topology-based communication protocols, such as Bluetooth and proprietary 2.4G, are frequently used. In this topology, a central device (such as a mobile phone, computer, or USB dongle) maintains a connection with peripheral devices (such as sensors, headphones, and wearable devices). These peripheral devices are typically battery-powered and have high requirements for low power consumption.
[0003] The heartbeat packet maintenance connection state refers to the peripheral device maintaining a connection with the central device when there are no data exchange tasks. This involves periodically sending and receiving empty packets at relatively large connection intervals to maintain heartbeat synchronization. This state occupies the majority of the product's usage time, and its power consumption essentially determines the overall power consumption of the product, significantly impacting battery life.
[0004] Due to cost and power consumption considerations, peripheral devices use low-precision, low-frequency oscillators (such as 32kHz RC) during sleep mode. These oscillators have significant errors, typically ranging from several hundred to over 1000ppm. As clock errors accumulate during sleep, peripheral devices cannot accurately determine the arrival time of data packets from the central device. They must open the receive window well before the predicted packet reception time to ensure successful packet reception. The larger the clock error, the longer the window needs to be opened in advance, thus reducing battery life. Summary of the Invention
[0005] This disclosure provides at least one wireless communication method, apparatus, electronic device, and storage medium to solve the aforementioned technical problems.
[0006] In a first aspect, embodiments of this disclosure provide a wireless communication method applied to a peripheral device, wherein the peripheral device is communicatively connected to a central device, comprising:
[0007] Obtain the actual arrival time of the current data packet sent by the central device; Clock deviation information is determined based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; Based on the clock skew information, the predicted arrival time of the next data packet is compensated; Based on the current packet reception status, adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time.
[0008] In one possible implementation, determining the clock skew information includes: Determine the connection interval between the peripheral device and the central device; Based on the ratio between the difference and the connection interval, the clock deviation coefficient of the peripheral device relative to the central device is obtained and used as the clock deviation information.
[0009] In one possible implementation, the compensation for the predicted arrival time of the next data packet includes: Obtain the product of the connection interval and the clock skew coefficient; The predicted arrival time of the next data packet is obtained by adding the arrival time of the current data packet to the product.
[0010] In one possible implementation, determining the connection interval between the peripheral device and the central device includes: When the current data packet is not successfully received, the actual arrival time is invalid. When predicting the arrival time of the next data packet, the value of the connection interval is determined based on the number of data packets skipped between the current data packet and the most recent valid data packet.
[0011] In one possible implementation, the method further includes: For all frame data packets except the first frame data packet, obtain the current clock deviation coefficient and the historical clock deviation coefficient corresponding to the current data packet. The historical clock deviation coefficient is the cumulative result of the clock deviation coefficients of all previous frame data packets after smoothing and filtering. The current clock deviation coefficient and the historical clock deviation coefficient are weighted and averaged, and the weighted average result is used as the clock deviation coefficient of the current frame.
[0012] In one possible implementation, the current clock deviation coefficient and the historical clock deviation coefficient each account for half the weight in the weighted average.
[0013] In one possible implementation, adjusting the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time includes: When the current data packet is successfully received, the advance amount is reduced by a step increment. When the current data packet is not successfully received, the advance amount is increased by a second step. Wherein, the second step size is greater than the first step size.
[0014] In one possible implementation, the method further includes: The advance amount stops decreasing when it decreases to a preset lower limit, and stops increasing when it increases to a preset upper limit.
[0015] In one possible implementation, before reducing the lead amount by a first incremental step, the method further includes: Determine if the number of consecutively successfully received data packets reaches a preset threshold.
[0016] In one possible implementation, obtaining the actual arrival time of the current data packet sent by the central device includes: The actual arrival time is obtained by capturing the arrival time of the radio frequency signal corresponding to the current data packet sent by the central device through hardware.
[0017] Secondly, this disclosure also provides a wireless communication device for use in a peripheral device, wherein the peripheral device is communicatively connected to a central device, comprising: The acquisition module is used to acquire the actual arrival time of the current data packet sent by the central device; The determination module is used to determine clock deviation information based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; The compensation module is used to compensate for the predicted arrival time of the next data packet based on the clock deviation information. The adjustment module is used to adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time, based on the current packet reception status.
[0018] Thirdly, this disclosure also provides an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, a wireless communication method as described in any one of the first aspects and various embodiments thereof is performed.
[0019] Fourthly, this disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the wireless communication method as described in any one of the first aspects and its various embodiments.
[0020] The aforementioned wireless communication method, apparatus, electronic device, and storage medium acquire the actual arrival time of the current data packet sent by the central device; determine clock skew information based on the difference between the actual arrival time and the predicted arrival time determined based on the local clock information of the peripheral device; compensate for the predicted arrival time of the next data packet based on the clock skew information; and adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time according to the packet reception status of the current data packet. By capturing the actual arrival time of the data packet from the central device and dynamically compensating for the clock skew of the peripheral device using the difference between it and the local predicted arrival time, and adaptively adjusting the advance amount of the receiving window according to the packet reception status, the invalid opening time of the receiving window is reduced, the power consumption of the peripheral device in the heartbeat packet-maintained connection state is reduced, and the battery life is extended.
[0021] Other advantages of this disclosure will be explained in more detail in conjunction with the following description and accompanying drawings.
[0022] It should be understood that the above description is merely an overview of the technical solution of this disclosure, so as to provide a general understanding of the technical means of this disclosure and to implement it in accordance with the contents of the specification. In order to make the above and other objects, features and advantages of this disclosure more apparent and understandable, specific embodiments of this disclosure are illustrated below. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. The accompanying drawings are incorporated in and constitute a part of this specification. These drawings illustrate embodiments conforming to this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure. It should be understood that the drawings only illustrate certain embodiments of this disclosure and should not be considered as a limitation on the scope of protection. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. Furthermore, the same reference numerals denote the same components throughout the drawings. In the drawings: Figure 1 This diagram illustrates the timing sequence of heartbeat packet transmission and reception between the peripheral device and the central device provided in an embodiment of this disclosure. Figure 2 A flowchart of a wireless communication method provided by an embodiment of this disclosure is shown; Figure 3 This illustration shows a schematic diagram of the clock skew compensation and lead optimization principles in the wireless communication method provided in this embodiment of the present disclosure; Figure 4 A schematic diagram of a wireless communication device provided in an embodiment of this disclosure is shown; Figure 5A schematic diagram of an electronic device provided in an embodiment of the present disclosure is shown. Detailed Implementation
[0024] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0025] In the description of embodiments disclosed herein, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of the disclosed features, figures, steps, behaviors, components, portions or combinations thereof in this specification, and do not exclude the possibility of the presence of one or more other features, figures, steps, behaviors, components, portions or combinations thereof.
[0026] Unless otherwise stated, " / " means "or". For example, A / B can mean A or B. In this article, "and / or" is merely a way of describing the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A alone, A and B at the same time, and B alone.
[0027] The terms "first," "second," etc., are used only for ease of description to distinguish identical or similar technical features and should not be construed as indicating or implying the relative importance or number of these technical features. Therefore, a feature defined by "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of embodiments of this disclosure, unless otherwise stated, the term "multiple" means two or more.
[0028] Research has found that, for example Figure 1 As shown, taking a typical 1-second connection interval heartbeat packet to maintain the connection as an example, assuming the maximum error of the peripheral device's 32k RC is 500ppm. The data packet from the central device arrives at time t2. Since the error may accumulate up to 500µs during the sleep period, and the direction of the error is unknown (it may arrive earlier or later), the peripheral device cannot accurately know the exact arrival time of the data packet from the central device. Therefore, the microcontroller unit (MCU) needs to be set to wake up at time t1 (i.e., 500µs before time t2) and open the receiving window in advance.
[0029] In this scenario, the average early RX packet reception time is 500µs. Assuming the average current is 10µA and the RX packet reception current is 7mA, this 500µs early RX contributes approximately 3.5µA of the average current, accounting for about 35% of the average current. If the early RX packet reception time can be reduced from 500µs to 250µs, the average current can be reduced from 10µA to 8.25µA, a reduction of approximately 17.5%, which can effectively extend battery life.
[0030] In order to at least partially solve one or more of the above-mentioned problems and other potential problems, this disclosure provides a wireless communication method, apparatus, electronic device and storage medium that can reduce the early opening time of the receiving window caused by clock errors when the peripheral device is in a heartbeat packet-maintained connection state, thereby reducing device power consumption and extending battery life.
[0031] To facilitate understanding of this embodiment, a wireless communication method disclosed in this disclosure will first be described in detail. The execution subject of the wireless communication method provided in this disclosure is a peripheral device. This peripheral device can be an electronic device with a certain computing capability, such as, but not limited to, Bluetooth headsets, wireless sensors, smart wearable devices, and IoT node devices. In some possible implementations, this wireless communication method can be implemented by a processor calling computer-readable instructions stored in memory.
[0032] See Figure 2 The diagram illustrates a flowchart of a wireless communication method provided in an embodiment of this disclosure. This method is applied to a peripheral device, which is communicatively connected to a central device, and includes the following steps S101-S104: S101: Obtain the actual arrival time of the current data packet sent by the central device; S102: Determine clock deviation information based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; S103: Based on clock skew information, compensate for the predicted arrival time of the next data packet; S104: Based on the current packet reception status, adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time.
[0033] To facilitate understanding of the wireless communication method provided in the embodiments of this disclosure, the application scenarios of the method will be described in detail below.
[0034] The wireless communication method provided in this disclosure can be applied to IoT wireless connection systems, particularly communication protocol scenarios based on the Piconet topology, such as Bluetooth and proprietary 2.4G. In this topology, central devices (such as mobile phones, computers, USB dongles, etc.) maintain a connection with peripheral devices (such as sensors, headphones, wearable devices, etc.). Peripheral devices are typically powered by batteries and have high requirements for low power consumption.
[0035] To address the aforementioned technical problems, this disclosure provides a novel solution. This solution obtains the actual arrival time of data packets sent by the central device, uses the difference between the actual arrival time and the locally predicted arrival time of the peripheral device to determine clock deviation information, and compensates for the predicted arrival time of the next data packet based on the clock deviation information. This enables the peripheral device to dynamically track the clock of the central device and improves the accuracy of the predicted arrival time.
[0036] In this embodiment, the peripheral device receives the current data packet sent by the central device and obtains the actual arrival time of the data packet. In this embodiment, the actual arrival time is obtained by hardware (such as an RF front-end or baseband processor). That is, when the hardware detects the arrival of the first bit of the RF signal, it automatically records the timestamp of that moment and stores it in a hardware register. The software can then read the register to obtain the time value.
[0037] The actual arrival time can be denoted as Tcap (cap is an abbreviation for capture). After the device enters the heartbeat packet maintenance connection state, the actual arrival time of each frame is denoted as Tcap_1, Tcap_2, ..., Tcap_n in sequence.
[0038] The peripheral device obtains the predicted arrival time of the current data packet, which is determined based on the peripheral device's local clock information. Then, the peripheral device calculates the difference between the actual arrival time and the predicted arrival time to obtain the deviation between the actual arrival time and the predicted arrival time.
[0039] The predicted arrival time here refers to the time when the peripheral device calculates the expected arrival time of the next data packet from the central device based on existing clock information and dynamic compensation results. The predicted arrival time is denoted as Tcal (cal for calculation). The predicted arrival time differs from the actual packet transmission time of the central device. Tcal incorporates dynamic compensation information from historical clock offset data and is the peripheral device's compensated prediction of the central device's packet transmission time. After entering the heartbeat packet maintenance connection state, the predicted arrival times of each frame are sequentially denoted as Tcal_1, Tcal_2, ..., Tcal_n, corresponding exactly to the frame sequence numbers of the actual arrival times.
[0040] Based on this difference, the peripheral device determines the clock skew information. Specifically, the peripheral device obtains the clock skew coefficient relative to the central device by dividing the difference by the connection interval, and uses this as the clock skew information.
[0041] The clock offset information here can be a parameter characterizing the real-time clock offset of the peripheral device relative to the central device, denoted as k_offset. k_offset is a dynamically changing value calculated based on the radio frequency packet time acquisition data of the central device, and is used for compensation when the peripheral device calculates the predicted arrival time.
[0042] Based on the clock offset information determined in step S102, the peripheral device compensates for the predicted arrival time of the next data packet. Specifically, the peripheral device obtains the product of the connection interval (Conn_Interval) and the clock offset coefficient (k_offset), adds the arrival time of the current data packet (Tcap_current) to this product, and obtains the predicted arrival time of the next data packet (Tcal_next = Tcap_current + Conn_Interval × k_offset).
[0043] Then, the peripheral device can determine the reception status of the current data packet, that is, whether the current data packet has been successfully received. Based on the different situations of successful or unsuccessful reception, the peripheral device adjusts the advance amount of opening the reception window before the compensated predicted arrival time accordingly: for example, if the current data packet is successfully received, the advance amount is reduced by a certain step; conversely, if the current data packet is not successfully received, the advance amount is increased by a certain step.
[0044] The receive window advance here refers to the length of time that the peripheral device opens the receive window before the predicted arrival time. This advance is used to cover the uncertainty caused by the accumulation of clock errors during sleep. The larger the advance, the higher the packet reception success rate, but the higher the power consumption; the smaller the advance, the lower the power consumption, but the higher the risk of packet reception failure. In the embodiments of this disclosure, the advance can be controlled by the p_error parameter.
[0045] To facilitate a further understanding of the overall concept of clock skew compensation and advance optimization in the embodiments of this disclosure, the relationship between the central device packet sending time, the peripheral device prediction time, and the wake-up time will be explained below.
[0046] In point-to-point connection systems, the central device uses a high-precision clock (crystal error typically between 10 and 50 ppm), and its data packet transmission time strictly adheres to the connection interval specified in the protocol. That is, the time interval between two consecutive data packet transmissions by the central device is exactly equal to the connection interval.
[0047] like Figure 3As shown, T_next is the theoretical arrival time of the next frame data packet calculated based on the high-precision clock of the central device. T_next is the optimal packet reception time pursued by the peripheral device. If the peripheral device can open its reception window exactly at T_next, the reception window does not need to be opened in advance, resulting in the lowest power consumption. T_next is calculated as: T_next = T_cap + Conn_Interval, which is the actual arrival time of the current frame plus a connection interval.
[0048] Due to cost and power consumption considerations, peripheral devices use low-precision, low-frequency oscillators (such as 32kHz RC) during sleep mode, resulting in significant errors, typically ranging from several hundred to over 1000ppm. There is a discrepancy between the arrival time (Tcal) predicted by the peripheral device based on its local clock information and the theoretical packet transmission time (T_next) of the central device. To ensure successful packet reception, the peripheral device needs to open its reception window well before the predicted time; this advance is denoted as t_error.
[0049] In traditional solutions, the lead time is calculated based on a fixed maximum error. Assuming the maximum error of the peripheral device's 32kHz RC oscillator is 500ppm, the accumulated error caused by the clock error over the connection interval is: t_error = Conn_Interval × 500 / 1000000 Therefore, the wake-up time of the peripheral device is: T_wkp = T_cap + Conn_Interval - t_error = T_cap + Conn_Interval -(Conn_Interval × 500 / 1000000) Taking a 1-second connection interval as an example, T_wkp = T_cap + 999.5ms, meaning that the peripheral device needs to open the receiving window 500µs in advance before the predicted arrival time.
[0050] In this scheme, regardless of how the actual clock offset changes, the lead is always reserved according to the worst-case scenario (500ppm), which prevents further optimization of power consumption. However, the closer T_wkp is to T_next, the shorter the invalid opening time of the receive window and the lower the power consumption.
[0051] To address the aforementioned issues, this disclosure introduces two dynamic coefficients to optimize the prediction time and lead time. The wake-up time calculation formula after introducing the two coefficients is as follows: T_wkp = T_cap + Conn_Interval × k_offset - (Conn_Interval × p_error / 1000000) in: k_offset (clock offset coefficient): This is the real-time clock offset coefficient between the two devices. It is dynamically calculated based on the RF packet time capture data of the central device. It is a dynamically changing value used to compensate for clock offset when the peripheral device calculates the predicted arrival time, so that Tcal continuously approaches T_next.
[0052] p_error (adaptive error coefficient): Replaces the fixed error value of 500 in the traditional scheme. It is dynamically adjusted according to the real-time packet reception situation, and continuously approaches a smaller value to control the advance of the reception window.
[0053] k_offset and p_error work together in two dimensions: k_offset is responsible for predicting the arrival time through dynamic compensation, so that Tcal gradually approaches the theoretical packet sending time T_next of the central device, thus solving the problem of inaccurate prediction; p_error, on the basis of accurate prediction, dynamically adjusts the lead amount, making it as small as possible while ensuring successful packet reception, thus solving the problem of excessive margin.
[0054] It is evident that through the synergistic effect of the two coefficients, T_wkp continuously approaches T_next, thereby minimizing power consumption while ensuring connection stability.
[0055] In this embodiment of the disclosure, the clock offset information can be determined through the following steps: Step 1: Determine the connection interval between peripheral equipment and central equipment; Step 2: Based on the ratio between the difference and the connection interval, obtain the clock deviation coefficient of the peripheral device relative to the central device, and use it as clock deviation information.
[0056] First, the peripheral device determines the connection interval (Conn_Interval) between itself and the central device. The connection interval is the time interval between two consecutive data packets sent by the central device. It is a parameter negotiated and determined by both parties when the connection is established, and the peripheral device can obtain this value from the protocol configuration parameters stored locally.
[0057] Then, based on the ratio between the difference calculated in step S102 (i.e., the difference between the actual arrival time Tcap and the predicted arrival time Tcal) and the connection interval (Conn_Interval), the peripheral device obtains the clock offset coefficient (k_offset) relative to the central device and uses it as clock offset information.
[0058] Specifically, the formula for calculating the clock skew coefficient is as follows: k_offset = 1 + (Tcap - Tcal) / Conn_Interval wherein, Tcap is the actual arrival time of the current data packet, Tcal is the predicted arrival time of the current data packet, and Conn_Interval is the connection interval.
[0059] The physical meaning of this formula is: when the clock of the peripheral device is completely synchronized with the clock of the central device, Tcap is equal to Tcal, and k_offset = 1; when the clock of the peripheral device is faster, Tcap<Tcal, and k_offset<1; when the clock of the peripheral device is slower, Tcap>Tcal, and k_offset>1.
[0060] In step S103, the specific method for the peripheral device to compensate the predicted arrival time of the next data packet is as follows: The peripheral device obtains the product of the connection interval (Conn_Interval) and the clock deviation coefficient (k_offset), then adds the arrival time (Tcap) of the current data packet to the product to obtain the predicted arrival time (Tcal_next) of the next data packet.
[0061] Specifically, the calculation formula for the predicted arrival time is: Tcal_next = Tcap_current + Conn_Interval × k_offset wherein, Tcap_current is the actual arrival time of the current data packet, Conn_Interval is the connection interval, and k_offset is the clock deviation coefficient of the current frame.
[0062] The physical meaning of this formula is: under the premise of the high-precision clock of the central device, the transmission time of the next frame of data packet of the central device should be the transmission time of the current frame plus one connection interval. However, since the peripheral device cannot directly know the transmission time of the central device, the peripheral device predicts the arrival time of the next frame of data packet based on the time (Tcap) when it actually receives the current frame, plus the product of the connection interval and the clock deviation coefficient. Here, the clock deviation coefficient k_offset corrects the connection interval, making the prediction result closer to the actual transmission time of the central device.
[0063] Under normal packet reception conditions, when the peripheral device predicts the arrival time of the next frame, the value of the connection interval is 1 connection interval. However, when one or more frames fail to be received, the peripheral device cannot obtain the actual arrival time (Tcap) of the frame, so special processing is required.
[0064] If the current data packet is not successfully received, the peripheral device will determine the actual arrival time of the current data packet as an invalid value. This invalid value will not be included in the clock skew information update calculation.
[0065] When predicting the arrival time of the next data packet, the peripheral device determines the value of the connection interval based on the number of data packets skipped between the current data packet and the most recent valid data packet.
[0066] Specifically, if m frames (m ≥ 1) are skipped between two consecutive valid packet receptions, then when calculating the predicted arrival time of the next frame, the connection interval changes from 1 to (m+1) frames, that is: Tcal_next = Tcap_valid + (m+1) × Conn_Interval × k_offset Where Tcap_valid is the actual arrival time of the most recent valid data packet, and m is the number of packets skipped.
[0067] For example, if packet reception fails in frame n, the valid Tcap from frame (n-1) is used. When predicting frame (n+1), the calculation of Conn_Interval changes from one to two. If packet reception fails for two consecutive frames, it becomes three, and so on.
[0068] After each data packet is successfully received, the peripheral device calculates a current clock offset coefficient (k_offset_cur). To improve the accuracy and stability of clock offset compensation, the peripheral device performs smoothing filtering on the current clock offset coefficient and the historical clock offset coefficient.
[0069] Specifically, for frame data packets other than the first frame data packet, the peripheral device performs the following operations: First, obtain the current clock offset coefficient (k_offset_cur) corresponding to the current data packet. This coefficient is calculated according to the method described above for clock offset coefficients.
[0070] Secondly, the historical clock offset coefficient (k_offset_his) is obtained. This historical clock offset coefficient is the cumulative result of the clock offset coefficients of all previous frame data packets after smoothing filtering. In other words, the historical clock offset coefficient is not the original value of a certain frame, but the cumulative value obtained after smoothing filtering of all historical data up to the previous frame. In practical applications, a portion of historical data can also be selected for smoothing filtering.
[0071] Then, the current clock offset coefficient and the historical clock offset coefficient are weighted and averaged, and the weighted average result is used as the clock offset coefficient (k_offset_n) of the current frame.
[0072] Finally, the clock offset coefficient (k_offset_n) of the current frame is used to compensate for the predicted arrival time of the next data packet.
[0073] In a preferred embodiment, the current clock skew coefficient and the historical clock skew coefficient each account for half the weight in the weighted average, that is: k_offset_n = k_offset_{n-1} × 1 / 2 + k_offset_cur × 1 / 2 Where k_offset_{n-1} is the cumulative result of the clock offset coefficients of all previous frame data packets after smoothing filtering (i.e., the k_offset value of the previous frame), and k_offset_cur is the newly calculated clock offset coefficient of the current frame.
[0074] Starting from the second frame of data, the peripheral device has at least one set of historical data and can begin performing the above smoothing filtering process. In the first frame of data, since there is no historical data available for comparison, the clock offset coefficient of the current frame is directly used as the k_offset value for that frame.
[0075] To facilitate a better understanding of the dynamic compensation scheme for k_offset, a complete example will be used to illustrate it in detail below.
[0076] For the first frame of data, the peripheral device reads the actual arrival time Tcap_1 of the frame and sets the predicted arrival time Tcal_1 of the frame to be the same as Tcap_1. At this time, there is only one frame of data, and there is no clock comparison information, so the clock deviation coefficient cannot be calculated. The predicted arrival time of the next frame (the second frame) is calculated according to Tcal_2 = Tcap_1 + Conn_Interval, that is, an additional connection interval is added to the actual arrival time of the first frame.
[0077] For the second frame of data, the peripheral device obtains the first pair of data that can be used for clock comparison.
[0078] The peripheral device calculates the difference (Tcap_2 - Tcal_2) between the actual arrival time Tcap_2 and the predicted arrival time Tcal_2 of the frame, and divides the difference by the connection interval (Conn_Interval) to obtain the clock offset (Tcap_2 - Tcal_2) / Conn_Interval corresponding to the frame.
[0079] Then, the peripheral device adds the clock offset to the base value 1 to obtain the clock offset coefficient k_offset_cur = 1 + (Tcap_2 - Tcal_2) / Conn_Interval for the current frame.
[0080] Since this is the first clock offset coefficient, there is no historical data available for smoothing filtering. The peripheral device directly uses this current clock offset coefficient as the clock offset coefficient k_offset_2 = k_offset_cur for the second frame, and uses it for prediction of the next frame.
[0081] For the third frame of data, the peripheral device already has multiple sets of clock offset data. The peripheral device calculates the clock offset coefficient k_offset_cur = 1 + (Tcap_3 - Tcal_3) / Conn_Interval for the current frame in the same way as for the second frame.
[0082] Then, the peripheral device obtains the historical clock offset coefficient. The historical clock offset coefficient is the cumulative result of the clock offset coefficients of all previous frame data packets after smoothing and filtering. For example, for the 3rd frame, the historical clock offset coefficient is the clock offset coefficient k_offset_2 of the 2nd frame.
[0083] The peripheral device performs a weighted average of the current clock offset coefficient k_offset_cur and the historical clock offset coefficient k_offset_2, and uses the weighted average result as the clock offset coefficient k_offset_3 for the current frame. In a preferred embodiment, the current clock offset coefficient and the historical clock offset coefficient each account for half the weight, that is: k_offset_3 = k_offset_2 × 1 / 2 + k_offset_cur × 1 / 2 The weighted average result k_offset_3 is used to compensate for the predicted arrival time of the next frame (frame 4): Tcal_4 = Tcap_3 + Conn_Interval × k_offset_3.
[0084] Similarly, for the nth frame of data (n ≥ 3), the peripheral device calculates the clock offset coefficient for the current frame as k_offset_cur = 1 + (Tcap_n - Tcal_n) / Conn_Interval. Then, it performs a weighted average of the current clock offset coefficient and the historical clock offset coefficient (i.e., k_offset_{n-1} for the (n-1)th frame) to obtain the clock offset coefficient for the current frame as k_offset_n = k_offset_{n-1} × 1 / 2 + k_offset_cur × 1 / 2. This coefficient is used to compensate for the predicted arrival time of the next frame (the (n+1)th frame): Tcal_{n+1} = Tcap_n + Conn_Interval × k_offset_n.
[0085] Through the above frame-by-frame weighted averaging process, the clock deviation coefficient of each frame incorporates the cumulative results of the current observation and all historical data, so that the clock deviation compensation can respond to the latest clock changes while maintaining the smoothness of history, and the compensation accuracy is continuously improved.
[0086] In step S104, the peripheral device adjusts the receive window advance based on the current packet reception status. Specifically, the adaptive adjustment of the advance mainly includes the following aspects: Peripheral devices determine the current packet reception status: When the current data packet is successfully received, the peripheral device reduces the lead in one step increment. This means that if packet reception is successful, it indicates that the current lead is sufficient to cover clock errors, and the peripheral device can attempt to reduce the lead to lower power consumption.
[0087] If the current data packet is not successfully received, the peripheral device increases the lead by a second step. This means that in the event of packet reception failure, the current lead may not be sufficient to cover clock errors, and the peripheral device needs to increase the lead to ensure connection reliability.
[0088] The second step amplitude is greater than the first step amplitude. That is, the rate at which the lead increases when packet reception fails is greater than the rate at which the lead decreases when packet reception succeeds. The reason for this design is that when packet reception fails, the system needs to respond quickly to restore the connection and prevent continuous packet loss due to insufficient lead; while when packet reception succeeds, the system can slowly decrease the lead to smoothly approach the optimal value, thereby minimizing power consumption while ensuring connection stability.
[0089] In a preferred embodiment, the first step increment is 25 ppm, and the second step increment is 50 ppm. That is, for each successful packet reception, p_error decreases by 25; for each failed packet reception, p_error increases by 50.
[0090] The peripheral equipment has preset lower and upper limits for lead time: When the lead time decreases to a preset lower limit, the peripheral device stops decreasing the lead time. The lower limit is set to prevent frequent packet loss due to excessively small lead time, thus ensuring basic connection reliability.
[0091] When the lead time increases to the preset upper limit, the peripheral device stops increasing the lead time. The upper limit is set to prevent excessive lead time from causing uncontrolled power consumption.
[0092] In a preferred embodiment, when the connection is first established by the heartbeat packet, the initial value of p_error is set to the maximum value of 500ppm. The lower limit of p_error can be determined based on actual testing. For example, it can be initially set to a more conservative value (such as 400ppm), and then continuously tried to lower it based on the actual packet reception situation to find the lowest possible value (such as 200ppm) that satisfies the premise of stable continuous packet reception.
[0093] To further ensure connection stability, the peripheral device needs to determine that the number of consecutively successfully received data packets reaches a preset threshold before reducing the lead amount in one step.
[0094] In other words, the peripheral device does not immediately reduce the lead amount after each successful packet reception. Instead, it only performs a step-by-step reduction after a certain number of consecutive successful receptions. This design is to avoid overly optimistic reduction of the lead amount due to a single, occasional success, and to prevent premature reduction of the lead amount before the link quality has fully stabilized, which could lead to subsequent packet loss.
[0095] In practical applications, the preset quantity threshold can be set according to the actual application scenario. When the packet reception situation improves (continuous and correct packet reception), the adjustment is slower to ensure a stable and reliable connection while gradually reducing power consumption. When the packet reception situation deteriorates (packet loss or even continuous packet loss occurs), the adjustment is faster to prevent the problem from escalating due to insufficient lead time.
[0096] In this embodiment of the disclosure, the peripheral device obtains the actual arrival time of the current data packet sent by the central device through hardware capture.
[0097] Specifically, when the hardware of the peripheral device (such as the RF front-end or baseband processor) detects the arrival of the first bit of the RF signal sent by the central device at the physical layer, it automatically records the timestamp of that moment and stores it in a hardware register. The software can then read the timestamp value from this register to obtain the actual arrival time of the data packet.
[0098] The reason for using hardware capture instead of software timestamp is that hardware capture has the following advantages: higher accuracy (the hardware records directly at the physical layer with a latency in the nanosecond range), lower latency (no need for multi-layer processing through the protocol stack), and is not affected by software scheduling jitter (the hardware completes automatically, regardless of CPU load).
[0099] In practical applications, the peripheral device's hardware captures the arrival timestamp of the first bit of all received RF packets and records it in a hardware register. The software reads and stores all timestamps in real time for subsequent clock skew calculations.
[0100] To further understand the wireless communication method provided in the embodiments of this disclosure, two specific examples will be described below.
[0101] Example 1: In this embodiment of the disclosure, the connection interval between the peripheral device and the central device is 1 second, the maximum error of the 32k RC oscillator of the peripheral device is 500ppm, and the error of the crystal of the central device does not exceed 50ppm.
[0102] After the peripheral device enters the heartbeat packet to maintain the connection, the initial value of p_error is set to 500ppm. During dynamic compensation, k_offset is continuously updated by capturing Tcap frame by frame and comparing it with Tcal. At the same time, p_error is adaptively adjusted according to the packet reception situation, gradually decreasing in increments of 25ppm when packets are received successfully consecutively, and rapidly increasing in increments of 50ppm when packets are received unsuccessfully.
[0103] After a period of dynamic compensation and adaptive adjustment, p_error can smoothly converge to the lower limit (e.g., 200ppm). At this time, the advance of the receiving window is reduced from the initial 500µs to about 200µs, and the average power consumption is reduced from about 10µA to about 8µA, saving about 20% energy.
[0104] Example 2: In this embodiment of the disclosure, it is assumed that p_error has been adjusted to 300ppm and the peripheral device is experiencing continuous packet reception errors.
[0105] According to the adaptive adjustment strategy of this disclosure embodiment, p_error increases by 50 ppm for each packet reception failure. Therefore, the order of p_error changes is: 300 ppm → 350 ppm → 400 ppm → 450 ppm → 500 ppm. When p_error reaches the upper limit of 500 ppm, it stops increasing.
[0106] As p_error increases rapidly, the receive window advance increases accordingly, thereby improving the packet reception success rate and helping the system recover quickly from packet loss. Once packet reception returns to normal, p_error gradually decreases at a slower rate (25ppm each time), ensuring stable connection while minimizing power consumption.
[0107] Thus, using the wireless communication method provided in this embodiment, in a point-to-point topology low-power Bluetooth device heartbeat packet-based connection maintenance state, the original average power consumption is 10µA, the maximum error of the peripheral device at 32k RC is 500ppm, and the error of the central device does not exceed 50ppm. In a normal radio frequency (RF) environment, the original 500µs reception window advance of the peripheral device can be reduced to about 200µs, and the average power consumption can be reduced from 10µA to about 8µA, resulting in energy savings of approximately 20% in this scenario. Considering other usage scenarios, the overall product achieves energy savings of approximately 15%.
[0108] In the description of this specification, references to terms such as "some possible implementations," "some implementations," "example," "specific example," or "some examples" indicate that a specific feature, structure, material, or characteristic described in connection with that implementation or example is included in at least one implementation or example of this disclosure, and the aforementioned terms do not necessarily refer to the same implementation or example. Furthermore, the described specific features, structures, materials, or characteristics can be combined in a suitable manner in any one or more implementations or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different implementations or examples described in this specification, as well as the features of different implementations or examples.
[0109] Regarding the method flowcharts of embodiments of this disclosure, certain operations are described as different steps performed in a certain order. Such flowcharts are illustrative and not restrictive. Some steps described herein may be grouped together and performed in a single operation, or some steps may be divided into multiple sub-steps, and some steps may be performed in an order different from that shown herein. The various steps shown in the flowcharts may be implemented in any way by any circuit structure and / or tangible mechanism (e.g., software running on a computer device, hardware (e.g., logic functions implemented by a processor or chip), and / or any combination thereof).
[0110] Those skilled in the art will understand that in the methods described in the above specific embodiments, the order in which the steps are written does not imply a strict execution order, and the specific execution order of each step should be determined by its function and possible internal logic.
[0111] Based on the same inventive concept, this disclosure also provides a wireless communication device corresponding to the wireless communication method. Since the principle of the device in this disclosure for solving the problem is similar to that of the wireless communication method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0112] Reference Figure 4The diagram shown is a schematic representation of a wireless communication device provided in an embodiment of this disclosure. This device is applied to a peripheral device, which is communicatively connected to a central device. The device includes: an acquisition module 201, a determination module 202, a compensation module 203, and an adjustment module 204; wherein... The acquisition module 201 is used to acquire the actual arrival time of the current data packet sent by the central device; The determination module 202 is used to determine clock deviation information based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; The compensation module 203 is used to compensate for the predicted arrival time of the next data packet based on clock deviation information. The adjustment module 204 is used to adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time, based on the current packet receiving situation.
[0113] This embodiment captures the actual arrival time of data packets from the central device, uses the difference between the actual arrival time and the locally predicted arrival time to dynamically compensate for the clock deviation of peripheral devices, and adaptively adjusts the advance of the receiving window according to the packet reception situation, thereby reducing the invalid opening time of the receiving window, reducing the power consumption of peripheral devices in the heartbeat packet-maintained connection state, and extending battery life.
[0114] In one possible implementation, the determining module 202 is configured to determine the clock offset information according to the following steps: Determine the connection interval between peripheral equipment and central equipment; Based on the ratio between the difference and the connection interval, the clock deviation coefficient of the peripheral device relative to the central device is obtained and used as clock deviation information.
[0115] In one possible implementation, the compensation module 203 is used to compensate for the predicted arrival time of the next data packet according to the following steps: Obtain the product of the connection interval and the clock skew coefficient; Add the arrival time of the current data packet to the product to obtain the predicted arrival time of the next data packet.
[0116] In one possible implementation, the determining module 202 is configured to determine the connection interval between the peripheral device and the central device according to the following steps: When the current data packet is not successfully received, the actual arrival time is an invalid value. When predicting the arrival time of the next data packet, the value of the connection interval is determined based on the number of data packets skipped between the current data packet and the most recent valid data packet.
[0117] In one possible implementation, it also includes: The smoothing module 205 is used to obtain the current clock deviation coefficient and the historical clock deviation coefficient corresponding to the current data packet for other frame data packets except the first frame data packet. The historical clock deviation coefficient is the cumulative result of the clock deviation coefficients of all previous frame data packets after smoothing filtering. The current clock deviation coefficient and the historical clock deviation coefficient are weighted and averaged, and the weighted average result is used as the clock deviation coefficient of the current frame.
[0118] In one possible implementation, the weighted average has the current clock deviation coefficient and the historical clock deviation coefficient each having a weight of half.
[0119] In one possible implementation, the adjustment module 204 is configured to adjust the advance by which the peripheral device opens the receiving window before the compensated predicted arrival time, according to the following steps: When the current data packet is successfully received, decrease the lead amount by one step increment; If the current data packet is not successfully received, increase the lead by a second step. The second step amplitude is greater than the first step amplitude.
[0120] In one possible implementation, the adjustment module 204 is further configured to: The lead amount stops decreasing when it decreases to the preset lower limit, and stops increasing when it increases to the preset upper limit.
[0121] In one possible implementation, the adjustment module 204 is further configured to: Before decreasing the lead amount in one step, determine that the number of consecutively successfully received data packets has reached a preset threshold.
[0122] In one possible implementation, the acquisition module 201 is configured to acquire the actual arrival time of the current data packet sent by the central device according to the following steps: The actual arrival time is obtained by capturing the arrival time of the radio frequency signal corresponding to the current data packet sent by the central device through hardware.
[0123] It should be noted that the apparatus in this embodiment can implement the various processes of the aforementioned method and achieve the same effects and functions, which will not be elaborated here.
[0124] This disclosure also provides an electronic device, such as... Figure 5 The diagram shown is a schematic representation of an electronic device structure provided in this embodiment of the present disclosure, including: a processor 301, a memory 302, and a bus 303. The memory 302 stores machine-readable instructions executable by the processor 301 (e.g., ...). Figure 4The device contains the execution instructions corresponding to the acquisition module 201, determination module 202, compensation module 203, and adjustment module 204. When the electronic device is running, the processor 301 and memory 302 communicate via bus 303. When machine-readable instructions are executed by the processor 301, the following processing is performed: Obtain the actual arrival time of the current data packet sent by the central device; Clock skew information is determined based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device. Based on clock skew information, compensate for the predicted arrival time of the next data packet; Based on the current packet reception status, adjust the lead time by which the peripheral devices open the receiving window before the compensated predicted arrival time.
[0125] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the wireless communication method described in the above-described method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0126] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the wireless communication method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0127] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0128] The various embodiments in this disclosure are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments. In particular, the description of the apparatus, device, and computer-readable storage medium embodiments is simplified because they are basically similar to the method embodiments, and the relevant parts can be referred to the description of the method embodiments.
[0129] The apparatus, device, and computer-readable storage medium provided in this disclosure correspond one-to-one with the method. Therefore, the apparatus, device, and computer-readable storage medium also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the apparatus, device, and computer-readable storage medium will not be repeated here.
[0130] Those skilled in the art will understand that embodiments of this disclosure can be implemented as methods and apparatus (devices or systems), or as computer-readable storage media. Therefore, this disclosure can be implemented entirely in hardware, entirely in software, or in a combination of software and hardware. Furthermore, this disclosure can be implemented as a computer-readable storage medium on one or more computer-readable storage media containing computer-usable program code (including, but not limited to, disk storage, read-only optical disc storage (CD-ROM), optical storage, etc.).
[0131] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices or systems), and computer-readable storage media according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to create a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or block diagrams.
[0132] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article including instruction means, wherein the instruction means implement the functions specified in one or more flowcharts and / or one or more blocks in a block diagram.
[0133] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more blocks in the block diagram.
[0134] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0135] Memory can include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0136] Computer-readable media include permanent and non-permanent, removable and non-removable media, which can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer-readable storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory, read-only memory, electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device. Furthermore, although the operations of the methods of this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. Additionally, certain steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple sub-steps.
[0137] While the spirit and principles of this disclosure have been described above with reference to several specific embodiments, it should be understood that this disclosure is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined. This disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A wireless communication method applied to a peripheral device, the peripheral device being in communication connection with a central device, the method comprising: include: Obtain the actual arrival time of the current data packet sent by the central device; Clock deviation information is determined based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; Based on the clock skew information, the predicted arrival time of the next data packet is compensated; Based on the current packet reception status, adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time.
2. The method of claim 1, wherein, The determination of clock offset information includes: Determine the connection interval between the peripheral device and the central device; Based on the ratio between the difference and the connection interval, the clock deviation coefficient of the peripheral device relative to the central device is obtained and used as the clock deviation information.
3. The method of claim 2, wherein, The compensation for the predicted arrival time of the next data packet includes: Obtain the product of the connection interval and the clock skew coefficient; The predicted arrival time of the next data packet is obtained by adding the arrival time of the current data packet to the product.
4. The method of claim 2, wherein, Determining the connection interval between the peripheral device and the central device includes: When the current data packet is not successfully received, the actual arrival time is invalid. When predicting the arrival time of the next data packet, the value of the connection interval is determined based on the number of data packets skipped between the current data packet and the most recent valid data packet.
5. The method according to claim 2, characterized in that, The method further includes: For all frame data packets except the first frame data packet, obtain the current clock deviation coefficient and the historical clock deviation coefficient corresponding to the current data packet. The historical clock deviation coefficient is the cumulative result of the clock deviation coefficients of all previous frame data packets after smoothing and filtering. The current clock deviation coefficient and the historical clock deviation coefficient are weighted and averaged, and the weighted average result is used as the clock deviation coefficient of the current frame.
6. The method according to claim 5, characterized in that, In the weighted average, the current clock deviation coefficient and the historical clock deviation coefficient each account for half the weight.
7. The method according to claim 1, characterized in that, The adjustment of the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time includes: When the current data packet is successfully received, the advance amount is reduced by a step increment. When the current data packet is not successfully received, the advance amount is increased by a second step. Wherein, the second step size is greater than the first step size.
8. The method according to claim 7, characterized in that, The method further includes: The advance amount stops decreasing when it decreases to a preset lower limit, and stops increasing when it increases to a preset upper limit.
9. The method according to claim 7, characterized in that, Before reducing the lead amount in one incremental step, the method further includes: Determine if the number of consecutively successfully received data packets reaches a preset threshold.
10. The method according to claim 1, characterized in that, The step of obtaining the actual arrival time of the current data packet sent by the central device includes: The actual arrival time is obtained by capturing the arrival time of the radio frequency signal corresponding to the current data packet sent by the central device through hardware.
11. A wireless communication device applied to a peripheral device, the peripheral device being communicatively connected to a central device, characterized in that, include: The acquisition module is used to acquire the actual arrival time of the current data packet sent by the central device; The determination module is used to determine clock deviation information based on the difference between the actual arrival time of the current data packet and the predicted arrival time determined based on the local clock information of the peripheral device; The compensation module is used to compensate for the predicted arrival time of the next data packet based on the clock deviation information. The adjustment module is used to adjust the advance amount by which the peripheral device opens the receiving window before the compensated predicted arrival time, based on the current packet reception status.
12. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is in operation, the processor communicates with the memory via the bus, and the machine-readable instructions, when executed by the processor, perform the wireless communication method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the wireless communication method as described in any one of claims 1 to 10.