A precise Bluetooth distance calculation method based on multi-stage RSSI filtering and dynamic path loss index.

CN122179728APending Publication Date: 2026-06-09GUIZHOU HUOYANSHAN ELECTRICAL CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUIZHOU HUOYANSHAN ELECTRICAL CORP
Filing Date
2026-03-10
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Traditional Bluetooth ranging technology suffers from signal fluctuations due to multipath effects in security-sensitive scenarios such as smart door locks, the inability of fixed path loss exponent processing to adapt to environmental changes, and the vulnerability of threshold triggering mechanisms to false triggering due to transient interference. Furthermore, existing solutions suffer from high hardware costs, data leakage risks, and response delays.

Method used

A multi-level RSSI filtering method (5-sample median filtering, 10th-order moving average filtering, and Kalman filtering) combined with the dynamic path loss index calculation method is adopted. By using a high sampling rate of 10Hz and local calculation, combined with three consecutive distance judgments and a ±0.2-meter fluctuation threshold to prevent instantaneous interference, a 0.3dB hysteresis interval is set to avoid frequent jumps in the n value, and a dynamic threshold of 0.5-30 meters is configured to adapt to different environments.

Benefits of technology

It effectively suppresses multipath signal fluctuations, improves ranging stability and real-time performance, reduces hardware costs, meets the needs of consumer-grade products, and has multiple security protection mechanisms to ensure the reliability and security of the system in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122179728A_ABST
    Figure CN122179728A_ABST
Patent Text Reader

Abstract

This invention relates to the field of IoT near-field identification and positioning technology, and particularly to a method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index. The method includes: acquiring Bluetooth signals broadcast by a mobile terminal through a Bluetooth Low Energy module, and extracting the original Received Signal Strength Indicator (RSSI) value; sequentially processing the original RSSI value using 5-sample median filtering, 10th-order moving average filtering, and Kalman filtering; calculating the standard deviation based on the RSSI samples, dynamically adjusting the path loss index n according to the standard deviation, and calculating the transition interval using a linear interpolation formula when the standard deviation and path loss index meet preset requirements; calculating the actual distance using a logarithmic path loss model, and triggering authorization control logic when the actual distance calculated three consecutive times meets the conditions. This invention achieves high-precision, low-latency, and low-cost Bluetooth ranging through three-level filtering and dynamic path loss index adjustment, and is suitable for authorization control in multiple scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of IoT near-field identification and positioning technology, and in particular to a method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index. Background Technology

[0002] Traditional RSSI-based Bluetooth ranging technology faces several technical bottlenecks: First, signal fluctuations caused by multipath effects can lead to RSSI value fluctuations of up to ±15dB in indoor environments. Second, the path loss index is fixed, with existing solutions often using empirical values ​​of 2.0-4.0, which cannot adapt to environmental changes from open spaces to areas with dense obstacles. Third, the threshold triggering mechanism is simplistic, relying solely on a single RSSI threshold for judgment, making it susceptible to momentary interference that can lead to false triggering.

[0003] Existing solutions have significant limitations: MAC address-based identification is no longer effective due to system privacy policies (Android 10+, iOS 14+); cloud-based solutions pose data leakage risks and response delays; and solutions using dedicated positioning chips (such as UWB) have high hardware costs, failing to meet the needs of consumer products. These technical bottlenecks limit the application of traditional Bluetooth ranging in security-sensitive scenarios such as smart door locks, necessitating a breakthrough solution. Summary of the Invention

[0004] The purpose of this invention is to provide a method for accurately calculating Bluetooth distance based on multi-level RSSI filtering and dynamic path loss index, thereby solving the above-mentioned technical problems existing in the prior art.

