CN-122028017-A - Data processing method, bluetooth device, electronic device and storage medium
Abstract
The application relates to the technical field of wireless communication and discloses a data processing method, a Bluetooth device, an electronic device and a storage medium, wherein the data processing method comprises the steps of receiving a Bluetooth beacon broadcast packet, and extracting MAC address, signal strength and payload data of target equipment; judging whether the MAC address of the target equipment is stored in the RAW array, if so, locating a first storage unit corresponding to the MAC address of the target equipment in the RAW array, updating a signal intensity field and a payload storage area of the first storage unit, updating an RSSI index array, if not, writing the MAC address, the signal intensity and the payload data of the target equipment in a second storage unit in the RAW array, and updating the MAC and RSSI index arrays. The method solves the problems that a single ordering strategy cannot meet the double requirements of equipment identification and signal quality and array elements need to be moved frequently during dynamic updating, and extra calculation overhead is generated.
Inventors
- WANG CHENLONG
Assignees
- 上海移为通信技术股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20251231
Claims (10)
- 1. The data processing method is applied to Bluetooth equipment, and is characterized in that the Bluetooth equipment is provided with a RAW array, a MAC index array, an RSSI index array and an effective equipment counter, wherein the RAW array is provided with N storage units, N is an integer larger than 0, each storage unit comprises a MAC address field, an RSSI signal strength field, a payload storage area and a status flag bit, the MAC index array is provided with N MAC pointer elements respectively pointing to each storage unit in the RAW array, the RSSI index array is provided with N RSSI pointer elements respectively pointing to each storage unit in the RAW array, the effective equipment counter is recorded with an effective equipment number M of the RAW array, the first M MAC pointer elements in the MAC index array are arranged according to ascending order of the MAC addresses, and the first M RSSI pointer elements in the RSSI index array are arranged according to descending order of the RSSI signal strength, and the method comprises the steps of: receiving a Bluetooth beacon broadcast packet, and extracting the MAC address, RSSI signal strength and payload data of target equipment; Judging whether the MAC address of the target equipment is stored in the RAW array; If the data exists, a first storage unit corresponding to the MAC address of the target equipment is positioned in the RAW array, the RSSI signal intensity field and the payload storage area of the first storage unit are updated according to the RSSI signal intensity and the payload data of the target equipment, and the state flag bit of the first storage unit is updated to be in an effective state; If the MAC address, the RSSI signal strength and the payload data of the target equipment are written into a second storage unit in the RAW array, the status flag bit of the second storage unit is updated to be in a valid state, the MAC index array is updated according to the MAC address of the target equipment, and the RSSI index array is updated according to the RSSI signal strength of the target equipment.
- 2. The method of claim 1, wherein writing the MAC address, RSSI signal strength, and payload data of the target device in the second memory unit in the RAW array comprises: judging the size relation between the effective equipment number M and the N; If the number M of the effective devices is smaller 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 in the second storage unit, wherein the value of the number M of the effective devices recorded by the effective device counter is increased by 1; And if the number M of the effective devices is equal to the N, taking the storage unit pointed by the RSSI pointer element at the tail end of the RSSI index array as the second storage unit, clearing the data of the second storage unit, and writing the MAC address, the RSSI signal strength and the payload data of the target device in the second storage unit.
- 3. The data processing method according to claim 1, wherein the determining whether the MAC address of the target device is stored in the RAW array includes: and searching whether the storage units pointed by the first M MAC pointer elements of the MAC index array store the MAC address of the target equipment according to a dichotomy.
- 4. A data processing method according to any one of claims 1 to 3, wherein the method further comprises: sequentially accessing each storage unit according to the sequence of each RSSI pointer element in the RSSI index array; In the process of accessing any storage unit, resetting the state flag bit to be in an invalid state when the state flag bit of the storage unit is in an valid state, moving an RSSI pointer element corresponding to the storage unit to the tail end of the RSSI index array in the RSSI index array when the state flag bit of the storage unit is in the invalid state, moving the MAC pointer element corresponding to the storage unit to the tail end of the MAC index array in the MAC index array, clearing data of the storage unit, and subtracting 1 from the value of the effective equipment number M recorded by the effective equipment counter.
- 5. A data processing method according to any one of claims 1 to 3, wherein the method further comprises: Constructing the RAW array, and initializing the MAC index array and the RSSI index array; and initializing a state, setting the count M of the effective equipment counter to 0, and setting the state flag bit of each storage unit in the RAW array to be in an invalid state.
- 6. A data processing method according to any one of claims 1 to 3, wherein before writing the MAC address, RSSI signal strength and payload data of the target device in the second storage unit in the RAW array, further comprises: judging whether the RSSI signal strength of the target equipment is lower than a preset threshold value or not; If yes, executing the step of writing the MAC address, the RSSI signal strength and the payload data of the target equipment in a second storage unit in the RAW array; if not, the MAC address, the RSSI signal strength and the payload data of the target equipment are not written.
- 7. The data processing method according to claim 1, wherein in the case where N is less than or equal to 256, the MAC index array and the RSSI index array each use an 8-bit unsigned integer as an index number of the storage unit; and under the condition that N is less than or equal to 65536, the MAC index array and the RSSI index array both adopt 16-bit unsigned integers as index numbers of storage units.
- 8. A Bluetooth device comprises a RAW array, a MAC index array, an RSSI index array and an effective device counter, wherein the RAW array is provided with N storage units, N is an integer larger than 0, each storage unit comprises a MAC address field, an RSSI signal strength field, a payload storage area and a status flag bit, the MAC index array is provided with N MAC pointer elements pointing to each storage unit in the RAW array respectively, the RSSI index array is provided with N RSSI pointer elements pointing to each storage unit in the RAW array respectively, the effective device counter records the effective device number M of the RAW array, the first M MAC pointer elements in the MAC index array are arranged according to the ascending order of the MAC address, and the first M RSSI pointer elements in the RSSI index array are arranged according to the descending order of the RSSI signal strength.
- 9. An electronic device comprising at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the data processing method of any one of claims 1 to 7.
- 10. A computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the data processing method of any one of claims 1 to 7.
Description
Data processing method, bluetooth device, electronic device and storage medium Technical Field The present application relates to the field of wireless communications technologies, and in particular, to a data processing method, a bluetooth device, an electronic device, and a storage medium. Background Bluetooth scanning technology discovers, identifies and enumerates surrounding bluetooth devices via radio signals, storing scanned device data with a fixed size array. However, the existing bluetooth scanning technology has the problems that a single ordering strategy cannot meet the dual requirements of equipment identification and signal quality, array elements are required to be moved frequently during dynamic updating, additional calculation overhead is generated, memory occupation grows linearly along with the number of the equipment, the resource limitation of embedded equipment is not met, and the traditional linear traversal mode is high in time complexity and difficult to meet the real-time requirement. Disclosure of Invention The embodiment of the application aims to provide a data processing method, bluetooth equipment, electronic equipment and a storage medium, so that the problem that a single ordering strategy cannot meet the double requirements of equipment identification and signal quality is solved, and the problem that array elements are required to be moved frequently during dynamic updating to generate additional calculation expense is solved. To solve the above technical problems, the embodiment of the application provides a data processing method applied to a Bluetooth device, wherein the Bluetooth device is provided with a RAW array, a MAC index array, an RSSI index array and an effective device counter, the RAW array is provided with N storage units, N is an integer larger than 0, each storage unit comprises a MAC address field, an RSSI signal strength field, a payload storage area and a status flag bit, the MAC index array is provided with N MAC pointer elements respectively pointing to each storage unit in the RAW array, the RSSI index array is provided with N RSSI pointer elements respectively pointing to each storage unit in the RAW array, the effective device counter is used for recording the effective device number M of the RAW array, the first M MAC pointer elements in the MAC index array are arranged according to the ascending order of the MAC address, the first M pointer elements in the RSSI index array are arranged according to the descending order of the RSSI signal strength, the method comprises the steps of receiving a Bluetooth broadcast packet, extracting the RSSI signal strength, extracting the target RSSI signal strength, the N pointer elements respectively pointing to each storage unit in the RAW array, the second MAC pointer elements in the RAW array are stored in the storage area according to the descending order of the RSSI signal strength, the second MAC index array is stored in the MAC address array, and the new target data storage area is stored in the new MAC address array according to the new target address, if the new target address has the new RSSI signal strength is stored in the new target address array, and the new target address is stored in the new target address array, and updating the MAC index array according to the MAC address of the target equipment and updating the RSSI index array according to the RSSI signal intensity of the target equipment. The embodiment of the application also provides Bluetooth equipment, which comprises a RAW array, a MAC index array, an RSSI index array and an effective equipment counter, wherein the RAW array is provided with N storage units, N is an integer larger than 0, each storage unit comprises a MAC address field, an RSSI signal strength field, a payload storage area and a status flag bit, the MAC index array is provided with N MAC pointer elements respectively pointing to each storage unit in the RAW array, the RSSI index array is provided with N RSSI pointer elements respectively pointing to each storage unit in the RAW array, the effective equipment counter is recorded with an effective equipment number M of the RAW array, the first M MAC pointer elements in the MAC index array are arranged according to the ascending order of the MAC addresses, and the first M RSSI pointer elements in the RSSI index array are arranged according to the descending order of the RSSI signal strength. The embodiment of the application also provides electronic equipment, which comprises at least one processor and a memory in communication connection with the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data processing method. Embodiments of the present application also provide a computer-readable storage medium storing a computer program which, when executed by