Data processing method, Bluetooth device, electronic device and storage medium

By introducing a dual-index sorting of RAW array, MAC index array, and RSSI index array into Bluetooth devices, the problems of balancing device identification and signal quality and computational overhead in Bluetooth scanning technology are solved, achieving efficient device identification and real-time scanning.

CN122028017APending Publication Date: 2026-05-12QUECLINK WIRELESS SOLUTIONS
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
QUECLINK WIRELESS SOLUTIONS
Filing Date
2025-12-31
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing Bluetooth scanning technology cannot simultaneously meet the dual requirements of device identification and signal quality. Dynamic updates require frequent shifting of array elements, resulting in additional computational overhead. Memory usage increases linearly with the number of devices, making it difficult to meet the resource constraints and real-time requirements of embedded devices.

Method used

A combination of RAW array, MAC index array, and RSSI index array is used. The MAC index array is sorted in ascending order by MAC address, and the RSSI index array is sorted in descending order by RSSI signal strength. Combined with an effective device counter, dual-index sorting is achieved. Only the index array and the counter need to be updated, avoiding changes to the order of storage cells in the RAW array.

Benefits of technology

It improves both device recognition efficiency and signal quality assessment, reduces computational overhead, decreases memory usage, and enhances the real-time performance and memory utilization of scanning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122028017A_ABST
    Figure CN122028017A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of wireless communication, and discloses a data processing method, Bluetooth equipment, electronic equipment and a storage medium, and the data processing method comprises the steps: receiving a Bluetooth beacon broadcast packet, and extracting an MAC address, signal strength and effective load data of target equipment; judging whether the MAC address of the target equipment is stored in the RAW array or not; if yes, positioning a first storage unit corresponding to the MAC address of the target equipment in the RAW array; updating a signal strength field and a payload storage area of the first storage unit; updating the RSSI index array; if not, the MAC address, the signal strength and the effective load data of the target equipment are written into a second storage unit in the RAW array; and updating the MAC index array and the RSSI index array. The problems that a single sorting strategy cannot give consideration to the double requirements of equipment identification and signal quality, array elements need to be moved frequently during dynamic updating, and additional calculation overhead is generated are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of wireless communication technology, and in particular to a data processing method, a Bluetooth device, an electronic device, and a storage medium. Background Technology

[0002] Bluetooth scanning technology discovers, identifies, and enumerates nearby Bluetooth devices using radio signals, storing the data of the scanned devices in a fixed-size array.

[0003] However, existing Bluetooth scanning technologies suffer from several drawbacks: a single sorting strategy cannot simultaneously meet the dual requirements of device identification and signal quality; dynamic updates require frequent shifting of array elements, resulting in additional computational overhead; memory usage increases linearly with the number of devices, which does not meet the resource constraints of embedded devices; and traditional linear traversal methods have high time complexity, making it difficult to meet real-time requirements. Summary of the Invention

[0004] The purpose of this application is to provide a data processing method, Bluetooth device, electronic device, and storage medium, thereby solving the problem that a single sorting strategy cannot simultaneously meet the dual requirements of device identification and signal quality, as well as the problem that frequent array element movement is required during dynamic updates, resulting in additional computational overhead.

[0005] To address the aforementioned technical problems, embodiments of this application provide a data processing method applied to a Bluetooth device. The Bluetooth device comprises a RAW array, a MAC index array, an RSSI index array, and a valid device counter. The RAW array has N storage units, where N is an integer greater than 0. Each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag. The MAC index array has N MAC pointer elements pointing to each storage unit in the RAW array. The RSSI index array has N RSSI pointer elements pointing to each storage unit in the RAW array. The valid device counter records the number M of valid devices in the RAW array. The first M MAC pointer elements in the MAC index array are arranged in ascending order of the MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of the RSSI signal strength. The method includes: receiving Bluetooth... The beacon broadcast packet extracts the target device's MAC address, RSSI signal strength, and payload data; it determines whether the target device's MAC address is stored in the RAW array; if it exists, it locates the first storage unit corresponding to the target device's MAC address in the RAW array; it updates the RSSI signal strength field and payload storage area of ​​the first storage unit according to the target device's RSSI signal strength and payload data, and updates the status flag of the first storage unit to a valid state; and it updates the RSSI index array according to the target device's RSSI signal strength; if it does not exist, it writes the target device's MAC address, RSSI signal strength, and payload data into the second storage unit in the RAW array, updates the status flag of the second storage unit to a valid state; and it updates the MAC index array according to the target device's MAC address and the RSSI index array according to the target device's RSSI signal strength.