[0005] To achieve the above objectives, this invention provides a method for accurately calculating Bluetooth distance based on multi-level RSSI filtering and dynamic path loss exponent, comprising the following steps: S1. Acquire the Bluetooth signal broadcast by the mobile terminal at a sampling rate of 10Hz using the Bluetooth Low Energy module, and extract the original Received Signal Strength Indicator (RSSI) value. Among them, the Bluetooth Low Energy model is BLE 5.0 and above; S2. Perform 5-sample median filtering, 10th-order moving average filtering and Kalman filtering on the original RSSI values ​​in sequence. Among them, median filtering is used to remove extreme values, moving average filtering is used to smooth signal fluctuations, and Kalman filtering is used to dynamically correct noise interference. S3. Calculate the standard deviation σ based on 30 filtered RSSI samples, and dynamically adjust the path loss index n according to the standard deviation. When the standard deviation and path loss index meet the preset requirements, the transition interval is calculated using a linear interpolation formula, and a hysteresis interval of 0.3 is set. S4. The actual distance is calculated using a logarithmic path loss model. When the actual distance calculated for three consecutive times is ≤ the preset distance threshold and the distance fluctuation is ≤ ±0.2 meters, the authorization control logic is triggered. The preset distance threshold is configured as any value within the range of 0.5-30m.

[0006] In some embodiments of this application, in S2, performing 5-sample median filtering includes: Five consecutive raw RSSI samples are collected. The maximum and minimum values ​​are removed using a quicksort algorithm. The arithmetic mean of the three middle samples is taken as the filtered result. The calculation formula is as follows: ; in, The result of the filtering is as follows. All are sorted sample arrays.

[0007] In some embodiments of this application, in step S2, performing a 10th-order moving average filter includes: The median filtering results are weighted and summed using a weighted coefficient array [0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.15, 0.1, 0.1, 0.05]. The calculation formula is as follows: ; in, For the k-th order weighting coefficients, , For the weighted summation result, This is the received signal strength indication value after median filtering of the k-th order.

[0008] In some embodiments of this application, in step S3, calculating the standard deviation σ based on 30 filtered RSSI samples includes: Collect 30 filtered RSSI samples and calculate the mean. ; Calculate the standard deviation ,in Let be the value of the i-th sample.

[0009] In some embodiments of this application, S4 further includes: Set up a relay attack protection mechanism: When the distance change calculated twice consecutively is greater than 5m / s, automatically reset the trigger counter and enter the anomaly detection state.

[0010] In some embodiments of this application, in S2, the median filtering window for 5 samples is selected as 3-7 samples, and the moving average order is selected as 8-12. The noise covariance of the Kalman filter process is selected as 0.05-0.2; the noise covariance of the Kalman filter measurement is selected as 0.5-2.0.

[0011] In some embodiments of this application, in S3, the adjustment range of the path loss index n is 2.0-4.0; When in an open outdoor environment, the path loss index n can be adjusted to a range of 2.0-2.5. In a semi-open environment, the path loss exponent n can be adjusted from 2.5 to 3.0. When in a complex indoor environment, the path loss index n can be adjusted to a range of 3.0-3.5. In extreme multipath environments, the path loss exponent n can be adjusted from 3.5 to 4.0.

[0012] In some embodiments of this application, in step S4, the method for configuring the preset distance threshold includes: When applied to smart door locks, the preset distance threshold is configured to 0.5m; When applied in the warehousing and logistics field, the preset distance threshold is configured as 30m; When applied to the field of shared devices, the preset distance threshold is configured to 5m; When used in pet anti-loss applications, the preset distance threshold is set to 2m; When applied to the smart home field, the preset distance threshold is configured to 8m.

[0013] The advantages and beneficial effects of this invention compared to the prior art are: 1. This invention employs a three-stage cascaded filtering mechanism (5-sample median filtering - 10th-order weighted moving average - Kalman filtering) to progressively reduce noise in the original RSSI signal, effectively suppressing ±15dB signal fluctuations caused by multipath effects. Simultaneously, based on the standard deviation σ of 30 filtered samples, the path loss exponent n (range 2.0-4.0) is dynamically adjusted, enabling the system to adaptively identify different environments such as open outdoor spaces, semi-open spaces, complex indoor environments, and extreme multipath effects. Combined with a 0.3dB hysteresis interval, this avoids frequent jumps in the value of n, thus improving stability.

