Ranging method and device based on signal strength indication (RSSI)
By linear weighting fitting of broadcast packets of multiple Bluetooth channels, the problem of inaccurate RSSI ranging is solved, and higher ranging accuracy is achieved.
Patent Information
- Application Number
- CN202311051564.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2025-02-21
AI Technical Summary
The ranging method based on signal strength indication (RSSI) has problems with inaccuracy, mainly because the total signal contains noise energy, resulting in inaccuracy of RSSI.
By scanning broadcast packets from different Bluetooth channels, multiple linear structures are generated and RSSI in the target linear structure that meets preset conditions are linearly weighted. The closer the broadcast packet to the current time, the higher the RSSI weight corresponding to it is, thereby improving the accuracy of distance measurement.
Linear weighted fitting improves the accuracy of RSSI, making the distance calculated based on RSSI more accurate and reducing the noise impact.
Smart Images

Figure CN119497187A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminals, and in particular to a ranging method and device based on signal strength indication (RSSI). Background Art
[0002] The distance measurement method based on received signal strength indication (RSSI) is a commonly used distance measurement method. It uses the principle that radio signals attenuate regularly as the distance increases to measure the distance between nodes. For example, the distance between a mobile phone and a Bluetooth headset can be measured by RSSI ranging. When the distance is within a preset distance range (for example, [20,50] cm), the mobile phone can pop up a pairing box for the user to choose whether to pair.
[0003] However, there are some factors in RSSI ranging that may lead to inaccurate ranging results. For example, the RSSI at the receiving end is generally the energy of the total signal detected by RF, and the total signal is the superposition of various noise energies and effective signal energy. Since the total signal also carries noise energy, the RSSI is inaccurate, which leads to inaccurate distance determined by RSSI. Summary of the invention
[0004] The embodiments of the present application provide a ranging method and device based on signal strength indication (RSSI), which can improve the accuracy of ranging based on RSSI.
[0005] In a first aspect, an embodiment of the present application provides a ranging method based on signal strength indication RSSI, which is applied to a first electronic device, including: scanning a first broadcast data packet, the first broadcast data packet includes multiple second broadcast data packets from a second electronic device, and the multiple second broadcast data packets are from different Bluetooth channels; determining the RSSI corresponding to each second broadcast data packet in the multiple second broadcast data packets; generating multiple different linear structures, the multiple different linear structures respectively include the RSSI corresponding to the second broadcast data packets from different Bluetooth channels; determining a target linear structure that meets preset conditions from the multiple different linear structures; performing linear weighted fitting on the RSSI in the target linear structure, and determining the RSSI corresponding to the current time according to the linear weighted fitting result; wherein, the closer the RSSI corresponding to the second broadcast data packet is to the current time, the higher the weight; determining the distance between the first electronic device and the second electronic device at the current time according to the RSSI corresponding to the current time.
[0006] Based on the method provided in the embodiment of the present application, the first electronic device can store broadcast data packets (second broadcast data packets) from different Bluetooth channels into different linear structures (e.g., linked lists), and then perform linear weighted fitting on the RSSI corresponding to the broadcast data packets in the target linear structure that meets the preset conditions. By setting the weights of the RSSI corresponding to different broadcast data packets, the weight of the RSSI corresponding to the broadcast data packet closer to the current time is higher (larger), and the weight of the RSSI corresponding to the broadcast data packet farther from the current time is lower (smaller). Compared with taking the average of the RSSI corresponding to multiple broadcast data packets (e.g., the 5 most recently reported broadcast data packets), the timeliness of linear fitting of the RSSI corresponding to different broadcast data packets is better, so that the distance calculated based on the RSSI will be more accurate.
[0007] In a possible implementation, determining a target linear structure that meets a preset condition from a plurality of different linear structures includes: determining a linear structure of a Bluetooth channel corresponding to a preset classification from a plurality of different linear structures; if the plurality of different linear structures include a linear structure of a Bluetooth channel corresponding to a preset classification, determining the linear structure of the Bluetooth channel corresponding to the preset classification as the target linear structure; if the plurality of different linear structures include a plurality of linear structures of Bluetooth channels corresponding to a preset classification, determining the linear structure with the smallest data fluctuation among the linear structures of the Bluetooth channels corresponding to the preset classification as the target linear structure. It should be noted that the broadcast data packet in the linear structure (e.g., a linked list) with the smallest data fluctuation is subject to the least interference. It is understandable that the broadcast data packet sent by the transmitter (e.g., a Bluetooth headset) may be interfered by a sudden factor (e.g., suddenly blocked), thereby causing the RSSI calculated based on the broadcast data packet to be inaccurate. If the data fluctuation of the linked list corresponding to the Bluetooth channel is small, it means that the Bluetooth channel is less interfered than other Bluetooth channels, and the distance calculated based on the RSSI corresponding to the broadcast data packet in the linked list corresponding to the Bluetooth channel will be more accurate.
[0008] In a possible implementation, performing linear weighted fitting on the RSSI in the target linear structure, and determining the RSSI corresponding to the current time according to the linear weighted fitting result includes: when the target linear structure includes multiple linear structures, performing linear weighted fitting on the RSSI in each linear structure in the target linear structure to obtain multiple linear weighted fitting results; determining the RSSI corresponding to the current time according to each linear weighted fitting result in the multiple linear weighted fitting results, and obtaining multiple RSSIs corresponding to the current time; determining the distance between the first electronic device and the second electronic device at the current time according to the RSSI corresponding to the current time includes: determining the distance between the first electronic device and the second electronic device at the current time according to the RSSI corresponding to the multiple current times, and obtaining multiple distances; determining the shortest distance among the multiple distances as the distance between the first electronic device and the second electronic device at the current time. It should be noted that the less interference a broadcast data packet in a linear structure (e.g., a linked list) receives, the smaller and more accurate the distance calculated according to the RSSI corresponding to the broadcast data packet in the linked list. Therefore, the shortest distance among the multiple distances is determined as the distance between the first electronic device and the second electronic device at the current time.
[0009] In a possible implementation, the first electronic device also includes a target register, and determining the RSSI corresponding to each of the plurality of second broadcast data packets includes: for each of the plurality of second broadcast data packets, performing a fast Fourier transform FFT on the in-phase orthogonal IQ data corresponding to the second broadcast data packet, separating the power corresponding to the baseband frequency of 250khz or 500khz, and storing it in the target register; determining the RSSI corresponding to the second broadcast data packet according to the power in the target register. In this way, the effective signal power (separating the power corresponding to the baseband frequency of 250khz or 500khz) can be obtained and stored in the target register (RX effective power register), so as to perform RSSI-RX power mapping according to the power in the RX effective power register, avoid the influence of noise, make RSSI-RX power mapping more accurate, and thus make the distance calculation according to RSSI more accurate.
[0010] In a possible implementation, the second broadcast data packet includes a first field, the first field carries first information, and the first information is used to indicate the channel number of the Bluetooth channel corresponding to the second broadcast data packet. In this way, the channel number can be determined according to the first field, the actual frequency of the channel can be determined according to the channel number, and the distance can be calculated according to the actual frequency, which can improve the accuracy of distance calculation.
[0011] In a possible implementation, the first field is a reserved field, and the channel number satisfies the following formula:
[0012] channel=(reserved&0x7f)>>1
[0013] Among them, channel represents the channel number, reserved represents the first information carried by the reserved field, & represents the AND operator, and >> represents the right shift operator.
[0014] In a possible implementation, performing linear weighted fitting on the RSSI corresponding to the second broadcast data packet in the target linear structure includes: performing linear weighted fitting on the RSSI in the target linear structure according to the following formula:
[0015] Y[i]=a*w[i]*x[i]+b
[0016] Wherein, Y[i] represents the RSSI corresponding to the i-th last broadcast data packet in the target linear structure, x[i] represents the time when the i-th last broadcast data packet is received, W[i] represents the weight of the i-th last broadcast data packet, a and b represent the parameter values to be fitted, W[i] = 1 / offet[i], and Offset[i] represents the time difference between the time when the i-th last broadcast data packet is received and the current time.
[0017] In a possible implementation, the second broadcast data packet is a Bluetooth broadcast data packet. That is, the first electronic device and the second electronic device can establish a Bluetooth connection and communicate via a Bluetooth communication protocol. The Bluetooth communication protocol may be a traditional Bluetooth protocol, or a BLE protocol, etc.
[0018] In a possible implementation, the method further includes: if the distance between the first electronic device and the second electronic device is less than or equal to a first preset distance, displaying first information, the first information being used to prompt Bluetooth pairing, Bluetooth connection, or Bluetooth unlocking. Thus, when the distance between the first electronic device (e.g., a mobile phone) and the second electronic device (e.g., a Bluetooth headset) is less than or equal to the first preset distance (e.g., 50 cm), the mobile phone can prompt the user to Bluetooth pairing, Bluetooth connection, or Bluetooth unlocking.
[0019] In a possible implementation, the method further includes: at the first position, determining the distance between the first electronic device and the second electronic device as a first distance; at the second position, determining the distance between the first electronic device and the second electronic device as a second distance; determining the distance between the first position and the second position as a third distance according to a pedestrian dead reckoning PDR algorithm; determining the azimuth between the first electronic device and the second electronic device according to the first distance, the second distance, and the third distance; and displaying second information, the second information being used to prompt the distance and azimuth between the first electronic device and the second electronic device. In this way, the first electronic device (e.g., a mobile phone) can prompt the user the distance between the second electronic device (e.g., a Bluetooth headset) and the mobile phone, as well as the direction (azimuth) of the Bluetooth headset relative to the mobile phone, to help the user find the Bluetooth headset.
[0020] In a second aspect, the present application provides a chip system, which includes one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via lines.
[0021] The chip system can be applied to an electronic device (first electronic device) including a communication module and a memory. The interface circuit is used to receive a signal from the memory of the electronic device and send the received signal to the processor, where the signal includes a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device can execute the method described in the first aspect and any possible design thereof.
[0022] In a third aspect, the present application provides a computer-readable storage medium, the computer-readable storage medium comprising computer instructions. When the computer instructions are executed on an electronic device (a first electronic device), the electronic device executes the method as described in the first aspect and any possible design thereof.
[0023] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any possible design thereof.
[0024] In a fifth aspect, an embodiment of the present application provides a ranging device based on RSSI, including a processor, the processor and a memory are coupled, and the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the device implements the method described in the first aspect and any possible design thereof. The device can be an electronic device (a first electronic device); or it can be a component of an electronic device, such as a chip.
[0025] In the sixth aspect, an embodiment of the present application provides a ranging device based on RSSI, and the device can be divided into different logical units or modules according to functions, and each unit or module performs different functions, so that the device executes the method described in the above-mentioned first aspect and any possible design method thereof.
[0026] In the seventh aspect, an embodiment of the present application provides a ranging system based on RSSI, including a first electronic device and a second electronic device, wherein the first electronic device and the second electronic device respectively perform some steps and cooperate with each other to implement the method described in the first aspect and any possible design method thereof.
[0027] It can be understood that the beneficial effects that can be achieved by the chip system described in the second aspect, the computer-readable storage medium described in the third aspect, the computer program product described in the fourth aspect, the devices described in the fifth aspect and the sixth aspect, and the system described in the seventh aspect provided above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A schematic diagram of a communication system provided in an embodiment of the present application;
[0029] Figure 2 A schematic diagram of a business scenario provided for an embodiment of the present application;
[0030] Figure 3 A schematic diagram of another business scenario provided in an embodiment of the present application;
[0031] Figure 4 A schematic diagram of the architecture of a Bluetooth system provided in an embodiment of the present application;
[0032] Figure 5 A schematic diagram of the hardware structure of a first electronic device provided in an embodiment of the present application;
[0033] Figure 6 A schematic diagram of the hardware structure of a second electronic device provided in an embodiment of the present application;
[0034] Figure 7 A schematic diagram of a method flow chart provided for an embodiment of the present application;
[0035] Figure 8 A schematic diagram of a broadcast event at a sending end and a scanning window at a receiving end provided in an embodiment of the present application;
[0036] Fig. 9 A schematic diagram of the relationship between broadcast data and channels provided in an embodiment of the present application;
[0037] Fig.10A schematic diagram of a linked list corresponding to a device provided in an embodiment of the present application;
[0038] Fig.11 A schematic diagram of a linked list corresponding to a Bluetooth channel provided in an embodiment of the present application;
[0039] Fig.12 A schematic diagram of a linear fitting provided in an embodiment of the present application;
[0040] Fig.13 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the description of the following embodiments clear and concise, a brief introduction to the relevant concepts or technologies is first given:
[0042] The RSSI spatial attenuation formula (also known as the free space loss formula) is as follows:
[0043] L = 32.45 + 20lgf + 20lgd Formula (1)
[0044] According to formula (1), formula (2) can be derived.
[0045] d=pow(10,(L-32.44-20*log(2450)) / 20)*1000 Formula (2)
[0046] Where, f represents frequency in MHz. d represents distance in km. pow represents exponential function, log represents logarithmic function. L represents the air loss of the signal, which can be expressed as formula 3:
[0047] L=TX Power -Lin-RSSI (Equation 3)
[0048] Among them, TX Power indicates the actual transmission power of the antenna port of the transmitter, and Lin indicates the insertion loss value of the antenna and RF front end of the receiver. The insertion loss value is related to the product model, product identifier (ID) and antenna type. The RF path loss of a mobile phone is about 3.5dB to 5dB, and the antenna efficiency is about -4.5dB, so Lin is about 8dB to 9.5dB. RSSI indicates the signal strength received by the receiver.
[0049] The TX Power may be carried in the TX Power field of a broadcast data packet. The broadcast data packet may be, for example, an LE advertising report.
[0050] For example, the format of LE advertising report is as follows:
[0051] Reserved: 0x000
[0052] TX Power:127dBm(not available)
[0053] It should be noted that since the frequency of the channel is not reflected in the LE advertising report format, formula (2) uses the average frequency of 2450. For example, Bluetooth low energy (BLE) broadcasts have three Bluetooth channels, namely channel 37 (Channel37), channel 38 (Channel38) and channel 39 (Channel39). The frequency of channel 37 is 2402Mhz; the frequency of channel 38 is 2426; the frequency of channel 39 is 2480. 2450 refers to the average frequency of the three Bluetooth channels. However, it is not reasonable to use the average frequency for distance calculation, which will lead to inaccurate calculated distance.
[0054] Exemplarily, as shown in Table 1, when L is the same, there is an error between the distance calculated based on the average frequency and the distance calculated based on the frequencies corresponding to different channels.
[0055] Table 1
[0056]
[0057] In addition, the RSSI in formula (3) is generally the RSSI detected by RF. Due to the spatial attenuation of the signal, it is easily affected by environmental interference. The RSSI detected by RF is not the energy of the effective signal, but the superposition of various noise energies and the effective signal energy. Therefore, directly calculating the distance based on the RSSI detected by RF will lead to inaccurate distance.
[0058] like Figure 1 As shown, a schematic diagram of a communication system architecture provided in an embodiment of the present application is provided. The communication system architecture may include a first electronic device (e.g., a mobile phone) and a second electronic device (e.g., a Bluetooth headset). The first electronic device and the second electronic device may establish a Bluetooth connection and communicate via a Bluetooth (BT) communication protocol.
[0059] Among them, the above-mentioned Bluetooth communication protocol can be a traditional Bluetooth protocol or a BLE protocol; of course, it can also be other new Bluetooth protocol types to be launched in the future, which is not limited in this application.
[0060] For example, Figure 2As shown, after the mobile phone scans the BLE broadcast (i.e., broadcast data packet) sent by the Bluetooth headset, the RSSI can be calculated based on the BLE broadcast, and the distance between the Bluetooth headset and the mobile phone can be determined based on the RSSI. If the mobile phone finds that the Bluetooth headset is nearby, for example, the mobile phone determines that the distance between the Bluetooth headset and the Bluetooth headset is less than or equal to the preset value, a pairing connection pop-up box 202 can be popped up on the current interface (e.g., desktop 201). The pairing connection pop-up box 202 is used to prompt the user "Headphone XXXXX detected, do you want to pair?" The pairing connection pop-up box 202 may include an OK button and a Cancel button. In response to the user's operation on the OK button (e.g., a click operation), Bluetooth pairing is performed between the mobile phone and the Bluetooth headset and a Bluetooth connection is established. After the Bluetooth headset and the mobile phone are paired, the Bluetooth headset and the mobile phone establish a Bluetooth service connection. Through the Bluetooth service connection, data interaction of Bluetooth service services can be performed between the mobile phone and the Bluetooth headset.
[0061] For example, Figure 3 As shown in (a), after the mobile phone scans the BLE broadcast sent by the Bluetooth speaker, it can calculate the RSSI based on the BLE broadcast and determine the distance between the Bluetooth speaker and the mobile phone based on the RSSI. If the mobile phone finds that the Bluetooth speaker is nearby, for example, the mobile phone determines that the distance between the Bluetooth speaker and the Bluetooth speaker is less than or equal to the preset value, it can establish a Bluetooth service connection with the Bluetooth speaker (the mobile phone and the Bluetooth speaker have been paired before), and you can enter the system interface without entering the lock screen password. Figure 3 As shown in (a) of FIG. 1 , when the mobile phone determines that the distance between the mobile phone and the Bluetooth speaker is less than or equal to a preset value, a lock screen interface 301 may be displayed. The lock screen interface 301 includes an unlock icon 302 and a prompt text “identifying Bluetooth device” 303. If the Bluetooth device is successfully connected, Figure 3 As shown in (b) of FIG. 1 , an interface 304 may be displayed, which may include an unlock icon 305 (the lock is in an open state, which may vividly prompt the user that the Bluetooth device is successfully unlocked) and a prompt text "Swipe up to enter" 306. In response to the user's swiping operation, Figure 3 As shown in (c) in FIG. 1 , the mobile phone can display the desktop or the interface of an application (system application or third-party application). Or, Figure 3 As shown in (c) in FIG. 1 , if the Bluetooth device is unlocked successfully, the mobile phone can be directly unlocked without additional user operation, that is, the desktop 307 (or the application interface) can be displayed immediately.
[0062] like Figure 4 As shown, an embodiment of the present application provides a Bluetooth protocol framework, including but not limited to BT controller hardware, BT controller software, BT system applications and BT third-party applications.
[0063] Among them, the BT controller hardware may include radio frequency (RF), analog-to-digital converter (ADC), modem, link layer and other bottom modules. For example, RF can filter and transmit data streams through microwaves in the 2.4GHz unlicensed ISM band. The modem can use Gauss frequency shift keying (GFSK) modulation.
[0064] The BT controller software may include a logical link control layer (LLC) and a host controller interface (HCI) low layer. The LLC layer may execute commands for establishing a transmission link for data packets, maintaining the link, and other functions.
[0065] BT system applications can include HCI up layer, host, framework, etc. Among them, the host defines the core protocol and stack profiles, including but not limited to the basic Bluetooth service protocol (service discovery protocol, SDP), logical link control and adaptation protocol (logical link control and adaptation protocol, L2CAP), etc. The host can perform more friendly encapsulation based on the logical link to shield the details of Bluetooth technology, making it easier to call BT third-party applications. The framework is the communication interface between the BT system application and the BT third-party application.
[0066] BT controller software and BT system applications can communicate through HCI low layer and HCI up layer. HCI low layer and HCI up layer both belong to HCI.
[0067] BT third-party applications can implement various application functions based on the interface provided by the BT system application. For example, in the embodiment of the present application, the BT third-party application (e.g., airlink) can shunt the broadcast data packets, perform weighted linear fitting on the RSSI corresponding to the shunt broadcast data packets, and perform distance judgment based on the fitting results.
[0068] The following takes the process of receiving data stream as an example to illustrate the processing process of each module of the Bluetooth protocol framework. Among them, the data stream may include multiple broadcast data packets from multiple Bluetooth devices. The RF receives the data stream and sends the data stream to the ADC for processing. The ADC can perform analog-to-digital conversion on the data stream to obtain the I component and the Q component. Among them, I represents in-phase, Q represents quadrature, and the phase difference with I is 90 degrees. The modem can perform a fast Fourier transform (FFT) of IQ data (i.e., I component and Q component). The result after the fast Fourier transform may include amplitude and frequency. The link layer can calculate the power of the receiving end (receive, RX) based on the result after the fast Fourier transform, and store it in the RX power register. It should be noted that in the embodiment of the present application, the link layer can also separate / filter out the power corresponding to the baseband frequency of 250khz or 500khz based on the result after the fast Fourier transform, and store it in the RX effective power register. The power corresponding to the baseband frequency of 250khz or 500khz is the energy corresponding to the Bluetooth signal, which filters out the influence of noise and other signals (for example, Wi-Fi signals). In addition, the link layer can also perform cyclic redundancy check (CRC) checking on the data of the broadcast data packet to ensure the correctness and integrity of data transmission. The data after CRC checking can be processed by dewhitening, device address matching, event encapsulation, packet encapsulation, etc. In addition, channel signal statistics can be performed based on the data after CRC checking to determine the quality of the channel corresponding to each broadcast data packet.
[0069] In the prior art, the LLC layer can perform RSSI-RX power mapping according to the data in the RX power register. Since the data in the RX power register includes the power of noise, the RSSI-RX power mapping will be inaccurate, which will lead to the problem of inaccurate distance calculation based on RSSI.
[0070] In the embodiment of the present application, the LLC layer can obtain the power corresponding to the baseband frequency of 250khz or 500khz from the RX effective power register and perform RSSI-RX power mapping. The influence of noise can be avoided, making the RSSI-RX power mapping more accurate, thereby making the distance calculated according to RSSI more accurate.
[0071] Then, the LLC layer can assemble the broadcast data packet. The broadcast data packet can be, for example, LE AdvertisingReport (i.e., Ble adv) or LE Extended Advertising Report (i.e., Ble ext adv). In addition, the LLC layer can also receive LL-CHANNEL-MAP-IND and assemble the data packet according to LL-CHANNEL-MAP-IND. Among them, LL-CHANNEL-MAP-IND is used to indicate the channel signal status. The link layer can transparently pass the LL_CHANNEL_MAP_IND message to the LLC layer via HCI vendor event.
[0072] Among them, LE Extended Advertising Report can carry the following information.
[0073] 1) Channel number (abbreviated as ch_num).
[0074] 2) The signal quality (abbreviated as ch_sign) of the channel (for example, channel 37, channel 38 or channel 39) is decomposed by lmp_channel_classification.
[0075] Then, the broadcast data packet is transmitted to the host through the HCI low layer and HCI high layer. The host then transmits the broadcast data packet to the BT third-party application through the framework.
[0076] After receiving the broadcast data packet, the BT third-party application can split the broadcast data packet according to the address, discard some broadcast data packets according to ch_sign, and then split the broadcast data packet according to ch_num, assign a weight to the RSSI corresponding to the broadcast data packet according to the timestamp, perform weighted linear fitting on the RSSI, calculate the RSSI spatial attenuation distance, and make a distance judgment. The specific process can refer to the following embodiments (for example, Figure 7 embodiment shown).
[0077] like Figure 5As shown, the embodiment of the present application takes the first electronic device as an electronic device 200 (such as a mobile phone) as an example, and illustrates the structure of the first electronic device provided by the embodiment of the present application. The electronic device 200 (such as a mobile phone) may include: a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc.
[0078] The processor 210 may include one or more processing units, for example, the processor 210 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0079] The controller may be the nerve center and command center of the electronic device 200. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0080] The processor 210 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory may store instructions or data that the processor 210 has just used or cyclically used. If the processor 210 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0081] In some embodiments, the processor 210 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0082] The wireless communication module 260 can provide wireless communication solutions for application in the electronic device 200, including WLAN (such as (wirelessfidelity, Wi-Fi) network), Bluetooth (bluetooth, BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), nearfield communication technology (nearfield communication, NFC), infrared technology (infrared, IR), etc.
[0083] The wireless communication module 260 may be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210. The wireless communication module 260 may also receive signals to be sent from the processor 210, modulate the frequencies of the signals, amplify the signals, and convert the signals into electromagnetic waves for radiation via the antenna 2.
[0084] The electronic device 200 implements the display function through a GPU, a display screen 294, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs, which execute program instructions to generate or change display information.
[0085] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel.
[0086] The electronic device 200 can realize the shooting function through the ISP, the camera 293, the video codec, the GPU, the display screen 294 and the application processor. The ISP is used to process the data fed back by the camera 293. The camera 293 is used to capture a static image or a video. In some embodiments, the electronic device 200 may include 1 or N cameras 293, where N is a positive integer greater than 1.
[0087] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0088] For example, the electronic device 100 may be a mobile phone, a smart remote controller, a PDA, an augmented reality (AR) / virtual reality (VR) device, a portable multimedia player (PMP), a media player, etc. The present application embodiment does not impose any restrictions on the specific type of the electronic device.
[0089] like Figure 6 As shown, the embodiment of the present application takes the second electronic device as an electronic device 300 (for example, a Bluetooth headset) as an example to illustrate the structure of the second electronic device provided in the embodiment of the present application. The electronic device 300 (for example, a Bluetooth headset) may include a wireless communication module 310, a positioning module 320, a processor 330, an internal memory 340, a power management module 350, a battery 360, a charging management module 370, an antenna 3, etc.
[0090] The processor 330 may include one or more processing units. For example, the processor 330 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU).
[0091] In some embodiments, the processor 330 may include one or more interfaces. The interface may include an I2C interface, an I2S interface, a PCM interface, a UART interface, a MIPI, a GPIO interface, a SIM card interface, and / or a USB interface, etc.
[0092] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0093] The charging management module 370 is used to receive charging input from a charger, where the charger can be a wireless charger or a wired charger.
[0094] The power management module 350 is used to connect the battery 360, the charging management module 370 and the processor 330. The power management module 350 receives input from the battery 360 and / or the charging management module 370, and supplies power to the processor 330, the internal memory 340, the external memory interface 220 and the wireless communication module 310. The power management module 350 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc.
[0095] The wireless communication function of the electronic device 300 can be implemented through the antenna 3 and the wireless communication module 310, the positioning module 320, etc.
[0096] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0097] The electronic device 300 may include, for example, a Bluetooth headset, a Bluetooth speaker, a smart bracelet, and a smart watch, which are not limited in this application. For example, the Bluetooth headset may be of various types, such as an earplug-type, in-ear type, head-mounted, earmuff-type, or ear-hanging type Bluetooth headset. For example, the Bluetooth device may be a true wireless stereo (TWS) headset or a neckband Bluetooth headset.
[0098] The technical scheme in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Wherein, in the description of the present application, unless otherwise specified, "at least one" refers to one or more, and "a plurality of" refers to two or more than two. In addition, in order to facilitate the clear description of the technical scheme of the embodiment of the present application, in the embodiment of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art will understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit necessarily different.
[0099] For ease of understanding, the RSSI-based ranging method provided in the embodiment of the present application is specifically introduced below with reference to the accompanying drawings.
[0100] like Figure 7 As shown, the embodiment of the present application provides a ranging method based on RSSI, which is described by taking the first electronic device as a mobile phone and the second electronic device as a Bluetooth headset as an example, including:
[0101] 701. The mobile phone scans a broadcast data packet (a first broadcast data packet).
[0102] In one example, if the Bluetooth function of the mobile phone is turned on, the mobile phone can perform Bluetooth scanning, that is, scanning broadcast data packets, to search for Bluetooth devices that can be discovered within the Bluetooth connection range of the mobile phone. In another example, if the Bluetooth function of the mobile phone is turned off, the user can turn on the Bluetooth function. In response to the user's operation of turning on the Bluetooth function, the mobile phone turns on the Bluetooth scanning function and scans the broadcast data packets. The broadcast data packets can be, for example, BLE broadcast data packets.
[0103] Exemplarily, the RF of a mobile phone can receive broadcast data packets sent by Bluetooth devices such as Bluetooth headsets and Bluetooth speakers. The RF can send the broadcast data packets to the ADC for processing. The ADC can send the processed data to the modem. It should be noted that the embodiment of the present application has been improved at the hardware level of the BT controller, and the IQ-FFT module in the modem (the FFT calculation unit of the IQ data of the BT controller) is reused to generate effective signal power (separate the power corresponding to the baseband frequency of 250khz or 500khz), and store it in the newly added RX effective power register, so that the LLC layer can perform RSSI-RX power mapping according to the power in the RX effective power register, avoid the influence of noise, make RSSI-RX power mapping more accurate, and thus make the distance calculated according to RSSI more accurate. Among them, performing RSSI-RX power mapping according to the power in the RX effective power register means determining the RSSI corresponding to the power in the RX effective power register based on the mapping between the known RSSI and the RX power.
[0104] In addition, the detection time granularity of RSSI energy intensity is aligned to the broadcast data packet (packet) rather than the broadcast event (event). Exemplarily, a broadcast event (e.g., advertising event) can contain three broadcast data packets. The three broadcast data packets are transmitted on different Bluetooth channels, for example, they can be transmitted on channel 37, channel 38, and channel 39 respectively. Since the interference degree of channel 37, channel 38, and channel 39 is different, when detecting energy on the hardware, the granularity is no longer based on the broadcast event, but on the broadcast data packet, so as to obtain a more accurate RSSI.
[0105] For example, Figure 8 As shown, taking the transmitting end (e.g., Bluetooth headset) and the receiving end (e.g., mobile phone) using BLE as an example, at the transmitting end, a broadcast event can occur every 20 milliseconds (ms). The duration of each broadcast event can be 10ms, and the time interval between each two broadcast events can be 10ms. When each broadcast event occurs, the advertiser at the transmitting end can send a broadcast data packet once on channel 37, channel 38, and channel 39, respectively. Exemplarily, the duration of each broadcast data packet can be 208μs or 416μs, and the time interval between each two broadcast data packets is at least 150 microseconds (μs). For example, Fig. 9 As shown, broadcast data packet 1 may be sent on channel 37, broadcast data packet 2 may be sent on channel 38, and broadcast data packet 3 may be sent on channel 39. Figure 8 As shown, the receiving end can scan with a certain scanning duty cycle. For example, the scanning window of the receiving end can be 60ms, and the scanning duty cycle can be 60ms / 600ms, that is, 60ms is used for scanning in every 600ms, and the remaining 540ms is not scanned (rest). It is understandable that the receiving end can scan different Bluetooth channels in different scanning windows. For example, in the first scanning window, the broadcast data packets sent by channel 37 can be scanned, in the second scanning window, the broadcast data packets sent by channel 38 can be scanned, in the third scanning window, the broadcast data packets sent by channel 39 can be scanned, and in the fourth scanning window, the broadcast data packets sent by channel 37 can be scanned again, and so on, until the scanning stops.
[0106] In an embodiment of the present application, the power corresponding to the baseband frequency of 250khz or 500khz can be obtained from the RX effective power register, and RSSI-RX power mapping can be performed. The influence of noise can be avoided, making the RSSI-RX power mapping more accurate, thereby making the distance calculated based on RSSI more accurate. After RSSI-RX power mapping, broadcast data packets can be grouped, for example, LE Extended Advertising Report can be grouped. The BT controller software transmits the LE Extended advertising report to the host through HCI. The host then transmits the LE Extended advertising report to the third-party application through the framework.
[0107] Among them, LE Extended Advertising Report can carry the following information.
[0108] 1) Channel number (e.g., channel 37, channel 38, or channel 39).
[0109] 2) Signal quality of the channel.
[0110] 3) RSSI, which is the RSSI corresponding to the power in the RX effective power register.
[0111] In a possible design, the reserved field of the LE Extended Advertising Report may carry the channel number, where the channel number satisfies the following formula:
[0112] channel=(reserved&0x7f)>>1 Formula (4)
[0113] Among them, channel represents the channel number, reserved represents the information carried by the reserved field (first information), & represents the AND operator, and >> represents the right shift operator.
[0114] In this way, the channel number can be determined based on the reserved field, and the actual frequency can be determined based on the channel number, that is, the frequency is implicitly reflected in the LE advertising report. Calculating the distance based on the actual frequency (for example, substituting the actual frequency into formula (2)) can improve the accuracy of the distance calculation.
[0115] 702. The mobile phone performs diversion processing on the broadcast data packet according to the Bluetooth address.
[0116] After receiving advertising data packets (for example, LE advertising report or LEExtended advertising report) from the host, the third-party application of the mobile phone can divert and process the advertising data packets according to the Bluetooth address.
[0117] It is understandable that the mobile phone can scan broadcast data packets from multiple devices in the same time period. For example, if there are Bluetooth headsets and Bluetooth speakers near the mobile phone, and both the Bluetooth headsets and Bluetooth speakers can send broadcast data packets, the mobile phone can scan the broadcast data packets of the Bluetooth headsets and Bluetooth speakers. After the mobile phone receives the broadcast data packets, it can divert the broadcast data packets according to the Bluetooth address, that is, distinguish the broadcast data packets from different devices. Exemplarily, the mobile phone can store broadcast data packets from different devices into different linear structures according to the Bluetooth address. A linear structure refers to a collection of ordered data elements. A linear structure may include a linear list (for example, a linked list), a stack, a queue, an array, etc. The embodiment of the present application is illustrated by taking a linear structure as a linked list as an example.
[0118] For example, Fig.10 As shown, the linked list corresponding to device 1 (e.g., a Bluetooth headset) may include broadcast data packet 1, broadcast data packet 2, broadcast data packet 3, broadcast data packet 4, broadcast data packet 5, etc. Of course, the linked list corresponding to the Bluetooth headset may also include more broadcast data packets, without limitation. Similarly, the linked list corresponding to device 2 (e.g., a Bluetooth speaker) may include broadcast data packet 11, broadcast data packet 12, broadcast data packet 13, broadcast data packet 14, broadcast data packet 15, etc. Of course, the linked list corresponding to the Bluetooth speaker may also include more broadcast data packets, without limitation. Among them, each broadcast data packet may carry information such as an indication of channel quality, a channel number, and the RSSI corresponding to the broadcast data packet.
[0119] 703. For the broadcast data packets of the same Bluetooth address, the broadcast data packets are split according to the channel numbers.
[0120] Taking the case where the device corresponding to the Bluetooth address is a Bluetooth headset as an example, the broadcast data packet (second broadcast data packet) from the Bluetooth headset can come from Bluetooth channel 37, Bluetooth channel 38 or Bluetooth channel 39 respectively. Therefore, the channel number can be determined according to the first field (e.g., reserved field) of the second broadcast data packet, and the broadcast data packet from the Bluetooth headset can be shunted according to the channel number. That is, the broadcast data packets from different Bluetooth channels are distinguished. Exemplarily, the mobile phone can store the broadcast data packets from different Bluetooth channels in different linear structures (e.g., linked lists).
[0121] For example, Fig.11As shown, the linked list corresponding to Bluetooth channel 37 may include broadcast data packet 1, broadcast data packet 2, broadcast data packet 3, etc. Similarly, the linked list corresponding to Bluetooth channel 38 may include broadcast data packet 4, broadcast data packet 5, broadcast data packet 6, etc. The linked list corresponding to Bluetooth channel 39 may include broadcast data packet 7, broadcast data packet 8, broadcast data packet 9, etc. Of course, the linked lists corresponding to Bluetooth channel 37, Bluetooth channel 38, and Bluetooth channel 39 may also include more broadcast data packets, without limitation. Each broadcast data packet may carry information indicating channel quality, channel number, and RSSI corresponding to the broadcast data packet.
[0122] In a possible design, the mobile phone can determine whether to store the broadcast data packet in the linked list corresponding to the corresponding Bluetooth channel (the Bluetooth channel corresponding to the broadcast data packet) according to the channel quality corresponding to the broadcast data packet. The channel quality corresponding to the broadcast data packet refers to the channel quality of the Bluetooth channel when the broadcast data packet is received from the Bluetooth channel. It can be understood that the channel quality of the Bluetooth channel (also referred to as channel classification) can include good, bad, and unknown.
[0123] Exemplarily, the definitions of the channel qualities of a Bluetooth channel as good, bad, and unknown may be as shown in Table 2.
[0124] Table 2
[0125]
[0126] If the channel quality corresponding to the broadcast data packet is excellent, the broadcast data packet can be stored in the linked list corresponding to the corresponding Bluetooth channel. If the channel quality corresponding to the broadcast data packet is poor or unknown, the broadcast data packet can be discarded and not stored in the linked list corresponding to the corresponding Bluetooth channel. In this way, the broadcast data packets with poor or unknown channel quality are eliminated, and the quality of the broadcast data packets in the linked list can be guaranteed.
[0127] 704. Select the target linked list.
[0128] The target linked list (target linear structure) refers to a linked list that meets preset conditions.
[0129] In some embodiments, the linked list that meets the preset conditions may refer to a linked list with excellent channel quality. The linked list with excellent channel quality may refer to a linked list in which the channel quality corresponding to each broadcast data packet in the linked list is excellent. The linked list with excellent channel quality is a linked list (linear structure) corresponding to Bluetooth channels of preset classification (e.g., Bluetooth channels with excellent channel quality).
[0130] In some other embodiments, the linked list satisfying the preset condition may be the linked list with the smallest data fluctuation among multiple linked lists with excellent channel quality. That is, if there are multiple linked lists with excellent channel quality at the same time, the linked list with the smallest data fluctuation may be selected.
[0131] It should be noted that the broadcast data packets in the linked list with the smallest data fluctuation are subject to the least interference. It is understandable that the broadcast data packets sent by the transmitter (for example, Bluetooth headset) may be interfered by sudden factors (for example, sudden obstruction), which may lead to the RSSI calculated based on the broadcast data packets being inaccurate. If the data fluctuation of the linked list corresponding to the Bluetooth channel is small, it means that the Bluetooth channel is less interfered than other Bluetooth channels, and the distance calculated based on the RSSI corresponding to the broadcast data packets in the linked list corresponding to the Bluetooth channel will be more accurate.
[0132] 705. Perform linear weighted fitting on the RSSI corresponding to the broadcast data packets in the target linked list.
[0133] In some embodiments, the RSSI corresponding to the broadcast data packets in the target linked list may be linearly weighted fit based on time. It is understandable that each broadcast data packet corresponds to a receiving time, and the closer the receiving time is to the current time, the more important the broadcast data packet is, and the greater the weight of the RSSI corresponding to the broadcast data packet. That is, the weight of the RSSI corresponding to the broadcast data packet closer to the current time is higher (larger), and the weight of the RSSI corresponding to the broadcast data packet farther from the current time is lower (smaller).
[0134] Exemplarily, a linear weighted fitting may be performed on the RSSI corresponding to the broadcast data packets in the target linked list according to the following one-dimensional formula:
[0135] Y[i]= a*w[i]*x[i] +b Formula (5)
[0136] Wherein, Y[i] represents the RSSI corresponding to the i-th last broadcast data packet in the target linear structure. Wherein, the i-th last broadcast data packet refers to the i-th broadcast data packet counted from the current time. For example, the first broadcast data packet is received at the moment before the current time (e.g., time t0) (e.g., time t1), the second broadcast data packet is received at the moment before time t1 (e.g., time t2), and so on. x[i] represents the time when the i-th last broadcast data packet is received, W[i] represents the weight of the i-th last broadcast data packet, and a and b represent the parameter values to be fitted.
[0137] In one possible design, W[i] can be expressed as shown in formula (6).
[0138] W[i]=1 / offet[i] Formula (6)
[0139] Wherein, Offset[i] represents the time difference between the time when the i-th last broadcast data packet is received and the current time.
[0140] In another possible design, W[i] can be shown as formula (7).
[0141]
[0142] Among them, γ is a coefficient that can be adjusted flexibly, and its value range is [0,1]. For example, the value can be 0.95. n represents the total number of broadcast packets in the target linear structure, that is, the total number of samples. I represents the i-th last broadcast packet, that is, the i-th broadcast packet counted from the current time.
[0143] In some embodiments, N (e.g., 5) broadcast data packets closest to the current time can be selected from the target linked list, and the RSSI corresponding to each of the N broadcast data packets can be substituted into the above formula (e.g., formula (5)) to obtain a linear weighted fitting result, i.e., the values of the parameters a and b to be fitted.
[0144] In this way, by setting the weights of the RSSI corresponding to different broadcast data packets, the weight of the RSSI corresponding to the broadcast data packet closer to the current time is higher (larger), and the weight of the RSSI corresponding to the broadcast data packet farther from the current time is lower (smaller). Compared with taking the average of the RSSI corresponding to multiple broadcast data packets (for example, the 5 most recently reported broadcast data packets), the linear fitting of the RSSI corresponding to different broadcast data packets is more timely, so that the distance calculated based on the RSSI will be more accurate. In addition, the problem of large errors in calculating the distance based on the RSSI caused by uneven time intervals for reporting broadcast data packets can be avoided.
[0145] Exemplarily, assume that the target linked list includes broadcast data packet 1, broadcast data packet 2, and broadcast data packet 3. The receiving times of broadcast data packet 1, broadcast data packet 2, and broadcast data packet 3 are t1, t2, and t3, respectively. Among them, the time difference between t1 and the current time is less than the time difference between t2 and the current time, and the time difference between t2 and the current time is less than the time difference between t3 and the current time. Taking the current time as 0 as an example, t1 can be -1, t2 can be -2, and t3 can be -3. Broadcast data packet 1, broadcast data packet 2, and broadcast data packet 3 correspond to RSSI 1, RSSI 2, and RSSI 3, respectively. Fig.12 As shown, Fig.12The horizontal axis of the coordinate system in represents time, and the vertical axis represents RSSI. The fitting point corresponding to broadcast data packet 1 is A, the horizontal axis of A is t3, and the vertical axis of A is 1 / t3*RSSI 1. The fitting point corresponding to broadcast data packet 2 is B, the horizontal axis of B is t2, and the vertical axis of B is 1 / t2*RSSI 2. The fitting point corresponding to broadcast data packet 3 is C, the horizontal axis of C is t1, and the vertical axis of C is 1 / t1*RSSI 3. According to the fitting points A, B, and C, the fitting line D corresponding to the target linked list can be obtained.
[0146] In some other embodiments, the RSSI corresponding to the broadcast data packet in the target linked list can be linearly integrated and weightedly fitted based on time and motion state. Exemplarily, the motion state can include states such as stillness, walking, and riding. For each broadcast data packet in the target linked list, if the motion state of the mobile phone is still when the broadcast data packet is received, the motion state weight of the RSSI corresponding to the broadcast data packet can be 1; if the motion state of the mobile phone is walking when the broadcast data packet is received, the motion state weight of the RSSI corresponding to the broadcast data packet can be 0.8. That is, the closer the motion state of the mobile phone is to stillness when the broadcast data packet is received, the higher (larger) the motion state weight of the RSSI corresponding to the broadcast data packet. In addition, the time offset weight of the RSSI corresponding to the broadcast data packet closer to the current time is higher. For example, the time offset weight of the RSSI corresponding to the broadcast data packet closest to the current time can be 1, the time offset weight of the RSSI corresponding to the previous data packet of the broadcast data packet closest to the current time can be 1 / offset, and the weight of the RSSI corresponding to each broadcast data packet can be the product of the motion state weight and the time offset weight.
[0147] 706. Determine the RSSI corresponding to the current time according to the linear weighted fitting result.
[0148] Exemplarily, the current time t (eg, t=0) may be substituted into the above linear formula to obtain the RSSI corresponding to the current time.
[0149] 707. Determine the distance between the mobile phone and the Bluetooth headset at the current time according to the RSSI corresponding to the current time.
[0150] For example, the RSSI corresponding to the current time can be substituted into the air loss calculation formula (for example, (Formula 3) above) to obtain the air loss of the signal (i.e., L), and then L is substituted into the distance calculation formula to obtain the distance between the mobile phone and the Bluetooth headset at the current time. The distance calculation formula can be, for example, as shown in Formula (6):
[0151] d=pow(10,(L-32.44-20*log(F)) / 20)*1000 Formula (6)
[0152] Among them, F represents the actual frequency of the channel corresponding to the target linked list. For example, when the channel corresponding to the target linked list is channel 37, F is 2402Mhz; when the channel corresponding to the target linked list is channel 38, F is 2426; when the channel corresponding to the target linked list is channel 39, F is 2480. The meanings of other parameters in formula (6) can refer to the relevant description of formula (2), which will not be repeated here.
[0153] In some embodiments, if there are multiple linked lists with excellent channel quality at the same time. For each of the multiple linked lists, select the N (for example, 5) broadcast data packets closest to the current time from the linked list, and substitute the RSSI corresponding to each of the 5 broadcast data packets into the above formula (for example, formula (5)) to obtain a linear weighted fitting result. Determine the RSSI corresponding to the current time based on the linear weighted fitting result, and then substitute the RSSI corresponding to the current time into the distance calculation formula (for example, formula (6)) to calculate the distance. In this way, multiple distances (values) can be obtained, and the minimum distance can be selected as the distance between the mobile phone and the Bluetooth headset at the current time. This is because the less interference the broadcast data packet in the linked list is subjected to, the smaller the distance calculated based on the RSSI corresponding to the broadcast data packet in the linked list, and the more accurate it is.
[0154] Exemplarily, it is assumed that there are multiple linked lists with excellent channel quality at the same time, including linked list 1 corresponding to channel 37 and linked list 2 corresponding to channel 38. For linked list 1, the N (for example, 5) broadcast data packets closest to the current time can be selected from the linked list to obtain the average RSSI corresponding to the group of broadcast data packets, and the average RSSI is substituted into the distance calculation formula (for example, formula (6)) to obtain the distance value 1. For linked list 2, the N (for example, 5) broadcast data packets closest to the current time can be selected from the linked list to obtain the average RSSI corresponding to the group of broadcast data packets, and the average RSSI is substituted into the distance calculation formula (for example, formula (6)) to obtain the distance value 2. If the distance value 1 is greater than the distance value 2, it is determined that the distance between the mobile phone and the Bluetooth headset at the current time is the distance value 2.
[0155] In some embodiments, when the mobile phone is in motion (e.g., walking), Kalman filtering and nonlinear power-rate fitting can be used to obtain the RSSI involved in distance calculation. For example, the state (speed v1, acceleration a1, RSSI 1) at the previous moment (t1) can be used to predict the state (speed v2, acceleration a2, RSSI 2) at the next moment (e.g., t2) through the Kalman filtering algorithm. When the mobile phone is stationary or slightly moving, nonlinear fitting (e.g., Gaussian filtering linear fitting) can be used to obtain the RSSI involved in distance calculation.
[0156] 708. The mobile phone determines the distance between itself and surrounding Bluetooth devices. When the distance between the mobile phone and surrounding Bluetooth devices is less than or equal to a preset value, a preset service is triggered.
[0157] For example, Figure 2 As shown, if the mobile phone finds that the Bluetooth headset is nearby, for example, the mobile phone determines that the distance between the mobile phone and the Bluetooth headset is less than or equal to a preset value, a pairing connection pop-up box 202 can be popped up on the current interface (for example, desktop 201). The pairing connection pop-up box 202 is used to prompt the user "Headphones XXXXX detected, do you want to pair". The pairing connection pop-up box 202 may include an OK button and a Cancel button. In response to the user's operation on the OK button (for example, a click operation), Bluetooth pairing is performed between the mobile phone and the Bluetooth headset and a Bluetooth connection is established. After the Bluetooth headset and the mobile phone are paired, the Bluetooth headset and the mobile phone establish a Bluetooth service connection. Through the Bluetooth service connection, data interaction of Bluetooth service services can be performed between the mobile phone and the Bluetooth headset.
[0158] For example, Figure 3 As shown in (a), after the mobile phone scans the BLE broadcast sent by the Bluetooth speaker, it can calculate the RSSI based on the BLE broadcast and determine the distance between the Bluetooth speaker and the mobile phone based on the RSSI. If the mobile phone finds that the Bluetooth speaker is nearby, for example, the mobile phone determines that the distance between the Bluetooth speaker and the Bluetooth speaker is less than or equal to the preset value, it can establish a Bluetooth service connection with the Bluetooth speaker (the mobile phone and the Bluetooth speaker have been paired before), and you can enter the system interface without entering the lock screen password. Figure 3 As shown in (a) of FIG. 1 , when the mobile phone determines that the distance between the mobile phone and the Bluetooth speaker is less than or equal to a preset value, a lock screen interface 301 may be displayed. The lock screen interface 301 includes an unlock icon 302 and a prompt text “identifying Bluetooth device” 303. If the Bluetooth device is successfully connected, Figure 3 As shown in (b) of FIG. 1 , an interface 304 may be displayed, which may include an unlock icon 305 (the lock is in an open state, which may vividly prompt the user that the Bluetooth device is successfully unlocked) and a prompt text "Swipe up to enter" 306. In response to the user's swiping operation, Figure 3 As shown in (c) in FIG. 1 , the mobile phone can display the desktop or the interface of an application (system application or third-party application). Or, Figure 3 As shown in (c) in FIG. 1 , if the Bluetooth device is unlocked successfully, the mobile phone can be directly unlocked without additional user operation, that is, the desktop 307 (or the application interface) can be displayed immediately.
[0159] The method provided in the embodiment of the present application is, first, improved at the hardware level of the BT controller, and the IQ-FFT module (FFT calculation unit of the IQ data of the BT controller) in the modem is reused to generate effective signal power (separate the power corresponding to the baseband frequency of 250khz or 500khz), and store it in the newly added RX effective power register, so as to perform RSSI-RX power mapping according to the power in the RX effective power register, avoid the influence of noise, make RSSI-RX power mapping more accurate, and thus make the distance calculated according to RSSI more accurate. Second, the ranging data processing scheme is improved, and the broadcast data packet can be shunted according to the channel number. The broadcast data packets from different Bluetooth channels can be stored in different linear structures (for example, linked lists), and then the RSSI corresponding to the broadcast data packets in the linked lists that meet the preset conditions is linearly weighted fitting, so that the distance calculated according to RSSI is more accurate. Third, the channel number can be determined according to the reserved field of the broadcast data packet, the actual frequency can be determined according to the channel number, and the distance is calculated according to the actual frequency (for example, the actual frequency is substituted into formula (6)), which can improve the accuracy of distance calculation.
[0160] The method provided in the embodiment of the present application can also be applied to the near-field search scenario of the device. Exemplarily, if the Bluetooth headset is lost, the user can find the Bluetooth headset through the mobile phone. The mobile phone can receive the broadcast data packet sent by the Bluetooth headset, and determine the distance between the mobile phone and the Bluetooth headset according to the RSSI corresponding to the broadcast data packet. The specific process can refer to steps 701-707. Assuming that when the user is at position A (the first position), the distance between the mobile phone and the Bluetooth headset is determined to be DA (the first distance) according to the RSSI corresponding to the broadcast data packet. When the user moves to position B (the second position), the distance between the mobile phone and the Bluetooth headset is determined to be DB (the second distance) according to the RSSI corresponding to the broadcast data packet. The distance moved by the user (the third distance, the distance between position A and position B, i.e. AB) can be obtained by the pedestrian dead reckoning (PDR) algorithm. According to DA, DB and AB, the distance and azimuth between the user (mobile phone) and the Bluetooth headset can be obtained. In this way, the mobile phone can prompt the user that the Bluetooth headset is nearby (for example, prompting the distance between the Bluetooth headset and the mobile phone, and the direction (azimuth) of the Bluetooth headset relative to the mobile phone), helping the user to find the Bluetooth headset.
[0161] The method provided in the embodiment of the present application can also be applied to other higher-precision ranging methods. For example, before starting high-precision ranging (such as phase ranging, or time of flight (TOF) ranging based on ultra-wideband (UWB)), ranging can be performed based on RSSI first, and when the distance is less than a preset value, the high-precision ranging (such as phase ranging, or TOF ranging based on UWB) function can be started, which can reduce power consumption.
[0162] The present application also provides a chip system, such as Fig.13 As shown, the chip system includes at least one processor 1301 and at least one interface circuit 1302. The processor 1301 and the interface circuit 1302 can be interconnected through a line. For example, the interface circuit 1302 can be used to receive signals from other devices (for example, a memory of an electronic device). For another example, the interface circuit 1302 can be used to send signals to other devices (for example, the processor 1301).
[0163] For example, the interface circuit 1302 can read the instruction stored in the memory of the electronic device and send the instruction to the processor 1301. When the instruction is executed by the processor 1301, the first electronic device (such as Figure 5 The electronic device 200 shown) or the second electronic device (such as Figure 6 The electronic device 300 shown in the figure performs each step in the above embodiment.
[0164] Of course, the chip system may also include other discrete devices, which is not specifically limited in the embodiments of the present application.
[0165] The present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a first electronic device (such as Figure 5 The electronic device 200 shown) or the second electronic device (such as Figure 6 When the electronic device 200 is run on the electronic device 300 shown in the figure, the electronic device 200 executes the various functions or steps executed by the mobile phone in the above method embodiment, and the electronic device 300 executes the various functions or steps executed by the Bluetooth headset or Bluetooth speaker in the above method embodiment.
[0166] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the electronic device in the above method embodiment.
[0167] An embodiment of the present application also provides a processing device, which can be divided into different logical units or modules according to functions, and each unit or module performs a different function, so that the processing device executes each function or step executed by the first electronic device or the second electronic device in the above method embodiment.
[0168] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0169] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0170] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0171] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0172] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0173] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A ranging method based on signal strength indication RSSI, characterized in that: Applicable to a first electronic device, comprising: Scanning a first broadcast data packet, wherein the first broadcast data packet includes a plurality of second broadcast data packets from a second electronic device, and the plurality of second broadcast data packets are from different Bluetooth channels; Determine the RSSI corresponding to each second broadcast data packet in the plurality of second broadcast data packets; Generate a plurality of different linear structures, wherein the plurality of different linear structures respectively include RSSIs corresponding to second broadcast data packets from different Bluetooth channels; Determining a target linear structure that meets a preset condition from the plurality of different linear structures; Performing linear weighted fitting on the RSSI in the target linear structure, and determining the RSSI corresponding to the current time according to the linear weighted fitting result; wherein the RSSI corresponding to the second broadcast data packet closer to the current time has a higher weight; The distance between the first electronic device and the second electronic device at the current time is determined according to the RSSI corresponding to the current time.
2. The method according to claim 1, characterized in that Determining a target linear structure satisfying a preset condition from the plurality of different linear structures comprises: Determine a linear structure of Bluetooth channels corresponding to a preset category from the multiple different linear structures; If the multiple different linear structures include a linear structure of Bluetooth channels corresponding to a preset category, determining the linear structure of Bluetooth channels corresponding to the preset category as the target linear structure; If the multiple different linear structures include multiple linear structures corresponding to Bluetooth channels of preset categories, a linear structure with the smallest data fluctuation among the multiple linear structures corresponding to Bluetooth channels of preset categories is determined as the target linear structure.
3. The method according to claim 1, characterized in that The performing linear weighted fitting on the RSSI in the target linear structure and determining the RSSI corresponding to the current time according to the linear weighted fitting result comprises: In a case where the target linear structure includes multiple linear structures, performing linear weighted fitting on the RSSI in each linear structure in the target linear structure to obtain multiple linear weighted fitting results; Determine the RSSI corresponding to the current time according to each of the multiple linear weighted fitting results, to obtain multiple RSSIs corresponding to the current time; The determining the distance between the first electronic device and the second electronic device at the current time according to the RSSI corresponding to the current time includes: Determine the distance between the first electronic device and the second electronic device at the current time according to the multiple RSSIs corresponding to the current times, respectively, to obtain multiple distances; The shortest distance among the multiple distances is determined as the distance between the first electronic device and the second electronic device at the current time.
4. The method according to any one of claims 1 to 3, characterized in that: The first electronic device further includes a target register, and the determining of the RSSI corresponding to each of the plurality of second broadcast data packets includes: For each second broadcast data packet in the plurality of second broadcast data packets, performing a fast Fourier transform FFT on the in-phase orthogonal IQ data corresponding to the second broadcast data packet, separating the power corresponding to the baseband frequency of 250 khz or 500 khz, and storing the power in the target register; The RSSI corresponding to the second broadcast data packet is determined according to the power in the target register.
5. The method according to any one of claims 1 to 4, characterized in that: The second broadcast data packet includes a first field, the first field carries first information, and the first information is used to indicate a channel number of a Bluetooth channel corresponding to the second broadcast data packet.
6. The method according to claim 5, characterized in that The first field is a reserved field, and the channel number satisfies the following formula: channel=(reserved&0x7f)>>1 Among them, channel represents the channel number, reserved represents the first information carried by the reserved field, & represents the AND operator, and >> represents the right shift operator.
7. The method according to any one of claims 1 to 6, characterized in that: The performing linear weighted fitting on the RSSI corresponding to the second broadcast data packet in the target linear structure comprises: A linear weighted fitting is performed on the RSSI in the target linear structure according to the following formula: Y[i]=a*w[i]*x[i]+b Wherein, Y[i] represents the RSSI corresponding to the i-th last broadcast data packet in the target linear structure, x[i] represents the time when the i-th last broadcast data packet is received, W[i] represents the weight of the i-th last broadcast data packet, a and b represent parameter values to be fitted, W[i]=1 / offet[i], and Offset[i] represents the time difference between the time when the i-th last broadcast data packet is received and the current time.
8. The method according to any one of claims 1 to 7, characterized in that: The second broadcast data packet is a Bluetooth broadcast data packet.
9. The method according to claim 8, characterized in that The method further comprises: If the distance between the first electronic device and the second electronic device is less than or equal to a first preset distance, first information is displayed, where the first information is used to prompt Bluetooth pairing, Bluetooth connection or Bluetooth unlocking.
10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: At a first position, determining a distance between the first electronic device and the second electronic device as a first distance; At a second position, determining a distance between the first electronic device and the second electronic device as a second distance; Determine, according to a pedestrian dead reckoning (PDR) algorithm, a distance between the first position and the second position as a third distance; determining an azimuth angle between the first electronic device and the second electronic device according to the first distance, the second distance, and the third distance; The second information is displayed, where the second information is used to prompt the distance between the first electronic device and the second electronic device and the azimuth angle.
11. An electronic device, characterized in that: The electronic device comprises: a wireless communication module, a memory and one or more processors; the wireless communication module, the memory and the processor are coupled; The memory is used to store computer program codes, and the computer program codes include computer instructions; when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: including computer instructions; When the computer instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 10.