Bluetooth device management method and electronic device
By optimizing the Bluetooth device management method, including querying and deleting device identifiers, the problem of low connection success rate between electronic devices and Bluetooth devices is solved, and a higher connection success rate and stability are achieved.
Patent Information
- Application Number
- CN202410725797.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-06-06
AI Technical Summary
In the existing technology, the connection success rate between electronic devices and Bluetooth devices is low, mainly due to the failure to effectively manage the device identification and historical device queue of the Bluetooth device, resulting in connection failure.
By implementing Bluetooth device management methods in electronic devices, including querying device queues and historical device queues, deleting unnecessary device identifiers, optimizing the length of the device queue, ensuring device identifier uniqueness, and deleting the earliest identifier when the historical device queue is full to improve the connection success rate.
It improves the connection success rate between electronic devices and Bluetooth devices, reduces connection failures, and enhances the connection stability of Bluetooth devices associated with sports and health applications.
Smart Images

Figure CN118301581B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the technical field of electronic devices, and in particular to a Bluetooth device management method and electronic device. Background Art
[0002] Bluetooth is a short-range wireless communication technology that can be used to achieve wireless information exchange between devices, such as wireless information exchange between electronic devices and Bluetooth devices. The prerequisite for wireless information exchange between electronic devices and Bluetooth devices is that the Bluetooth on both the electronic device and the Bluetooth device are turned on, and the electronic device and the Bluetooth device have established a Bluetooth connection. The electronic device establishes a Bluetooth connection with the Bluetooth device based on the Bluetooth type of the Bluetooth device queried. If the Bluetooth type of the Bluetooth device is not queried, the connection between the electronic device and the Bluetooth device may fail.
[0003] Therefore, how to improve the connection success rate between electronic devices and Bluetooth devices is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a Bluetooth device management method and an electronic device, which are helpful to improve the connection success rate between the electronic device and the Bluetooth device.
[0005] In a first aspect, an embodiment of the present application provides a Bluetooth device management method, which can be applied to an electronic device including Bluetooth. The method may include: in response to Bluetooth being turned on and scanning a first Bluetooth device through Bluetooth, querying whether a device queue includes a device identifier of the first Bluetooth device; in response to the device queue not including the device identifier of the first Bluetooth device, saving the device identifier and Bluetooth type of the first Bluetooth device to the device queue to obtain the first device queue, and saving the device identifier of the first Bluetooth device to the historical device queue to obtain the first historical device queue; in response to the number of device identifiers in the first historical device queue being greater than or equal to a threshold, deleting the first device identifier from the first historical device queue to obtain a second historical device queue; in response to the second historical device queue including a target device identifier, continuing to save the device identifier and Bluetooth type of the target Bluetooth device in the first device queue, the target device identifier is the same as the first device identifier in the first historical device queue, and the target device identifier is used to identify the target Bluetooth device; wherein the device queue includes at least one device identifier arranged in the order of scanning time and not repeated, the historical device queue includes at least one device identifier arranged in the order of scanning time, and the queue length of the device queue is less than or equal to the queue length of the historical device queue. That is to say, the device IDs in the device queue are unique and non-repetitive; the device IDs in the historical device queue can be repeated.
[0006] Implement the Bluetooth device management method provided in the first aspect. When the number of device identifiers in the historical device queue is greater than or equal to a threshold, delete the first device identifier in the historical device queue. If the device identifier is still included in the historical device queue after deletion, retain the device identifier in the device queue instead of deleting it. This can improve the connection success rate between the electronic device and the Bluetooth device when the Bluetooth device identified by the device identifier is scanned later.
[0007] In combination with the method provided in the first aspect, in some embodiments, in response to the second historical device queue including the target device identifier, and the target device identifier is the same as the device identifier of the first Bluetooth device, the device identifier and Bluetooth type of the first Bluetooth device continue to be stored in the first device queue. That is, when the queue length of the first historical device queue exceeds the threshold, after deleting the first device identifier in the first historical device queue, there is still a device identifier in the second historical device queue that is the same as the first device identifier in the first historical device queue, and the device identifier is the device identifier of the first Bluetooth device, then the device identifier and Bluetooth type of the first Bluetooth device are not deleted from the first device queue, thereby improving the success rate of the electronic device connecting to the first Bluetooth device.
[0008] In combination with the method provided in the first aspect, in some embodiments, the electronic device further includes a sports health application; when the first device queue includes a device identifier and a Bluetooth type of the first Bluetooth device, in response to the first Bluetooth device being a Bluetooth device associated with the sports health application, the device identifier of the first Bluetooth device is displayed on the device management interface of the sports health application; a connection operation for the first Bluetooth device is received on the device management interface of the sports health application, and in response to the connection operation, the Bluetooth type of the first Bluetooth device is obtained from the first device queue; based on the Bluetooth type of the first Bluetooth device, a pairing request is sent to the first Bluetooth device. Bluetooth devices associated with sports health applications, such as bracelets, watches, body fat scales, etc., are thereby helpful in improving the connection success rate between electronic devices and Bluetooth devices associated with sports health applications.
[0009] In combination with the method provided in the first aspect, in some embodiments, after the electronic device is connected to the first Bluetooth device, or after the device identification of the first Bluetooth device is displayed in the device management interface of the sports health application, if a deletion operation for the first Bluetooth device is received in the device management interface of the sports health application, then in response to the deletion operation, the device identification and Bluetooth type of the first Bluetooth device are deleted from the first device queue to free up space.
[0010] In combination with the method provided in the first aspect, in some embodiments, in response to the second historical device queue not including the target device identifier, the device identifier and Bluetooth type of the target Bluetooth device are deleted from the first device queue to free up space.
[0011] In combination with the method provided in the first aspect, in some embodiments, the electronic device also includes a Bluetooth protocol stack and a Bluetooth chip, the Bluetooth protocol stack is used to manage a device queue and a historical device queue; the Bluetooth chip is used to scan Bluetooth devices and obtain a device identifier and a Bluetooth type of the Bluetooth device.
[0012] In combination with the method provided in the first aspect, in some embodiments, a click operation on the Bluetooth shutdown mark is received, and in response to the click operation, the Bluetooth protocol stack and the Bluetooth chip are controlled to be in a working state; the Bluetooth chip is called to scan the Bluetooth devices in the environment where the electronic device is located; in response to the Bluetooth chip scanning a first Bluetooth device, the Bluetooth chip is called to obtain the first Bluetooth device, the device identifier and the Bluetooth type; the Bluetooth chip is called to transmit the first Bluetooth device, the device identifier and the Bluetooth type to the Bluetooth protocol stack; and the Bluetooth protocol stack is called to query whether the device queue includes the first Bluetooth device, the device identifier and the Bluetooth type.
[0013] In combination with the method provided in the first aspect, in some embodiments, the Bluetooth protocol stack is called to continue to store the device identification and Bluetooth type of the target Bluetooth device in the first device queue.
[0014] In the second aspect, the embodiment of the present application provides a Bluetooth device management method, which can be applied to an electronic device including Bluetooth. The method may include: in response to Bluetooth being turned on and scanning a first Bluetooth device through Bluetooth, querying whether the device queue includes the device identification of the first Bluetooth device; in response to the device queue not including the device identification of the first Bluetooth device, saving the device identification and Bluetooth type of the first Bluetooth device to the device queue to obtain the first device queue, and querying whether the historical device queue includes the device identification of the first Bluetooth device; in response to the historical device queue including the device identification of the first Bluetooth device, deleting the device identification of the first Bluetooth device from the historical device queue to obtain the first historical device queue, and saving the device identification of the first Bluetooth device to the first historical device queue to obtain the second historical device queue; in response to the number of device identifications in the second historical device queue being greater than or equal to a threshold, deleting the first device identification from the second historical device queue to obtain a third historical device queue, and deleting the device identification and Bluetooth type of the first target Bluetooth device from the first device queue, the device identification of the first target Bluetooth device is the same as the first device identification in the second historical device queue. Among them, the device identification in the device queue is unique and non-repetitive; the device identification in the historical device queue is also unique and non-repetitive.
[0015] By implementing the Bluetooth device management method provided in the second aspect, there are no duplicate device identifiers in the historical device queue, which can reduce the probability that the queue length of the historical device queue exceeds the threshold to a certain extent, thereby helping to improve the connection success rate between the electronic device and the Bluetooth device. Even if the queue length of the historical device queue exceeds the threshold, the first device identifier in the historical device queue is deleted, and the device identifier is deleted from the device queue to free up space.
[0016] In combination with the method provided in the second aspect, in some embodiments, in response to the historical device queue not including the device identification of the first Bluetooth device, the device identification of the first Bluetooth device is saved in the historical device queue to obtain a fourth historical device queue; in response to the number of device identifications in the fourth historical device queue being greater than or equal to a threshold, the first device identification is deleted from the fourth historical device queue to obtain a fifth historical device queue, and the device identification and Bluetooth type of the second target Bluetooth device are deleted from the first device queue to free up space. The device identification of the second target Bluetooth device is the same as the first device identification in the fourth historical device queue.
[0017] In combination with the method provided in the second aspect, in some embodiments, the electronic device also includes a sports health application; when the first device queue includes a device identifier and a Bluetooth type of the first Bluetooth device, in response to the first Bluetooth device being a Bluetooth device associated with the sports health application, the device identifier of the first Bluetooth device is displayed on the device management interface of the sports health application; a connection operation for the first Bluetooth device is received on the device management interface of the sports health application, and in response to the connection operation, the Bluetooth type of the first Bluetooth device is obtained from the first device queue; based on the Bluetooth type of the first Bluetooth device, a pairing request is sent to the first Bluetooth device. Bluetooth devices associated with sports health applications, such as bracelets, watches, body fat scales, etc., are thereby helpful to improve the connection success rate between electronic devices and Bluetooth devices associated with sports health applications.
[0018] In combination with the method provided in the second aspect, in some embodiments, a deletion operation for the first Bluetooth device is received in the device management interface of the sports health application. In response to the deletion operation, the device identifier and Bluetooth type of the first Bluetooth device are deleted from the first device queue, and the device identifier of the first Bluetooth device is deleted from the second historical device queue to free up space and avoid duplicate device identifiers in the historical device queue.
[0019] In combination with the method provided in the second aspect, in some embodiments, the electronic device also includes a Bluetooth protocol stack and a Bluetooth chip, the Bluetooth protocol stack is used to manage the device queue and the historical device queue; the Bluetooth chip is used to scan the Bluetooth device and obtain the device identification and Bluetooth type of the Bluetooth device.
[0020] In combination with the method provided in the second aspect, in some embodiments, a click operation on the Bluetooth shutdown mark is received, and in response to the click operation, the Bluetooth protocol stack and the Bluetooth chip are controlled to be in a working state; the Bluetooth chip is called to scan the Bluetooth devices in the environment where the electronic device is located; in response to the Bluetooth chip scanning a first Bluetooth device, the Bluetooth chip is called to obtain the first Bluetooth device, the device identifier and the Bluetooth type; the Bluetooth chip is called to transmit the first Bluetooth device, the device identifier and the Bluetooth type to the Bluetooth protocol stack; and the Bluetooth protocol stack is called to query whether the device queue includes the first Bluetooth device, the device identifier and the Bluetooth type.
[0021] In combination with the method provided in the second aspect, in some embodiments, the Bluetooth protocol stack is called to delete the first device identifier from the second historical device queue, obtain a third historical device queue, and delete the device identifier and Bluetooth type of the first target Bluetooth device from the first device queue.
[0022] In a third aspect, the present application provides an electronic device, comprising one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device executes the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.
[0023] In a fourth aspect, the present application provides a computer-readable storage medium comprising instructions. When the instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.
[0024] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when the computer program product is run on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation of the first aspect, or execute the method described in the second aspect and any possible implementation of the second aspect.
[0025] In a sixth aspect, the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute the method described in the first aspect and any possible implementation method of the first aspect, or execute the method described in the second aspect and any possible implementation method of the second aspect.
[0026] It can be understood that the electronic device provided in the third aspect, the computer storage medium provided in the fourth aspect, the computer program product provided in the fifth aspect, and the chip system provided in the sixth aspect are all used to execute the method provided in the first aspect or the second aspect of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figures 1 to 3 It is a sample diagram of the user interface of several pairing methods involved in the sports health application;
[0028] Figure 4 These are example diagrams of several user interfaces involved in Bluetooth applications;
[0029] Figure 5A This is a flowchart of the first connection between the mobile phone and the bracelet 2 through the sports health application;
[0030] Figure 5B This is a flowchart of the mobile phone connecting to the bracelet 2 through the sports health application for a non-first time;
[0031] Figure 6 is a software architecture diagram of an electronic device provided in an embodiment of the present application;
[0032] Figure 7 It is a flowchart of a Bluetooth device management method provided in an embodiment of the present application;
[0033] Figure 8 It is a flowchart of another Bluetooth device management method provided in an embodiment of the present application;
[0034] Fig. 9 It is a hardware structure diagram of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] The terms "first", "second", "third", etc. in the embodiments of the present application are distinguished from different objects, rather than being used to describe a specific order. In addition, the terms "include" and "have" and any variation thereof are intended to cover non-exclusive inclusions. For example, a series of steps or units are included, or alternatively, steps or units not listed are also included, or other steps or units inherent to these processes, methods, products or devices are optionally included. The terms "one embodiment" or "some embodiments", etc. mean that the specific features, structures or characteristics described in conjunction with the embodiment are included in one or more embodiments of the present application. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in the differences in the embodiments of the present application are not necessarily all with reference to the same embodiment, but mean "one or more but not all embodiments", unless otherwise particularly emphasized.
[0037] In addition, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects before and after the association are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or plural.
[0038] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application.
[0039] 1. Electronic devices and Bluetooth devices
[0040] In the embodiment of the present application, the electronic device supports the Bluetooth function, and may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device, and / or a smart city device. In the embodiment of the present application, the electronic device takes a mobile phone as an example.
[0041] In the embodiment of the present application, the Bluetooth device also supports the Bluetooth function, can establish a Bluetooth connection with the electronic device, and then can exchange or transmit wireless information with the electronic device. The Bluetooth device can be a Bluetooth headset, a bracelet, a watch, a body fat scale, a Bluetooth blood pressure monitor, a wearable device (such as Bluetooth glasses, VR glasses, etc.), a vehicle-mounted device, a Bluetooth speaker, a smart home device and / or a smart city device, an Internet of Things device, a projector, a sensor and other devices, and can also be a mobile phone, a tablet computer, a PDA and other electronic devices. The device types of the Bluetooth device and the electronic device can be the same, for example, both are mobile phones, or they can be different, for example, the electronic device is a mobile phone and the Bluetooth device is a watch or a bracelet.
[0042] Different applications on electronic devices are associated with different Bluetooth devices. For example, Bluetooth applications can be associated with various types of Bluetooth devices, audio applications can be associated with Bluetooth speakers, Bluetooth headsets and projectors, and sports and health applications can be associated with bracelets, watches, skipping ropes, spinning bikes, blood glucose meters, rowing machines, blood pressure monitors, treadmills and body fat scales.
[0043] 2. Bluetooth type
[0044] Bluetooth type refers to the type of Bluetooth protocol supported by the Bluetooth device. In the Bluetooth 4.0 standard, the Bluetooth protocol can be divided into the Classic Bluetooth (BT) protocol and the Bluetooth Low Energy (BLE) protocol. BT can also be described as Basic Rate (BR), Enhanced Data Rate (EDR), etc., and BLE can also be described as Smart Bluetooth (Bluetooth Smart), low power consumption, etc. For example, in the Bluetooth 4.0 standard, the performance comparison of BT and BLE can be seen in Table 1 below.
[0045] Table 1
[0046]
[0047] For devices that support the Bluetooth 4.0 standard, the devices can be further divided into BT single mode, BLE single mode, and BT and BLE dual mode. As the name implies, BT single mode means supporting BT but not BLE, BLE single mode means supporting BLE but not BT, and BT and BLE dual mode means supporting BT and BLE. Usually, electronic devices such as mobile phones support BT and BLE dual mode, while some Bluetooth devices support BLE single mode in order to save power, such as sensors; or some Bluetooth devices support BT single mode due to limited transmission distance, such as wearable devices, Bluetooth speakers, etc. It should be noted that some Bluetooth devices can also support BT and BLE dual mode, but support one mode under one operating system. For example, if the operating system of the watch is Android system, then the watch can support BT single mode; if the operating system of the watch is IOS system, then the watch can support BLE single mode.
[0048] With the development of Bluetooth technology, the Bluetooth 5.0 standard with longer transmission distance and faster data rate came into being. Compared with the Bluetooth 4.0 standard, the performance of the Bluetooth 5.0 standard has been improved, but the basic Bluetooth protocol can still be divided into the BT protocol and the BLE protocol.
[0049] In the embodiment of the present application, the Bluetooth type of the Bluetooth device can be divided into BT type and BLE type. For Bluetooth devices of different Bluetooth types, the electronic device calls different Bluetooth connection interfaces. For example, for a BT type Bluetooth device, the electronic device calls the BR connection interface to establish a Bluetooth connection with the Bluetooth device; for a BLE type Bluetooth device, the electronic device calls the BLE connection interface to establish a Bluetooth connection with the Bluetooth device.
[0050] 3. Bluetooth pairing
[0051] Bluetooth pairing is a method of information registration for connecting Bluetooth devices or electronic devices. The connection between devices is achieved by registering device information between devices. The device information may include but is not limited to device identification, Bluetooth type, device type, power information, Media Access Control (MAC) address, Internet Protocol (IP) address, etc. The device identification is used to uniquely identify the device and can be automatically generated by the device or generated in response to a string input by the user. The Bluetooth type can be BT type or BLE type. The device type can be a watch, bracelet, Bluetooth headset, etc. The power information is used to indicate the remaining power of the electronic device or Bluetooth device.
[0052] For example, the electronic device is a mobile phone, and the Bluetooth device is a watch 1. Assuming that the mobile phone is the master pairing partner and the watch 1 is the slave pairing partner, for the sports health application on the mobile phone, the Bluetooth pairing method between the mobile phone and the watch 1 can be any of the following:
[0053] (1) Proximity discovery pairing means that the distance between the mobile phone and the watch 1 is short, so that the mobile phone can scan the watch 1 within its scanning range, thereby pairing to establish a Bluetooth connection between the mobile phone and the watch 1. For example, the user interface involved in this pairing method can be found in Figure 1 (1) to Figure 1 The user interface shown in (6). Figure 1 The user interface shown in (1) is a main interface or theme interface on a mobile phone. The user interface displays a Bluetooth icon 103, indicating that the Bluetooth application on the mobile phone is turned on, that is, the Bluetooth application is in working state. The user interface also displays an icon 101 of a sports health application and a sports health card 102. When a click operation on the icon 101 or a click operation on the sports health card 102 is detected, in response to the click operation, Figure 1 The user interface shown in (1) jumps to the user interface of the sports health application, which may include a "health" control, a "sports" control, a "device" control, and a "my" control. A click operation on the "device" control is detected, and in response to the click operation, a display such as Figure 1 The user interface shown in (2) of FIG. 1 shows an "add device" control 104. A click operation on the control is detected. In response to the click operation, the following may be displayed: Figure 1 The scanning radar in the user interface shown in (3) searches for Bluetooth devices in the environment where the mobile phone is located. In response to the search for watch 1, Figure 1 The user interface shown in (3) also displays an available device column 105, which includes device information of the watch 1, such as a device identification and remaining power, etc. A click operation on the watch 1 is detected, and in response to the click operation, the following may be displayed: Figure 1 The user interface shown in (4) of the embodiment can be used to obtain the Bluetooth message synchronization service permission, and a skip control and an consent control are displayed. A click operation on the consent control is detected, and in response to the click operation, a display such as Figure 1 The user interface shown in (5) of FIG. 1 is displayed, and a pairing request is sent to watch 1. The user interface indicates that the mobile phone is pairing with watch 1. After receiving the pairing confirmation response from watch 1, the following may be displayed: Figure 1 The user interface shown in (6) indicates that the pairing between the mobile phone and the watch 1 is completed and the connection is successful, so that the mobile phone and the watch 1 can exchange wireless information.
[0054] in, Figure 1 The user interface shown in (1) displays a Bluetooth icon 103, which is generated in response to a click operation on a Bluetooth off mark. The Bluetooth off mark can be a Bluetooth off mark in the control center interface or a Bluetooth off mark in the setting interface.
[0055] (2) Manual pairing refers to pairing based on the Bluetooth device type selected by the user. For example, the user interface involved in this pairing method can be found in Figure 2 (1) to Figure 2 After entering the user interface of the sports health application, a click operation on the "device" control is detected. In response to the click operation, the following may be displayed: Figure 1 The user interface shown in (1) of FIG. 1 shows an "add device" control 104. A click operation on the control is detected. In response to the click operation, the following may be displayed: Figure 2 The scanning radar in the user interface shown in (2) of FIG. 1 further displays a manual adding control 106 and a scan code adding control. A click operation on the manual adding control 106 is detected, and in response to the click operation, a display such as Figure 2 The user interface shown in (3) of the embodiment may provide various types of Bluetooth devices and different product models under the same type of Bluetooth devices, such as watches or bracelets of different product models. Assuming that the product model of watch 1 is product model 1, a click operation on product model 1 under the watch is detected. In response to the click operation, the following may be displayed: Figure 2 The user interface shown in (4) of FIG. 1 displays configuration prompt information and a start pairing control. A click operation on the start pairing control is detected. In response to the click operation, a scan is performed based on the product model 1 of the watch to determine whether there is a watch of the product model in the environment where the mobile phone is located. When a watch of the product model is scanned, the following may be displayed: Figure 1 The user interface shown in (3) of FIG. 1 shows an available device column 105, and the available device column 105 includes the device information of the watch of the product model scanned, such as the device information of watch 1. A click operation on watch 1 is detected, and in response to the click operation, a display such as Figure 1 The user interface shown in (4) of the embodiment can be used to obtain the Bluetooth message synchronization service permission, and a skip control and an consent control are displayed. A click operation on the consent control is detected, and in response to the click operation, a display such as Figure 1 The user interface shown in (5) of FIG. 1 is displayed, and a pairing request is sent to watch 1. The user interface indicates that the mobile phone is pairing with watch 1. After receiving the pairing confirmation response from watch 1, the following may be displayed: Figure 1The user interface shown in (6) indicates that the pairing between the mobile phone and the watch 1 is completed and the connection is successful, so that the mobile phone and the watch 1 can exchange wireless information.
[0056] (3) Scanning QR code pairing refers to pairing the mobile phone with the watch 1 through Bluetooth by scanning the QR code of the watch 1. For example, the user interface involved in this pairing method can be found in Figure 3 (1) to Figure 3 After entering the user interface of the sports health application, a click operation on the "device" control is detected. In response to the click operation, the following may be displayed: Figure 1 The user interface shown in (1) of FIG. 1 shows an "add device" control 104. A click operation on the control is detected. In response to the click operation, the following may be displayed: Figure 3 The scanning radar in the user interface shown in (1) of FIG. 1 further displays a manual add control and a scan code add control 107. A click operation on the scan code add control 107 is detected, and in response to the click operation, a display such as Figure 3 The user interface shown in (2) of FIG. 1 includes a code scanning box 108 for scanning a QR code displayed on a Bluetooth device, such as a QR code displayed on a watch. In response to scanning the QR code displayed on the watch 1, the MAC address of the watch 1 is obtained based on the QR code, the watch 1 is scanned to obtain the device information of the watch 1, and Figure 3 The device information of the watch 1 is displayed in the available device column 105 in the user interface shown in (3). A click operation on the watch 1 is detected, and in response to the click operation, the following may be displayed: Figure 1 The user interface shown in (4) of the embodiment can be used to obtain the Bluetooth message synchronization service permission, and a skip control and an consent control are displayed. A click operation on the consent control is detected, and in response to the click operation, a display such as Figure 1 The user interface shown in (5) of FIG. 1 is displayed, and a pairing request is sent to watch 1. The user interface indicates that the mobile phone is pairing with watch 1. After receiving the pairing confirmation response from watch 1, the following may be displayed: Figure 1 The user interface shown in (6) indicates that the pairing between the mobile phone and the watch 1 is completed and the connection is successful, so that the mobile phone and the watch 1 can exchange wireless information.
[0057] For the Bluetooth application of the electronic device, it can scan the Bluetooth devices in the environment where the electronic device is located, and then pair with the scanned Bluetooth devices. For example, see Figure 4 (1) to Figure 4 The user interface shown in (4). Figure 4The user interface shown in (1) is a main interface or theme interface on a mobile phone. The user interface displays a Bluetooth icon 201, indicating that the Bluetooth application on the mobile phone is turned on, that is, the Bluetooth application is in working state. The user interface also displays an icon 202 for setting the application. A click operation on the icon 202 is detected. In response to the click operation, Figure 4 The user interface shown in (1) jumps to the setting user interface (such as Figure 4 As shown in (2) of FIG. 1 ), the user interface may include multiple options, such as Bluetooth, personal hotspot, mobile network, more connections, display and brightness, storage, etc., wherein the status of Bluetooth is turned on. A click operation on Bluetooth is detected, and in response to the click operation, a display such as Figure 4 The user interface shown in (3) of the embodiment includes a paired device list and an available device list. The paired device list indicates the Bluetooth devices that the mobile phone has paired with, and the available device list indicates the scanned Bluetooth devices. These Bluetooth devices have not been paired with the mobile phone, or have been paired but the pairing relationship with the mobile phone has been deleted. Assuming that the available device list includes Bluetooth device a and Bluetooth device b, and a click operation on Bluetooth device a is detected, in response to the click operation, the following may be displayed: Figure 4 The user interface shown in (4) of the embodiment includes a dialog box 203, which is used to prompt whether to pair with Bluetooth device a, including a cancel control and a pairing control. A click operation on the pairing control is detected, and in response to the click operation, a pairing request is sent to Bluetooth device a. A pairing confirmation response is received from Bluetooth device a, indicating that the pairing of the mobile phone and Bluetooth device a is completed and the connection is successful, so that the mobile phone and Bluetooth device a can exchange wireless information. In addition, after the pairing of the mobile phone and Bluetooth device a is completed, Bluetooth device a is added to the paired device list, and Bluetooth device a is deleted from the available device list.
[0058] In response to the Bluetooth on the electronic device being turned on, the electronic device starts scanning. After scanning a certain Bluetooth device, if the device information of the Bluetooth device does not exist in the device list, the device information of the Bluetooth device can be saved in the device queue, and the device identification of the Bluetooth device can be saved in the historical device queue. Among them, the device identification stored in the device queue is unique, and the device identification stored in the historical device queue is repeatable. After the number of device identifications stored in the historical device queue is greater than the threshold, if the first device identification in the historical device queue, that is, the device identification stored in the historical device queue earliest, identifies a Bluetooth device that is not paired with the electronic device, then the device identification of the Bluetooth device will be deleted from the historical device queue, and the device information of the Bluetooth device will be deleted from the device list.
[0059] For example, taking the sports health application as an example, the flowchart of the mobile phone connecting to the bracelet 2 for the first time through the sports health application can be referred to Figure 5A As shown, the process may include the following steps:
[0060] 1. A scanning operation is detected in the user interface of the sports health application.
[0061] The scanning operation can be for Figure 1 Alternatively, it may be a click operation on the "add device" control 104 of the user interface shown in (2); or Figure 2 Alternatively, it may be a click operation for manually adding the control 106 of the user interface shown in (2); or Figure 3 The scan code addition control 107 of the user interface shown in (1) is clicked.
[0062] 2. In response to the scanning operation, the sports health application sends a first scanning instruction to the Bluetooth protocol stack.
[0063] 3. The Bluetooth protocol stack sends a second scanning instruction to the Bluetooth chip to drive the Bluetooth chip to scan the Bluetooth devices in the environment where the mobile phone is located.
[0064] 4. The Bluetooth chip scans Bluetooth device 1.
[0065] 5. In response to scanning the Bluetooth device 1, the Bluetooth chip feeds back the device information of the Bluetooth device 1 to the Bluetooth protocol stack.
[0066] The device information may include but is not limited to one or more of the following information: device identification, Bluetooth type, remaining battery power, etc.
[0067] 6. The Bluetooth protocol stack updates the device queue and the historical device queue based on the device information of Bluetooth device 1.
[0068] The Bluetooth protocol stack responds to the device information of Bluetooth device 1 and detects whether the device identifier of Bluetooth device 1 exists in the device queue. In response to the absence of the device identifier of Bluetooth device 1 in the device queue, the Bluetooth protocol stack saves the device information of Bluetooth device 1 to the device queue, and saves the device identifier of Bluetooth device 1 to the historical device queue. Assuming that before scanning Bluetooth device 1, neither the device queue nor the historical device queue saves any device identifier, then the device queue and the historical device queue can be shown in the following Table 1.1, taking the example of both saving device identifiers.
[0069] Table 1.1
[0070]
[0071] Optionally, in response to the presence of the device identifier of Bluetooth device 1 in the device queue, the Bluetooth protocol stack will not update the device queue, nor will it synchronously update the historical device queue.
[0072] 7. The Bluetooth chip scans bracelet 2.
[0073] 8. In response to scanning the bracelet 2, the Bluetooth chip feeds back the device information of the bracelet 2 to the Bluetooth protocol stack.
[0074] 9. The Bluetooth protocol stack updates the device queue and historical device queue based on the device information of bracelet 2.
[0075] The Bluetooth protocol stack responds to the device information of wristband 2 and detects whether the device identification of wristband 2 exists in the device queue. In response to the absence of the device identification of wristband 2 in the device queue, the device information of wristband 2 is saved to the device queue, and the device identification of wristband 2 is saved to the historical device queue. The Bluetooth protocol stack can update Table 1.1 to obtain the following Table 1.2.
[0076] Table 1.2
[0077]
[0078] In Table 1.2, the first device identification of the queue is taken as the earliest saved device identification. Optionally, Table 1.1 may be updated to obtain the following Table 1.3. In the embodiment of the present application, the first device identification of the queue is taken as the earliest saved device identification.
[0079] Table 1.3
[0080]
[0081] Optionally, in response to the presence of the device identification of bracelet 2 in the device queue, the Bluetooth protocol stack will not update the device queue, nor will it synchronously update the historical device queue.
[0082] 10. The Bluetooth protocol stack sends a display instruction to the sports health application.
[0083] In response to the Bluetooth protocol stack determining that the wristband 2 is a Bluetooth device associated with the sports health application based on the device information of the wristband 2, a display instruction is sent to the sports health application so that the device management interface of the sports health application can display the wristband 2. Among them, the device management interface can be Figure 1 The user interface shown in (3) of FIG. 1 shows an available device column 105 for displaying the scanned Bluetooth devices associated with the sports health application. Since Bluetooth device 1 is not a Bluetooth device associated with the sports health application, the Bluetooth protocol stack will not send a display instruction to the sports health application when receiving the device information of Bluetooth device 1.
[0084] The order of executing step 10 and step 9 is not limited. Step 10 and step 9 can be executed simultaneously, or step 9 can be executed first and then step 10, or step 10 can be executed first and then step 9.
[0085] 11. The sports health application responds to the display instruction and displays the wristband 2 on the device management interface.
[0086] When displaying the wristband 2, the device management interface of the sports health application can display the device identification of the wristband 2 and other device information of the wristband 2, such as the device form, remaining power, etc.
[0087] 12. The sports health application receives the connection operation for the wristband 2.
[0088] For the connection operation of bracelet 2, it can be Figure 1 The available device column 105 in the user interface shown in (3) shows the wristband 2, and the click operation for the wristband 2 can also be for Figure 2 In the user interface shown in (3), the click operation of the product model corresponding to the wristband 2 and the Figure 2 The click operation of the start pairing control in the user interface shown in (4); it can also be Figure 3 The available device column 105 in the user interface shown in (3) displays the wristband 2, and a click operation is performed on the wristband 2.
[0089] 13. The sports health application sends a Bluetooth type query instruction to the Bluetooth protocol stack.
[0090] In response to the connection operation, the sports health application sends a Bluetooth type query instruction to the Bluetooth protocol stack to query the Bluetooth type of the wristband 2. The device queue stores device information of each Bluetooth device, and the device information includes the Bluetooth type, which is BT type or BLE type.
[0091] 14. The Bluetooth protocol stack queries the Bluetooth type of the wristband 2 in response to the Bluetooth type query instruction.
[0092] The Bluetooth protocol stack responds to the Bluetooth type query instruction and queries the Bluetooth type of the wristband 2 in the device queue.
[0093] 15. The Bluetooth protocol stack feeds back the Bluetooth type of wristband 2 to the sports health application.
[0094] It is assumed that the Bluetooth type of wristband 2 is BLE type.
[0095] 16. The sports health application sends a connection instruction based on the BLE connection interface to the Bluetooth protocol stack.
[0096] 17. The Bluetooth protocol stack sends a connection instruction to the Bluetooth chip, and the connection instruction is also based on the BLE connection interface.
[0097] The Bluetooth chip sends a pairing request to bracelet 2 based on the BLE connection interface.
[0098] 18. The Bluetooth chip sends a connection success response to the Bluetooth protocol stack.
[0099] When the Bluetooth chip receives the pairing confirmation response from the bracelet 2, it sends a connection success response to the Bluetooth protocol stack, so that the mobile phone can exchange wireless information with the bracelet 2 through the sports health application.
[0100] 19. The Sports Health application detects the deletion operation on the bracelet 2.
[0101] The deletion operation for wristband 2 may be a deletion operation for wristband 2 when wristband 2 is displayed on the device management interface. Figure 4 In the user interface shown in (3), a click operation on the setting control corresponding to the wristband 2 in the paired device list displays the setting interface corresponding to the wristband 2, which includes a cancel pairing control. The deletion operation on the wristband 2 can be a click operation on the cancel pairing control.
[0102] 20. In response to the deletion operation, the sports health application sends a deletion instruction to the Bluetooth protocol stack.
[0103] 21. The Bluetooth protocol stack updates the device queue in response to the delete instruction.
[0104] In response to the deletion instruction, the Bluetooth protocol stack deletes the device information of wristband 2 from the device queue and does not update the historical device queue. The Bluetooth protocol stack can update Table 1.2 to obtain the following Table 1.4.
[0105] Table 1.4
[0106]
[0107] The flowchart of the mobile phone connecting to the bracelet 2 through the sports health application is not the first time. Figure 5B As shown, the process may include the following steps:
[0108] 31. A scanning operation is detected in the user interface of the sports health application.
[0109] 32. In response to the scanning operation, the sports health application sends a third scanning instruction to the Bluetooth protocol stack.
[0110] 33. The Bluetooth protocol stack sends a fourth scanning instruction to the Bluetooth chip to drive the Bluetooth chip to scan the Bluetooth devices in the environment where the mobile phone is located.
[0111] 34. The Bluetooth chip scans the Bluetooth device x.
[0112] 35. In response to scanning the Bluetooth device x, the Bluetooth chip feeds back the device information of the Bluetooth device x to the Bluetooth protocol stack.
[0113] 36. The Bluetooth protocol stack updates the device queue and the historical device queue based on the device information of the Bluetooth device x.
[0114] The Bluetooth protocol stack updates the device queue and historical device queue tables based on the device information of Bluetooth device x, as shown in Table 2.1.
[0115] Table 2.1
[0116]
[0117] 37. The Bluetooth chip scans bracelet 2.
[0118] 38. In response to scanning the wristband 2, the Bluetooth chip feeds back the device information of the wristband 2 to the Bluetooth protocol stack.
[0119] 39. The Bluetooth protocol stack updates the device queue and the historical device queue based on the device information of bracelet 2.
[0120] because Figure 5A In step 39, the Bluetooth protocol stack deletes the device information of wristband 2 from the device queue. Then, the device information of wristband 2 does not exist in the device queue. Therefore, in step 39, the Bluetooth protocol stack saves the device information of wristband 2 to the device queue and simultaneously saves the device identification of wristband 2 to the historical device queue. The Bluetooth protocol stack can update Table 2.1 to obtain the following Table 2.2.
[0121] Table 2.2
[0122]
[0123] 40. In response to the historical device queue being full, the Bluetooth protocol stack deletes the first device identifier in the historical device queue.
[0124] The historical device queue is full, that is, the number of device identifiers saved in the historical device queue is greater than or equal to the threshold, which is set by the mobile phone manufacturer. Delete the first device identifier in the historical device queue, that is, delete the device identifier that is earliest saved in the historical device queue. If the Bluetooth device identified by the device identifier is not paired with the mobile phone, the Bluetooth protocol stack will synchronously delete the device information of the Bluetooth device in the device queue. The Bluetooth protocol stack can update Table 2.2 to obtain the following Table 2.3.
[0125] Table 2.3
[0126]
[0127] 41. The Bluetooth protocol stack sends a display instruction to the sports health application.
[0128] 42. The sports health application responds to the display instruction and displays the wristband 2 on the device management interface.
[0129] 43. The Bluetooth chip scans Bluetooth device y.
[0130] 44. In response to scanning the Bluetooth device y, the Bluetooth chip feeds back the device information of the Bluetooth device y to the Bluetooth protocol stack.
[0131] 45. The Bluetooth protocol stack updates the device queue and the historical device queue based on the device information of Bluetooth device y. If the historical device queue is full, the first device identifier in the historical device queue is deleted.
[0132] After the Bluetooth protocol stack deletes Bluetooth device 1, it obtains the device information of Bluetooth device y. After saving the device ID of Bluetooth device y in the historical device queue, the historical device queue is full again, so it is necessary to delete the first device ID in the historical device queue, which is the device ID of wristband 2. However, since the historical device queue can be stored repeatedly, the device ID of wristband 2 may still exist in the historical device queue. Since wristband 2 has not been paired with the mobile phone at this time, the device information of wristband 2 is deleted from the device queue.
[0133] The Bluetooth protocol stack can update Table 2.3 to obtain the following Table 2.4.
[0134] Table 2.4
[0135]
[0136] 46. The sports health application receives a connection operation for the wristband 2.
[0137] 47. The sports health application sends a Bluetooth type query instruction to the Bluetooth protocol stack.
[0138] 48. The Bluetooth protocol stack queries the Bluetooth type of the wristband 2 in response to the Bluetooth type query instruction.
[0139] 49. The Bluetooth protocol stack reports to the sports health application that the Bluetooth type of bracelet 2 cannot be found.
[0140] In response to the Bluetooth type query instruction, the Bluetooth protocol stack queries the Bluetooth type of the wristband 2 in the device queue. Since the device information of the wristband 2 does not exist in the device queue, the Bluetooth protocol stack feeds back to the sports health application that the Bluetooth type of the wristband 2 is not found.
[0141] 50. The sports health application sends a connection instruction based on the BR connection interface to the Bluetooth protocol stack.
[0142] Since the sports health application did not query the Bluetooth type of the bracelet 2, the BR connection interface is used by default, and a connection instruction based on the BR connection interface is sent to the Bluetooth protocol stack.
[0143] 51. The Bluetooth protocol stack sends a connection instruction to the Bluetooth chip, and the connection instruction is also based on the BR connection interface.
[0144] 52. The Bluetooth chip sends a connection failure response to the Bluetooth protocol stack.
[0145] Since the BR connection interface does not match the Bluetooth type of wristband 2, the Bluetooth chip cannot send a pairing request to wristband 2 through the BR connection interface. Even if the pairing request can be sent successfully, wristband 2 will not feedback a pairing confirmation response to the mobile phone or wristband 2 will feedback a pairing failure response to the mobile phone. Therefore, the Bluetooth chip sends a connection failure response to the Bluetooth protocol stack without receiving a pairing confirmation response. As a result, the mobile phone cannot successfully pair with wristband 2 through the sports health application, and the connection between the mobile phone and wristband 2 fails.
[0146] Depend on Figure 5B It can be seen that when the historical device queue is full and the first device identifier is deleted from the historical device queue, the device information of the Bluetooth device to be connected may be deleted from the device queue simultaneously, resulting in a connection failure with the Bluetooth device.
[0147] In view of this, the embodiment of the present application provides a Bluetooth device management method and an electronic device. The method can be applied to an electronic device with Bluetooth function, and the electronic device can also install a sports health application, such as a mobile phone, a tablet computer, etc.
[0148] By implementing the Bluetooth device management method provided in the embodiment of the present application, when the historical device queue is full and the first device identifier in the historical device queue needs to be deleted, it will not affect the connection between the electronic device and the Bluetooth device to be connected, thereby helping to improve the connection success rate between the electronic device and the Bluetooth device.
[0149] The following specifically introduces the specific process of the electronic device implementing the Bluetooth device management device method.
[0150] first, Figure 6 The software architecture of the electronic device 100 is exemplarily shown.
[0151] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0152] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, the hardware abstraction layer (HAL), and the kernel layer.
[0153] The application layer can include a series of application packages. Figure 2 As shown, the application package may include applications such as camera, gallery, Bluetooth, sports health application, etc. Among them, the sports health application can provide sports health management for users, and can also obtain sports health data from the Bluetooth device through the associated Bluetooth device. For example, if the associated Bluetooth device is a bracelet or watch, the sports health application can obtain health data such as heart rate and number of steps from the bracelet or watch.
[0154] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 2 As shown, the application framework layer may include a window manager, a phone manager, a content provider, a notification manager, a resource manager, a Bluetooth manager, and the like.
[0155] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The phone manager is used to provide communication functions for the electronic device 100. For example, the management of call status (including connected, hung up, etc.). The content provider is used to provide various display contents. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify the completion of downloads, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt tone is issued, the electronic device vibrates, the indicator light flashes, etc. The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The Bluetooth manager is used to manage Bluetooth and call the Bluetooth protocol stack to drive the operation of the Bluetooth chip.
[0156] The system library can also be called a local C / C++ library. The system library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the core library of Android. The system library can include multiple functional modules. For example: Bluetooth protocol stack, media library (Media Libraries), etc. In an embodiment of the present application, the Bluetooth protocol stack can be used to manage and maintain device queues and historical device queues. The media library supports a variety of commonly used audio and video format playback and recording, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0157] The Hardware Abstraction Layer (HAL) provides a standard interface that can be used to control the actions of the hardware. The HAL includes multiple library modules, each of which implements a set of interfaces for a specific type of hardware component, such as a Bluetooth module, an audio module, etc.
[0158] The kernel layer is the foundation of the Android system, such as threads and low-level memory management. The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, a Bluetooth driver, an audio driver, a sensor driver, etc. In the embodiment of the present application, the Bluetooth driver can drive the Bluetooth chip so that the Bluetooth chip scans the Bluetooth devices in the environment where the electronic device 100 is located.
[0159] In the embodiments of the present application, Figure 1 The user interface shown in (1) displays a Bluetooth icon 103, indicating that the Bluetooth protocol stack and the Bluetooth chip are in working state. The electronic device receives a click operation for the Bluetooth shutdown mark, and in response to the click operation, controls the Bluetooth protocol stack and the Bluetooth chip to be in working state, so that Bluetooth is turned on and can scan Bluetooth devices in the surrounding environment. For example, in response to the click operation, the Bluetooth scanning interface in the application framework layer is called to control the Bluetooth protocol stack and the Bluetooth chip to be in working state, so that the Bluetooth chip can scan Bluetooth devices in the surrounding environment.
[0160] Combination Figure 1-Figure 4 The user interface shown and Figure 6 The software architecture of the electronic device 100 is shown. Below, the embodiment of the present application will specifically introduce the process of the electronic device 100 implementing the Bluetooth device management method.
[0161] For example, see Figure 7 , is a flowchart of a Bluetooth device management method provided in an embodiment of the present application, which may include but is not limited to the following steps:
[0162] S701, a scanning operation is detected in the user interface of the sports health application.
[0163] The scanning operation can be for Figure 1 Alternatively, it may be a click operation on the "add device" control 104 of the user interface shown in (2); or Figure 2 Alternatively, it may be a click operation for manually adding the control 106 of the user interface shown in (2); or Figure 3 The scan code addition control 107 of the user interface shown in (1) is clicked.
[0164] S702: The sports health application sends a scan instruction to the Bluetooth protocol stack in response to the scan operation.
[0165] In response to the scanning operation, the sports health application sends a scanning instruction to the Bluetooth protocol stack in the system library through the Bluetooth scanning interface of the application framework layer. The application framework layer includes a Bluetooth manager, and the Bluetooth manager can provide a Bluetooth scanning interface.
[0166] S703: The Bluetooth protocol stack sends a scan instruction to the Bluetooth chip.
[0167] The Bluetooth protocol stack sends a scanning instruction to the Bluetooth chip in response to a scanning instruction from the Bluetooth scanning interface, which may include: the Bluetooth protocol stack calls the Bluetooth module in the hardware abstraction layer to send a driving instruction to the Bluetooth driver, and the Bluetooth driver drives the Bluetooth chip in response to the driving instruction to enable the Bluetooth chip to scan the Bluetooth devices in the environment where the electronic device is located.
[0168] S704: The Bluetooth chip scans and detects a first Bluetooth device.
[0169] The Bluetooth chip scans Bluetooth devices in the environment of the electronic device, scans a first Bluetooth device, and obtains device information of the first Bluetooth device, where the device information includes at least a device identifier and a Bluetooth type, and optionally also includes information such as remaining power.
[0170] S705: In response to scanning and finding the first Bluetooth device, the Bluetooth chip sends device information of the first Bluetooth device to the Bluetooth protocol stack.
[0171] In response to scanning the first Bluetooth device, the Bluetooth chip can directly send the device information of the first Bluetooth device to the Bluetooth protocol stack. Optionally, the Bluetooth chip can send the device information of the first Bluetooth device to the Bluetooth protocol stack via the Bluetooth driver and the Bluetooth module in sequence.
[0172] S706: In response to the fact that the device queue does not include the device identifier of the first Bluetooth device, the Bluetooth protocol stack updates the device queue to obtain the first device queue, and updates the historical device queue to obtain the first historical device queue.
[0173] The Bluetooth protocol stack receives the device identification of the first Bluetooth device, and determines whether the device identification of the first Bluetooth device exists in the device queue. If it exists, the subsequent steps will not be executed. If it does not exist, the device queue will be updated to obtain the first device queue, and the historical device queue will be synchronously updated to obtain the first historical device queue. The device queue is updated to obtain the first device queue, that is, the device information of the first Bluetooth device is saved to the device queue to obtain the first device queue. The first device queue may include the device information of the first Bluetooth device, and the device information includes at least the device identification and the Bluetooth type. The historical device queue is updated to obtain the first historical device queue, that is, the device identification of the first Bluetooth device is saved to the historical device queue to obtain the first historical device queue. The first historical device queue may include the device identification of the first Bluetooth device. Exemplarily, the first device queue and the first historical device queue may be shown in Table 3.1 below.
[0174] Table 3.1
[0175]
[0176] S707 : In response to the first historical device queue being full, the Bluetooth protocol stack deletes the first device identifier in the first historical device queue to obtain a second historical device queue.
[0177] The Bluetooth protocol stack detects whether the number of device identifiers in the first historical device queue is greater than or equal to a threshold value. If not, the first historical device queue is not processed. If yes, the first device identifier in the first historical device queue (i.e., the device identifier earliest stored in the historical device queue) is deleted to obtain a second historical device queue. Exemplarily, based on the first historical device queue shown in Table 3.1, the second historical device queue after deleting the first device identifier may be shown in Table 3.2 below.
[0178] Table 3.2
[0179]
[0180] S708: In response to the second historical device queue including the target device identifier, the Bluetooth protocol stack continues to store the device information of the target Bluetooth device in the first device queue.
[0181] Among them, the target device identifier is the same as the first device identifier in the first historical device queue, and the target device identifier is used to identify the target Bluetooth device. Exemplarily, based on Table 3.1, the first device identifier in the first historical device queue is watch 1, then the Bluetooth protocol stack further determines whether watch 1 still exists in the second historical device queue. If watch 1 still exists, the device information of watch 1 continues to be saved in the first device queue. Regardless of whether watch 1 is paired with an electronic device at this time, the device information of watch 1 is still saved in the first device queue and will not be deleted from the first device queue. Therefore, when a connection operation for watch 1 is received on the sports health application, the electronic device can obtain the Bluetooth type of watch 1 from the first device queue in response to the connection operation, and then establish a Bluetooth connection with watch 1 based on the Bluetooth type of watch 1.
[0182] If the target device identifier is the same as the device identifier of the first Bluetooth device, and the second historical device queue includes the target device identifier, that is, the first device identifier in the first historical device queue is the device identifier of the first Bluetooth device, and the second historical device queue also includes the device identifier of the first Bluetooth device, then the device information of the first Bluetooth device will continue to be stored in the first device queue, and the device information of the first Bluetooth device will not be deleted from the first device queue because the first historical device queue is full. Therefore, the Bluetooth connection between the electronic device and the first Bluetooth device will not be affected.
[0183] If the second historical device queue does not include the target device identifier, the Bluetooth protocol stack may delete the device information of the target Bluetooth device from the first device queue.
[0184] Optionally, S709, the Bluetooth protocol stack sends a display instruction to the sports health application in response to the first Bluetooth device being a Bluetooth device associated with the sports health application.
[0185] If the first Bluetooth device is a Bluetooth device associated with the sports health application, the Bluetooth protocol stack may send a display instruction to the sports health application to display the first Bluetooth device on the device management interface of the sports health application.
[0186] Step S709 and step S706 to step S708 may be executed simultaneously, or step S709 may be executed first and then step S706 to step S708, or step S706 to step S708 may be executed first and then step S709.
[0187] Optionally, S710, the sports health application displays the first Bluetooth device on the device management interface in response to the display instruction.
[0188] Optionally, S711, the sports health application receives a connection operation for the first Bluetooth device.
[0189] Optionally, S712, the sports health application sends a Bluetooth type query instruction to the Bluetooth protocol stack.
[0190] Optionally, S713, the Bluetooth protocol stack responds to the Bluetooth type query instruction and queries the Bluetooth type of the first Bluetooth device based on the first device queue.
[0191] If the target device identifier is the same as the device identifier of the first Bluetooth device, and the second historical device queue includes the target device identifier, the first device queue still stores the device information of the first Bluetooth device, so the Bluetooth protocol stack can find the Bluetooth type of the first Bluetooth device from the first device queue.
[0192] Optionally, S714, the Bluetooth protocol stack feeds back the Bluetooth type of the first Bluetooth device to the sports health application.
[0193] Optionally, S715, the sports health application sends a connection instruction to the Bluetooth protocol stack.
[0194] Optionally, S716, the Bluetooth protocol stack sends a connection instruction to the Bluetooth chip.
[0195] Optionally, S717, the Bluetooth chip sends a connection success response to the Bluetooth protocol stack.
[0196] The implementation process of steps S710 to S717 can be found in Figure 5A The specific description of steps 11 to 18 in the above description will not be repeated here. Optionally, after step S717, a pairing deletion process for the first Bluetooth device may also be performed, for example, a deletion operation for the first Bluetooth device is received in the device management interface of the sports health application, and in response to the deletion operation, the Bluetooth protocol stack deletes the device information of the first Bluetooth device from the first device queue, and the device management device interface of the sports health application does not display the first Bluetooth device.
[0197] exist Figure 7 In the illustrated embodiment, when the number of device identifiers in the historical device queue is greater than or equal to a threshold value, the first device identifier in the historical device queue is deleted. If the device identifier is still included in the historical device queue after deletion, the device identifier is retained in the device queue instead of being deleted. This can improve the connection success rate between the electronic device and the Bluetooth device when the Bluetooth device identified by the device identifier is scanned later.
[0198] For example, see Figure 8 , is a flowchart of another Bluetooth device management method provided in an embodiment of the present application, which may include but is not limited to the following steps:
[0199] S801, a scanning operation is detected in the user interface of the sports health application.
[0200] S802: The sports health application sends a scan instruction to the Bluetooth protocol stack in response to the scan operation.
[0201] S803: The Bluetooth protocol stack sends a scan instruction to the Bluetooth chip.
[0202] S804: The Bluetooth chip scans and detects a first Bluetooth device.
[0203] S805: In response to scanning and finding the first Bluetooth device, the Bluetooth chip sends device information of the first Bluetooth device to the Bluetooth protocol stack.
[0204] The implementation process of steps S801 to S805 can be found in Figure 7 The specific description of steps S701 to S705 in the illustrated embodiment will not be repeated here.
[0205] S806: In response to the fact that the device queue does not include the device identifier of the first Bluetooth device, the Bluetooth protocol stack updates the device queue to obtain the first device queue.
[0206] The Bluetooth protocol stack receives the device identification of the first Bluetooth device, and determines whether the device identification of the first Bluetooth device exists in the device queue. If it exists, the subsequent steps are not performed. If it does not exist, the device queue is updated to obtain the first device queue. The device queue is updated to obtain the first device queue, that is, the device information of the first Bluetooth device is saved in the device queue to obtain the first device queue. The first device queue may include the device information of the first Bluetooth device, and the device information at least includes the device identification and the Bluetooth type.
[0207] S807: In response to the historical device queue including the device identification of the first Bluetooth device, the Bluetooth protocol stack deletes the device identification of the first Bluetooth device to obtain a first historical device queue.
[0208] After updating the device queue, the Bluetooth protocol stack determines whether the device identification of the first Bluetooth device exists in the historical device queue. If so, the device identification of the first Bluetooth device is deleted from the historical device queue to obtain the first historical device queue, so that the historical device queue does not store duplicate device identifications. If not, the device identification of the first Bluetooth device is saved in the historical device queue.
[0209] S808: The Bluetooth protocol stack saves the device identifier of the first Bluetooth device to a first historical device queue to obtain a second historical device queue.
[0210] Since the device identification of the first Bluetooth device is deleted from the historical device queue in S807, the device identification of the first Bluetooth device is saved in the first historical device queue in step S808 to obtain a second historical device queue. The second historical device queue only includes the device identification of the first Bluetooth device, and the historical device queue in Table 2.2 may not include duplicate device identifications.
[0211] S809 , in response to the second historical device queue being full, the Bluetooth protocol stack updates the second historical device queue to obtain a third historical device queue, and updates the first device queue to obtain a second device queue.
[0212] The Bluetooth protocol stack detects whether the number of device identifiers in the second historical device queue is greater than or equal to a threshold value. If not, the second historical device queue is not processed. If so, the first device identifier in the second historical device queue (i.e., the device identifier earliest stored in the historical device queue) is deleted to obtain the third historical device queue, and the first device queue is synchronously updated to obtain the second device queue. The first device queue is updated to obtain the second device queue, that is, the device information of the first target Bluetooth device is deleted from the first device queue, and the device identifier of the first target Bluetooth device is the same as the first device identifier in the second historical device queue. Exemplarily, the first device queue and the second historical device queue can be shown in Table 4.1 below, and the second device queue and the third historical device queue can be shown in Table 4.2 below.
[0213] Table 4.1
[0214]
[0215] Table 4.2
[0216]
[0217] Optionally, if the historical device queue does not include the device identifier of the first Bluetooth device, the Bluetooth protocol stack saves the device identifier of the first Bluetooth device to the historical device queue to obtain a fourth historical device queue. If the number of device identifiers in the fourth historical device queue is greater than or equal to a threshold, the Bluetooth protocol stack deletes the first device identifier from the fourth historical device queue to obtain a fifth historical device queue, and deletes the device information of the second target Bluetooth device from the first device queue. The device identifier of the second target Bluetooth device is the same as the first device identifier in the fourth historical device queue.
[0218] Since there are no duplicate device identifiers in the historical device queue, the probability of the historical device queue being full can be reduced to a certain extent, thereby helping to improve the connection success rate between the electronic device and the Bluetooth device.
[0219] Optionally, S810, the Bluetooth protocol stack sends a display instruction to the sports health application in response to the first Bluetooth device being a Bluetooth device associated with the sports health application.
[0220] Optionally, S811, the sports health application responds to the display instruction and displays the first Bluetooth device on the device management interface.
[0221] Optionally, S812, the sports health application receives a connection operation for the first Bluetooth device.
[0222] Optionally, S813, the sports health application sends a Bluetooth type query instruction to the Bluetooth protocol stack.
[0223] Optionally, S814, the Bluetooth protocol stack responds to the Bluetooth type query instruction and queries the Bluetooth type of the first Bluetooth device based on the first device queue.
[0224] Optionally, S815, the Bluetooth protocol stack feeds back the Bluetooth type of the first Bluetooth device to the sports health application.
[0225] Optionally, S816, the sports health application sends a connection instruction to the Bluetooth protocol stack.
[0226] Optionally, S817, the Bluetooth protocol stack sends a connection instruction to the Bluetooth chip.
[0227] Optionally, S818, the Bluetooth chip sends a connection success response to the Bluetooth protocol stack.
[0228] The implementation process of steps S711 to S818 can be found in Figure 5A The specific description of steps 10 to 18 in the above description will not be repeated here. Optionally, after step S818, a pairing deletion process for the first Bluetooth device may also be performed, for example, a deletion operation for the first Bluetooth device is received in the device management interface of the sports health application, and in response to the deletion operation, the Bluetooth protocol stack deletes the device information of the first Bluetooth device from the first device queue, and the device management device interface of the sports health application does not display the first Bluetooth device.
[0229] exist Figure 8 In the illustrated embodiment, there are no duplicate device identifiers in the historical device queue, which can reduce the probability of the queue length of the historical device queue exceeding a threshold to a certain extent, thereby helping to improve the connection success rate between the electronic device and the Bluetooth device.
[0230] Fig. 9 The schematic diagram of the hardware structure of the electronic device 100 is exemplarily shown.
[0231] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0232] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0233] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0234] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0235] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0236] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0237] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces.
[0238] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0239] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0240] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0241] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0242] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0243] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0244] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0245] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0246] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0247] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0248] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0249] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0250] The modulation and demodulation processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor.
[0251] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module.
[0252] In the embodiment of the present application, the Bluetooth can scan the Bluetooth devices in the environment of the electronic device 100 and establish a connection with the Bluetooth devices.
[0253] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0254] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0255] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor, etc. The ISP is used to process the data fed back by the camera 193.
[0256] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0257] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0258] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0259] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0260] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0261] Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally referred to as DDR5 SDRAM), etc. Non-volatile memory may include disk storage devices and flash memory.
[0262] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle. It can be divided into single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level. It can be divided into universal flash storage (UFS), embedded multimedia card (eMMC), etc. according to the storage specification.
[0263] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.
[0264] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .
[0265] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.
[0266] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0267] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0268] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0269] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0270] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0271] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0272] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194 .
[0273] The gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .
[0274] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0275] The magnetic sensor 180D includes a Hall sensor, and the electronic device 100 can detect the opening and closing of the flip leather case by using the magnetic sensor 180D.
[0276] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0277] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0278] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector such as a photodiode.
[0279] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0280] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0281] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy.
[0282] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect a touch operation acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
[0283] Bone conduction sensor 180M can obtain vibration signals.
[0284] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0285] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback.
[0286] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0287] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0288] In the implementation of the present application, when the number of device identifiers in the historical device queue is greater than or equal to the threshold, the first device identifier in the historical device queue is deleted. If the device identifier is still included in the deleted historical device queue, the device identifier is retained in the device queue without being deleted, so that when the Bluetooth device identified by the device identifier is scanned later, the connection success rate between the electronic device and the Bluetooth device can be improved. Alternatively, if there are no duplicate device identifiers in the historical device queue, the probability that the queue length of the historical device queue exceeds the threshold can be reduced to a certain extent, thereby helping to improve the connection success rate between the electronic device and the Bluetooth device.
[0289] The term "user interface (UI)" in the specification, claims and drawings of this application refers to the medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on the terminal device, and finally presented as content that the user can recognize, such as pictures, text, buttons and other controls. A control, also called a widget, is a basic element of a user interface. Typical controls include a toolbar, menu bar, text box, button, scrollbar, picture and text. The properties and contents of controls in the interface are defined by tags or nodes, such as XML through <textview> 、 <imgview> 、 <videoview>Nodes such as .js are used to specify the controls contained in the interface. A node corresponds to a control or attribute in the interface. After parsing and rendering, the node is presented as user-visible content. In addition, many applications, such as hybrid applications, usually also contain web pages in their interfaces. A web page, also known as a page, can be understood as a special control embedded in the application interface. A web page is source code written in a specific computer language, such as hypertext markup language (GTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as user-recognizable content by a browser or a web page display component with similar functions to a browser. The specific content contained in a web page is also defined by tags or nodes in the web page source code. For example, GTML is defined by 、 、 <video> 、 <canvas>To define the elements and attributes of a web page.
[0290] The most common form of user interface is graphical user interface (GUI), which refers to a user interface related to computer operation that is displayed in a graphical manner. It can be an icon, window, control or other interface element displayed on the display screen of an electronic device, where a control can include icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets and other visual interface elements.
[0291] As used in the specification and appended claims of the present application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items. As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrase "when determining..." or "if (stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "when (stated condition or event) is detected" or "in response to detecting (stated condition or event)", depending on the context.
[0292] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0293] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. A method for managing a Bluetooth device, characterized in that: The method is applied to an electronic device including a Bluetooth chip, wherein the Bluetooth chip is used to scan a Bluetooth device and obtain a device identifier and a Bluetooth type of the Bluetooth device; the method comprises: In response to scanning a first Bluetooth device through the Bluetooth chip, querying whether a device queue includes a device identification of the first Bluetooth device; In response to the device queue not including the device identification of the first Bluetooth device, saving the device identification and Bluetooth type of the first Bluetooth device to the device queue to obtain a first device queue, and saving the device identification of the first Bluetooth device to a historical device queue to obtain a first historical device queue; In response to the number of device identifiers in the first historical device queue being greater than or equal to a threshold, deleting a first device identifier from the first historical device queue to obtain a second historical device queue; In response to the second historical device queue including the target device identifier, continuing to store the device identifier and Bluetooth type of the target Bluetooth device in the first device queue, the target device identifier being the same as the first device identifier in the first historical device queue, and the target device identifier being used to identify the target Bluetooth device; Among them, the device queue includes at least one device identification arranged in the order of scanning time and without repetition, the historical device queue includes at least one device identification arranged in the order of scanning time, and the queue length of the device queue is less than or equal to the queue length of the historical device queue.
2. The method according to claim 1, characterized in that In response to the second historical device queue including the target device identifier, continuing to store the device identifier and the Bluetooth type of the target Bluetooth device in the first device queue includes: In response to the second historical device queue including the target device identifier, and the target device identifier is the same as the device identifier of the first Bluetooth device, the device identifier and Bluetooth type of the first Bluetooth device continue to be stored in the first device queue.
3. The method according to claim 1, characterized in that The electronic device also includes a sports health application; The method further comprises: In response to the first Bluetooth device being a Bluetooth device associated with the sports health application, displaying a device identification of the first Bluetooth device on a device management interface of the sports health application; receiving a connection operation for the first Bluetooth device in a device management interface of the sports health application, and acquiring a Bluetooth type of the first Bluetooth device from the first device queue in response to the connection operation; Based on the Bluetooth type of the first Bluetooth device, a pairing request is sent to the first Bluetooth device.
4. The method according to claim 3, characterized in that The method further comprises: A deletion operation for the first Bluetooth device is received on the device management interface of the sports health application, and in response to the deletion operation, the device identification and Bluetooth type of the first Bluetooth device are deleted from the first device queue.
5. The method according to claim 1, characterized in that The method further comprises: In response to the second historical device queue not including the target device identifier, deleting the device identifier and Bluetooth type of the target Bluetooth device from the first device queue.
6. The method according to any one of claims 1 to 5, characterized in that: The electronic device further comprises a Bluetooth protocol stack, and the Bluetooth protocol stack is used for managing the device queue and the historical device queue.
7. The method according to claim 6, characterized in that In response to scanning a first Bluetooth device through the Bluetooth chip, querying whether a device queue includes a device identifier of the first Bluetooth device includes: receiving a click operation for a close mark of a Bluetooth application, and in response to the click operation, controlling the Bluetooth protocol stack and the Bluetooth chip to be in a working state; Invoking the Bluetooth chip to scan Bluetooth devices in the environment where the electronic device is located; In response to the Bluetooth chip scanning a first Bluetooth device, calling the Bluetooth chip to obtain a device identifier and a Bluetooth type of the first Bluetooth device; Calling the Bluetooth chip to transmit the device identification and Bluetooth type of the first Bluetooth device to the Bluetooth protocol stack; The Bluetooth protocol stack is called to query whether the device queue includes the device identification and Bluetooth type of the first Bluetooth device.
8. The method according to claim 6, characterized in that The step of continuing to store the device identification and the Bluetooth type of the target Bluetooth device in the first device queue includes: The Bluetooth protocol stack is called to continue to store the device identification and Bluetooth type of the target Bluetooth device in the first device queue.
9. An electronic device, characterized in that: The method comprises one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program codes, wherein the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the method according to any one of claims 1 to 8 is executed.
10. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-8.
11. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the method according to any one of claims 1 to 8 is executed.