[0014] 2. This invention adopts a 10Hz high sampling rate combined with a local computing architecture, and compresses the data processing latency to less than 500ms through optimized filtering algorithms to meet the real-time requirements of contactless unlocking; at the same time, it sets up multiple security protection mechanisms: three consecutive distance judgments combined with a ±0.2m fluctuation threshold prevent instantaneous interference from triggering falsely, and relay attack detection with a 5m / s speed threshold can automatically reset the abnormal state.

[0015] 3. This invention is based on the BLE5.0 universal module, eliminating the need for dedicated positioning chips such as UWB, which greatly saves hardware costs and meets the needs of large-scale mass production of consumer products; modular parameter configuration can adapt to diverse application scenarios.

[0016] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0017] Figure 1 This is a flowchart of a method for accurately calculating Bluetooth distance based on multi-level RSSI filtering and dynamic path loss index in an embodiment of the present invention. Detailed Implementation

[0018] In the description of this invention, it should be noted that the terms "upper," "lower," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product is in use. They are used only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," and "connect" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0019] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0020] like Figure 1 As shown, this invention provides a method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss exponent, including the following steps: S1. Acquire the Bluetooth signal broadcast by the mobile terminal at a sampling rate of 10Hz using the Bluetooth Low Energy module, and extract the original Received Signal Strength Indicator (RSSI) value. Among them, the Bluetooth Low Energy model is BLE 5.0 and above; S2. Perform 5-sample median filtering, 10th-order moving average filtering and Kalman filtering on the original RSSI values ​​in sequence. Among them, median filtering is used to remove extreme values, moving average filtering is used to smooth signal fluctuations, and Kalman filtering is used to dynamically correct noise interference. S3. Calculate the standard deviation σ based on 30 filtered RSSI samples, and dynamically adjust the path loss index n according to the standard deviation. When the standard deviation and path loss index meet the preset requirements, the transition interval is calculated using a linear interpolation formula, and a hysteresis interval of 0.3 is set. When σ < 2dB, n = 2.0; when σ > 4dB, n = 3.5. The transition interval is calculated using the linear interpolation formula n = 2.0 + 0.75 × (σ - 2), and a hysteresis interval of 0.3 is set to avoid frequent fluctuations.

[0021] S4. The actual distance is calculated using a logarithmic path loss model. When the actual distance calculated for three consecutive times is ≤ the preset distance threshold and the distance fluctuation is ≤ ±0.2 meters, the authorization control logic is triggered. This invention employs a three-stage cascaded filtering mechanism (5-sample median filtering - 10th-order weighted moving average - Kalman filtering) to progressively reduce noise in the original RSSI signal, effectively suppressing ±15dB signal fluctuations caused by multipath effects. Simultaneously, based on the standard deviation σ of 30 filtered samples, the path loss exponent n (range 2.0-4.0) is dynamically adjusted, enabling the system to adaptively identify different environments such as open outdoor spaces, semi-open spaces, complex indoor environments, and extreme multipath effects. Combined with a 0.3dB hysteresis range, frequent jumps in the value of n are avoided, thus improving stability.

[0022] This invention employs a 10Hz high sampling rate combined with a local computing architecture. By optimizing the filtering algorithm, the data processing latency is compressed to less than 500ms, meeting the real-time requirements of seamless unlocking. At the same time, multiple security protection mechanisms are set up: three consecutive distance judgments combined with a ±0.2-meter fluctuation threshold prevent accidental triggering due to instantaneous interference, and relay attack detection with a 5m / s speed threshold can automatically reset the abnormal state.

[0023] The preset distance threshold is configured as any value within the range of 0.5-30m.

[0024] In some embodiments of this application, in S2, performing 5-sample median filtering includes: Five consecutive raw RSSI samples are collected. The maximum and minimum values ​​are removed using a quicksort algorithm. The arithmetic mean of the three middle samples is taken as the filtered result. The calculation formula is as follows: ; in, The result of the filtering is as follows. All are sorted sample arrays.

[0025] In some embodiments of this application, in step S2, performing a 10th-order moving average filter includes: The median filtering results are weighted and summed using a weighted coefficient array [0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.15, 0.1, 0.1, 0.05]. The calculation formula is as follows: ; in, For the k-th order weighting coefficients, , For the weighted summation result, This is the received signal strength indication value after median filtering of the k-th order.

