Data processing method and device, computer device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN SIYUAN ELECTRONICS TECH CO LTD
- Filing Date
- 2026-04-02
- Publication Date
- 2026-08-04
AI Technical Summary
[0005]本申请实施例的目的在于提出一种数据处理方法、装置、计算机设备及存储介质,以解决现有的蓝牙扫描数据处理方法存在内存抖动与主线程阻塞的技术问题
[0009] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described data processing method.
Smart Images

Figure CN122513337A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to data processing methods, apparatus, computer equipment and storage media. Background Technology
[0002] In applications involving Bluetooth scanning, such as smart home control, Bluetooth gateway management, and intensive scanning of logistics tags, existing technologies typically employ a direct scan-reporting approach. This involves calling a system API (such as Android's `startScan`), after which the Bluetooth controller indiscriminately reports all received broadcast packets to the application layer via a callback interface. The application layer then performs simple list refresh operations (such as `notifyAdapter`) within the callback. This approach has significant technical drawbacks. Due to the frequent broadcast packet reporting, the application layer frequently creates objects in the callbacks, easily leading to memory jitter. Furthermore, the concentration of large amounts of data processing on the main thread can cause it to block, severely impacting application performance and response speed.
[0003] For example, in a scenario of dense scanning of logistics tags, numerous logistics tags in the warehouse continuously send broadcast packets. The Bluetooth controller quickly and in large quantities reports these broadcast packets to the application layer. The application layer continuously creates objects in the callback to process this data, causing memory usage to fluctuate drastically. At the same time, the main thread is too busy processing this data to respond to other operations in a timely manner, resulting in low scanning efficiency and even application lag or crashes.
[0004] Therefore, there is an urgent need to provide an optimized Bluetooth scanning data processing method to solve the problems of memory jitter and main thread blocking, and improve the performance and stability of applications in Bluetooth scanning scenarios. Summary of the Invention
[0005] The purpose of this application is to provide a data processing method, apparatus, computer device, and storage medium to solve the technical problems of memory jitter and main thread blocking in existing Bluetooth scanning data processing methods.
[0006] Firstly, a data processing method is provided, including: When a broadcast packet is received, the device address is extracted from the broadcast packet to obtain the corresponding address information. Invoke the preset Bloom filter and initialize the Bloom filter; Based on the Bloom filter, the address information is hash-mapped using multiple target hash functions to obtain the corresponding computed data. The calculated data is checked for bit values based on a preset conflict detection strategy to obtain the corresponding bit value check results. Based on the bit value check results, the broadcast packet is filtered for duplicate devices to obtain the deduplicated target device information. The target device information is distributed to a preset rendering layer.
[0007] Secondly, a data processing apparatus is provided, comprising: The extraction module is used to extract the device address from the broadcast packet when a reported broadcast packet is received, so as to obtain the corresponding address information. The first processing module is used to call a preset Bloom filter and initialize the Bloom filter. The second processing module is used to perform hash mapping processing on the address information based on the Bloom filter and through multiple target hash functions to obtain the corresponding calculated data. The checking module is used to perform bit value checks on the calculated data based on a preset conflict detection strategy, and obtain the corresponding bit value check results. The filtering module is used to filter the broadcast packets for duplicate devices based on the bit value check results, so as to obtain the deduplicated target device information; The distribution module is used to distribute the target device information to a preset rendering layer.
[0008] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described data processing method.
[0009] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described data processing method.
[0010] In the above-described data processing method, apparatus, computer equipment, and storage medium, when a reported broadcast packet is received, the device address of the broadcast packet is extracted to obtain the corresponding address information; then, a preset Bloom filter is invoked and initialized; subsequently, based on the Bloom filter, the address information is hashed using multiple target hash functions to obtain the corresponding calculated data; subsequently, the calculated data is checked for bit values based on a preset conflict detection strategy to obtain the corresponding bit value check result; further, the broadcast packet is filtered for duplicate devices based on the bit value check result to obtain deduplicated target device information; finally, the target device information is distributed to a preset rendering layer. Based on the above automated processing flow, when this application receives a reported broadcast packet, it extracts the device address from the broadcast packet to obtain address information. Then, it initializes the invoked Bloom filter and, based on the Bloom filter, performs hash mapping on the address information using multiple target hash functions to obtain calculated data. Subsequently, it uses a collision detection strategy to perform bit value checks on the calculated data to obtain bit value check results. Based on the bit value check results, it filters the broadcast packet for duplicate devices to obtain deduplicated target device information. Finally, it distributes the target device information to the rendering layer. Thus, by using a Bloom filter as the filtering layer for Bluetooth scanning, this application significantly reduces the amount of data processed subsequently, avoids repeatedly parsing the same broadcast packets, reduces UI rendering pressure, solves the memory jitter and main thread blocking problems caused by frequent object creation, effectively reduces memory usage and CPU load, and thus improves system response speed. Attached Figure Description
[0011] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is an exemplary system architecture diagram to which this application can be applied; Figure 2 This is a flowchart of an embodiment of the data processing method according to this application; Figure 3 This is a schematic diagram of the structure of an embodiment of the data processing apparatus according to this application; Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0013] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0014] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0015] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0016] like Figure 1 As shown, system architecture 100 may include terminal device 101, network 102, and server 103. Terminal device 101 may be a laptop 1011, tablet 1012, or mobile phone 1013. Network 102 is used as a medium to provide a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0017] Users can use terminal device 101 to interact with server 103 via network 102 to receive or send messages, etc. Various communication client applications can be installed on terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0018] Terminal device 101 can be various electronic devices with a display screen and support web browsing. In addition to laptops 1011, tablets 1012, or mobile phones 1013, terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer, and a desktop computer, etc.
[0019] Server 103 can be a server that provides various services, such as a backend server that provides support for the pages displayed on terminal device 101.
[0020] It should be noted that the data processing method provided in the embodiments of this application is generally executed by a server / terminal device, and correspondingly, the data processing device is generally located in the server / terminal device.
[0021] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0022] Continue to refer to Figure 2 A flowchart illustrating an embodiment of the data processing method according to this application is shown. The order of steps in the flowchart can be changed, and some steps can be omitted, depending on different needs. The data processing method provided by this application embodiment can be applied to any scenario requiring data processing, and therefore can be applied to products in these scenarios. The data processing method includes the following steps: Step S201: When a broadcast packet is received, the device address is extracted from the broadcast packet to obtain the corresponding address information.
[0023] In this embodiment, the data processing method runs on an electronic device (e.g., Figure 1The server / terminal device shown can obtain the reported broadcast packets via wired or wireless connection. It should be noted that the aforementioned wireless connection methods may include, but are not limited to, 3G / 4G / 5G connections, WiFi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB (ultra-wideband) connections, and other currently known or future wireless connection methods. The executing entity of this application is specifically a data processing system, which can be simply referred to as the system. When the underlying Bluetooth module reports the scan result, i.e., the broadcast packet (ScanResult), it first extracts the device's MAC address (i.e., address information, such as a string in the format AA:BB:CC:DD:EE:FF) from the broadcast packet. The MAC address is the device's unique identifier, used for subsequent hash calculations and deduplication. The number of broadcast packets may include multiple packets.
[0024] Step S202: Invoke the preset Bloom filter and initialize the Bloom filter.
[0025] In this embodiment, a Bloom filter interception layer can be implanted between the Bluetooth adapter's ScanCallback interface and the UI rendering layer.
[0026] The initialization process of the Bloom filter includes: 1) Bit array creation: First, allocate a fixed-length binary bit array (e.g., 1024 bits) and initialize all bits to 0. This bit array is used to record whether the device has been scanned, and its size directly affects the deduplication accuracy and memory usage (the larger the bit array, the lower the false positive rate, but the higher the memory consumption).
[0027] 2) Hash Function Selection: Select k independent and evenly distributed hash functions (e.g., variants of MD5 and SHA-1, or non-cryptographic hash functions such as MurmurHash). These hash functions map the device's unique identifier (e.g., MAC address) to different index positions in the bit array. The number of hash functions, k, needs to be dynamically adjusted based on the bit array length and the expected number of devices, typically using a formula... Calculate (where m is the length of the bit array and n is the number of devices to be stored).
[0028] Step S203: Based on the Bloom filter, the address information is hash-mapped using multiple target hash functions to obtain the corresponding calculated data.
[0029] In this embodiment, the specific implementation process of hash mapping the address information using multiple target hash functions based on the Bloom filter to obtain the corresponding calculated data will be further described in detail in subsequent specific embodiments of this application, and will not be elaborated on here.
[0030] Step S204: Perform bit value checks on the calculated data based on a preset conflict detection strategy to obtain the corresponding bit value check results.
[0031] In this embodiment, the bit value check includes checking the calculated data, specifically whether all the bit values corresponding to the k indices are 1. If all bits are 1, it indicates that the device may have been recorded / already exists (there is a possibility of a hash collision leading to a false judgment). In this case, the current broadcast packet is directly discarded without further processing. Specifically, it is intercepted and discarded directly in the callback thread and not passed up. If any bit is 0, it is determined that the device definitely does not exist.
[0032] Step S205: Based on the bit value check result, the broadcast packet is subjected to duplicate device filtering processing to obtain the deduplicated target device information.
[0033] In this embodiment, if any bit in the k indexes is 0, it means that the device is being scanned for the first time. At this time, all k bits are set to 1, and device information (including MAC address, RSSI signal strength, broadcast data, etc.) is encapsulated to generate a device object.
[0034] Step S206: Distribute the target device information to a preset rendering layer.
[0035] In this embodiment, the aforementioned rendering layer is specifically a UI rendering layer, which can be achieved by encapsulating the target device information before distributing it to the UI rendering layer. Specifically, encapsulated device data (including MAC address, RSSI signal strength, broadcast data, etc.) can be passed to the UI layer for rendering. The entire process is implemented through a data flow of "lower-level broadcast packet → MAC extraction → hash calculation → Bloom filter judgment → interception / allowing → UI rendering," ensuring that only a single device is processed and reducing invalid data transmission.
[0036] When this application receives a reported broadcast packet, it extracts the device address of the broadcast packet to obtain the corresponding address information; then it calls a preset Bloom filter and initializes the Bloom filter; subsequently, based on the Bloom filter, it performs hash mapping processing on the address information through multiple target hash functions to obtain the corresponding calculated data; subsequently, it performs bit value checking on the calculated data based on a preset conflict detection strategy to obtain the corresponding bit value checking result; further, based on the bit value checking result, it performs duplicate device filtering processing on the broadcast packet to obtain deduplicated target device information; finally, it distributes the target device information to a preset rendering layer. Based on the above automated processing flow, when this application receives a reported broadcast packet, it extracts the device address from the broadcast packet to obtain address information. Then, it initializes the invoked Bloom filter and, based on the Bloom filter, performs hash mapping on the address information using multiple target hash functions to obtain calculated data. Subsequently, it uses a collision detection strategy to perform bit value checks on the calculated data to obtain bit value check results. Based on the bit value check results, it filters the broadcast packet for duplicate devices to obtain deduplicated target device information. Finally, it distributes the target device information to the rendering layer. Thus, by using a Bloom filter as the filtering layer for Bluetooth scanning, this application significantly reduces the amount of data processed subsequently, avoids repeatedly parsing the same broadcast packets, reduces UI rendering pressure, solves the memory jitter and main thread blocking problems caused by frequent object creation, effectively reduces memory usage and CPU load, and thus improves system response speed.
[0037] In some alternative implementations, step S203 includes the following steps: Based on the Bloom filter, the address information is hashed using the multiple target hash functions to generate multiple corresponding hash values.
[0038] In this embodiment, a hash function is a function that maps an input of arbitrary length (such as a MAC address) to an output of fixed length (such as an integer), requiring a uniform distribution of the output to reduce collisions. K independent and uniformly distributed hash functions (e.g., variants of MD5 or SHA-1, or non-cryptographic hash functions such as MurmurHash) are pre-selected. Then, the k hash functions are used to calculate the hash values for the MAC addresses extracted from the broadcast packets, generating k different hash values.
[0039] Get the pre-created bit array.
[0040] In this embodiment, a bit array is a data structure consisting of binary bits (0 or 1) used to efficiently store Boolean states. A fixed-length binary bit array (e.g., 1024 bits) is pre-created, and all bits are initialized to 0. This bit array is used to record whether the device has been scanned.
[0041] The multiple hash values are transformed based on the bit array to obtain the corresponding position data.
[0042] In this embodiment, each hash value can be converted into an index position of a bit array using a modulo operation (hash_value % m), i.e., positional data (e.g., hash value 1000 modulo 1024 yields index 100). This step ensures that the same MAC address always maps to the same k bit array positions. The modulo operation refers to calculating the remainder after dividing the hash value by the length of the bit array, which is used to convert the hash value into a bit array index.
[0043] The location data is used as the calculation data.
[0044] This application utilizes a Bloom filter and multiple target hash functions to perform hash calculations on the address information, generating multiple corresponding hash values. Then, a pre-created bit array is obtained. Subsequently, the multiple hash values are transformed based on the bit array to obtain corresponding location data. This location data is then used as the calculation data. Based on this processing flow, this application, by using a Bloom filter and multiple target hash functions to perform hash calculations on the address information to obtain multiple hash values, and then transforming these hash values based on a pre-created bit array, uses the obtained location data as the corresponding calculation data. This enables automatic and accurate hash mapping of address information, improving the processing efficiency of hash mapping and ensuring the accuracy of the generated calculation data.
[0045] In some optional implementations of this embodiment, after step S206, the electronic device may further perform the following steps: Within a preset time window, the number of valid devices obtained after deduplication by the Bloom filter is counted.
[0046] In this embodiment, when the system starts up, it initializes a fixed-length time window (e.g., 2 seconds) as the period for counting the number of devices. This time window is used to dynamically assess the device density of the current environment, avoiding frequent parameter adjustments due to instantaneous fluctuations.
[0047] Among them, within each time window, the number of valid devices after deduplication by the Bloom filter is counted (denoted as N). The Bloom filter has filtered out duplicate devices, so N directly reflects the number of newly discovered unique devices in the current window and serves as the core indicator for environmental density assessment.
[0048] Data analysis is performed on the number of valid devices based on a preset environmental density analysis strategy to obtain corresponding target environmental information.
[0049] In this embodiment, for the specific implementation process of performing data analysis on the number of valid devices based on a preset environmental density analysis strategy to obtain corresponding target environmental information, this application will further describe the details in subsequent specific embodiments and will not elaborate too much here.
[0050] Obtain a target parameter adjustment strategy corresponding to the target environmental information.
[0051] In this embodiment, the above target environmental information includes a dense environment or a sparse environment, and the corresponding target parameter adjustment strategy includes a first parameter adjustment strategy corresponding to the dense environment, or includes a second parameter adjustment strategy corresponding to the sparse environment.
[0052] Specifically, the content of the above first parameter adjustment strategy includes: Dense environment processing: When N > high, the system believes that there are too many devices in the current area and needs to reduce the scanning frequency to reduce power consumption. At this time, the underlying Bluetooth scanning interface is called (such as BluetoothLeScanner.startScan) to adjust two key parameters: Scan Interval: Extend the time interval between two scan starts (for example, from 100 milliseconds to 500 milliseconds) to reduce the scan trigger frequency.
[0053] Scan Window: Shorten the duration of each scan (for example, from 50 milliseconds to 20 milliseconds) to reduce the energy consumption of a single scan.
[0054] Duty cycle calculation: Duty cycle = Scan Window / Scan Interval (for example, 20ms / 500ms = 4%). After adjustment, the duty cycle drops from 50% to 40%, significantly reducing power consumption. The duty cycle reflects the density of scanning activities and directly affects power consumption and discovery speed.
[0055] The content of the above second parameter adjustment strategy includes: Sparse environment processing: When N < low, the system believes that there are few devices in the current area and needs to accelerate device discovery to improve the user experience. At this time, the parameters are adjusted in the opposite direction: Scan Interval: Shorten the interval time (for example, from 500 milliseconds to 100 milliseconds) to increase the scan trigger frequency.
[0056] Scan window: Increase the time for a single scan (e.g., from 20 milliseconds to 50 milliseconds) to improve the coverage of a single scan.
[0057] Duty cycle calculation: The adjusted duty cycle increases from 40% to 60% (e.g., 50ms / 100ms=50%), speeding up device detection.
[0058] The scanning parameters are adjusted accordingly based on the target parameter adjustment strategy.
[0059] In this embodiment, the strategy content of the adjustment strategy can be adjusted according to the selected target parameters to perform corresponding scanning parameter adjustment processing.
[0060] The system also features closed-loop control and parameter reset capabilities. The specific implementation process includes: window reset and re-counting: After each parameter adjustment, the time window is immediately reset (clearing the currently counted N value), and a new 2-second cycle is started to re-count the number of valid devices. This mechanism ensures that parameter adjustments are based on the latest environmental data, avoiding lag effects. Continuous adaptive loop: The system continuously senses environmental changes and dynamically optimizes the scanning strategy through a closed-loop process of "counting N → comparing thresholds → adjusting parameters → resetting the window." For example, when a user moves from a dense area to a sparse area, the system automatically increases the duty cycle; conversely, it reduces power consumption, creating a seamless adaptive experience.
[0061] In addition, adaptive scanning parameter adjustment resolves the performance conflict between Bluetooth scanning in dense and sparse environments by dynamically balancing discovery speed and power consumption: Dense environment optimization: reducing scanning frequency and duty cycle to lower power consumption and avoid signal interference, but may prolong device discovery time (which needs to be compensated for by extending the scan cycle). Sparse environment optimization: increasing the duty cycle to accelerate discovery, but increasing power consumption (which needs to be limited by shortening the scan cycle).
[0062] This mechanism relies on the deduplication result (N value) of the Bloom filter as the accurate assessment basis for environmental density, avoiding interference from duplicate devices. Closed-loop control ensures that the system can continuously sense environmental changes (such as user movement, device additions or removals) and adjust parameters in real time, forming an intelligent "perception-decision-execution" cycle. This solution is particularly suitable for mobile devices or battery-powered scenarios (such as smartphones and wearable devices), significantly extending battery life without sacrificing user experience. By reasonably setting thresholds (such as high=15, low=5) and adjusting step sizes (such as the increase or decrease of intervals / windows), the adaptive sensitivity and stability can be further optimized.
[0063] In this application, within a preset time window, the number of valid devices obtained after deduplication by the Bloom filter is counted; then, data analysis is performed on the number of valid devices based on a preset environmental density analysis strategy to obtain corresponding target environmental information; then, a target parameter adjustment strategy corresponding to the target environmental information is obtained; subsequently, corresponding adjustment processing is performed on the scanning parameters based on the target parameter adjustment strategy. Based on the above processing flow, this application uses the deduplication result based on the Bloom filter as an accurate evaluation basis for environmental density, which can avoid interference from duplicate devices in judgment. Then, by obtaining the target parameter adjustment strategy corresponding to the target environmental information and adjusting the scanning parameters in real time according to the target parameter adjustment strategy, the accuracy of the strategy adjustment is effectively ensured, enabling the system to continuously adapt to environmental changes and dynamically adjust the scanning parameters to balance the discovery speed and power consumption.
[0064] In some optional implementation manners, the data analysis of the number of valid devices based on a preset environmental density analysis strategy to obtain corresponding target environmental information includes the following steps: Obtain a preset upper limit threshold and a lower limit threshold.
[0065] In this embodiment, according to actual business requirements, two key thresholds are predefined: high (i.e., the upper limit threshold, such as 15) and low (i.e., the lower limit threshold, such as 5). High represents the upper limit of a device-dense environment, and low represents the lower limit of a sparse environment. If N > high, it is determined as a dense environment; if N < low, it is determined as a sparse environment; if low ≤ N ≤ high, the current scanning parameters remain unchanged.
[0066] Judge whether the number of valid devices is greater than the upper limit threshold.
[0067] In this embodiment, the numerical comparison between the counted number of valid devices and the above upper limit threshold can be performed to generate a corresponding first numerical comparison result. The first numerical comparison result includes that the number of valid devices is greater than the upper limit threshold or the number of valid devices is less than the upper limit threshold.
[0068] If the number of valid devices is greater than the upper limit threshold, the target environmental information is determined as a dense environment.
[0069] In this embodiment, if it is detected that the number of valid devices is greater than the upper limit threshold, that is, the number of valid devices is greater than the upper limit of the dense environment, then the above target environmental information will be determined as a dense environment.
[0070] If the number of valid devices is less than the upper limit threshold, then judge whether the number of valid devices is less than the lower limit threshold.
[0071] In this embodiment, a second numerical comparison result can be generated by comparing the statistically counted number of valid devices with the aforementioned lower threshold. The second numerical comparison result includes either a number of valid devices being less than the lower threshold or a number of valid devices being greater than the lower threshold.
[0072] If so, the target environment information is determined to be a sparse environment.
[0073] In this embodiment, if the number of valid devices is detected to be less than the lower threshold, that is, the number of valid devices is less than the lower limit of the sparse environment, the above target environment information will be determined as a sparse environment.
[0074] This application obtains preset upper and lower threshold values; then determines whether the number of effective devices is greater than the upper threshold value; if the number of effective devices is greater than the upper threshold value, the target environment information is determined to be a dense environment; if the number of effective devices is less than the upper threshold value, it determines whether the number of effective devices is less than the lower threshold value; if so, the target environment information is determined to be a sparse environment. Based on the above processing flow, this application compares the number of effective devices using the upper and lower threshold values, and then analyzes the obtained numerical comparison results, thereby automatically and accurately completing the data analysis of the number of effective devices, effectively improving the accuracy and intelligence of the generated target environment information.
[0075] In some optional implementations of this embodiment, after step S206, the electronic device may further perform the following steps: Determine whether a Bluetooth device connection request initiated by the user has been received.
[0076] In this embodiment, the user can initiate a Bluetooth device connection request related to the target device according to their own needs.
[0077] If so, obtain the request information corresponding to the Bluetooth device connection request, and encapsulate the request information into a target object.
[0078] In this embodiment, when a user initiates a Bluetooth device connection request, the system encapsulates the request information (including the target device's MAC address, connection timeout (e.g., 5 seconds), callback function, etc.) into a ConnectionTask object (i.e., the target object). This target object, as the smallest unit of the task, carries all the context data required for the connection.
[0079] The target object is pushed into a pre-built first-in-first-out blocking queue.
[0080] In this embodiment, a first-in-first-out (FIFO) blocking queue (such as a thread-safe queue implemented based on a linked list) is pre-initialized to store ConnectionTask objects to be processed in the order they are initiated. The blocking nature of the queue ensures that when the queue is empty, the scheduling thread will wait for new tasks to arrive, avoiding idle processing and resource consumption. Then, the generated target objects are pushed into the aforementioned blocking queue.
[0081] Among them, the blocking queue: when the queue is empty, the thread that retrieves an element will be blocked until the queue is not empty; when the queue is full, the thread that adds an element will be blocked until the queue is not full.
[0082] Obtain the preset semaphore control mechanism.
[0083] In this embodiment, the semaphore control mechanism includes: Semaphore definition: Creating a binary semaphore with a license count of 1, whose core function is to restrict only one connection task to execute at a time. The license count of the semaphore represents the number of available resources; setting it to 1 here means that resources (such as the Bluetooth protocol stack) cannot be accessed concurrently.
[0084] Initial state: The initial permit count for the semaphore is 1, indicating that the scheduler can immediately process the first task; if the permit count is 0, subsequent tasks must wait for the preceding task to release the semaphore.
[0085] Based on the semaphore control mechanism, a preset scheduler is used to perform physical connection processing on the objects in the blocking queue.
[0086] Semaphores are a synchronization primitive used to control access permissions to shared resources. Here, the number of concurrent connections is limited by the number of permissions.
[0087] In this embodiment, the scheduler described above can be a scheduling thread. The task processing flow based on the scheduler includes: 1) Task dequeueing: The scheduling thread retrieves the earliest enqueued ConnectionTask object from the head of the FIFO queue (the first-in-first-out principle ensures the order). If the queue is empty, the scheduling thread blocks until a new task is enqueued.
[0088] 2) Semaphore Acquisition: The scheduling thread attempts to acquire a permit for the semaphore (by calling the acquire() method). If the current permit count is 1, the acquisition is successful, and the scheduling thread continues execution; if the permit count is 0 (the preceding task has not been released), the scheduling thread is blocked until the semaphore is released.
[0089] 3) Physical Connection Initiation: After acquiring the semaphore, the scheduling thread calls the underlying Bluetooth interface (such as connectGatt()) to initiate a physical connection with the target device, passing in callback functions for connection success / failure. connectGatt() is the underlying method in the Android Bluetooth API for initiating a GATT connection, responsible for establishing a BLE communication link with the device.
[0090] In addition, the system also has the functions of connection status callback and semaphore release, the specific implementation process of which includes: Successful path: If the connection is successful and subsequent steps (such as GATT service discovery and cached data loading) are completed, the system calls the semaphore's release() method to restore the permit count from 0 to 1, waking up the next task waiting in the queue. After releasing the semaphore, the current ConnectionTask object is marked as complete and removed from the queue (if the queue is not empty, the next task will continue to be processed).
[0091] Failure path: If the connection fails (e.g., device unreachable, protocol error) or exceeds the preset timeout (e.g., not completing within 5 seconds), the system catches the exception and forcibly calls the `release()` method to release the semaphore, preventing a deadlock in the entire queue due to task blocking. Failed tasks can log errors or trigger a retry mechanism (e.g., re-enqueueing), but the number of retries must be limited to prevent infinite loops. Deadlock: A state where multiple threads are waiting for each other to release resources, causing the system to be unable to continue execution. Deadlock is avoided here by forcibly releasing the semaphore.
[0092] The complete data flow includes: user command → ConnectionTask encapsulation → FIFO queue enqueue → semaphore request → physical connection initiation → status callback (success / failure) → semaphore release → next task processing.
[0093] The abnormal recovery mechanism includes: if the scheduling thread terminates abnormally (such as failing to release the semaphore), the system must provide a timeout forced release mechanism (such as monitoring the semaphore status through a daemon thread) to ensure that the queue is not permanently blocked due to a single task failure.
[0094] This application determines whether a user-initiated Bluetooth device connection request has been received. If so, it obtains the request information corresponding to the Bluetooth device connection request and encapsulates the request information into a target object. Then, it pushes the target object into a pre-built first-in-first-out (FIFO) blocking queue. Next, it obtains a preset semaphore control mechanism. Subsequently, based on the semaphore control mechanism, a preset scheduler performs physical connection processing on the objects in the blocking queue. Based on the above processing flow, this application achieves serialized scheduling of connection tasks through semaphores and blocking queues, effectively solving the protocol stack blocking problem caused by concurrent connections. Semaphores ensure that only one task executes at a time, avoiding resource contention; the blocking queue ensures that tasks are processed in the order they are initiated, maintaining timing controllability.
[0095] In some optional implementations of this embodiment, after the step of performing physical connection processing on objects in the blocking queue using a preset scheduler based on the semaphore control mechanism, the method further includes: Obtain the status information corresponding to the physical connection processing.
[0096] In this embodiment, the status information corresponding to the physical connection processing described above may include success or failure.
[0097] If the status information is successful, a target device fingerprint corresponding to the target device in the physical connection process is generated.
[0098] In this embodiment, the specific implementation process of generating the target device fingerprint corresponding to the target device in the physical connection process will be further described in detail in subsequent specific embodiments of this application, and will not be elaborated on here.
[0099] A cache query is performed on the local database based on the target device fingerprint.
[0100] In this embodiment, the serialized GATT attribute table (value) is pre-stored in a local database (such as SQLite) using the device fingerprint as the key. The attribute table contains the following core information: Service UUID list: Unique identifiers for all GATT services supported by the device (e.g., 0x180F represents the battery service). Characteristic UUID list: UUIDs of characteristic values contained under each service (e.g., the battery power characteristic value is 0x2A19). Handle ID mapping table: The handle of the characteristic value is an internal identifier in the Bluetooth protocol stack, used for direct reading and writing of data. The cache needs to record the mapping relationship between UUIDs and Handles to avoid re-parsing after each connection.
[0101] Among them, GATT (Generic Attribute Profile) is the core protocol of Bluetooth Low Energy (BLE), defining the hierarchical structure of data exchange between devices (service, characteristic, descriptor). Service UUID: A unique 16-bit or 128-bit ID identifying a GATT service (e.g., 0x180D represents the heart rate service). Characteristic UUID: A unique ID identifying a characteristic value, containing the actual data (e.g., heart rate value). Handle ID: An integer identifier assigned internally by the Bluetooth protocol stack for each characteristic value, used for directly reading and writing data; dynamically generated and may change with each connection.
[0102] Specifically, the system queries the local database using the target device fingerprint as a condition. If a matching record is found, the cache is considered to have been hit; otherwise, it is marked as a miss, and the standard service discovery process must be executed.
[0103] Additionally, cache miss handling (service discovery and storage) includes: Standard service discovery: The discoverServices() method of the Bluetooth protocol stack is called, triggering the underlying scanning of GATT services and characteristics supported by the device. This process requires interaction with the device via Bluetooth HCI commands and typically takes 200-500 milliseconds (depending on device complexity).
[0104] Result Serialization: Convert the BluetoothGattService and BluetoothGattCharacteristic objects returned by service discovery into a storable format (such as JSON), recording the following information: Service UUID, Feature UUID, Descriptor UUID (if any), Handle ID for each feature (a key optimization point to avoid reassignment in the future), and permissions for the feature (e.g., readable, writable, and notification-enabled).
[0105] Write to database: Store the serialized data in the local database with the device fingerprint as the key and set an expiration time (e.g., 7 days) to prevent the cache from becoming invalid after the device firmware is upgraded.
[0106] If a cache hit occurs, the serialized service list data corresponding to the target device fingerprint is read from the local database.
[0107] In this embodiment, if a cache hit is detected, the serialized service list data corresponding to the target device fingerprint is read from the local database, i.e., GATT attribute table data (such as JSON or binary format).
[0108] Based on the serialized data of the service list, perform the corresponding deserialization and object injection processing.
[0109] In this embodiment, the above deserialization and object injection processes include: Deserialization: Reads serialized GATT attribute table data (such as JSON or binary format) from the database and parses it into in-memory data structures (such as lists or dictionaries).
[0110] Object instantiation: Dynamically create BluetoothGattService and BluetoothGattCharacteristic objects using reflection. Service object: Instantiate the corresponding BluetoothGattService based on the Service UUID in the serialized data, and populate its list of feature values.
[0111] Feature value object: Instantiate BluetoothGattCharacteristic based on Characteristic UUID and Handle ID, and bind it to the service it belongs to.
[0112] Injection into the current connection: The instantiated service object and feature value object are directly injected into the current BluetoothGatt instance, skipping the service discovery process of the underlying protocol stack, i.e., the discoverServices() step. At this time, the application layer can immediately read and write feature value data through the cached Handle ID.
[0113] Terminology: Reflection: A programming language feature that allows objects to be created or properties to be accessed dynamically at runtime; here, it's used to bypass static code generation of the BluetoothGattService instance. Serialization: Converting an in-memory object into a storable or transmittable format (such as JSON or binary); here, it's used to persist the GATT property table to a database.
[0114] The coordination with the connection scheduling mechanism includes: Semaphore dependency: In connection scheduling, the release of a semaphore (release()) depends on the completion of GATT cache loading. Specifically, if the cache is hit, the semaphore is released immediately after deserialization, allowing the next connection task to execute. If the cache is missed, the semaphore is released only after service discovery is complete and the cache is written to the database.
[0115] Exception handling: If service discovery fails (e.g., device disconnection), the semaphore must be forcibly released and part of the cache cleared (e.g., marked as "invalid") to prevent subsequent tasks from failing due to reliance on the faulty cache.
[0116] Additionally, the complete data flow includes: Successful path: Connection successful → Generate device fingerprint → Query cache → Hit → Deserialization → Inject GATT object → Release semaphore → Communication ready. Failed path: Connection successful → Generate device fingerprint → Query cache → Hit → Perform service discovery → Serialization result → Store in database → Release semaphore → Communication ready.
[0117] In addition, GATT attribute table caching significantly optimizes Bluetooth connectivity performance by reusing metadata from devices of the same model. Skip service discovery: Service discovery requires interaction with the device via the Bluetooth protocol stack, which is the main time-consuming part of the connection process (especially for low-power devices). Caching directly provides pre-parsed Handle IDs, reducing connection time from hundreds of milliseconds to tens of milliseconds.
[0118] Device fingerprint uniqueness: The fingerprint must be generated based on stable fields (such as model and manufacturer ID) to avoid cache invalidation due to changes in device name or dynamic updates of broadcast data.
[0119] In coordination with connection scheduling: When the cache loading is not complete, the connection scheduling mechanism (step 3) will block subsequent tasks to ensure that all operations that depend on the cache (such as data reading and writing) are executed after the cache is ready, thus avoiding race conditions.
[0120] This application obtains status information corresponding to the physical connection processing; if the status information is successful, it generates a target device fingerprint of the target device corresponding to the physical connection processing; then, it performs a cache query on the local database based on the target device fingerprint; if the cache hits, it reads the service list serialization data corresponding to the target device fingerprint from the local database; subsequently, it performs corresponding deserialization and object injection processing based on the service list serialization data. Based on the above processing flow, when the status information corresponding to the physical connection processing is detected to be successful, this application generates a target device fingerprint of the target device corresponding to the physical connection processing, performs a cache query on the local database based on the target device fingerprint, and if the cache hits, it reads the service list serialization data corresponding to the target device fingerprint from the local database, and then performs corresponding deserialization and object injection processing based on the use of the service list serialization data. In this way, by caching the GATT attribute table of the same model of device, this application achieves a balance between connection stability and response speed, skips the time-consuming service discovery process (usually requiring hundreds of milliseconds), and significantly shortens the connection establishment time.
[0121] In some optional implementations of this embodiment, generating the target device fingerprint corresponding to the target device in the physical connection process includes the following steps: Extract key information corresponding to the target device from the preset channels.
[0122] In this embodiment, the aforementioned preset channel may include the device's GATT service or broadcast packets. Once the Bluetooth device connection is established, the system can extract key information from the device's GATT service or broadcast packets as the basis for generating the device fingerprint.
[0123] The GATT service path involves querying the device's Device Information Service (standard UUID is 0x180A) to read the Model Number String characteristic value (such as the string "Light-V1"). This value is usually fixed by the device manufacturer and identifies the device model.
[0124] Broadcast packet path: If the device does not expose the Device Information Service, then extract fixed information from the Manufacturer Data field of the broadcast packet, such as the manufacturer ID (2 bytes) and model code (custom bytes), and combine them into a unique identifier.
[0125] Obtain the preset fingerprint generation rules.
[0126] In this embodiment, the fingerprint generation rules include: converting the extracted model string or manufacturer ID + model code into a fixed-length string using a hash algorithm (such as MD5 or SHA-1), or directly concatenating them into a unique key (such as "Vendor123_Model456") to ensure that the fingerprints of devices of the same model are consistent.
[0127] Based on the fingerprint generation rules, the key information is processed to generate fingerprint data.
[0128] In this embodiment, the extracted key information can be processed to generate a fingerprint based on the rules of the fingerprint generation rules described above, and the obtained fingerprint data can be used as the corresponding target device fingerprint.
[0129] The fingerprint data is used as the fingerprint of the target device.
[0130] This application extracts key information corresponding to the target device from a preset channel; then obtains a preset fingerprint generation rule; subsequently, it performs fingerprint generation processing on the key information based on the fingerprint generation rule to obtain corresponding fingerprint data; and finally, it uses the fingerprint data as the fingerprint of the target device. Based on the above processing flow, this application extracts key information corresponding to the target device from a preset channel, then performs fingerprint generation processing on the extracted key information based on the use of fingerprint generation rules, and uses the obtained fingerprint data as the corresponding target device fingerprint. This enables automatic and intelligent generation of the target device fingerprint, improving the generation efficiency and ensuring the accuracy of the generated target device fingerprint.
[0131] In some alternative implementations, the user information obtained is subject to user consent and complies with relevant laws and policies.
[0132] Furthermore, any software tools or components not belonging to our company that appear in the embodiments of this application are merely illustrative examples and do not represent actual use.
[0133] Furthermore, this application enables efficient management of a dense network of surrounding Bluetooth devices (such as dozens to hundreds of smart devices) within a mobile application (App). It optimizes the scanning process through algorithms to reduce memory and CPU consumption; resolves concurrency blocking issues in the Bluetooth protocol stack through a scheduling mechanism; and accelerates the service discovery process through a caching mechanism. Ultimately, it achieves the technical benefits of "fast scanning without lag, batch connections without timeouts, and instant device control response."
[0134] Furthermore, the technical solution of this application has the following advantages: 1. Break through performance bottlenecks and eliminate UI lag: By using a Bloom filter to perform O(1) deduplication at the data source, the number of objects entering the Java heap memory is reduced by more than 90%, which completely solves the memory jitter and main thread blocking problems caused by frequent object creation.
[0135] 2. Improve connection success rate to over 99%: By using semaphores and FIFO queues, concurrent business logic is transformed into low-level serial execution, strictly adhering to the timing requirements of the Bluetooth protocol stack, effectively avoiding 133 errors and connection timeouts caused by HCI command congestion.
[0136] 3. Achieve a "instant connection" interactive experience: Through the GATT property table caching mechanism, for devices of the same model, the time-consuming service discovery process (usually taking 1-2 seconds) is eliminated, reducing the time from device connection to a controllable state to within 300 milliseconds.
[0137] 4. Intelligent power consumption management: The adaptive scanning strategy dynamically adjusts the RF operating parameters according to the ambient signal density, avoiding over-scanning when the device has already been detected, and significantly reducing the power consumption of the App.
[0138] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0139] It should be emphasized that, in order to further ensure the privacy and security of the aforementioned target device information, the target device information can also be stored in a blockchain node.
[0140] The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0141] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results. Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0142] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0143] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0144] Further reference Figure 3 As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of a data processing apparatus, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0145] like Figure 3 As shown, the data processing device 300 described in this embodiment includes: an extraction module 301, a first processing module 302, a second processing module 303, an inspection module 304, a filtering module 305, and a distribution module 306. Wherein: Extraction module 301 is used to extract the device address from the broadcast packet when a reported broadcast packet is received, and obtain the corresponding address information. The first processing module 302 is used to call a preset Bloom filter and initialize the Bloom filter. The second processing module 303 is used to perform hash mapping processing on the address information based on the Bloom filter and through multiple target hash functions to obtain the corresponding calculated data. The inspection module 304 is used to perform bit value checks on the calculated data based on a preset conflict detection strategy, and obtain the corresponding bit value check results. The filtering module 305 is used to perform duplicate device filtering on the broadcast packet based on the bit value check result to obtain the deduplicated target device information; The distribution module 306 is used to distribute the target device information to a preset rendering layer.
[0146] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here.
[0147] In some optional implementations of this embodiment, the second processing module 303 includes: The calculation submodule is used to perform hash calculations on the address information based on the Bloom filter and using the multiple target hash functions respectively to generate multiple corresponding hash values; The first submodule is used to retrieve a pre-created bit array; The conversion submodule is used to convert the multiple hash values based on the bit array to obtain the corresponding position data; The first determining submodule is used to use the location data as the calculation data.
[0148] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here.
[0149] In some optional implementations of this embodiment, the data processing apparatus further includes: The statistics module is used to count the number of valid devices obtained after deduplication by the Bloom filter within a preset time window. The analysis module is used to perform data analysis on the number of effective devices based on a preset environmental density analysis strategy to obtain the corresponding target environmental information; The first acquisition module is used to acquire the target parameter adjustment strategy corresponding to the target environment information; The adjustment module is used to adjust the scanning parameters according to the target parameter adjustment strategy.
[0150] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here. In some optional implementations of this embodiment, the analysis module includes: The second acquisition submodule is used to acquire the preset upper limit threshold and lower limit threshold; The first judgment submodule is used to determine whether the number of valid devices is greater than the upper limit threshold. The first determination submodule is used to determine the target environment information as a dense environment if the number of effective devices is greater than the upper limit threshold. The second judgment submodule is used to determine whether the number of valid devices is less than the lower limit threshold if the number of valid devices is less than the upper limit threshold. The second determination submodule is used to determine the target environment information as a sparse environment if the condition is met.
[0151] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here.
[0152] In some optional implementations of this embodiment, the data processing apparatus further includes: The judgment module is used to determine whether a Bluetooth device connection request initiated by the user has been received; The third processing module is used to, if yes, obtain request information corresponding to the Bluetooth device connection request, and encapsulate the request information into a target object; The push module is used to push the target object into a pre-built first-in-first-out blocking queue; The second acquisition module is used to acquire the preset semaphore control mechanism; The execution module is used to perform physical connection processing on objects in the blocking queue using a preset scheduler based on the semaphore control mechanism.
[0153] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here. In some optional implementations of this embodiment, the data processing apparatus further includes: The third acquisition module is used to acquire status information corresponding to the physical connection processing; The generation module is used to generate a target device fingerprint corresponding to the target device in the physical connection process if the status information is successful. The query module is used to perform cached queries on the local database based on the fingerprint of the target device; The reading module is used to read the service list serialization data corresponding to the target device fingerprint from the local database if the cache is hit. The fourth processing module is used to perform corresponding deserialization and object injection processing based on the serialized data of the service list.
[0154] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here. In some optional implementations of this embodiment, the generation module includes: An extraction submodule is used to extract key information corresponding to the target device from a preset channel; The third acquisition submodule is used to acquire preset fingerprint generation rules; The generation submodule is used to perform fingerprint generation processing on the key information based on the fingerprint generation rules to obtain the corresponding fingerprint data. The second determining submodule is used to use the fingerprint data as the fingerprint of the target device.
[0155] In this embodiment, the operations performed by the above modules or units correspond one-to-one with the steps of the data processing method in the aforementioned embodiments, and will not be repeated here.
[0156] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0157] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected via a system bus. It should be noted that only the computer device 4 with components 41-43 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0158] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0159] The memory 41 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as the hard disk or memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device 4. Of course, the memory 41 may include both the internal storage unit and its external storage device of the computer device 4. In this embodiment, the memory 41 is typically used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions for data processing methods. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or will be output.
[0160] In some embodiments, the processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to execute computer-readable instructions stored in the memory 41 or to process data, for example, to execute computer-readable instructions for the data processing method.
[0161] The network interface 43 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 4 and other electronic devices.
[0162] Compared with the prior art, the embodiments of this application have the following beneficial effects: In this embodiment, when a reported broadcast packet is received, the device address of the broadcast packet is extracted to obtain the corresponding address information; then, a preset Bloom filter is invoked and initialized; subsequently, based on the Bloom filter, the address information is hashed using multiple target hash functions to obtain the corresponding calculated data; subsequently, the calculated data is checked for bit values based on a preset conflict detection strategy to obtain the corresponding bit value check results; further, the broadcast packet is filtered for duplicate devices based on the bit value check results to obtain deduplicated target device information; finally, the target device information is distributed to a preset rendering layer. Based on the above automated processing flow, when this application receives a reported broadcast packet, it extracts the device address from the broadcast packet to obtain address information. Then, it initializes the invoked Bloom filter and, based on the Bloom filter, performs hash mapping on the address information using multiple target hash functions to obtain calculated data. Subsequently, it uses a collision detection strategy to perform bit value checks on the calculated data to obtain bit value check results. Based on the bit value check results, it filters the broadcast packet for duplicate devices to obtain deduplicated target device information. Finally, it distributes the target device information to the rendering layer. Thus, by using a Bloom filter as the filtering layer for Bluetooth scanning, this application significantly reduces the amount of data processed subsequently, avoids repeatedly parsing the same broadcast packets, reduces UI rendering pressure, solves the memory jitter and main thread blocking problems caused by frequent object creation, effectively reduces memory usage and CPU load, and thus improves system response speed.
[0163] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the data processing method described above.
[0164] Compared with the prior art, the embodiments of this application have the following main advantages: In this embodiment, when a reported broadcast packet is received, the device address of the broadcast packet is extracted to obtain the corresponding address information; then, a preset Bloom filter is invoked and initialized; subsequently, based on the Bloom filter, the address information is hashed using multiple target hash functions to obtain the corresponding calculated data; subsequently, the calculated data is checked for bit values based on a preset conflict detection strategy to obtain the corresponding bit value check results; further, the broadcast packet is filtered for duplicate devices based on the bit value check results to obtain deduplicated target device information; finally, the target device information is distributed to a preset rendering layer. Based on the above automated processing flow, when this application receives a reported broadcast packet, it extracts the device address from the broadcast packet to obtain address information. Then, it initializes the invoked Bloom filter and, based on the Bloom filter, performs hash mapping on the address information using multiple target hash functions to obtain calculated data. Subsequently, it uses a collision detection strategy to perform bit value checks on the calculated data to obtain bit value check results. Based on the bit value check results, it filters the broadcast packet for duplicate devices to obtain deduplicated target device information. Finally, it distributes the target device information to the rendering layer. Thus, by using a Bloom filter as the filtering layer for Bluetooth scanning, this application significantly reduces the amount of data processed subsequently, avoids repeatedly parsing the same broadcast packets, reduces UI rendering pressure, solves the memory jitter and main thread blocking problems caused by frequent object creation, effectively reduces memory usage and CPU load, and thus improves system response speed.
[0165] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0166] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
[0167] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
Claims
1. A data processing method, characterized in that, Includes the following steps: When a broadcast packet is received, the device address is extracted from the broadcast packet to obtain the corresponding address information. Invoke the preset Bloom filter and initialize the Bloom filter; Based on the Bloom filter, the address information is hash-mapped using multiple target hash functions to obtain the corresponding computed data. The calculated data is checked for bit values based on a preset conflict detection strategy to obtain the corresponding bit value check results. Based on the bit value check results, the broadcast packet is filtered for duplicate devices to obtain the deduplicated target device information. The target device information is distributed to a preset rendering layer.
2. The data processing method according to claim 1, characterized in that, The step of performing hash mapping processing on the address information using multiple target hash functions based on the Bloom filter to obtain the corresponding computational data specifically includes: Based on the Bloom filter, the address information is hashed using the multiple target hash functions to generate multiple corresponding hash values. Get the pre-created bit array; Based on the bit array, the multiple hash values are transformed to obtain the corresponding position data; The location data is used as the calculation data.
3. The data processing method according to claim 1, characterized in that, After the step of distributing the target device information to a preset rendering layer, the method further includes: Within a preset time window, the number of valid devices obtained after deduplication by the Bloom filter is counted. Based on a preset environmental density analysis strategy, the number of effective devices is analyzed to obtain the corresponding target environmental information. Obtain the target parameter adjustment strategy corresponding to the target environment information; The scanning parameters are adjusted accordingly based on the target parameter adjustment strategy.
4. The data processing method according to claim 3, characterized in that, The step of analyzing the number of effective devices based on a preset environmental density analysis strategy to obtain corresponding target environmental information specifically includes: Obtain the preset upper and lower threshold values; Determine whether the number of valid devices is greater than the upper limit threshold; If the number of effective devices is greater than the upper limit threshold, the target environment information is determined to be a dense environment; If the number of valid devices is less than the upper limit threshold, then determine whether the number of valid devices is less than the lower limit threshold; If so, the target environment information is determined to be a sparse environment.
5. The data processing method according to claim 1, characterized in that, After the step of distributing the target device information to a preset rendering layer, the method further includes: Determine whether a Bluetooth device connection request initiated by the user has been received; If so, obtain the request information corresponding to the Bluetooth device connection request, and encapsulate the request information into a target object; The target object is pushed into a pre-built first-in-first-out blocking queue; Obtain the preset semaphore control mechanism; Based on the semaphore control mechanism, a preset scheduler is used to perform physical connection processing on the objects in the blocking queue.
6. The data processing method according to claim 5, characterized in that, After the step of performing physical connection processing on objects in the blocking queue using a preset scheduler based on the semaphore control mechanism, the method further includes: Obtain the status information corresponding to the physical connection processing; If the status information is successful, a target device fingerprint corresponding to the target device in the physical connection process is generated; Perform a cached query on the local database based on the target device fingerprint; If the cache is hit, the serialized service list data corresponding to the target device fingerprint is read from the local database. Based on the serialized data of the service list, perform the corresponding deserialization and object injection processing.
7. The data processing method according to claim 6, characterized in that, The step of generating the target device fingerprint corresponding to the target device in the physical connection process specifically includes: Extract key information corresponding to the target device from the preset channels; Obtain the preset fingerprint generation rules; Based on the fingerprint generation rules, the key information is processed to generate fingerprint data. The fingerprint data is used as the fingerprint of the target device.
8. A data processing apparatus, characterized in that, include: The extraction module is used to extract the device address from the broadcast packet when a reported broadcast packet is received, so as to obtain the corresponding address information. The first processing module is used to call a preset Bloom filter and initialize the Bloom filter. The second processing module is used to perform hash mapping processing on the address information based on the Bloom filter and through multiple target hash functions to obtain the corresponding calculated data. The checking module is used to perform bit value checks on the calculated data based on a preset conflict detection strategy, and obtain the corresponding bit value check results. The filtering module is used to filter the broadcast packets for duplicate devices based on the bit value check results, so as to obtain the deduplicated target device information; The distribution module is used to distribute the target device information to a preset rendering layer.
9. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the data processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the data processing method as described in any one of claims 1 to 7.