Bluetooth scanning method and device, terminal, storage medium and computer program product
By setting up function queues and listener queues in the mini program, detecting Bluetooth scanning and device collection status, and using the device container pool to store information, the problem of mutual scanning influence when the terminal communicates with multiple Bluetooth devices is solved, and the probability of communication failure is reduced.
Patent Information
- Application Number
- CN202410330274.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-21
- Publication Date
- 2025-09-23
AI Technical Summary
When a terminal communicates with multiple Bluetooth devices, Bluetooth scans affect each other, causing communication failure.
By setting up function queues and listener queues in the applet, the status of Bluetooth scanning and device collection is detected, and device information is stored in the device container pool to avoid repeated Bluetooth scanning.
It reduces the probability of Bluetooth communication failure and improves the efficiency of multi-dimensional Bluetooth scanning.
Smart Images

Figure CN120692537A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of Bluetooth technology, and in particular to a Bluetooth scanning method, device, terminal, storage medium, and computer program product. Background Art
[0002] With the development of Internet technology, shared two-wheeled vehicles have emerged, bringing great convenience to people's work and life.
[0003] Currently, borrowing and returning shared two-wheeled vehicles is often accomplished through Bluetooth communication between terminals and the vehicles. However, as services evolve, Bluetooth-enabled devices are increasingly common, such as electronic fences using Bluetooth road studs. Consequently, terminals may be communicating simultaneously with both the Bluetooth road studs and the shared two-wheeled vehicles.
[0004] In the above situation, it is easy for Bluetooth scans to affect each other, resulting in Bluetooth communication failure. Summary of the Invention
[0005] The embodiments of the present disclosure provide a Bluetooth scanning method, apparatus, terminal, storage medium, and computer program product, which can avoid mutual influence of Bluetooth scans and reduce the probability of Bluetooth communication failure.
[0006] In a first aspect, an embodiment of the present disclosure provides a Bluetooth scanning method, the method comprising:
[0007] When the target function of the mini program is triggered, the preset function queue is detected, wherein the target function is implemented through Bluetooth communication, and the function queue is used to store the function identifier;
[0008] Perform Bluetooth scanning based on the detection results of the function queue and update the function queue;
[0009] Detecting a preset listener queue, wherein the listener queue is used to store the listener identifier of the functional listener;
[0010] Devices are collected based on the detection results of the listener queue, and the device container pool and listener queue are updated. The device container pool is used to store the collected device information of Bluetooth devices for the function listener of the applet to select the Bluetooth device to implement the corresponding function.
[0011] In a second aspect, an embodiment of the present disclosure provides a Bluetooth scanning device, the device comprising:
[0012] A function queue detection module is used to detect a preset function queue when a target function of the mini program is triggered, wherein the target function is implemented via Bluetooth communication and the function queue is used to store function identifiers;
[0013] The Bluetooth scanning module is used to perform Bluetooth scanning according to the detection results of the function queue and update the function queue;
[0014] A listener queue detection module is used to detect a preset listener queue, wherein the listener queue is used to store the listener identifier of the functional listener;
[0015] The device collection module is used to collect devices based on the detection results of the listener queue and update the device container pool and the listener queue. The device container pool is used to store the collected device information of Bluetooth devices for the function listener of the applet to select the Bluetooth device to implement the corresponding function.
[0016] In a third aspect, an embodiment of the present disclosure provides a terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the computer program.
[0017] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0018] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0019] The Bluetooth scanning method, device, terminal, storage medium and computer program product provided by the embodiments of the present disclosure detect the preset function queue when the target function of the mini-program is triggered; perform Bluetooth scanning based on the detection results of the function queue and update the function queue; detect the preset listener queue; collect devices based on the detection results of the listener queue, and update the device container pool and the listener queue. The embodiments of the present disclosure determine whether Bluetooth scanning and device collection are turned on by setting the function queue and the listener queue, and store device information by setting the device container pool so that the function listener can select the Bluetooth device with the corresponding function from the device container pool. In this way, when implementing multi-dimensional Bluetooth scanning, the mutual influence caused by repeated initiation of Bluetooth scanning can be avoided, thereby reducing the probability of Bluetooth communication failure. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A diagram showing an application environment of a Bluetooth scanning method in one embodiment;
[0021] Figure 2 1 is a flow chart of a Bluetooth scanning method according to an embodiment;
[0022] Figure 3A flowchart of the steps of performing Bluetooth scanning and updating a function queue in one embodiment;
[0023] Figure 4 This is a flowchart illustrating the steps of collecting devices and updating the device container pool and listener queue in one embodiment;
[0024] Figure 5 This is a second flow chart of the steps of collecting devices and updating the device container pool and listener queue in one embodiment;
[0025] Figure 6 A flowchart illustrating steps for shutting down a device collector and a Bluetooth scanner in one embodiment;
[0026] Figure 7 A block diagram of a Bluetooth scanning device in one embodiment;
[0027] Figure 8 FIG. 4 is a diagram showing the internal structure of a terminal in an embodiment. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure more clear, the embodiments of the present disclosure are further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the embodiments of the present disclosure and are not intended to limit the embodiments of the present disclosure.
[0029] First, before specifically introducing the technical solutions of the embodiments of the present disclosure, we will first introduce the technical background or technological evolution of the embodiments of the present disclosure. With the development of Internet technology, shared two-wheeled vehicles have emerged, bringing great convenience to people's work and life. Currently, the borrowing and returning of shared two-wheeled vehicles is often achieved through Bluetooth communication between the terminal and the shared two-wheeled vehicle. As business develops, the number of devices with Bluetooth capabilities has gradually increased. For example, electronic fences use Bluetooth road studs. In this case, the terminal may simultaneously communicate with the Bluetooth road studs and the shared two-wheeled vehicle through Bluetooth. For example, the terminal establishes Bluetooth communication with the Bluetooth road studs to determine whether the terminal is within the electronic fence, and the terminal communicates with the shared two-wheeled vehicle through Bluetooth to enable the borrowing and returning of the shared two-wheeled vehicle. In this case, the terminal may need to scan the shared two-wheeled vehicle while scanning the Bluetooth road studs. The two Bluetooth scans may easily interfere with each other, resulting in the failure of Bluetooth communication between the terminal, the Bluetooth road studs, and the shared two-wheeled vehicle. Therefore, how to achieve multi-functional Bluetooth scanning has become a difficult problem that needs to be solved urgently. In addition, it should be noted that the applicant has expended a lot of creative effort to solve the above-mentioned problems and the technical solutions described in the following embodiments.
[0030] The following describes the technical solutions involved in the embodiments of the present disclosure in conjunction with the scenarios to which the embodiments of the present disclosure are applied.
[0031] The Bluetooth scanning method provided by the embodiment of the present disclosure can be applied to Figure 1 The application environment shown in FIG. This application environment includes a terminal 101 and a Bluetooth device 102. The terminal 101 may be a smartphone, tablet computer, or portable wearable device, and the portable wearable device may be a smartwatch, smart bracelet, or head-mounted device. The terminal 101 is equipped with a Bluetooth device that can radiate and scan Bluetooth signals, thereby enabling Bluetooth communication between the terminal 101 and the Bluetooth device 102. The Bluetooth device 102 includes, but is not limited to, the lock, central control, and Bluetooth road studs of a shared two-wheeled vehicle.
[0032] In one embodiment, Figure 2 As shown, a Bluetooth scanning method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:
[0033] Step 201: When the target function of the mini program is triggered, the preset function queue is detected.
[0034] Among them, the target function is realized through Bluetooth communication, and the function queue is used to store the function identifier, which is the unique identifier of each function in the mini program.
[0035] The terminal has an application pre-installed that supports multiple mini-programs, one of which allows users to use a shared two-wheeled vehicle. For example, Application A supports a Didi Chuxing mini-program. This mini-program has multiple functions, such as locking the vehicle, communicating with the shared two-wheeled vehicle's central control system via Bluetooth, and communicating with Bluetooth road studs via Bluetooth. Any of these functions can be the target function.
[0036] After the terminal opens the mini program, it can detect whether the function of the mini program is triggered in a variety of ways. For example, after receiving a touch operation for closing the vehicle lock control in the mini program, the terminal determines that the target function is to close the vehicle lock, and the target function is triggered. After detecting the scanning of the identification code of the shared two-wheeled vehicle, the terminal determines that the target function is to communicate with the central control of the shared two-wheeled vehicle via Bluetooth, and the target function is triggered. It should be noted that the target function of the mini program and the detection method for the triggering of the target function are not limited to the above description. In actual applications, other functions and other detection methods may also be included.
[0037] The mini program pre-sets a function queue, which can store the function identifier of the target function. After the target function is triggered, the mini program will check the function queue to see if the function identifier is stored in the function queue, and then determine whether Bluetooth scanning is enabled.
[0038] In one embodiment, detecting the function queue may include: detecting the length of the function queue; if the length of the function queue is 0, indicating that the function identifier is not stored in the function queue, it is determined that Bluetooth scanning is not turned on; if the length of the function queue is not 0, indicating that the function identifier is stored in the function queue, it is determined that Bluetooth scanning is turned on.
[0039] Step 202: Perform Bluetooth scanning according to the detection result of the function queue and update the function queue.
[0040] If the function queue detection result indicates that Bluetooth scanning is not enabled, Bluetooth scanning is enabled and scanned, and the function queue is updated according to the function identifier of the target function. If the function queue detection result indicates that Bluetooth scanning is enabled, the function queue is directly updated according to the function identifier of the target function.
[0041] Step 203: Detect the preset listener queue.
[0042] The listener queue is used to store the listener identifier of the function listener. Each function of the mini program is set with a corresponding function listener for listening to events related to the function. The listener identifier is the unique identifier of the function listener.
[0043] After performing a Bluetooth scan and updating the function queue, the applet will test the listener queue to determine whether the listener queue has stored the listener identifier, and thus determine whether device collection has been turned on.
[0044] In one embodiment, detecting the listener queue may include: detecting the length of the listener queue; if the length of the listener queue is 0, indicating that the listener identifier is not stored in the listener queue, and determining that device collection is not enabled; if the length of the listener queue is not 0, indicating that the listener identifier is stored in the listener queue, and determining that device collection is enabled.
[0045] Step 204: collect devices according to the detection result of the listener queue, and update the device container pool and the listener queue.
[0046] The device container pool is used to store the collected Bluetooth device information, allowing the mini-program's function listener to select the Bluetooth device that implements the corresponding function. Device information can include device identification code, vendor identification code, device serial number, system version number, firmware model, firmware version number, etc.
[0047] If the listener queue detection result indicates that device collection is not enabled, device collection is enabled and the device information of the Bluetooth device is collected. The device container pool is updated based on the collected device information, and the listener queue is updated based on the listener ID of the function listener of the target function.
[0048] If the detection result of the listener queue indicates that device collection is enabled, the device container pool is updated according to the collected device information, and the listener queue is updated according to the listener identifier of the function listener of the target function.
[0049] As you can understand, since the collected device information is stored in the device container pool, each function listener can simply select the Bluetooth device with the corresponding function from the device container pool when listening, without having to repeatedly initiate Bluetooth scanning. This prevents the two Bluetooth scans from interfering with each other, thereby reducing the chance of Bluetooth communication failure.
[0050] In the above embodiment, when the target function of the mini program is triggered, the preset function queue is detected; Bluetooth scanning is performed based on the detection results of the function queue, and the function queue is updated; the preset listener queue is detected; device collection is performed based on the detection results of the listener queue, and the device container pool and the listener queue are updated. The embodiment of the present disclosure determines whether Bluetooth scanning and device collection are turned on by setting the function queue and the listener queue, and stores device information by setting the device container pool so that the function listener can select the Bluetooth device with the corresponding function from the device container pool. In this way, when implementing multi-dimensional Bluetooth scanning, the mutual influence caused by repeated initiation of Bluetooth scanning can be avoided, thereby reducing the probability of Bluetooth communication failure.
[0051] In one embodiment, the step of “performing Bluetooth scanning according to the detection result of the function queue and updating the function queue” involved in the above embodiment is exemplarily introduced and explained.
[0052] like Figure 3 As shown, one implementation of this step may include:
[0053] Step 301: When the detection result of the function queue indicates that Bluetooth scanning is not enabled, the pre-set scanning enable interface of the bottom layer of the mini program is called to enable the Bluetooth scanner for Bluetooth scanning.
[0054] Mini programs have pre-configured scan start interfaces and Bluetooth scanners. For example, in the Didi Chuxing mini program, which is based on WeChat, the scan start interface is wx.startBluetoothDevicesDiscovery. This scan start interface can be an API (Application Program Interface).
[0055] If the detection result of the function queue indicates that Bluetooth scanning is not enabled, for example, the length of the function queue is 0, the above-mentioned scanning enable interface is called to enable the Bluetooth scanner, and the Bluetooth scanner is used to scan Bluetooth devices around the terminal.
[0056] Step 302: Store the function identifier of the target function into a function queue.
[0057] During the Bluetooth scanning process, the function identifier of the target function is stored in the function queue. On the one hand, it can indicate whether the Bluetooth scanning is turned on, and on the other hand, it can indicate that the target function is triggered by the mini program.
[0058] Another implementation of this step may include: when the detection result of the function queue indicates that Bluetooth scanning has been enabled, storing the function identifier of the target function in the function queue.
[0059] If the detection result of the function queue indicates that Bluetooth scanning is enabled, for example, the length of the function queue is not 0, indicating that the Bluetooth scanner is enabled and can continue to scan Bluetooth, then there is no need to call the above scanning start interface wx.startBluetoothDevicesDiscovery. In this case, you only need to store the function identifier of the target function in the function queue.
[0060] In the above embodiment, when the detection result of the function queue indicates that the Bluetooth scan is not turned on, the scan start interface pre-set at the bottom layer of the mini program is called to turn on the Bluetooth scanner for Bluetooth scanning; and the function identifier of the target function is stored in the function queue. When the detection result of the function queue indicates that the Bluetooth scan is turned on, the function identifier of the target function is stored in the function queue. The embodiment of the present disclosure can determine whether the Bluetooth scan is turned on through the detection of the function queue. When the Bluetooth scan is not turned on, the preset scan start interface is called to turn on the Bluetooth scanner to implement the Bluetooth scan; and when the Bluetooth scan is turned on, there is no need to repeatedly call the scan start interface. In this way, the mutual influence of the two Bluetooth scans can be avoided, thereby reducing the probability of Bluetooth communication failure.
[0061] In one embodiment, the step of “collecting devices according to the detection result of the listener queue, and updating the device container pool and the listener queue” in the above embodiment is exemplarily introduced and explained.
[0062] like Figure 4 As shown, one implementation of the above steps may include:
[0063] Step 401: When the detection result of the listener queue indicates that no Bluetooth device is collected, the collection start interface preset at the bottom layer of the mini-program is called to start the device collector to collect the device.
[0064] The underlying layer of the mini program pre-sets the network activation interface and device collector. For example, when the underlying layer of the Didi Chuxing mini program is WeChat, the network activation interface is wx.onBluetoothDeviceFound. This network activation interface can be an API.
[0065] If the detection result of the listener queue indicates that device collection is not enabled, for example, the length of the listener queue is 0, the above-mentioned collection enable interface is called to enable the device collector, and the device information of the Bluetooth devices scanned by the Bluetooth scanner is collected through the device collector.
[0066] In one embodiment, a Bluetooth scanner detects a Bluetooth device, and a device collector collects device information of the Bluetooth device. For example, if a Bluetooth scanner detects a lock on a shared two-wheeled vehicle, the device collector collects the lock's device information; if a Bluetooth scanner detects a Bluetooth road stud, the device collector collects the Bluetooth road stud's device information.
[0067] In another embodiment, after the Bluetooth scanner detects multiple Bluetooth devices around the terminal, the device collector collects the device information of these Bluetooth devices. For example, if the Bluetooth scanner detects the lock and Bluetooth road spikes of a shared two-wheeled vehicle, the device collector collects the device information of the lock and the Bluetooth road spikes.
[0068] It should be noted that the timing for collecting device information can be set according to actual conditions and is not limited to the above two implementation methods.
[0069] Step 402: Store the collected device information of the Bluetooth devices into a device container pool.
[0070] After the device collector collects the device information of the Bluetooth device, the applet stores the device information in the device container pool. In this way, function listeners with different functions can select the Bluetooth device with the corresponding function from the device container pool.
[0071] In actual applications, there are many ways to select devices. For example, a correspondence between listener identifiers and device identifiers can be pre-established, and the function listener can select a Bluetooth device from the device container pool based on the correspondence. Alternatively, a first correspondence between listener identifiers and function identifiers, and a second correspondence between function identifiers and device identifiers can be pre-established. The function listener can first determine the function it monitors based on the first correspondence, and then determine the Bluetooth device corresponding to the monitored function based on the second correspondence.
[0072] It should be noted that other selection rules may also be used for selection, and the selection method is not limited to the above two methods.
[0073] Step 403: Store the listener identifier of the function listener corresponding to the target function into the listener queue.
[0074] The mini program has determined that the target function has been triggered, and the Bluetooth device required by the target function has been scanned, and the device information of the Bluetooth device has been collected, then the listener identifier of the function listener corresponding to the target function is stored in the listener queue.
[0075] like Figure 5 As shown, another implementation of the above steps may include:
[0076] Step 501 : When the detection result of the listener queue indicates that the Bluetooth devices have been collected, the device information of the collected Bluetooth devices is stored in a device container pool.
[0077] If the detection result of the listener queue indicates that device collection has been enabled, for example, the length of the listener queue is not 0, there is no need to call the above-mentioned collection enable interface wx.onBluetoothDeviceFound. The device collector can continue to collect device information of Bluetooth devices scanned by the Bluetooth scanner.
[0078] The mini program can store device information in the device container pool so that function listeners with different functions can select Bluetooth devices with corresponding functions from the device container pool.
[0079] Step 502: Store the listener identifier of the function listener corresponding to the target function into the listener queue.
[0080] Similarly, the applet stores the listener identifier of the function listener corresponding to the target function in the listener queue, so as to determine whether the device collector is enabled according to the listener queue.
[0081] In the above embodiment, when the detection result of the listener queue indicates that the Bluetooth device has not been collected, the collection start interface pre-set at the bottom layer of the applet is called to start the device collector for device collection; the device information of the collected Bluetooth device is stored in the device container pool; the listener identifier of the function listener corresponding to the target function is stored in the listener queue. When the detection result of the listener queue indicates that the Bluetooth device has been collected, the device information of the collected Bluetooth device is stored in the device container pool; the listener identifier of the function listener corresponding to the target function is stored in the listener queue. The embodiment of the present disclosure can determine whether device collection is turned on through the detection of the listener queue. When device collection is not turned on, the preset collection start interface is called to turn on the device collector to achieve device collection; and when device collection is turned on, there is no need to repeatedly call the collection start interface. In this way, the two Bluetooth scans can avoid affecting each other, thereby reducing the probability of Bluetooth communication failure.
[0082] In one embodiment, the method may further include: when the target function is deactivated, deleting the function identifier in the function queue, the listener identifier in the listener queue, and the device information in the device container pool corresponding to the target function.
[0083] In practice, after the mini program completes its target function, it can deactivate it. In this case, the mini program removes the target function's function ID from the function queue, removes the listener ID of the function listener corresponding to the target function from the listener queue, and removes the device information of the Bluetooth device required by the target function from the device container pool.
[0084] For example, when the target function is to close the car lock, after the car lock is closed, the target function is disabled, the mini program deletes the function identifier of closing the car lock from the function queue, deletes the listener identifier of the function listener of closing the car lock from the listener queue, and deletes the device information of the car lock from the device container pool.
[0085] In the above embodiment, when the target function is deactivated, the function identifier in the function queue, the listener identifier in the listener queue, and the device information in the device container pool corresponding to the target function are deleted. In the embodiment of the present disclosure, when the target function is deactivated, the function queue, the listener queue, and the device container pool are updated in a timely manner so that the function queue, the listener queue, and the device container pool can accurately reflect the usage of the function and the communication status of the device, and accurately reflect whether Bluetooth scanning and device collection are enabled, thereby avoiding interference caused by repeated interface calls.
[0086] In one embodiment, Figure 6 As shown, after deleting the above identification and device information, the embodiment of the present disclosure may further include the following steps:
[0087] Step 601: Detect the function queue.
[0088] Check whether there are still function identifiers stored in the function queue. If there are still function identifiers stored in the function queue, it indicates that there are still functions in use in the mini program; if there are no function identifiers in the function queue, it indicates that all functions of the mini program have been disabled, then execute step 602.
[0089] For example, the length of the function queue is detected. If the length of the function queue is not 0, it indicates that other functions are in use and the device collector and Bluetooth scanner still need to be used. If the length of the function queue is 0, it indicates that no function is in use and the device collector and Bluetooth scanner can be disabled, and then step 602 is executed.
[0090] Step 602: Call the collection closing interface preset at the bottom layer of the applet according to the detection result of the function queue, close the device collector and stop collecting devices.
[0091] The underlying layer of the mini program is pre-set with a network shutdown interface. For example, when the underlying layer of the Didi Chuxing mini program is WeChat, the network shutdown interface is wx.offBluetoothDeviceFound. This network shutdown interface can be an API.
[0092] Call the collection shutdown interface to shut down the device collector, thereby stopping the collection device.
[0093] Step 603: Call the scan closing interface preset in the bottom layer of the applet to close the Bluetooth scanner and stop Bluetooth scanning.
[0094] The Mini Program's underlying layer is pre-configured with a scan-disable interface. For example, in the case of the Didi Chuxing Mini Program's underlying layer being WeChat, the scan-disable interface is wx.stopBluetoothDevicesDiscovery. This scan-disable interface can be an API.
[0095] Call the scan close interface to close the Bluetooth scanner, thereby stopping Bluetooth scanning.
[0096] In the above embodiment, the function queue is checked; based on the function queue check result, a collection shutdown interface pre-set in the applet's underlying layer is called to shut down the device collector and stop collecting devices; and a scan shutdown interface pre-set in the applet's underlying layer is called to shut down the Bluetooth scanner and stop Bluetooth scanning. In the disclosed embodiment, after all functions of the applet are disabled, calling the shutdown interface to shut down the device collector and Bluetooth scanner can save power consumption in the terminal.
[0097] In one embodiment, a Bluetooth scanning method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the terminal in the figure:
[0098] Step 1: When the target function of the mini program is triggered, the preset function queue is detected.
[0099] Perform step 2 or step 3 based on the detection result of the functional queue.
[0100] Step 2: If the detection result of the function queue indicates that Bluetooth scanning is not enabled, call the scan enable interface pre-set at the bottom layer of the mini program to enable the Bluetooth scanner for Bluetooth scanning; and store the function identifier of the target function in the function queue.
[0101] Step 4: When the detection result of the function queue indicates that Bluetooth scanning has been turned on, the function identifier of the target function is stored in the function queue.
[0102] Step 5: Check the preset listener queue.
[0103] Execute step 6 or step 7 based on the detection result of the listener queue.
[0104] Step 6. When the detection result of the listener queue indicates that no Bluetooth device is collected, call the collection start interface pre-set at the bottom layer of the mini program to start the device collector for device collection; store the collected device information of the Bluetooth device in the device container pool; store the listener identifier of the function listener corresponding to the target function in the listener queue.
[0105] The device container pool is used to store the collected device information of Bluetooth devices, so that the function listener of the mini program can select the Bluetooth device that implements the corresponding function.
[0106] Step 7: If the detection result of the listener queue indicates that the Bluetooth devices have been collected, the device information of the collected Bluetooth devices is stored in the device container pool; and the listener identifier of the function listener corresponding to the target function is stored in the listener queue.
[0107] Step 8: When the target function is disabled, the function identifier in the function queue, the listener identifier in the listener queue, and the device information in the device container pool corresponding to the target function are deleted.
[0108] Step 9, test the function queue; call the collection closing interface preset at the bottom layer of the applet according to the test result of the function queue, close the device collector and stop collecting devices; call the scan closing interface preset at the bottom layer of the applet, close the Bluetooth scanner and stop Bluetooth scanning.
[0109] In the above embodiment, whether Bluetooth scanning and device collection are turned on is determined by setting a function queue and a listener queue, and device information is stored by setting a device container pool so that the function listener can select a Bluetooth device with the corresponding function from the device container pool. In this way, when implementing multi-dimensional Bluetooth scanning, the mutual influence caused by repeated initiation of Bluetooth scanning can be avoided, thereby reducing the probability of Bluetooth communication failure.
[0110] It should be understood that, although the various steps in the above flow chart are shown in sequence as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above flow chart may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily to be performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0111] In one embodiment, Figure 7 As shown, a Bluetooth scanning device is provided, comprising:
[0112] A function queue detection module 701 is configured to detect a preset function queue when a target function of a mini-program is triggered, wherein the target function is implemented via Bluetooth communication and the function queue is configured to store a function identifier;
[0113] A Bluetooth scanning module 702 is configured to perform Bluetooth scanning according to the detection result of the function queue and update the function queue;
[0114] A listener queue detection module 703 is used to detect a preset listener queue, wherein the listener queue is used to store the listener identifier of the functional listener;
[0115] The device collection module 704 is used to collect devices according to the detection results of the listener queue and update the device container pool and the listener queue, wherein the device container pool is used to store the collected device information of Bluetooth devices for the function listener of the applet to select the Bluetooth device to implement the corresponding function.
[0116] In one embodiment, the Bluetooth scanning module 702 is specifically used to call the scan start interface pre-set at the bottom layer of the mini program to start the Bluetooth scanner for Bluetooth scanning when the detection result of the function queue indicates that the Bluetooth scanning is not turned on; and store the function identifier of the target function in the function queue.
[0117] In one embodiment, the Bluetooth scanning module 702 is specifically configured to store the function identifier of the target function in the function queue when the detection result of the function queue indicates that Bluetooth scanning has been enabled.
[0118] In one embodiment, the listener queue detection module 703 is specifically used to call the collection start interface pre-set at the bottom layer of the mini program to start the device collector for device collection when the detection result of the listener queue indicates that no Bluetooth device is collected; store the device information of the collected Bluetooth device in the device container pool; and store the listener identifier of the function listener corresponding to the target function in the listener queue.
[0119] In one embodiment, the listener queue detection module 703 is specifically used to store the device information of the collected Bluetooth devices into the device container pool when the detection result of the listener queue indicates that the Bluetooth devices have been collected; and store the listener identifier of the function listener corresponding to the target function into the listener queue.
[0120] In one embodiment, the apparatus further comprises:
[0121] The deleting module is configured to, when the target function is deactivated, delete the function identifier in the function queue, the listener identifier in the listener queue, and the device information in the device container pool corresponding to the target function.
[0122] In one embodiment, the apparatus further comprises:
[0123] The function queue detection module 701 is further used to detect the function queue;
[0124] The device collector closing module is used to call the collection closing interface preset at the bottom layer of the applet according to the detection result of the function queue, close the device collector and stop collecting devices;
[0125] The Bluetooth scanner closing module is used to call the scan closing interface preset at the bottom layer of the applet to close the Bluetooth scanner and stop Bluetooth scanning.
[0126] The specific definition of the Bluetooth scanning device can be found in the definition of the Bluetooth scanning method above and will not be repeated here. Each module in the Bluetooth scanning device described above can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the modules can be embedded in or independent of the processor in the terminal in hardware form, or stored in the terminal's memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0127] Figure 8 1 is a block diagram illustrating a terminal 1300 according to an exemplary embodiment. Terminal 1300 may include one or more of the following components: a processing component 1302, a memory 1304, a power component 1306, a multimedia component 1308, an audio component 1310, an input / output (I / O) interface 1312, a sensor component 1314, and a communication component 1316. The memory stores computer programs or instructions that run on the processor.
[0128] Processing component 1302 generally controls the overall operation of terminal 1300, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. Processing component 1302 may include one or more processors 1320 to execute instructions to perform all or part of the steps of the above-described method. In addition, processing component 1302 may include one or more modules to facilitate interaction between processing component 1302 and other components. For example, processing component 1302 may include a multimedia module to facilitate interaction between multimedia component 1308 and processing component 1302.
[0129] The memory 1304 is configured to store various types of data to support operations on the terminal 1300. Examples of such data include instructions for any application or method operating on the terminal 1300, contact data, phone book data, messages, pictures, videos, etc. The memory 1304 can be implemented by any type of volatile or non-volatile memory device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0130] Power component 1306 provides power to various components of terminal 1300. Power component 1306 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to terminal 1300.
[0131] The multimedia component 1308 includes a touchscreen display that provides an output interface between the terminal 1300 and the user. In some embodiments, the touchscreen display may include a liquid crystal display (LCD) and a touch panel (TP). The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensors can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action. In some embodiments, the multimedia component 1308 includes a front camera and / or a rear camera. When the terminal 1300 is in an operating mode, such as a capture mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can have a fixed optical lens system or have focal length and optical zoom capabilities.
[0132] The audio component 1310 is configured to output and / or input audio signals. For example, the audio component 1310 includes a microphone (MIC) that is configured to receive external audio signals when the terminal 1300 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in the memory 1304 or transmitted via the communication component 1316. In some embodiments, the audio component 1310 also includes a speaker for outputting audio signals.
[0133] I / O interface 1312 provides an interface between processing component 1302 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to, a home button, volume buttons, a start button, and a lock button.
[0134] Sensor assembly 1314 includes one or more sensors for providing various aspects of terminal 1300 status assessment. For example, sensor assembly 1314 can detect the open / closed state of terminal 1300, the relative positioning of components, such as the display and keypad of terminal 1300. Sensor assembly 1314 can also detect changes in the position of terminal 1300 or a component of terminal 1300, the presence or absence of user contact with terminal 1300, the orientation or acceleration / deceleration of terminal 1300, and changes in the temperature of terminal 1300. Sensor assembly 1314 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 1314 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 1314 can also include an accelerometer, a gyroscope, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0135] The communication component 1316 is configured to facilitate wired or wireless communication between the terminal 1300 and other devices. The terminal 1300 can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 1316 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1316 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0136] In an exemplary embodiment, the terminal 1300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-mentioned Bluetooth scanning method.
[0137] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1304 including instructions. The instructions can be executed by the processor 1320 of the terminal 1300 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0138] In an exemplary embodiment, a computer program product is also provided. When executed by a processor, the computer program can implement the above-described method. The computer program product includes one or more computer instructions. When these computer instructions are loaded and executed on a computer, they can implement part or all of the above-described method in whole or in part according to the processes or functions described in the embodiments of the present disclosure.
[0139] It should be noted that any solutions described in this specification and in the examples that involve the processing of personal information will be processed only with a legitimate basis (such as with the consent of the personal information subject or as necessary for the performance of a contract) and only within the prescribed or agreed scope. A user's refusal to process personal information other than that required for basic functions will not affect their use of these functions.
[0140] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described method embodiments. Any reference to memory, storage, database, or other media used in the embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0141] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0142] The above-described embodiments merely represent several implementation methods of the embodiments of the present disclosure. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that a person of ordinary skill in the art can make several modifications and improvements without departing from the concept of the embodiments of the present disclosure, all of which fall within the scope of protection of the embodiments of the present disclosure. Therefore, the scope of protection of the patent for the embodiments of the present disclosure shall be based on the appended claims.
Claims
1. A Bluetooth scanning method, characterized in that: The method comprises: When a target function of the mini program is triggered, a preset function queue is detected, wherein the target function is implemented via Bluetooth communication, and the function queue is used to store function identifiers; Performing Bluetooth scanning according to the detection result of the function queue and updating the function queue; Detecting a preset listener queue, wherein the listener queue is used to store a listener identifier of a functional listener; Devices are collected according to the detection results of the listener queue, and the device container pool and the listener queue are updated, wherein the device container pool is used to store the collected device information of Bluetooth devices for the function listener of the applet to select a Bluetooth device to implement the corresponding function.
2. The method according to claim 1, characterized in that The performing of Bluetooth scanning according to the detection result of the function queue and updating the function queue includes: If the detection result of the function queue indicates that Bluetooth scanning is not enabled, calling the scan enable interface pre-set at the bottom layer of the applet to enable the Bluetooth scanner for Bluetooth scanning; The function identifier of the target function is stored in the function queue.
3. The method according to claim 2, characterized in that The performing of Bluetooth scanning according to the detection result of the function queue and updating the function queue includes: When the detection result of the function queue indicates that Bluetooth scanning has been turned on, the function identifier of the target function is stored in the function queue.
4. The method according to claim 2, characterized in that The collecting devices according to the detection result of the listener queue and updating the device container pool and the listener queue includes: When the detection result of the listener queue indicates that no Bluetooth device is collected, calling the collection start interface preset by the bottom layer of the applet to start the device collector to collect the device; Storing the collected device information of the Bluetooth devices in the device container pool; The listener identifier of the function listener corresponding to the target function is stored in the listener queue.
5. The method according to claim 4, characterized in that The collecting devices according to the detection result of the listener queue and updating the device container pool and the listener queue includes: If the detection result of the listener queue indicates that the Bluetooth devices have been collected, storing the device information of the collected Bluetooth devices in the device container pool; The listener identifier of the function listener corresponding to the target function is stored in the listener queue.
6. The method according to claim 4, characterized in that The method further comprises: When the target function is deactivated, the function identifier in the function queue, the listener identifier in the listener queue, and the device information in the device container pool corresponding to the target function are deleted.
7. The method according to claim 6, characterized in that The method further comprises: Testing the functional queue; Calling the collection closing interface preset at the bottom layer of the applet according to the detection result of the function queue to close the device collector and stop collecting devices; Call the scan closing interface preset at the bottom layer of the applet to close the Bluetooth scanner and stop Bluetooth scanning.
8. A Bluetooth scanning device, characterized in that: The device comprises: A function queue detection module is used to detect a preset function queue when a target function of the mini program is triggered, wherein the target function is implemented via Bluetooth communication and the function queue is used to store function identifiers; A Bluetooth scanning module, configured to perform Bluetooth scanning according to the detection result of the function queue and update the function queue; A listener queue detection module, configured to detect a preset listener queue, wherein the listener queue is used to store a listener identifier of a functional listener; The device collection module is used to collect devices according to the detection results of the listener queue and update the device container pool and the listener queue, wherein the device container pool is used to store the collected device information of Bluetooth devices for the function listener of the applet to select the Bluetooth device to implement the corresponding function.
9. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Bluetooth device communication method and device
CN103561479A
Method for realizing data transmission by using Bluetooth based on WeChat applet platform
CN110913376A
Bluetooth reconnection method and terminal equipment
CN114125805A
Optimization algorithm based on Bluetooth scanning
CN114980051A
OTA type new energy charger maintenance test system based on GD32
CN115712558A