[0006] Embodiments of this application also provide a Bluetooth device, including: a RAW array, a MAC index array, an RSSI index array, and a valid device counter; the RAW array has N storage units, where N is an integer greater than 0; each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag bit; the MAC index array has N MAC pointer elements that point to each storage unit in the RAW array; the RSSI index array has N RSSI pointer elements that point to each storage unit in the RAW array; the valid device counter records the number M of valid devices in the RAW array; the first M MAC pointer elements in the MAC index array are arranged in ascending order of the MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of the RSSI signal strength.

[0007] Embodiments of this application also provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the data processing method as described above.

[0008] Embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the data processing method described above.

[0009] In some embodiments, writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit in the RAW array includes: determining the relationship between the number of valid devices M and N; if the number of valid devices M is less than N, selecting a blank (M+1) storage unit in the RAW array as the second storage unit, and writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit; incrementing the value of the number of valid devices M recorded by the valid device counter by 1; if the number of valid devices M is equal to N, using the storage unit pointed to by the RSSI pointer element at the end of the RSSI index array as the second storage unit, clearing the data in the second storage unit, and writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit.

[0010] In some embodiments, determining whether the MAC address of the target device is stored in the RAW array includes: using a binary search method to find whether the storage unit pointed to by the first M MAC pointer elements of the MAC index array stores the MAC address of the target device.

[0011] In some embodiments, the method further includes: accessing each of the storage cells sequentially according to the order of the RSSI pointer elements in the RSSI index array; during the access of any of the storage cells, if the status flag of the storage cell is in a valid state, resetting the status flag to an invalid state; if the status flag of the storage cell is in an invalid state, moving the RSSI pointer element corresponding to the storage cell to the end of the RSSI index array, and moving the MAC pointer element corresponding to the storage cell to the end of the MAC index array; clearing the data in the storage cell, and decrementing the value of the number of valid devices M recorded by the valid device counter by 1.

[0012] In some embodiments, the method further includes: constructing the RAW array and initializing the MAC index array and the RSSI index array; performing state initialization by setting the count M of the valid device counter to 0 and setting the state flag bits of each of the storage cells in the RAW array to an invalid state.

[0013] In some embodiments, before writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit of the RAW array, the method further includes: determining whether the RSSI signal strength of the target device is lower than a preset threshold; if so, performing the step of writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit of the RAW array; if not, not writing the MAC address, RSSI signal strength, and payload data of the target device.

[0014] In some embodiments, when N is less than or equal to 256, both the MAC index array and the RSSI index array use 8-bit unsigned integers as the index numbers of the storage units; when N is less than or equal to 65536, both the MAC index array and the RSSI index array use 16-bit unsigned integers as the index numbers of the storage units.

[0015] The technical solution provided in this application has at least the following advantages: This application embodiment sets up a MAC index array, an RSSI index array, and an effective device counter in the Bluetooth device. The effective device counter records the number of effective devices M in the RAW array. The first M MAC pointer elements in the MAC index array are arranged in ascending order of MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of RSSI signal strength. By using a dual-index sorting method, when adding a new device or updating the device's RSSI, only the sorting in the MAC index array and RSSI index array, as well as the number of effective devices M recorded by the effective device counter, need to be updated. There is no need to change the order of each storage unit in the RAW array. This solves the problem that a single sorting strategy cannot simultaneously meet the dual requirements of device identification and signal quality, as well as the problem that frequent array element movement during dynamic updates generates additional computational overhead. Attached Figure Description

[0016] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0017] Figure 1 This is a schematic flowchart of a data processing method according to an embodiment of this application; Figure 2 This is a flowchart illustrating each sub-step of step 104; Figure 3 This is another schematic flowchart of a data processing method according to an embodiment of this application; Figure 4 This is a structural block diagram of an electronic device according to another embodiment of this application. Detailed Implementation

[0018] As can be seen from the background technology, existing Bluetooth scanning technologies suffer from several problems: a single sorting strategy cannot simultaneously meet the dual requirements of device identification and signal quality; dynamic updates require frequent shifting of array elements, resulting in additional computational overhead; memory usage increases linearly with the number of devices, which does not meet the resource constraints of embedded devices; and traditional linear traversal methods have high time complexity, making it difficult to meet real-time requirements.