[0026] In some embodiments of this application, in step S3, calculating the standard deviation σ based on 30 filtered RSSI samples includes: Collect 30 filtered RSSI samples and calculate the mean. ; Calculate the standard deviation ,in Let be the value of the i-th sample.

[0027] In some embodiments of this application, S4 further includes: Set up a relay attack protection mechanism: When the distance change calculated twice consecutively is greater than 5m / s, automatically reset the trigger counter and enter the anomaly detection state.

[0028] In some embodiments of this application, in S2, the median filtering window for 5 samples is selected as 3-7 samples, and the moving average order is selected as 8-12. The noise covariance of the Kalman filter process is selected as 0.05-0.2; the noise covariance of the Kalman filter measurement is selected as 0.5-2.0.

[0029] In some embodiments of this application, in S3, the adjustment range of the path loss index n is 2.0-4.0; When in an open outdoor environment, the path loss index n can be adjusted to a range of 2.0-2.5. In a semi-open environment, the path loss exponent n can be adjusted from 2.5 to 3.0. When in a complex indoor environment, the path loss index n can be adjusted to a range of 3.0-3.5. In extreme multipath environments, the path loss exponent n can be adjusted from 3.5 to 4.0.

[0030] In some embodiments, a dynamic adjustment mechanism for the path loss index (n value) based on environment awareness is also included to address the adaptability issues of traditional fixed-parameter models in complex scenarios. The system calculates the statistical characteristics of the most recent 50 RSSI samples every 300ms, using the standard deviation (σ) to determine environmental complexity: n=2.0 when σ<2dB (e.g., open outdoor environment); n=3.5 when σ>4dB (e.g., multi-partition indoor environment); the transition interval uses a linear interpolation formula. Dynamic adjustment. To avoid frequent fluctuations in the n value, a hysteresis interval of 0.3 is set: when the environment changes from complex to simple, a decrease in the n value is triggered only when σ ≤ 1.7 dB; when the environment changes from simple to complex, an increase in the n value is triggered only when σ ≥ 4.3 dB. The n value adjustment algorithm is as follows: ① Collect 50 filtered RSSI samples; ② Calculate the mean μ and standard deviation σ; ③ Determine the n value based on the σ value interval; ④ Determine whether to update the n value based on the hysteresis rule; ⑤ Input the n value into the logarithmic path loss model to calculate the distance. In an office environment test (σ = 3.2 dB), the dynamic n value reduced the distance measurement error at 10 meters from ±2.1 meters to ±0.3 meters, improving accuracy by 700%.

[0031] In some embodiments of this application, in step S4, the method for configuring the preset distance threshold includes: When applied to smart door locks, the preset distance threshold is configured to 0.5m; at this time, the ranging error is ≤ ±0.1m, the response time is ≤300ms, and it is compatible with home anti-theft locks, office access control and other devices, achieving contactless unlocking through close-range authorization.

[0032] When applied in the warehousing and logistics field, the preset distance threshold is configured to 30m; at this time, the ranging error is ≤±3 meters, and it supports simultaneous recognition of multiple tags (≥20 tags / second), and is compatible with asset tracking equipment such as warehouse shelf tags, logistics turnover boxes, and medical equipment positioning.

[0033] When applied to the field of shared devices, the preset distance threshold is configured to 5m; it supports dynamic authorization range adjustment (1-10 meters), and is compatible with shared bicycles, shared power banks, vending machines and other devices, enabling automatic unlocking when the user approaches.

[0034] When applied to pet anti-loss applications, the preset distance threshold is configured to 2m; it supports multi-level warnings (2-meter warning, 5-meter alarm), and is compatible with wearable devices such as pet collars and child locators, preventing pets from getting lost through distance abrupt change detection.

[0035] When applied to the smart home field, the preset distance threshold is configured to 8m. It supports device linkage triggering (such as automatically turning on lights when approaching), and is compatible with smart switches, environmental sensors, home appliance controls, and other devices to achieve scenario-based smart home control.