[0019] Analysis revealed that the reasons for the above problems are as follows: (1) The arrays in the traditional scheme can only be sorted according to a single rule, such as RSSI (Received Signal Strength Indicator) sorting, MAC (Media Access Control) sorting, or time sorting. This can only achieve efficient searching under one sorting method. The search efficiency of other methods is low, and it cannot meet the dual requirements of device identification and signal quality. (2) Since the traditional arrays are sorted according to RSSI, MAC, or time, when a new device is added or the RSSI of the device is updated, the array will be dynamically updated, which requires frequent movement of array elements, thus generating additional computational overhead. (3) In the traditional scheme, each array is pre-allocated a fixed space. If the new device scanned is small, it will lead to waste of redundant content. If the new device scanned is large, it will lead to frequent expansion and memory fragmentation, that is, memory usage varies. The number of devices grows linearly, which does not meet the resource limitations of embedded devices. The MCU of the embedded device has only 32KB of memory. If there are many new devices, such as 1000 devices × 50 bytes = 50KB, it exceeds the 32KB limit of the MCU. (4) When the Bluetooth device scans a new device or updates the device RSSI, it needs to first check whether the device exists in the original array. If there are 100 arrays in the local array, it will need to traverse 100 arrays at most, that is, perform a maximum of 100 comparisons, which results in high time complexity and low efficiency in finding the device. A single Bluetooth scan will take a lot of time, which reduces the scanning frequency of the Bluetooth device and makes it difficult to meet the real-time requirements.

[0020] To address the aforementioned technical problems, this application provides a data processing method applied to a Bluetooth device. The Bluetooth device comprises a RAW array, a MAC index array, an RSSI index array, and a valid device counter. The RAW array has N storage units, where N is an integer greater than 0. Each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag. The MAC index array has N MAC pointer elements pointing to each storage unit in the RAW array. The RSSI index array has N RSSI pointer elements pointing to each storage unit in the RAW array. The valid device counter records the number M of valid devices in the RAW array. The first M MAC pointer elements in the MAC index array are arranged in ascending order of MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of RSSI signal strength. The method includes: receiving Bluetooth beacon broadcast packets and extracting the MAC address, RSSI signal strength, and payload data of the target device. The process involves determining whether the target device's MAC address is stored in the RAW array. If it exists, the process locates the first storage unit corresponding to the target device's MAC address in the RAW array. The process updates the RSSI signal strength field and payload storage area of ​​the first storage unit based on the target device's RSSI signal strength and payload data, and updates the status flag of the first storage unit to a valid state. The process also updates the RSSI index array based on the target device's RSSI signal strength. If the target device does not exist, the process writes the target device's MAC address, RSSI signal strength, and payload data into the second storage unit in the RAW array, updates the status flag of the second storage unit to a valid state, and updates the MAC index array based on the target device's MAC address and the RSSI index array based on the target device's RSSI signal strength.

[0021] This application embodiment sets up a MAC index array, an RSSI index array, and an effective device counter in the Bluetooth device. The effective device counter records the number of effective devices M in the RAW array. The first M MAC pointer elements in the MAC index array are arranged in ascending order of MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of RSSI signal strength. By using a dual-index sorting method, when adding a new device or updating the device's RSSI, only the sorting in the MAC index array and RSSI index array, as well as the number of effective devices M recorded by the effective device counter, need to be updated. There is no need to change the order of each storage unit in the RAW array. This solves the problem that a single sorting strategy cannot simultaneously meet the dual requirements of device identification and signal quality, as well as the problem that frequent array element movement during dynamic updates generates additional computational overhead.

[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details are presented in the various embodiments of this application to facilitate a better understanding of the application. However, the technical solutions claimed in this application can be implemented even without these technical details and various variations and modifications based on the following embodiments. The division of the various embodiments below is for ease of description and should not constitute any limitation on the specific implementation of this application. The various embodiments can be combined with and referenced by each other without contradiction.

[0023] One embodiment of this application relates to a data processing method, the specific flowchart of which is shown below. Figure 1 As shown, the data processing method in this embodiment includes the following steps: Step 101: Receive Bluetooth beacon broadcast packets and extract the target device's MAC address, RSSI signal strength, and payload data.

[0024] The data processing method of this application embodiment is applied to a Bluetooth device. The Bluetooth device constructs a RAW (raw data) array, a MAC index array, an RSSI index array, and an active device counter. The RAW array has N storage units, where N is an integer greater than 0. Each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag bit. The MAC index array has N MAC pointer elements that point to each storage unit in the RAW array. The RSSI index array has N RSSI pointer elements that point to each storage unit in the RAW array. The active device counter records the number M of active devices in the RAW array. The first M MAC pointer elements in the MAC index array are arranged in ascending order of MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of RSSI signal strength.

[0025] This application introduces a three-array structure: a RAW array, a MAC index array, and an RSSI index array. The RAW array stores complete beacon data, including a MAC address field, an RSSI signal strength field, a payload storage area, and status flags. The MAC index array is a pointer array sorted in ascending order of MAC address; the RSSI index array is a pointer array sorted in descending order of signal strength.

[0026] This application embodiment can also perform Bluetooth device initialization, which can be done at any stage of the data processing method in this embodiment, either before step 101 or after steps 103 and 104, as long as the Bluetooth device has the initialization conditions. The specific initialization process is as follows: construct a RAW array and initialize the MAC index array and RSSI index array; perform state initialization, set the count M of the valid device counter to 0, and set the state flag bits of each storage unit in the RAW array to an invalid state (i.e., flag=0).

[0027] The process of constructing the RAW array in this embodiment is as follows: a fixed number (e.g., N) of storage units are pre-allocated, each unit containing a MAC address field (6 bytes), an RSSI signal strength field (1 byte), a payload storage area (variable length), and a status flag bit (1 byte, including an update flag).

[0028] The process of initializing the MAC index array is as follows: it is initialized with N MAC pointer elements, which point to the storage units of the RAW array in sequence. The pointing relationship of the N MAC pointer elements is as follows: MAC_index[0]→&RAW[0], MAC_index[1]→&RAW[1], ..., MAC_index[N-1] → &RAW[N-1]; Where RAW[0], RAW[1], ..., RAW[N-1] represent the index numbers of each storage unit in the RAW array.

[0029] The process of initializing the RSSI index array is as follows: it is initialized with N RSSI pointer elements, which point to the memory units of the RAW array in sequence. The pointing relationship of the N RSSI pointer elements is as follows: RSSI_index[0] → &RAW[0] RSSI_index[1]→&RAW[1], ..., RSSI_index[N-1]→&RAW[N-1]; Where RAW[0], RAW[1], ..., RAW[N-1] represent the index numbers of each storage unit in the RAW array.

[0030] In this embodiment, to minimize the storage space of the MAC index array and RSSI index array, when N is less than or equal to 256, both the MAC index array and RSSI index array use 8-bit unsigned integers as the index numbers of the storage units; that is, 1 byte (8 bits) of unsigned integer is used to replace 8 bytes of pointers to store the relative positions of each storage unit in the RAW array instead of absolute addresses, thereby saving memory space. When N is less than or equal to 65536, both the MAC index array and RSSI index array use 16-bit unsigned integers as the index numbers of the storage units; that is, 2 bytes (16 bits) of unsigned integer are used to replace 8 bytes of pointers to store the relative positions of each storage unit in the RAW array instead of absolute addresses, thereby saving memory space.

[0031] The state initialization process in this application embodiment is as follows: the count M of the valid device counter is set to 0, and the state flag bits of all storage cells in the RAW array are set to invalid state (i.e., flag=0).

[0032] This embodiment of the application, through the aforementioned pre-associative indexing mechanism, establishes a static mapping relationship between RAW units and the index array during initialization. Only the MAC index array and RSSI index array need to be dynamically maintained, avoiding the problem of dynamic memory allocation for the RAW array. Simultaneously, the MAC index array and RSSI index array always maintain their complete length, with the actual usage range controlled by the count M of the valid device counter. This embodiment of the application also implements dual-dimensional sorting for maintenance: the MAC index array dynamically maintains an ordered set of valid devices, supporting fast device retrieval; the RSSI index array dynamically maintains signal strength priority, supporting efficient data eviction. This embodiment of the application also implements index consistency maintenance, ensuring that the first M MAC pointer elements in the MAC index array point to valid devices, and ensuring that the first M RSSI pointer elements in the RSSI index array are arranged in descending order of signal strength.

[0033] Step 102: Determine whether the MAC address of the target device is stored in the RAW array.

[0034] If it exists, proceed to step 103; if it does not exist, proceed to step 104.

[0035] In this embodiment of the application, determining whether the MAC address of the target device is stored in the RAW array includes: searching the storage unit pointed to by the first M MAC pointer elements of the MAC index array using a binary search method to see if the MAC address of the target device is stored.

[0036] For example, among the first M valid MAC pointer elements, the MAC address stored in the memory cell corresponding to the M / 2 (rounded)th MAC pointer element is determined. The relationship between this MAC address and the MAC address of the target device is then assessed. If the MAC address of the target device is greater than this MAC address, it is determined that the MAC address of the target device may exist in the next M / 2 MAC pointer elements. The MAC address of the target device is then compared with the MAC address corresponding to the 3M / 4 (rounded)th MAC pointer element, thus continuously narrowing the comparison range until the comparison range no longer narrows and the corresponding MAC address of the target device is still not found (the MAC address of the target device is not stored in the RAW array), or until the MAC address of the target device is found in the M memory cells (the MAC address of the target device is stored in the RAW array). This application embodiment uses a binary search method to quickly identify devices, resolving the contradiction between fast device identification and efficient signal quality assessment. This application embodiment, through the binary search method, provides both device identification speed and real-time data updates, solving the problem of high time complexity and difficulty in meeting real-time requirements in traditional linear traversal methods, and also resolving the contradiction between real-time data updates and limited computing resources.

[0037] Step 103: Locate the first storage unit corresponding to the MAC address of the target device in the RAW array; update the RSSI signal strength field and payload storage area of ​​the first storage unit according to the RSSI signal strength and payload data of the target device, update the status flag of the first storage unit to the valid status; and update the RSSI index array according to the RSSI signal strength of the target device.

[0038] In this embodiment of the application, when the MAC address of the target device is stored in the RAW array, the process of updating the RSSI signal strength field and payload data of the target device is entered. By using the above-mentioned binary search method, the storage location (which storage unit) of the MAC address of the target device in the RAW array can be located as the first storage unit. The RSSI signal strength field and payload storage area of ​​the first storage unit are updated with the RSSI signal strength and payload data of the target device, and the status flag bit of the first storage unit is set to a valid state (flag=1, indicating that the status has been updated). The RSSI index array is updated according to the RSSI signal strength of the target device.

[0039] Specifically, updating the RSSI index array based on the RSSI signal strength of the target device includes: arranging the RSSI pointer elements corresponding to the first storage unit in descending order of RSSI signal strength in the RSSI index array. That is, removing the RSSI pointer elements corresponding to the first storage unit from their original positions and rearranging them in descending order of RSSI signal strength in the RSSI index array.

[0040] In this embodiment, a binary search method can be used to insert the RSSI pointer element corresponding to the first storage unit into the RSSI index array. For example, among the first M valid RSSI pointer elements, the RSSI signal strength stored in the storage unit corresponding to the M / 2 (rounded)th RSSI pointer element is determined. The relationship between this RSSI signal strength and the RSSI signal strength stored in the first storage unit is determined. If the RSSI signal strength stored in the first storage unit is greater than this RSSI signal strength, then the RSSI pointer element corresponding to the first storage unit should be inserted into the first M / 2 RSSI pointer elements. The RSSI signal strength stored in the first storage unit is then compared with the RSSI signal strength corresponding to the M / 4 (rounded)th RSSI pointer element, thereby continuously narrowing down the insertion range until the insertion position is found.

[0041] Step 104: Write the target device's MAC address, RSSI signal strength, and payload data into the second storage cell of the RAW array, update the status flag of the second storage cell to the valid status, and update the MAC index array according to the target device's MAC address and the RSSI index array according to the target device's RSSI signal strength.

[0042] In this embodiment of the application, when the MAC address of the target device is not stored in the RAW array, the process of adding a new device is initiated. The process of adding a new device requires determining a second storage unit in the RAW array to write the MAC address, RSSI signal strength and payload data of the target device. The second storage unit can be a storage unit for storing data or a storage unit with the weakest RSSI signal strength. This implementation process will be described in detail later.

[0043] In this embodiment, updating the MAC index array based on the MAC address of the target device and updating the RSSI index array based on the RSSI signal strength of the target device includes: arranging the MAC pointer elements corresponding to the second storage unit in ascending order of MAC address in the MAC index array, that is, removing the MAC pointer elements corresponding to the second storage unit from their original positions and rearranging them in ascending order of MAC address in the MAC index array; and arranging the RSSI pointer elements corresponding to the second storage unit in descending order of RSSI signal strength in the RSSI index array, that is, removing the RSSI pointer elements corresponding to the second storage unit from their original positions and rearranging them in descending order of RSSI signal strength in the RSSI index array.

[0044] In this embodiment, a binary search method can be used to arrange the MAC pointer elements corresponding to the second storage unit in the MAC index array. For example, among the first M valid MAC pointer elements, the MAC address stored in the storage unit corresponding to the M / 2 (rounded)th MAC pointer element is determined. The relationship between this MAC address and the MAC address stored in the second storage unit is compared. If the MAC address stored in the second storage unit is greater than this MAC address, then the MAC pointer element corresponding to the second storage unit should be inserted into the next M / 2 MAC pointer elements. The MAC address stored in the second storage unit is then compared with the MAC address corresponding to the 3M / 4 (rounded)th MAC pointer element, thereby continuously narrowing down the insertion range until the insertion position is found.

[0045] In this embodiment, a binary search method can also be used to insert the RSSI pointer element corresponding to the second storage unit into the RSSI index array. For example, among the first M valid RSSI pointer elements, the RSSI signal strength stored in the storage unit corresponding to the M / 2 (rounded)th RSSI pointer element is determined. The relationship between this RSSI signal strength and the RSSI signal strength stored in the second storage unit is determined. If the RSSI signal strength stored in the second storage unit is greater than this RSSI signal strength, then the RSSI pointer element corresponding to the second storage unit should be inserted into the first M / 2 RSSI pointer elements. The RSSI signal strength stored in the second storage unit is then compared with the RSSI signal strength corresponding to the M / 4 (rounded)th RSSI pointer element, thereby continuously narrowing down the insertion range until the insertion position is found.

[0046] Before step 104, i.e., writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit of the RAW array, this embodiment of the application further includes: determining whether the RSSI signal strength of the target device is lower than a preset threshold; if yes, performing the step of writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit of the RAW array; if no, not writing the MAC address, RSSI signal strength, and payload data of the target device.

[0047] like Figure 2 The diagram shown is a flowchart of each sub-step in step 104.

[0048] Step 104 involves writing the target device's MAC address, RSSI signal strength, and payload data into the second storage unit of the RAW array, including the following sub-steps: Step 1041: Determine the relationship between the number of valid devices M and N.

[0049] If the number of valid devices M is less than N, proceed to step 1042; if the number of valid devices M is equal to N, proceed to step 1043.

[0050] Step 1042: Select an empty storage cell in the RAW array as the second storage cell, and write the target device's MAC address, RSSI signal strength, and payload data into the second storage cell; increment the value of the valid device counter M by 1.

[0051] The second storage unit can be a storage unit that does not store data. For example, the M+1th storage unit (i.e., the storage unit with index number RAW[M]) can be selected as the second storage unit to store the MAC address, RSSI signal strength and payload data of the new target device (this process is dynamic expansion). The first M storage units have all stored the corresponding data, so they are stored in order for easy management.

[0052] Step 1043: Use the storage unit pointed to by the RSSI pointer element at the end of the RSSI index array as the second storage unit, clear the data in the second storage unit, and write the MAC address, RSSI signal strength and payload data of the target device into the second storage unit.

[0053] In this embodiment, the RSSI pointer element at the end of the RSSI index array points to the storage unit with the weakest RSSI signal strength. When all storage units are full, the data stored in the second storage unit with the weakest RSSI signal strength is deleted (this process is an elimination mechanism), and the MAC address, RSSI signal strength, and payload data of the new target device are re-stored. Compared to traditional methods, this solves the problem of memory usage increasing linearly with the number of devices, which does not meet the resource limitations of embedded devices, and also resolves the contradiction between limited memory capacity and dynamic data updates. At this time, the value of the effective device counter, M, remains unchanged.

[0054] This application's embodiments achieve a balance between data timeliness and data integrity through the coordinated control of a replacement mechanism and dynamic expansion. By implementing a dual binary search using the MAC index array and RSSI index array, the algorithm's complexity is reduced to O(2log n), significantly improving query efficiency. Memory usage is reduced by more than 40% compared to traditional solutions, further optimizing memory usage. The update operation time complexity remains stable at the O(log n) level, enhancing real-time performance. The dynamic replacement mechanism ensures that the RAW array stores the optimal set of signal quality, guaranteeing data validity.

[0055] Another embodiment of this application relates to a data processing method. Compared with the previous embodiment, which was mainly applied in the data storage and update stage, this embodiment is mainly applied in the periodic maintenance stage. Figure 3 The diagram shown is a flowchart illustrating a data processing method according to an embodiment of this application. The data processing method of this embodiment includes the following steps: Step 201: Access each memory unit sequentially according to the order of the RSSI pointer elements in the RSSI index array.

[0056] Step 202: During the access to any storage unit, determine whether the status flag of the storage unit is valid.

[0057] If yes, proceed to step 203; otherwise, proceed to step 204.

[0058] Step 203: Reset the status flag to an invalid state.

[0059] In this embodiment of the application, for storage units where the status flag is valid (flag=1), the status flag is reset to invalid (flag=0). Only the status flag of this part of the data is changed, and the data itself is still stored in the corresponding storage unit.

[0060] Step 204: Move the RSSI pointer element corresponding to the storage unit to the end of the RSSI index array, and move the MAC pointer element corresponding to the storage unit to the end of the MAC index array; clear the data in the storage unit, and decrement the value of the number of valid devices M recorded by the valid device counter by 1.

[0061] In this embodiment of the application, for a storage cell with an invalid status flag (flag=0), the corresponding RSSI pointer element in the RSSI index array is moved to the end of the RSSI index array. In the MAC index array, the MAC pointer element corresponding to the storage cell is located by binary search, and the MAC pointer element is moved to the end of the corresponding MAC index array. The data in the storage cell is cleared, and the array of the count M of the valid device counter is decremented by 1.

[0062] In this embodiment of the application, only the data of the storage unit with the status flag bit in the valid state (flag=1) is retained during the periodic maintenance phase, thereby deleting the device data that has not been updated within a cycle. That is, a zero-copy strategy is used during data aging process to avoid the problem of frequent expansion and memory fragmentation caused by continuous data accumulation, which meets the resource limitation requirements of embedded devices.

[0063] Another embodiment of this application relates to a Bluetooth device, which is constructed with a RAW array, a MAC index array, an RSSI index array, and an active device counter; the RAW array has N storage units, where N is an integer greater than 0; each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag bit; the MAC index array has N MAC pointer elements that point to each storage unit in the RAW array; the RSSI index array has N RSSI pointer elements that point to each storage unit in the RAW array; the active device counter records the number M of active devices in the RAW array; the first M MAC pointer elements in the MAC index array are arranged in ascending order of MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of RSSI signal strength.

[0064] This embodiment is a Bluetooth device embodiment corresponding to the above embodiments. The relevant technical details mentioned above are still valid in this embodiment, and will not be repeated here to avoid repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiments, and will not be repeated here to avoid repetition.

[0065] Another embodiment of this application relates to an electronic device, such as... Figure 4 The diagram shown is a structural block diagram of the electronic device of this embodiment. The electronic device includes at least one processor 301 and a memory 302 communicatively connected to at least one processor 301. The memory 302 stores instructions that can be executed by at least one processor 301. The instructions are executed by at least one processor 301 to enable at least one processor 301 to perform the data processing method described above.

[0066] The memory 302 and processor 301 are connected via a bus, which can include any number of interconnecting buses and bridges. The bus connects various circuits of one or more processors 301 and memory 302 together. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 301 is transmitted over a wireless medium via an antenna, which further receives data and transmits it to processor 301.

[0067] Processor 301 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 302 can be used to store data used by processor 301 during operation.

[0068] Another embodiment of this application relates to a computer-readable storage medium storing a computer program. When the computer program is executed by processor 301, it implements the method embodiments described above.

[0069] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0070] Those skilled in the art will understand that the above embodiments are specific embodiments for implementing this application, and in practical applications, various changes can be made to them in form and detail without departing from the spirit and scope of this application.