[0036] In some embodiments, a multi-condition collaborative distance threshold triggering logic is designed to avoid the risk of false authorization caused by a single parameter judgment. Authorization triggering requires that three conditions be met simultaneously: ①RPA address verification passed (AES-CMAC algorithm matches IRK key); ② The filtered RSSI value is greater than or equal to the preset threshold (the corresponding distance is less than or equal to the configured value); ③ The distance fluctuation Δd ≤ ±0.2 meters after three consecutive tests (100ms interval).

[0037] The system supports dynamic threshold configuration from 0.5 to 30 meters. Distance codes (0x00 = 0.5 m / -50 dBm, 0x01 = 5 m / -65 dBm, 0x02 = 30 m / -85 dBm) can be written using the GATT feature value 0000FFE2. For relay attack protection, a distance mutation detection mechanism is designed: when two consecutive distance changes are detected to be greater than 5 m / s, the system automatically enters a verification lock state and records an anomaly log. The trigger logic state machine includes four states: standby (scanning broadcast packets), verification (RPA matching), ranging (continuous sampling), and authorization (triggering peripherals). State transitions must meet strict preconditions to ensure decision reliability in complex electromagnetic environments.

[0038] The following experimental verification is conducted in conjunction with the embodiments.

[0039] The hardware implementation of this invention is based on a low-cost embedded system architecture. The core algorithm is implemented in C language and embedded in the MCU Flash. The software adopts an event-driven design to ensure low-power operation. The overall system BOM cost is controlled within 8 yuan, and it can be directly integrated into micro-devices such as smart door locks and asset tags. During implementation, key attention needs to be paid to the RF circuit layout (ensuring antenna efficiency ≥60%), the real-time performance of the filtering algorithm (single processing time ≤1ms), and the security of encrypted storage (AES-128 hardware encryption). Modular design achieves end-to-end optimization from signal acquisition to distance output.

[0040] Step 1: Hardware system design and core component selection.

[0041] The hardware system is based on a "Bluetooth module + MCU" architecture, with peripheral circuits including power management, RF matching, and memory expansion modules, totaling ≤25 components. The selection of core components follows the principle of "performance meets standards + optimal cost," and key parameters are shown in Table 1. Table 1 Hardware System Parameters

[0042] Key hardware design considerations: The Bluetooth module communicates with the MCU via a UART interface (115200bps baud rate, hardware flow control). The RF circuit employs a π-type matching network (1nH inductor + 2pF capacitor) to optimize impedance matching. The power path design supports dual power supply from a CR2032 coin cell battery (3V) and USB 5V, automatically switching and prioritizing external power. The PCB layout adopts an RF-digital partitioning design, with antenna area clearance ≥2mm, and differential routing of critical signal lines (0.2mm line width, 0.3mm spacing) to reduce EMI interference. In smart door lock applications, the overall hardware size can be controlled within 30×40mm, meeting embedded installation requirements.

[0043] Step 2: Implementation of multi-stage filtering algorithm.

[0044] The multi-stage filtering algorithm is implemented in the MCU through interrupt service routines (ISR) and the main loop. The raw RSSI data is collected every 100ms, and after three stages of processing, a stable value is output. This is implemented using code.

[0045] The optimization of the filter window size is based on the following: 5-sample median filtering effectively eliminates sudden interference (such as a sharp drop in RSSI caused by Wi-Fi frame collisions) while controlling data latency to within 400ms; the 10th-order moving average uses a weighted strategy with lighter weights at the beginning and heavier weights at the end to balance the smoothing effect of historical data with the response speed of new samples; and Kalman filtering further suppresses slowly changing environmental interference (such as signal shadowing effects caused by people moving around) by dynamically adjusting the noise covariance. In smart home environment testing, the three-stage filtering reduced the RSSI standard deviation from 12dB to 1.8dB, providing a stable input for distance calculation.

[0046] Step 3: Implement the code for adjusting the dynamic path loss index.