Claims

1. A data processing method, characterized in that, Applied to Bluetooth devices, the Bluetooth devices are constructed with a RAW array, a MAC index array, an RSSI index array, and a valid device counter; the RAW array has N storage units, where N is an integer greater than 0; each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag bit; The MAC index array has N MAC pointer elements that point to each storage unit in the RAW array; The RSSI index array has N RSSI pointer elements that point to each storage unit in the RAW array; the valid device counter records the number M of valid devices in the RAW array; The first M MAC pointer elements in the MAC index array are arranged in ascending order of the MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of the RSSI signal strength; the method includes: Receive Bluetooth beacon broadcast packets and extract the target device's MAC address, RSSI signal strength, and payload data; Determine whether the MAC address of the target device is stored in the RAW array; If it exists, locate the first storage unit corresponding to the MAC address of the target device in the RAW array; update the RSSI signal strength field and payload storage area of ​​the first storage unit according to the RSSI signal strength and payload data of the target device, update the status flag of the first storage unit to the valid status; and update the RSSI index array according to the RSSI signal strength of the target device. If not, the MAC address, RSSI signal strength, and payload data of the target device are written into the second storage unit in the RAW array, and the status flag of the second storage unit is updated to a valid status; and the MAC index array is updated according to the MAC address of the target device, and the RSSI index array is updated according to the RSSI signal strength of the target device.