[0047] The path loss index (n value) dynamic adjustment algorithm is executed every 300ms. It achieves environmental adaptation by analyzing the statistical characteristics of the most recent 50 filtered RSSI samples and is implemented in code.

[0048] Environmental Adaptive Implementation Example: In an open outdoor environment (σ=1.5dB), the system automatically adjusts the n value to 2.0, resulting in a distance measurement error of ±0.2 meters at 10 meters. Upon entering an indoor multi-partition environment (σ=4.5dB), the n value increases to 3.5, reducing the distance measurement error at 5 meters from ±1.8 meters to ±0.3 meters. In a semi-open corridor environment (σ=2.8dB), n=2.0+0.75 is calculated using a linear interpolation formula. (2.8-2)=2.6, achieving smooth adaptation in the transition region. The hysteresis interval design effectively avoids the jitter of the n value caused by brief occlusion by people, reducing the adjustment frequency from 2Hz without hysteresis to 0.3Hz, thereby reducing system power consumption.

[0049] Step 4: Distance threshold triggering logic and security protection.

[0050] The system uses a finite state machine to manage the authorization process and achieves safe and reliable distance threshold triggering through multi-condition judgment, which is implemented in code.

[0051] The security protection mechanism includes: relay attack protection (verification is reset upon detecting a sudden change in distance >20 cm / 100 ms), RPA address dynamic verification (address is updated every 15 minutes to prevent MAC address spoofing), and encrypted storage of initialization information (IRK key encrypted with AES-128 and stored in the Flash encrypted partition). In smart door lock applications, the system strictly controls the authorization process through a state machine: from standby to final authorization, RPA verification (time ≤100 ms) and three consecutive distance detections (total time 300 ms) must be completed. The response time of ≤500 ms throughout the process meets the user's need for seamless interaction, while multi-condition judgment controls the probability of false authorization to below 0.01%.

[0052] The following performance testing and verification are conducted: To comprehensively verify the actual effect of the technical solution of this invention, the testing team carried out multi-dimensional tests in a standardized laboratory environment and real application scenarios, covering four major indicators: steady-state ranging accuracy, system power consumption characteristics, cross-platform compatibility, and security protection capabilities. The test adopted the controlled variable method, and by comparing the key data of the traditional fixed parameter scheme and the dynamic adjustment scheme of this invention, the performance improvement brought by the multi-level filtering and dynamic n-value adjustment technology was quantitatively verified. The test environment strictly followed GB / T38636-2020 "Test Specification for IoT Sensing Layer Devices", and the key equipment included a spectrum analyzer (R&SFSV13), a high-precision positioning robot (positioning accuracy ±0.5mm), an electromagnetic compatibility anechoic chamber (3m method), and multiple brands of smartphone terminals.

[0053] Steady-state performance testing: In three typical application scenarios, a high-precision positioning platform was used to control the test mobile phone at three key distance points of 0.5 meters, 10 meters, and 30 meters for fixed-point testing. 100 sets of sample data were collected at each distance, and the mean error and standard deviation were calculated. The test results are shown in Table 2, indicating that the proposed solution is significantly superior to the traditional fixed n-value solution (n=2.5) in all scenarios.

[0054] Table 2 Steady-state performance test results

[0055] In a multi-partition office environment (σ=3.2dB), traditional methods at a distance of 10 meters suffer from RSSI fluctuations of ±8dB due to multipath effects, resulting in drastic range-bound distance measurement between 7.9 and 12.1 meters. This invention dynamically adjusts the n-value to 3.2, combined with three-stage filtering, to control RSSI fluctuations within ±1.2dB, stabilizing the distance measurement within the 9.72-10.28 meter range, with a 95% confidence interval error of only ±0.28 meters. In a 30-meter long-distance test, the dynamic n-value algorithm effectively compensates for changes in signal attenuation characteristics, reducing the error from ±5.7 meters in traditional methods to ±0.89 meters, meeting the accuracy requirements of asset tracking scenarios.

[0056] Power consumption characteristics and battery life test: Based on the power supply conditions of a CR2032 button battery (220mAh), the system current consumption was tested under different operating conditions. The average power consumption and theoretical battery life were calculated by weighting the duty cycle. The test used a high-precision current probe (Tektronix TCP0030) in conjunction with an oscilloscope to collect transient current. The results are shown in Table 3.