2. The data processing method according to claim 1, characterized in that, The step of writing the target device's MAC address, RSSI signal strength, and payload data into the second storage unit of the RAW array includes: Determine the relationship between the number of valid devices M and the number of devices N; If the number of valid devices M is less than N, select an empty (M+1) storage unit in the RAW array as the second storage unit, and write the MAC address, RSSI signal strength and payload data of the target device into the second storage unit; increment the value of the number of valid devices M recorded by the valid device counter by 1; If the number of valid devices M is equal to N, the storage unit pointed to by the RSSI pointer element at the end of the RSSI index array is taken as the second storage unit, the data in the second storage unit is cleared, and the MAC address, RSSI signal strength and payload data of the target device are written into the second storage unit.

3. The data processing method according to claim 1, characterized in that, The step of determining whether the MAC address of the target device is stored in the RAW array includes: The binary search method is used to determine whether the storage unit pointed to by the first M MAC pointer elements of the MAC index array stores the MAC address of the target device.

4. The data processing method according to any one of claims 1 to 3, characterized in that, The method further includes: Access each storage unit sequentially according to the order of the RSSI pointer elements in the RSSI index array; During access to any of the storage units, if the status flag of the storage unit is valid, the status flag is reset to invalid; if the status flag of the storage unit is invalid, the RSSI pointer element corresponding to the storage unit is moved to the end of the RSSI index array, and the MAC pointer element corresponding to the storage unit is moved to the end of the MAC index array; the data of the storage unit is cleared, and the value of the number of valid devices M recorded by the valid device counter is decremented by 1.