[0057] Table 3 Power consumption characteristics and battery life test results

[0058] The dynamic broadcast interval strategy enables the Bluetooth module to use a 2-second scanning interval when no device is present, automatically switching to a 500ms interval when a potential device is detected, reducing scanning power consumption by 60% compared to a fixed 500ms interval. Hardware implementation of the multi-level filtering algorithm (accelerated by the Bluetooth module's built-in DSP) reduces the energy consumption for a single ranging calculation from 2.1mJ to 0.7mJ. The MCU's Stop2 mode (current ≤10μA) combined with the event-triggered wake-up mechanism controls the system's idle power consumption to 8.7μA. In practical applications, due to the extremely low percentage of authorized triggers (<0.01%), the CR2032 battery achieved a tested battery life of 6.2 months, meeting the maintenance-free requirements of scenarios such as smart door locks.

[0059] Cross-platform compatibility testing: Mainstream models of HarmonyOS, Android, and iOS were selected to test three key indicators: ranging consistency, response time, and recognition success rate. A total of 500 valid samples were tested for each model. The results of the cross-platform compatibility testing are shown in Table 4.

[0060] Table 4 Cross-platform compatibility test results

[0061] Analysis revealed compatibility optimization measures: For iOS, the RPA address update mechanism (forced refresh every 15 minutes) was addressed by maintaining a 30-minute address cache list on the device side to prevent verification failures; Huawei's HarmonyOS distributed Bluetooth feature required adding device type identifiers (0x01 = master device, 0x02 = slave device) to the broadcast packet; Android fragmentation issues were resolved by dynamically adjusting the scanning window (30ms for Xiaomi models, 20ms for OPPO models). No more than three consecutive recognition failures occurred during testing, and all anomalies automatically recovered within three scan cycles, meeting industrial-grade reliability requirements.

[0062] Security and anti-interference testing: Typical interference scenarios were simulated in an electromagnetic compatibility anechoic chamber. A 2.4GHz band interference signal (power -80dBm to -40dBm) was injected through a signal generator to test the system's ranging stability. Replay attacks and relay attacks were carried out using professional Bluetooth attack tools (UbertoothOne + Kismet) to verify the effectiveness of security protection.

[0063] Narrowband interference protection: By injecting -60dBm interference signals at three key frequency points of 2402MHz (channel 1), 2441MHz (channel 11), and 2480MHz (channel 14), the ranging error of the present invention increases by ≤8% (the error increase of the traditional solution reaches 35%). Anti-interference is achieved through frequency hopping scanning (switching 3 broadcast channels per second) and signal quality weighting algorithm.

[0064] Replay attack protection: When a replay attack is launched using the recorded RPA address and RSSI value, the system successfully intercepts 100% of the attack attempts through timestamp verification (broadcast contains a 4-byte UTC timestamp) and distance mutation detection (two consecutive distance differences > 5 meters / second), resulting in an attack success rate of 0%.

[0065] Physical security protection: After physical disassembly of the device, the data in the Bluetooth module's Flash encrypted partition is encrypted with AES-128 and displayed as random ciphertext when analyzed using a hexadecimal editor; when attempting to read MCU data through the JTAG interface, the hardware security fuse automatically blows, triggering the key erasure mechanism.

[0066] Relay attack protection: A signal relay device is used at a distance of 10 meters to amplify the RSSI value (from -65dBm to -45dBm, simulating a close-range illusion). The system identifies anomalies by detecting the rate of change of RSSI (RSSI change ≤2dB / second in normal mobile scenarios), triggers secondary verification (requiring 3 consecutive stable tests), and successfully thwarts the relay attack.

[0067] Security test results show that the present invention maintains ranging accuracy under electromagnetic interference environment, and resists common Bluetooth attack methods through multi-layer security mechanisms, meeting the level 2 protection standard specified in GB / T22239-2019.

[0068] In this application, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. In case of any inconsistency, the meaning set forth in this specification or derived from the content described herein shall prevail. Furthermore, the terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit the scope of this application.

[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A Bluetooth distance precision calculation method based on multi-stage RSSI filtering and dynamic path loss exponent, characterized in that, Includes the following steps: S1. Acquire the Bluetooth signal broadcast by the mobile terminal at a sampling rate of 10Hz using the Bluetooth Low Energy module, and extract the original Received Signal Strength Indicator (RSSI) value. Among them, the Bluetooth Low Energy model is BLE 5.0 and above; S2. Perform 5-sample median filtering, 10th-order moving average filtering and Kalman filtering on the original RSSI values ​​in sequence. Among them, median filtering is used to remove extreme values, moving average filtering is used to smooth signal fluctuations, and Kalman filtering is used to dynamically correct noise interference. S3. Calculate the standard deviation σ based on 30 filtered RSSI samples, and dynamically adjust the path loss index n according to the standard deviation. When the standard deviation and path loss index meet the preset requirements, the transition interval is calculated using a linear interpolation formula, and a hysteresis interval of 0.3 is set. S4. The actual distance is calculated using a logarithmic path loss model. When the actual distance calculated for three consecutive times is ≤ the preset distance threshold and the distance fluctuation is ≤ ±0.2 meters, the authorization control logic is triggered. The preset distance threshold is configured as any value within the range of 0.5-30m.

2. The method of claim 1, wherein the method is a Bluetooth distance accurate calculation method based on multi-stage RSSI filtering and dynamic path loss exponent, characterized in that, In S2, the 5-sample median filtering includes: Five consecutive raw RSSI samples are collected. The maximum and minimum values ​​are removed using a quicksort algorithm. The arithmetic mean of the three middle samples is taken as the filtered result. The calculation formula is as follows: ; in, The result of the filtering is as follows. All are sorted sample arrays.

3. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index according to claim 2, characterized in that, In S2, performing a 10th-order moving average filter includes: The median filtering results are weighted and summed using a weighted coefficient array [0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.15, 0.1, 0.1, 0.05]. The calculation formula is as follows: ; in, For the k-th order weighting coefficients, , For the weighted summation result, This is the received signal strength indication value after median filtering of the k-th order.

4. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index according to claim 3, characterized in that, In step S3, the standard deviation σ is calculated based on 30 filtered RSSI samples, including: Collect 30 filtered RSSI samples and calculate the mean. ; Calculate the standard deviation ,in Let be the value of the i-th sample.

5. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss exponent as described in claim 4, characterized in that, S4 also includes: Set up a relay attack protection mechanism: When the distance change calculated twice consecutively is greater than 5m / s, automatically reset the trigger counter and enter the anomaly detection state.

6. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss exponent as described in claim 5, characterized in that, In S2, the median filtering of 5 samples involves selecting 3-7 samples for the median filtering window and selecting an 8-12 order for the moving average. The noise covariance of the Kalman filter process is selected as 0.05-0.2; the noise covariance of the Kalman filter measurement is selected as 0.5-2.

0.

7. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index according to claim 6, characterized in that, In S3, the path loss index n is adjusted within the range of 2.0-4.0; When in an open outdoor environment, the path loss index n can be adjusted to a range of 2.0-2.

5. In a semi-open environment, the path loss exponent n can be adjusted from 2.5 to 3.

0. When in a complex indoor environment, the path loss index n can be adjusted to a range of 3.0-3.

5. In extreme multipath environments, the path loss exponent n can be adjusted from 3.5 to 4.

0.

8. The method for accurate Bluetooth distance calculation based on multi-level RSSI filtering and dynamic path loss index according to claim 7, characterized in that, In step S4, the method for configuring the preset distance threshold includes: When applied to smart door locks, the preset distance threshold is configured to 0.5m; When applied in the warehousing and logistics field, the preset distance threshold is configured as 30m; When applied to the field of shared devices, the preset distance threshold is configured to 5m; When used in pet anti-loss applications, the preset distance threshold is set to 2m; When applied to the smart home field, the preset distance threshold is configured to 8m.