5. The data processing method according to any one of claims 1 to 3, characterized in that, The method further includes: Construct the RAW array, and initialize the MAC index array and the RSSI index array; Perform state initialization by setting the count M of the valid device counter to 0 and setting the state flag bits of each storage cell in the RAW array to an invalid state.

6. The data processing method according to any one of claims 1 to 3, characterized in that, Before writing the MAC address, RSSI signal strength, and payload data of the target device into the second storage unit of the RAW array, the method further includes: Determine whether the RSSI signal strength of the target device is lower than a preset threshold; If so, execute the step of writing the MAC address, RSSI signal strength and payload data of the target device into the second storage unit in the RAW array; If not, the MAC address, RSSI signal strength, and payload data of the target device will not be written.

7. The data processing method according to claim 1, characterized in that, When N is less than or equal to 256, both the MAC index array and the RSSI index array use 8-bit unsigned integers as the index numbers of the storage units; When N is less than or equal to 65536, both the MAC index array and the RSSI index array use 16-bit unsigned integers as the index numbers of the storage units.

8. A Bluetooth device, characterized in that, include: The system comprises a RAW array, a MAC index array, an RSSI index array, and a valid device counter; the RAW array has N storage units, where N is an integer greater than 0; each storage unit includes a MAC address field, an RSSI signal strength field, a payload storage area, and a status flag bit; The MAC index array has N MAC pointer elements that point to each storage unit in the RAW array; The RSSI index array has N RSSI pointer elements that point to each storage unit in the RAW array; the valid device counter records the number M of valid devices in the RAW array; The first M MAC pointer elements in the MAC index array are arranged in ascending order of the MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged in descending order of the RSSI signal strength.

9. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the data processing method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the data processing method according to any one of claims 1 to 7.