Bluetooth communication method and electronic equipment
By carrying broadcast packets with filter identifiers in Bluetooth communications, the problem of resource waste when electronic devices scan BLE broadcast packets is solved, achieving more efficient resource utilization and improving user experience.
Patent Information
- Application Number
- CN202410227592.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-28
- Publication Date
- 2025-09-05
AI Technical Summary
When an electronic device scans a BLE broadcast packet from another electronic device, it performs two matching operations, resulting in a waste of resources.
By carrying the filter identifier in the scanned broadcast packet, the application manager of the electronic device can directly determine the corresponding application, avoid re-matching, and reduce resource waste.
It reduces resource waste of electronic devices, improves resource utilization efficiency, and enhances user experience.
Smart Images

Figure CN120602897A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic devices, and in particular to a Bluetooth communication method and electronic device. Background Art
[0002] With the popularization of smart devices and the development of communication technology, electronic devices (such as mobile phones, etc.) can include one or more Bluetooth three-party applications. For example, an electronic device (such as a mobile phone, etc.) can establish a Bluetooth connection with other electronic devices (such as smart watches, etc.) through a Bluetooth three-party application, thereby enabling the electronic device to communicate with other electronic devices through Bluetooth.
[0003] When an electronic device establishes a Bluetooth connection with another electronic device through a Bluetooth three-party application, the electronic device initiates a Bluetooth low energy (BLE) scan through the Bluetooth three-party application, allowing the electronic device to scan the BLE broadcast packets of the other electronic device. When the electronic device determines that the scanned BLE broadcast packet is a match, the electronic device can establish a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet.
[0004] However, when an electronic device scans a BLE broadcast packet from another electronic device, it matches the scanned BLE broadcast packet twice. If both matches are successful, the electronic device can establish a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet. This results in a waste of electronic device resources when the electronic device establishes a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet. Summary of the Invention
[0005] Embodiments of the present application provide a Bluetooth communication method and electronic device, which can reduce the number of matches of the electronic device on scanned BLE broadcast packets, thereby avoiding waste of resources of the electronic device.
[0006] To achieve the above objectives, the present invention adopts the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a Bluetooth communication method, which is applied to an electronic device. The Bluetooth communication method may include: receiving a user's start operation for a first application; starting a scanning function in response to the start operation; when a first broadcast packet of a Bluetooth device is scanned and there is a first filter in the filter of the electronic device that matches the first broadcast packet, determining a second broadcast packet based on the first broadcast packet and the filter identifier of the first filter; the second broadcast packet carries the filter identifier of the first filter; based on the second broadcast packet, determining the first application corresponding to the filter identifier of the first filter; and returning the second broadcast packet to the first application, so that the first application communicates with the Bluetooth device based on the second broadcast packet.
[0008] Based on the Bluetooth communication method described in the first aspect, since the electronic device carries the filter identifier of the filter corresponding to the first broadcast packet in the broadcast packet (i.e., the second broadcast packet) after successfully matching the scanned first broadcast packet, the application manager of the electronic device does not need to match the first broadcast packet with the filter corresponding to the first application again. That is, when the electronic device of the solution of the present application scans the first broadcast packet, the electronic device matches the scanned broadcast packet once, which can avoid the waste of electronic device resources when the electronic device communicates with the Bluetooth device based on the scanned BLE broadcast packet.
[0009] Furthermore, because the electronic device carries the filter identifier of the filter corresponding to the first broadcast packet in the broadcast packet (i.e., the second broadcast packet), the electronic device can determine the first application based on the filter identifier. Thus, the electronic device can accurately call back the first broadcast packet to its corresponding application, thereby preventing the electronic device from calling back the first broadcast packet to other applications and further avoiding waste of electronic device resources.
[0010] In combination with the first aspect, in another possible implementation, determining the first application corresponding to the filter identifier of the first filter based on the second broadcast packet may include: determining the first application identifier corresponding to the filter identifier of the first filter based on the second broadcast packet and the first correspondence; the first correspondence includes the correspondence between the application identifiers of multiple applications and the filter identifiers of the filters corresponding to each application; and determining the first application based on the first application identifier.
[0011] Based on this possible implementation, since the electronic device carries the filter identifier of the filter corresponding to the first broadcast packet in the broadcast packet (i.e., the second broadcast packet), the electronic device can determine the first application based on the filter identifier and the correspondence between the application identifiers of multiple applications and the filter identifiers of the filters corresponding to each application. Thus, the electronic device can accurately call back the first broadcast packet to its corresponding application, avoiding the electronic device calling back the first broadcast packet to other applications, further avoiding waste of electronic device resources.
[0012] In combination with the first aspect, in another possible implementation, before starting the scanning function, the above-mentioned Bluetooth communication method may also include: assigning a first application identifier to the first application; constructing at least one filter corresponding to the first application based on the first application identifier; assigning corresponding filter identifiers to at least one filter respectively; and determining a first corresponding relationship based on the first application identifier and at least one filter identifier.
[0013] Based on this possible implementation method, since the electronic device can determine the correspondence between the application identifiers of multiple applications and the filter identifiers of the filters corresponding to each application, when the electronic device can carry the filter identifier in the second broadcast packet, the electronic device can accurately determine the corresponding application based on the filter identifier.
[0014] In combination with the first aspect, in another possible implementation, after constructing at least one filter corresponding to the first application, the above-mentioned Bluetooth communication method may also include: the Bluetooth protocol module of the electronic device generates a filter command corresponding to at least one filter; the filter command includes an immediate reporting command, a batch reporting command, a direct discard command, a rolling update command, a reply broadcast packet command or a broadcast packet discard command after connection; the Bluetooth protocol module of the electronic device transmits the filter command to the Bluetooth chip of the electronic device.
[0015] Based on this possible implementation, since the electronic device can generate different filter commands, when the electronic device scans a broadcast packet of a Bluetooth device, the electronic device can perform different actions based on different filter commands, thereby improving the user experience.
[0016] In combination with the first aspect, in another possible implementation, returning the second broadcast packet to the first application may include: the Bluetooth chip returns the second broadcast packet to the first application in response to the filter command being an immediate report command.
[0017] Based on this possible implementation method, when the filter command is an immediate reporting command, when the electronic device scans the broadcast packet of the Bluetooth device, the electronic device can immediately return the matching broadcast packet (i.e., the second broadcast packet) to the first application, so that the first application can communicate with the Bluetooth device in a timely manner, thereby improving the user experience.
[0018] In combination with the first aspect, in another possible implementation, the above-mentioned returning the second broadcast packet to the first application may include: the Bluetooth chip responds to the filter command as a batch reporting command, and returns the second broadcast packet to the first application when the number of second broadcast packets is greater than a preset threshold.
[0019] Based on this possible implementation method, when the filter command is a batch reporting command, when the electronic device scans the broadcast packet of the Bluetooth device, the electronic device can return the matching broadcast packet (i.e., the second broadcast packet) to the first application when the number of matching broadcast packets (i.e., the second broadcast packet) is sufficient, thereby avoiding the first application from being woken up multiple times and saving the power consumption of the electronic device.
[0020] In combination with the first aspect, in another possible implementation, before determining the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the above-mentioned Bluetooth communication method may also include: the Bluetooth chip responds to the filter command as a direct discard command, and discards the first broadcast packet if the first broadcast packet is a broadcast packet in the blacklist.
[0021] Based on this possible implementation method, when the filter command is a direct discard command, when the electronic device scans a broadcast packet of a Bluetooth device, if the broadcast packet is a broadcast packet in the blacklist, the electronic device can discard the broadcast packet, thereby avoiding the electronic device from communicating with the Bluetooth device in the blacklist.
[0022] In combination with the first aspect, in another possible implementation, before determining the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the above-mentioned Bluetooth communication method may also include: the Bluetooth chip responds to the filter command as a rolling update command, and when a third broadcast packet of the Bluetooth device is scanned, and there is a second filter matching the third broadcast packet in the filter of the electronic device, updates the first broadcast packet based on the third broadcast packet; the third broadcast packet is a broadcast packet after the first broadcast packet; the Bluetooth protocol module of the electronic device generates a broadcast packet acquisition command and transmits the broadcast packet acquisition command to the Bluetooth chip; the Bluetooth chip responds to the broadcast packet acquisition command, based on the third broadcast packet and the filter identifier of the second filter, determines a fourth broadcast packet; the fourth broadcast packet carries the filter identifier of the second filter; based on the fourth broadcast packet, determines the first application corresponding to the filter identifier of the second filter; and returns the fourth broadcast packet to the first application, so that the first application communicates with the Bluetooth device based on the fourth broadcast packet.
[0023] Based on this possible implementation method, when the filter command is a rolling update command, when the electronic device scans the broadcast packet of the Bluetooth device, the electronic device can roll over the matching broadcast packet, so that when the Bluetooth chip receives the broadcast packet acquisition command, it can return the latest broadcast packet to the first application, thereby avoiding the first application from being woken up multiple times and saving the power consumption of the electronic device.
[0024] In combination with the first aspect, in another possible implementation, the above-mentioned Bluetooth communication method may further include: the Bluetooth chip responds to the filter command as a reply broadcast packet command, and returns broadcast information to the Bluetooth device, so that the Bluetooth device broadcasts based on the broadcast information.
[0025] Based on this possible implementation, when the filter command is a reply broadcast packet command, after the electronic device establishes a connection with the Bluetooth device based on the second broadcast packet, the electronic device can return broadcast information to the Bluetooth device so that the Bluetooth device broadcasts based on the broadcast information.
[0026] In combination with the first aspect, in another possible implementation, after the first application establishes a connection with the Bluetooth device, the above-mentioned Bluetooth communication method may further include: when the fifth broadcast packet of the Bluetooth device is scanned and there is a third filter in the filter of the electronic device that matches the fifth broadcast packet, the Bluetooth chip responds to the filter command of discarding the broadcast packet after connection and discards the fifth broadcast packet.
[0027] Based on this possible implementation method, when the filter command is a command to discard the broadcast packet, after the electronic device establishes a connection with the Bluetooth device based on the second broadcast packet, if the electronic device scans the fifth broadcast packet of the Bluetooth device, and there is a third filter in the filter in the electronic device that matches the fifth broadcast packet, the Bluetooth chip discards the fifth broadcast packet, which can reduce the multiple wake-up times of the first application, thereby saving power consumption of the electronic device.
[0028] In a second aspect, embodiments of the present application provide a Bluetooth communication device that can be applied to an electronic device and used to implement the method described in the first aspect. The functions of the Bluetooth communication device can be implemented through hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions, such as a receiving module, an opening module, a determination module, and a sending module.
[0029] The receiving module may be configured to receive a user's opening operation for the first application.
[0030] The start module can be used to start the scanning function in response to the start operation.
[0031] The determination module can be used to determine the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter when the first broadcast packet of the Bluetooth device is scanned and there is a first filter matching the first broadcast packet in the filter of the electronic device; the second broadcast packet carries the filter identifier of the first filter.
[0032] The determination module may also be configured to determine, based on the second broadcast packet, a first application corresponding to the filter identifier of the first filter.
[0033] The sending module can be used to return the second broadcast packet to the first application, so that the first application communicates with the Bluetooth device based on the second broadcast packet.
[0034] In a third aspect, a Bluetooth communication device is provided, which has the functionality to implement the method described in the first aspect. This functionality can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the functionality described above.
[0035] In a fourth aspect, a Bluetooth communication device is provided, comprising: a processor and a memory; the memory is used to store computer-executable instructions, and when the Bluetooth communication device is running, the processor executes the computer-executable instructions stored in the memory to enable the Bluetooth communication device to perform the Bluetooth communication method as described in any one of the first aspects above.
[0036] In a fifth aspect, embodiments of the present application provide a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by an electronic device, the electronic device implements the Bluetooth communication method as described in the first aspect or any possible implementation of the first aspect.
[0037] In a sixth aspect, an embodiment of the present application provides a computer program product, comprising a computer-readable code, which, when executed in an electronic device, enables the electronic device to implement a Bluetooth communication method as described in the first aspect or any one of the possible implementations of the first aspect.
[0038] In a seventh aspect, a device (for example, a chip system) is provided, which includes a processor for supporting an electronic device in implementing the functions described in the first aspect. In one possible design, the device also includes a memory for storing program instructions and data necessary for the electronic device. When the device is a chip system, it can be composed of a chip or include a chip and other discrete devices.
[0039] It should be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A schematic diagram of establishing Bluetooth communication between an electronic device and a Bluetooth device;
[0041] Figure 2 A schematic diagram of a framework for Bluetooth communication between an electronic device and a Bluetooth device in the related art;
[0042] Figure 3 A schematic diagram of a process for Bluetooth communication between an electronic device and a Bluetooth device in the related art;
[0043] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0044] Figure 5 A schematic diagram of a framework of an electronic device provided in an embodiment of the present application;
[0045] Figure 6 A schematic diagram of a Bluetooth communication method provided in an embodiment of the present application Figure 1;
[0046] Figure 7 A schematic diagram of a Bluetooth communication method provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0048] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature specified as "first" or "second" may explicitly or implicitly include one or more of such features. Throughout this application, unless otherwise specified, "plurality" means two or more.
[0049] 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 be limiting of the present application. 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 " / " means or, for example, A / B can mean A or B; "and / or" in the text is merely a description of the association relationship of associated persons, indicating that three relationships can exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0050] With the popularization of smart devices and the development of communication technology, electronic devices (such as mobile phones, etc.) can include one or more Bluetooth third-party applications (APPs). For example, an electronic device (such as a mobile phone, etc.) can establish a Bluetooth connection with other electronic devices (such as a smart watch, etc.) through a Bluetooth third-party application, thereby enabling the electronic device to communicate with other electronic devices through Bluetooth.
[0051] For example, combined with Figure 1As shown, when the electronic device is a mobile phone 01 and the other electronic device is a smart watch 02, the mobile phone 01 can establish a Bluetooth connection with the smart watch 02 through the Bluetooth third-party application included therein (such as the application corresponding to the smart watch), so that the mobile phone 01 can communicate with the smart watch 02 through Bluetooth. For example, the smart watch 02 can send the user's recorded step data and other data to the mobile phone 01, so that the user can view the step data through the Bluetooth third-party application on the mobile phone 01.
[0052] When an electronic device establishes a Bluetooth connection with another electronic device through a Bluetooth three-party application, the electronic device initiates a Bluetooth low energy (BLE) scan through the Bluetooth three-party application, allowing the electronic device to scan the BLE broadcast packets of the other electronic device. When the electronic device determines that the scanned BLE broadcast packet is a match, the electronic device can establish a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet.
[0053] However, when an electronic device scans a BLE broadcast packet from another electronic device, it matches the scanned BLE broadcast packet twice. If both matches are successful, the electronic device can establish a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet. This results in a waste of electronic device resources when the electronic device establishes a Bluetooth connection with the other electronic device based on the scanned BLE broadcast packet.
[0054] The following is combined with Figure 2 And attached Figure 3 The process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application is schematically described.
[0055] Combine Figure 2 As shown, taking a mobile phone as an example, the electronic device may include a Bluetooth three-party application, a Bluetooth adapter framework (i.e., bluetooth adapter framework), a Bluetooth protocol stack (i.e., bluetooth protocol stack) and a Bluetooth chip (i.e., bluetooth controller, BTC).
[0056] like Figure 2 As shown, the Bluetooth three-party application may include a Bluetooth adapter (ie, bluethadapter), that is, the Bluetooth three-party application may establish a connection with the Bluetooth adapter service in the Bluetooth adapter framework by calling the Bluetooth adapter.
[0057] The Bluetooth adapter framework can include a Bluetooth adapter service (i.e., bluetooth adapter service). The Bluetooth adapter service can be located in the Bluetooth application JAVA layer (i.e., bluetha app java layer) in the Bluetooth adapter framework. The Bluetooth adapter service can include an application manager (i.e., app manager), a filter manager (i.e., filter manager), and an advertising packet matching module (i.e., filter-advertiser-matcher).
[0058] Among them, the application manager can be used to manage applications, such as allocating and reclaiming application identifiers (APP ID) for third-party applications, and managing filter identifiers (filter ID) for third-party applications. That is, the application manager can establish an application list (i.e., APP list) and manage third-party applications through the application list. The application manager can also establish a correspondence between the application identifier of the third-party application and the filter identifier corresponding to the third-party application. Through the correspondence between the application identifier of the third-party application and the filter identifier corresponding to the third-party application, the application manager can determine the application identifier corresponding to the filter identifier through the filter identifier, thereby being able to determine the corresponding third-party application.
[0059] The filter manager can be used to manage filters associated with applications, such as querying the number of filters associated with the Bluetooth chip, and can also allocate and recycle filter IDs for third-party applications. In other words, the filter manager can create a filter list and manage filters associated with third-party applications through the filter list.
[0060] The broadcast packet matching module can be used to match broadcast packets scanned by the Bluetooth chip with filters. That is, through the broadcast packets scanned by the Bluetooth chip and the filter list, the filter and the corresponding filter identifier corresponding to the broadcast packet are determined.
[0061] like Figure 2 As shown, the Bluetooth protocol stack may include a broadcast packet assembly (ie, ble adv assembly) module and a host control interface (HCI) upper layer module.
[0062] The broadcast packet assembly module can be used to assemble the broadcast packets scanned by the Bluetooth chip and send them to the broadcast packet matching module in the Bluetooth adaptation service.
[0063] The HCI upper layer module can be used to receive broadcast packets sent by the HCI lower layer module in the Bluetooth chip.
[0064] like Figure 2 As shown, the Bluetooth chip may include an HCI lower layer module, a broadcast packet matching module (ie, filter-advertiser-matcher), a broadcast packet and event manager (ie, packet and event manager), and a modem (ie, modem).
[0065] Among them, the modem can be used to scan broadcast packets from other electronic devices.
[0066] The broadcast packet and event manager can be used to transmit the broadcast packet scanned by the modem to the broadcast packet matching module. The broadcast packet and event manager can also be used to manage and respond to events related to the broadcast packet.
[0067] The broadcast packet matching module can be used to match broadcast packets with filters for broadcast packets and broadcast packets transmitted by the event manager. That is, through the broadcast packets scanned by the Bluetooth chip and the filter list, the filter and the corresponding filter identifier of the broadcast packet are determined.
[0068] The HCI lower layer module can be used to send the broadcast packets successfully matched by the broadcast packet matching module in the Bluetooth chip to the HCI upper layer module in the Bluetooth protocol stack.
[0069] The following is combined with Figure 3 This section provides a schematic diagram of the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application. Figure 3 As shown, the electronic device may include an application processor (AP) and a Bluetooth chip (ie, BTC).
[0070] The application manager (AP) includes applications (such as Bluetooth third-party applications), system services (such as the Bluetooth framework, i.e., the Bluetooth adapter framework mentioned above), and Bluetooth applications (i.e., Bluetooth applications in the electronic device's system). Bluetooth applications include the application manager (i.e., app manager), the filter manager (i.e., filter manager), the broadcast packet matching module (i.e., filter-advertiser-matcher), and the Bluetooth protocol stack (i.e., blueth protocol stack).
[0071] The Bluetooth chip (ie, BTC) includes a broadcast packet matching module (ie, filter-advertiser-matcher), a broadcast packet and event manager (ie, packet and event manager), and a modem (ie, modem).
[0072] like Figure 3 As shown, the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application includes the following.
[0073] When a Bluetooth third-party application in an electronic device (such as a smartwatch application in a mobile phone) needs to establish Bluetooth with a Bluetooth device (such as a smartwatch), the Bluetooth third-party application can obtain Bluetooth services. That is, the Bluetooth third-party application can call the Bluetooth framework in the system service.
[0074] After a Bluetooth third-party application can call the Bluetooth framework in the system service, the Bluetooth framework can call the application manager in the Bluetooth application. The application manager can then assign an application ID, meaning the application manager can assign a corresponding application identifier to the Bluetooth third-party application. After the application manager assigns an application identifier to the Bluetooth third-party application, the application manager can create an application list (i.e., APPlist) and manage the third-party applications through the application list.
[0075] After the application manager assigns a corresponding application identifier to the Bluetooth third-party application, the Bluetooth third-party application can construct a scan filter.
[0076] After a Bluetooth third-party application constructs a filter, it can call the filter manager within the application. The filter manager can then assign a filter ID to the filter constructed by the Bluetooth third-party application. That is, the filter manager can assign a corresponding filter identifier to the filter constructed by the Bluetooth third-party application. After the filter manager assigns the corresponding filter identifier to the filter constructed by the Bluetooth third-party application, the filter manager can create a filter list (i.e., a filter list) to manage the filters corresponding to the third-party application.
[0077] After the filter manager assigns a filter identifier to the filter constructed by the Bluetooth third-party application, it calls the advertising packet matching module in the Bluetooth chip. The Bluetooth chip's advertising packet matching module then constructs a filter list and uses it to match advertising packets scanned by the Bluetooth chip.
[0078] Afterwards, the Bluetooth third-party application can initiate a scan, that is, the Bluetooth third-party application can call the modem in the Bluetooth chip to enable the modem to scan. After the Bluetooth third-party application calls the modem in the Bluetooth chip, the advertising packet matching module in the Bluetooth chip can return a confirmation message to the Bluetooth third-party application, which is used to instruct the modem to scan.
[0079] After that, the modem in the Bluetooth chip can scan. After the modem in the Bluetooth chip scans the broadcast packet (such as the broadcast packet corresponding to the smart watch), the modem can call the broadcast packet and event manager in the Bluetooth chip, so that the broadcast packet and event manager can package the scanned broadcast packet.
[0080] Afterwards, the broadcast packet and event manager can call the broadcast packet matching module in the Bluetooth chip, so that the broadcast packet matching module in the Bluetooth chip can match the broadcast packet with the filters in the filter list through the filter list.
[0081] After the advertising packet successfully matches the filter in the filter list, the advertising packet matching module in the Bluetooth chip can call the Bluetooth protocol stack in the Bluetooth application, so that the Bluetooth protocol stack can assemble the matching advertising packet.
[0082] Afterwards, the Bluetooth protocol stack may call the advertising packet matching module in the Bluetooth application, so that the advertising packet matching module in the Bluetooth application may match the matching advertising packet with the filters in the filter list again through the filter list.
[0083] After the matched advertising packet successfully matches the filter in the filter list again, the advertising packet matching module in the Bluetooth application can call the application manager in the Bluetooth application, so that the application manager can call back the advertising packet that successfully matches again.
[0084] That is, the application manager will call back the advertising packet that has been successfully matched again to all Bluetooth third-party applications of the filters corresponding to the advertising packet that has been successfully matched again.
[0085] For example, when an electronic device includes multiple Bluetooth third-party applications corresponding to a manufacturer's name (such as manufacturer A) (such as a body fat scale application corresponding to manufacturer A, a smart watch third-party application corresponding to manufacturer A, and a smart bracelet third-party application corresponding to manufacturer A), the filter constructed by the body fat scale application corresponding to manufacturer A can be a filter corresponding to the manufacturer's name (i.e., manufacturer A), the filter constructed by the smart watch application corresponding to manufacturer A can also be a filter corresponding to the manufacturer's name (i.e., manufacturer A), and the filter constructed by the smart bracelet application corresponding to manufacturer A can also be a filter corresponding to the manufacturer's name (i.e., manufacturer A). If the Bluetooth chip scans the broadcast packet of the body fat scale corresponding to manufacturer A, the broadcast packet matching module in the Bluetooth chip and the broadcast packet matching module in the Bluetooth application determine that the broadcast packet of the body fat scale corresponding to manufacturer A is successfully matched, the application manager will call back the broadcast packet of the body fat scale corresponding to manufacturer A to the body fat scale application corresponding to manufacturer A, the smart watch third-party application corresponding to manufacturer A, and the smart bracelet third-party application corresponding to manufacturer A.
[0086] After the Bluetooth three-party application receives the re-matching successful broadcast packet callbacked by the application manager, the Bluetooth three-party application can process the re-matching successful broadcast packet, such as the Bluetooth three-party application can establish a Bluetooth connection with the Bluetooth device corresponding to the re-matching successful broadcast packet based on the re-matching successful broadcast packet.
[0087] Through the above Figure 2 as well as Figure 3 As shown in the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application, it can be seen that when an electronic device scans a broadcast packet (i.e., a BLE broadcast packet) from another electronic device, the broadcast packet matching module in the Bluetooth chip of the electronic device will match the scanned broadcast packet, and the broadcast packet matching module in the Bluetooth application of the electronic device can also match the scanned broadcast packet. That is, when an electronic device scans a broadcast packet (i.e., a BLE broadcast packet) from another electronic device, the electronic device will match the scanned broadcast packet twice. When both matches are successful, the electronic device can establish a Bluetooth connection with the other electronic device based on the scanned broadcast packet.
[0088] When an electronic device scans a broadcast packet (i.e., a BLE broadcast packet) from another electronic device, the electronic device will match the scanned broadcast packet twice. This results in a waste of the electronic device's resources (such as application processor resources) when the electronic device establishes a Bluetooth connection with other electronic devices based on the scanned BLE broadcast packet.
[0089] Moreover, when the electronic device matches the scanned broadcast packet twice and both matches are successful, the Bluetooth application of the electronic device will call back the broadcast packet to all Bluetooth third-party applications corresponding to the filter corresponding to the broadcast packet. This will cause all Bluetooth third-party applications corresponding to the filter corresponding to the broadcast packet to be awakened, while all Bluetooth third-party applications corresponding to the filter corresponding to the broadcast packet do not need to be awakened, which further leads to a waste of resources of the electronic device (such as resources of the application processor).
[0090] In response to the above problems, an embodiment of the present application provides a device connection method, which is applied to an electronic device. The device connection method may include that the application manager in the application processor of the electronic device can establish a correspondence between the filter identifier of the filter corresponding to the Bluetooth three-party application and the application identifier of the Bluetooth three-party application. After the Bluetooth chip of the electronic device scans the broadcast packet of the Bluetooth device, the Bluetooth chip of the electronic device matches the scanned broadcast packet with the filters in the filter list in the Bluetooth chip. After the scanned broadcast packet is successfully matched, the Bluetooth chip carries the filter identifier of the filter corresponding to the scanned broadcast packet in the broadcast packet, and sends the broadcast packet carrying the filter identifier to the application manager in the application processor of the electronic device. The application manager of the electronic device determines the application identifier corresponding to the filter identifier based on the filter identifier carried in the broadcast packet, and determines the corresponding Bluetooth three-party application based on the application identifier. The application manager of the electronic device calls back the broadcast packet to the determined Bluetooth three-party application, so that the Bluetooth three-party application can establish a Bluetooth connection with the Bluetooth device based on the broadcast packet.
[0091] In the solution of the present application, after the Bluetooth chip of the electronic device successfully matches the scanned broadcast packet, the filter identifier of the filter corresponding to the scanned broadcast packet is carried in the broadcast packet, so that the application manager of the electronic device does not need to match the scanned broadcast packet with the filter corresponding to the Bluetooth three-party application again. That is, when the electronic device of the solution of the present application scans the broadcast packet (i.e., BLE broadcast packet) of other electronic devices (i.e., Bluetooth devices), the electronic device will match the scanned broadcast packet once, which can avoid the waste of the electronic device's resources (such as application processor resources) when the electronic device establishes a Bluetooth connection with other electronic devices based on the scanned BLE broadcast packet.
[0092] Furthermore, since the Bluetooth chip of the electronic device carries the filter identifier of the filter corresponding to the scanned broadcast packet in the broadcast packet, the application manager of the electronic device can determine the Bluetooth three-party application corresponding to the broadcast packet based on the filter identifier and the correspondence between the filter identifier of the filter and the application identifier of the Bluetooth three-party application. Thus, the application manager of the electronic device can call back the broadcast packet to its corresponding Bluetooth three-party application, thereby preventing the application manager of the electronic device from calling back the broadcast packet to other Bluetooth three-party applications, and further avoiding waste of electronic device resources (such as application processor resources).
[0093] The following describes the device connection method provided in the embodiment of the present application.
[0094] The device connection method provided in the embodiments of the present application can be applied to the above-mentioned electronic devices. In some embodiments, the above-mentioned electronic devices can be mobile phones, tablet computers, handheld computers, personal computers (PCs), cellular phones, personal digital assistants (PDAs), and other electronic devices that include Bluetooth three-party applications. The embodiments of the present application do not limit the specific form of the electronic devices.
[0095] In some examples, a Bluetooth third-party application may be a third-party smart watch application, smart bracelet application, body fat scale application, or other Bluetooth third-party application that can establish a Bluetooth connection with other electronic devices. The specific type of Bluetooth third-party application is not limited in the embodiments of the present application.
[0096] For example, taking the electronic device as a mobile phone, Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown.
[0097] like Figure 4As shown, the electronic device may include a processor 410, an external memory interface 420, an internal memory 421, a universal serial bus (USB) interface 430, a charging management module 440, a power management module 441, a battery 442, an antenna 1, an antenna 2, a mobile communication module 450, a wireless communication module 460, an audio module 470, a speaker 470A, a receiver 470B, a microphone 470C, an earphone interface 470D, a sensor module 480, a button 490, a motor 491, an indicator 492, a camera 493, a display screen 494, and a subscriber identification module (SIM) card interface 495, etc. Among them, the sensor module 480 can include a pressure sensor 480A, a gyroscope sensor 480B, an air pressure sensor 480C, a magnetic sensor 480D, an acceleration sensor 480E, a distance sensor 480F, a proximity light sensor 480G, a fingerprint sensor 480H, a temperature sensor 480J, a touch sensor 480K, an ambient light sensor 480L, a bone conduction sensor 480M, etc.
[0098] It should be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0099] The processor 410 may include one or more processing units. For example, the processor 410 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.
[0100] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0101] Processor 410 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 410 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 410. If processor 410 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 410 latency, and thus improves system efficiency.
[0102] In some embodiments, the processor 410 may include one or more interfaces. The interfaces 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.
[0103] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 450, wireless communication module 460, modem processor and baseband processor.
[0104] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0105] The mobile communication module 450 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to electronic devices. The mobile communication module 450 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 450 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 450 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the processor 410. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the same device as at least some of the modules of the processor 410.
[0106] The wireless communication module 460 can provide wireless communication solutions for electronic devices, 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. The wireless communication module 460 can be one or more devices that integrate at least one communication processing module. The wireless communication module 460 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 410. The wireless communication module 460 can also receive the signal to be sent from the processor 410, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0107] In some embodiments, antenna 1 of the electronic device is coupled to mobile communication module 450, and antenna 2 is coupled to wireless communication module 460, so that the electronic device can communicate with a network and other devices via wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology.
[0108] The electronic device implements display functionality through a GPU, display screen 494, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 494 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 410 may include one or more GPUs that execute program instructions to generate or modify display information.
[0109] Display screen 494 is used to display images, videos, and the like. Display screen 494 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 (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLED, or a quantum dot light-emitting diode (QLED). In some embodiments, the electronic device can include one or N display screens 494, where N is a positive integer greater than one.
[0110] The electronic device can implement the shooting function through the ISP, camera 493, video codec, GPU, display 494 and application processor, etc. In some embodiments, the electronic device can include 1 or N cameras 493, where N is a positive integer greater than 1.
[0111] The internal memory 421 can be used to store computer executable program codes, which include instructions. The processor 410 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 421. The internal memory 421 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data established during the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the internal memory 421 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0112] The acceleration sensor 480E can periodically collect acceleration data of the electronic device at a certain frequency. For example, it can collect the acceleration magnitude of the electronic device in various directions (generally the X, Y, and Z axes).
[0113] Of course, it is understandable that the above Figure 4 The figure is only an example of the electronic device being a mobile phone. If the electronic device is a tablet computer, handheld computer, PC, PDA, wearable device (such as smart watch, smart bracelet) or other device forms, the structure of the electronic device may include more than Figure 4 The structure shown in the figure is less than Figure 4 More structures are shown in the figure, which are not limited here.
[0114] It is understandable that, generally speaking, the realization of electronic device functions requires not only hardware support but also software cooperation.
[0115] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. Taking the system as an example, the software structure of the electronic device is illustrated.
[0116] Figure 5 This is a software structure block diagram of the electronic device provided in the embodiment of the present application.
[0117] Combine Figure 5As shown, the electronic device may include a Bluetooth three-party application, a Bluetooth adapter framework (ie, bluetooth adapter framework), a Bluetooth protocol stack (ie, bluetooth protocol stack) and a Bluetooth chip (ie, bluetooth controller, BTC).
[0118] like Figure 5 As shown, the Bluetooth three-party application may include a Bluetooth adapter (ie, bluethadapter), that is, the Bluetooth three-party application may establish a connection with the Bluetooth adapter service in the Bluetooth adapter framework by calling the Bluetooth adapter.
[0119] The Bluetooth adapter framework may include a Bluetooth adapter service (i.e., bluetooth adapter service). The Bluetooth adapter service may be located in the Bluetooth application JAVA layer (i.e., bluetha app java layer) in the Bluetooth adapter framework. The Bluetooth adapter service may include an application manager (i.e., app manager) and a filter manager (i.e., filter manager).
[0120] Among them, the application manager can be used to manage applications, such as allocating and recycling application identifiers (application identifier, APP ID) for Bluetooth three-party applications, and managing filter identifiers (filter identifier, filter ID) for Bluetooth three-party applications. That is, the application manager can establish an application list (i.e., APP list) and manage Bluetooth three-party applications through the application list. The application manager can also establish a correspondence between the application identifier of the Bluetooth three-party application and the filter identifier corresponding to the Bluetooth three-party application. Through the correspondence between the application identifier of the Bluetooth three-party application and the filter identifier corresponding to the Bluetooth three-party application, the application manager can determine the application identifier of the Bluetooth three-party application corresponding to the filter identifier through the filter identifier, thereby being able to determine the corresponding Bluetooth three-party application.
[0121] The filter manager manages the filters associated with Bluetooth third-party applications. For example, it can query the number of filters associated with the Bluetooth chip and allocate and recycle filter IDs for Bluetooth third-party applications. The filter manager can also create a filter list and manage the filters associated with Bluetooth third-party applications through the filter list.
[0122] like Figure 5As shown, the Bluetooth protocol stack may include a broadcast packet assembly (ie, ble adv assembly) module and a host control interface (HCI) upper layer module.
[0123] The broadcast packet assembly module can be used to assemble the broadcast packets scanned by the Bluetooth chip and send them to the broadcast packet matching module in the Bluetooth adaptation service.
[0124] The HCI upper layer module can be used to receive broadcast packets sent by the HCI lower layer module in the Bluetooth chip.
[0125] like Figure 5 As shown, the Bluetooth chip may include an HCI lower layer module, a broadcast packet matching module (ie, filter-advertiser-matcher), a broadcast packet and event manager (ie, packet and event manager), and a modem (ie, modem).
[0126] Among them, the modem can be used to scan broadcast packets from other electronic devices.
[0127] The broadcast packet and event manager can be used to transmit the broadcast packet scanned by the modem to the broadcast packet matching module. The broadcast packet and event manager can also be used to manage and respond to events related to the broadcast packet.
[0128] The broadcast packet matching module can be used to match broadcast packets with filters for broadcast packets and broadcast packets transmitted by the event manager. That is, through the broadcast packets scanned by the Bluetooth chip and the filter list, the filter and the corresponding filter identifier of the broadcast packet are determined.
[0129] The HCI lower layer module can be used to carry the corresponding filter identifier in the broadcast packet successfully matched by the broadcast packet matching module in the Bluetooth chip, and send the broadcast packet carrying the filter identifier to the HCI upper layer module in the Bluetooth protocol stack.
[0130] Next, combine Figure 6 In the embodiment of the present application, the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application is schematically described as follows. Figure 6 As shown, the electronic device may include an application processor (AP) and a Bluetooth chip (ie, BTC).
[0131] The application manager (AP) includes applications (such as Bluetooth third-party applications), system services (such as the Bluetooth framework, i.e. the Bluetooth adapter framework mentioned above), and Bluetooth applications (i.e. Bluetooth applications in the electronic device system). Bluetooth applications include the application manager (i.e., app manager), the filter manager (i.e., filter manager), and the Bluetooth protocol stack (i.e., blueth protocol stack).
[0132] The Bluetooth chip (ie, BTC) includes a broadcast packet matching module (ie, filter-advertiser-matcher), a broadcast packet and event manager (ie, packet and event manager), and a modem (ie, modem).
[0133] Next, combine Figure 6 In the embodiment of the present application, the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application is schematically described as follows. Figure 6 As shown, the process of establishing a Bluetooth connection between an electronic device and other electronic devices through a Bluetooth three-party application includes the following.
[0134] When a Bluetooth third-party application in an electronic device needs to establish a Bluetooth connection with a Bluetooth device, the Bluetooth third-party application can obtain Bluetooth services. That is, the Bluetooth third-party application can call the Bluetooth framework in the system service.
[0135] After a Bluetooth third-party application can call the Bluetooth framework in the system service, the Bluetooth framework can call the application manager in the Bluetooth application. The application manager can then assign an application ID, meaning the application manager can assign a corresponding application identifier to the Bluetooth third-party application. After the application manager assigns an application identifier to the Bluetooth third-party application, the application manager can create an application list (i.e., APPlist) and manage the third-party applications through the application list.
[0136] After the application manager assigns a corresponding application identifier to the Bluetooth third-party application, the Bluetooth third-party application can construct a scan filter.
[0137] After a Bluetooth third-party application constructs a filter, it can call the filter manager within the application. The filter manager can then assign a filter ID to the filter constructed by the Bluetooth third-party application. That is, the filter manager can assign a corresponding filter identifier to the filter constructed by the Bluetooth third-party application. After the filter manager assigns the corresponding filter identifier to the filter constructed by the Bluetooth third-party application, the filter manager can create a filter list (i.e., a filter list) to manage the filters corresponding to the third-party application.
[0138] After the filter manager assigns a corresponding filter identifier to the filter constructed by the Bluetooth third-party application, the application manager can also establish a correspondence between the application identifier of the Bluetooth third-party application and the filter identifier corresponding to the Bluetooth third-party application. The filter manager can then call the advertising packet matching module in the Bluetooth chip. The advertising packet matching module in the Bluetooth chip can then construct a filter list (i.e., filter list) and use the filter list to match advertising packets scanned by the Bluetooth chip.
[0139] Afterwards, the Bluetooth third-party application can initiate a scan, that is, the Bluetooth third-party application can call the modem in the Bluetooth chip to enable the modem to scan. After the Bluetooth third-party application calls the modem in the Bluetooth chip, the advertising packet matching module in the Bluetooth chip can return a confirmation message to the Bluetooth third-party application, which is used to instruct the modem to scan.
[0140] After that, the modem in the Bluetooth chip can scan. After the modem in the Bluetooth chip scans the advertising packet, the modem can call the advertising packet and event manager in the Bluetooth chip, so that the advertising packet and event manager can package the scanned advertising packet.
[0141] Afterwards, the broadcast packet and event manager can call the broadcast packet matching module in the Bluetooth chip, so that the broadcast packet matching module in the Bluetooth chip can match the broadcast packet with the filters in the filter list through the filter list.
[0142] After the broadcast packet successfully matches the filter in the filter list, the Bluetooth chip (such as the HCI lower layer module in the Bluetooth chip) may carry the filter identifier corresponding to the broadcast packet in the matched broadcast packet.
[0143] Afterwards, the Bluetooth chip (such as the HCI lower layer module in the Bluetooth chip) can call the Bluetooth protocol stack in the Bluetooth application and send the broadcast packet carrying the filter identifier to the Bluetooth protocol stack, so that the Bluetooth protocol stack can assemble the matching broadcast packets.
[0144] Afterwards, the Bluetooth protocol stack can call the application manager in the Bluetooth application, so that the application manager can determine the application identifier corresponding to the broadcast packet based on the filter identifier carried in the broadcast packet, and the correspondence between the application identifier of the Bluetooth third-party application and the filter identifier corresponding to the Bluetooth third-party application, and determine the Bluetooth third-party application corresponding to the broadcast packet based on the application identifier corresponding to the broadcast packet.
[0145] Afterwards, the application manager in the Bluetooth application can call back the advertising packet to the Bluetooth third-party application corresponding to the advertising packet.
[0146] After the Bluetooth third-party application corresponding to the broadcast packet receives the broadcast packet called back by the application manager, the Bluetooth third-party application can process the broadcast packet. For example, the Bluetooth third-party application can establish a Bluetooth connection with the Bluetooth device corresponding to the broadcast packet based on the broadcast packet.
[0147] The device connection method provided in the embodiment of the present application is described in detail below.
[0148] The methods in the following embodiments can all be implemented in an electronic device (such as a mobile phone) having the above hardware structure or software structure.
[0149] The following is combined with Figure 7 , the device connection method provided in the embodiment of the present application is described in detail, and the device connection method can be applied to electronic devices (such as mobile phones, etc.). Figure 7 As shown, the device connection method may include the following S701-S717.
[0150] S701: The electronic device receives a user's operation to start a Bluetooth three-party application.
[0151] The Bluetooth third-party application (in the embodiments of this application, the Bluetooth third-party application may also be referred to as the first application) may be a third-party application of the electronic device. The Bluetooth third-party application may be a third-party smartwatch application, smart bracelet application, body fat scale application, or other Bluetooth third-party application that can establish a Bluetooth connection with other electronic devices. The embodiments of this application do not limit the specific type of Bluetooth third-party application.
[0152] When a user needs to establish a Bluetooth connection with a Bluetooth device corresponding to the Bluetooth three-party application through the Bluetooth three-party application on the electronic device, the user can open the Bluetooth three-party application on the electronic device. That is, the electronic device can receive the user's opening operation of the Bluetooth three-party application.
[0153] For example, when a user needs to establish a Bluetooth connection with a smartwatch (i.e., the Bluetooth device corresponding to the smartwatch application) through a Bluetooth third-party application on an electronic device, such as a smartwatch application, the user can open the smartwatch application on the electronic device. That is, the electronic device can receive the user's opening operation of the smartwatch application.
[0154] S702: In response to a user's opening operation of a Bluetooth three-party application, an application processor of the electronic device allocates an application identifier to the Bluetooth three-party application.
[0155] When the electronic device receives the user's operation to start the Bluetooth three-party application, the electronic device can start the scanning function in response.
[0156] In some examples, before the electronic device turns on the scanning function, the electronic device (such as the application processor of the electronic device) can assign a first application identifier to the Bluetooth three-party application (i.e., the first application). Thus, the electronic device (i.e., the first application in the electronic device) can construct at least one filter corresponding to the first application based on the first application identifier. Afterwards, the electronic device (such as the application processor of the electronic device) can assign corresponding filter identifiers to at least one filter. Afterwards, the electronic device (such as the application processor of the electronic device) can determine a first corresponding relationship based on the first application identifier and at least one filter identifier. That is, before the electronic device turns on the scanning function, the electronic device can execute S702-S709.
[0157] In some examples, the electronic device can assign an application identifier to the Bluetooth three-party application, and the application processor of the electronic device can assign an application identifier to the Bluetooth three-party application (the application identifier of the Bluetooth three-party application in the embodiment of the present application can also be referred to as the first application identifier).
[0158] The application identifier can be used to identify different Bluetooth applications, that is, different Bluetooth applications correspond to different application identifiers.
[0159] The application identifier can be an application ID, or the application package name, the application signature certificate, or the application version number, etc. In the embodiments of the present application, the specific type of the application identifier is not limited. In the embodiments of the present application, the application identifier is an application ID as an example for illustration.
[0160] In some examples, an application processor of the electronic device allocates an application identifier to the Bluetooth three-party application, and an application manager included in the Bluetooth application in the application processor of the electronic device may allocate the application identifier to the Bluetooth three-party application.
[0161] For example, combined with Figure 6 As shown, when an electronic device receives a user's request to start a Bluetooth third-party application, the electronic device's application processor assigns an application identifier to the Bluetooth third-party application in response. This may include the Bluetooth third-party application acquiring Bluetooth services. Specifically, the Bluetooth third-party application may invoke the Bluetooth framework in the system services in the application processor.
[0162] After the Bluetooth third-party application can call the Bluetooth framework in the system service in the application processor, the Bluetooth framework can call the application manager in the Bluetooth application in the application processor. Thereafter, the application manager can assign a corresponding application identifier, i.e., an application ID, to the Bluetooth third-party application.
[0163] After the application manager assigns a corresponding application identifier to the Bluetooth three-party application, the application manager may return the corresponding application identifier to the Bluetooth three-party application, so that the Bluetooth three-party application may construct its corresponding filter based on the application identifier of the Bluetooth three-party application.
[0164] It should be noted that after the application manager assigns the corresponding application ID to the Bluetooth third-party application, the application manager can also create an application list to manage the Bluetooth third-party application through the application list, such as allocating and recycling the application ID of the Bluetooth third-party application through the application list.
[0165] S703: The Bluetooth three-party application of the electronic device constructs a corresponding filter based on the application identifier of the Bluetooth three-party application.
[0166] After the application processor of the electronic device allocates an application identifier for the Bluetooth three-party application, the Bluetooth three-party application of the electronic device may construct a filter corresponding to the Bluetooth three-party application based on the application identifier of the Bluetooth three-party application.
[0167] A filter for a Bluetooth 3D app is a set of filtering mechanisms set by the Bluetooth 3D app during a Bluetooth scan based on specific rules or conditions. The purpose of the filter is to limit the scan results to only return Bluetooth devices that meet the specified criteria, thereby improving the efficiency and accuracy of the scan.
[0168] In some examples, the Bluetooth third-party application constructs a corresponding filter based on the application identifier of the Bluetooth third-party application. In other words, the Bluetooth third-party application sets a scan filter condition based on the application identifier of the Bluetooth third-party application.
[0169] It should be noted that the filter corresponding to the Bluetooth three-party application program constructed based on the application identifier of the Bluetooth three-party application program can be one filter or multiple filters, which is not limited in the embodiments of the present application.
[0170] In some examples, the filters corresponding to the Bluetooth three-party application constructed by the Bluetooth three-party application based on the application identifier of the Bluetooth three-party application may include a filter that enables a broadcast address, a filter that enables a service data change, a filter that enables a service universally unique identifier (UUID) check, a filter that enables a service request UUID check, a filter that enables a local name check, a filter that enables a manufacturer data check, a filter that enables a service data check, a filter that enables a transmission discovery service check, or a filter that enables an announcement type check, etc. In the embodiments of the present application, the specific type of the filter corresponding to the Bluetooth three-party application constructed by the Bluetooth three-party application based on the application identifier of the Bluetooth three-party application is not limited.
[0171] For example, combined with Figure 6 As shown, the Bluetooth three-party application of the electronic device constructs a corresponding filter based on the application identifier of the Bluetooth three-party application. After the application manager in the Bluetooth application in the application processor assigns a corresponding application identifier to the Bluetooth three-party application, the application manager can return its corresponding application identifier to the Bluetooth three-party application, so that the Bluetooth three-party application can construct its corresponding filter based on the application identifier of the Bluetooth three-party application.
[0172] S704: The application processor of the electronic device allocates a filter identifier to the filter corresponding to the Bluetooth three-party application.
[0173] After the Bluetooth three-party application of the electronic device constructs a filter corresponding to the Bluetooth three-party application based on the application identifier of the Bluetooth three-party application, the application processor of the electronic device may assign a filter identifier to the filter corresponding to the Bluetooth three-party application.
[0174] The filter identifier can be used to identify different filters, that is, different filters have different filter identifiers.
[0175] The filter can be a filter ID. The filter identifier can also include elements such as the filter type, filter conditions, filter rules, timestamp, priority, and dependencies. These elements together constitute the complete information of the filter identifier, which facilitates accurate and efficient data processing. The specific type of filter identifier is not limited in the embodiments of this application. The embodiments of this application use the filter identifier as an example for illustrative purposes.
[0176] In some examples, an application processor of an electronic device assigns a filter identifier to a filter corresponding to a Bluetooth three-party application, and a filter manager included in the Bluetooth application in the application processor of the electronic device assigns a filter identifier to a filter corresponding to the Bluetooth three-party application.
[0177] For example, combined with Figure 6 As shown, the application processor of the electronic device assigns a filter identifier to the filter corresponding to the Bluetooth three-party application. After the application manager of the electronic device assigns the corresponding application identifier to the Bluetooth three-party application, the application manager can return its corresponding application identifier to the Bluetooth three-party application, so that the Bluetooth three-party application can construct its corresponding filter based on the application identifier of the Bluetooth three-party application.
[0178] After a Bluetooth third-party application constructs its corresponding filter based on its application identifier, the Bluetooth third-party application invokes a filter manager within the application processor. The filter manager then assigns a filter identifier to the filter corresponding to the Bluetooth third-party application. Specifically, the Bluetooth third-party application sends the constructed filter to the filter manager within the application processor. After receiving the filter manager, the filter manager assigns a filter identifier to the filter corresponding to the Bluetooth third-party application.
[0179] It should be noted that after the filter manager assigns a corresponding filter identifier to the filter corresponding to the Bluetooth third-party application, the filter manager may also establish a filter list and manage the filters corresponding to the Bluetooth third-party application through the filter list. For example, the filter manager may allocate and reclaim the filter identifiers of the filters corresponding to the Bluetooth third-party application through the filter list.
[0180] After the filter manager assigns a corresponding filter identifier to the filter corresponding to the Bluetooth third-party application, the filter manager may also return the filter identifier of the filter corresponding to the Bluetooth third-party application to the application manager, so that the application manager can determine the first correspondence based on the application identifier of the Bluetooth third-party application and the filter identifier of the filter corresponding to the Bluetooth third-party application, that is, the correspondence between the filter identifier of the filter corresponding to the Bluetooth third-party application and the application identifier of the Bluetooth third-party application.
[0181] S705: The application processor of the electronic device determines a first corresponding relationship, where the first corresponding relationship is a corresponding relationship between a filter identifier of a filter corresponding to the Bluetooth three-party application and an application identifier of the Bluetooth three-party application.
[0182] After the application processor of the electronic device assigns a filter identifier to the filter corresponding to the Bluetooth three-party application, the application processor of the electronic device may determine a first correspondence. The first correspondence may be a correspondence between the filter identifier of the filter corresponding to the Bluetooth three-party application and the application identifier of the Bluetooth three-party application. Thus, when the broadcast packet returned by the Bluetooth chip includes the filter identifier, the application processor of the electronic device may determine the Bluetooth three-party application corresponding to the broadcast packet based on the filter identifier included in the broadcast packet returned by the Bluetooth chip and the first correspondence.
[0183] That is, the first correspondence may include a correspondence between the application identifiers of the plurality of application programs and the filter identifiers of the filters corresponding to the respective application programs.
[0184] In some examples, the application processor of the electronic device determines the first correspondence, which can be an application manager in the Bluetooth application in the application processor of the electronic device, based on the filter identifier of the filter corresponding to the Bluetooth three-party application and the application identifier of the Bluetooth three-party application.
[0185] For example, combined with Figure 6 As shown, the application processor of the electronic device determines the first corresponding relationship, which can be that after the filter manager in the Bluetooth application in the application processor of the electronic device assigns a corresponding filter identifier to the filter corresponding to the Bluetooth three-party application, the filter manager can also return the filter identifier of the filter corresponding to the Bluetooth three-party application to the application manager in the Bluetooth application in the application processor.
[0186] After the application manager receives the filter identifier of the filter corresponding to the Bluetooth third-party application returned by the filter manager, the application manager can determine the first correspondence based on the application identifier of the Bluetooth third-party application and the filter identifier of the filter corresponding to the Bluetooth third-party application, that is, the correspondence between the filter identifier of the filter corresponding to the Bluetooth third-party application and the application identifier of the Bluetooth third-party application.
[0187] S706: The application processor of the electronic device sends the filter and filter identifier corresponding to the Bluetooth three-party application to the Bluetooth chip.
[0188] After the application processor of the electronic device determines the first correspondence, that is, the correspondence between the filter identifier of the filter corresponding to the Bluetooth three-party application and the application identifier of the Bluetooth three-party application, the application processor of the electronic device can send the filter and filter identifier corresponding to the Bluetooth three-party application to the Bluetooth chip.
[0189] In some examples, the application processor of the electronic device sends the filters and filter identifiers corresponding to the Bluetooth third-party application to the Bluetooth chip. The filter manager in the Bluetooth application in the application processor of the electronic device sends the filters and filter identifiers corresponding to the Bluetooth third-party application to the Bluetooth chip of the electronic device.
[0190] For example, combined with Figure 6 As shown, the Bluetooth chip of the electronic device receives the filter and filter identifier corresponding to the Bluetooth three-party application and creates a filter list. After the filter manager in the Bluetooth application in the application processor of the electronic device assigns the corresponding filter identifier to the filter corresponding to the Bluetooth three-party application, the filter manager can send the filter identifier and the filter corresponding to the Bluetooth three-party application to the broadcast packet matching module in the Bluetooth chip of the electronic device. The broadcast packet matching module in the Bluetooth chip can then construct a filter list based on the filter and filter identifier corresponding to the Bluetooth three-party application.
[0191] It should be noted that after the application processor of the electronic device assigns a filter identifier to the filter corresponding to the Bluetooth three-party application, the electronic device may first execute the above S705 and then execute the above S706. The electronic device may also first execute the above S706 and then execute the above S705. The electronic device may also execute the above S706 and the above S705 simultaneously. That is, the embodiment of the present application does not limit the order of execution between the above S705 and S706. The embodiment of the present application is illustrated by taking the example that after the application processor of the electronic device assigns a filter identifier to the filter corresponding to the Bluetooth three-party application, the electronic device may first execute the above S705 and then execute the above S706.
[0192] It should be noted that when the application processor of an electronic device sends the filter and filter identifier corresponding to a Bluetooth third-party application to the Bluetooth chip, the application processor of the electronic device may also set a filter command for the filter corresponding to the Bluetooth third-party application. The filter command can be used to instruct the Bluetooth chip to perform the action corresponding to the filter command when scanning an advertisement packet. For example, the Bluetooth chip can scan according to the filter command, or the Bluetooth chip can process the advertisement packet according to the filter command when scanning the advertisement packet.
[0193] In some examples, the filter commands may include an immediate report command, a batch report command, a direct discard command, a rolling update command, a reply broadcast packet command, a discard broadcast packet command after connection, and the like.
[0194] The immediate report command can be used to instruct the Bluetooth chip to immediately report the scanned broadcast packet when it scans the broadcast packet. That is, when the Bluetooth chip scans the broadcast packet, the Bluetooth chip immediately reports the scanned broadcast packet to the application processor of the electronic device.
[0195] The batch reporting command can be used to instruct the Bluetooth chip to batch report the scanned broadcast packets when it scans the broadcast packets. That is, when the Bluetooth chip scans the broadcast packets, the Bluetooth chip does not immediately report the scanned broadcast packets to the application processor of the electronic device, but when the number of scanned broadcast packets reaches a preset number, it reports a preset number of scanned broadcast packets to the application processor of the electronic device.
[0196] The direct discard command can be used to instruct the Bluetooth chip to discard the scanned broadcast packet when it scans the broadcast packet. It should be noted that the direct discard command may include the identifier of the broadcast packet to be discarded or the content of the broadcast packet to be discarded. That is, when the Bluetooth chip scans the broadcast packet, the Bluetooth chip can determine whether the scanned broadcast packet is a broadcast packet that needs to be discarded (also referred to as a preset broadcast packet). When the scanned broadcast packet is a broadcast packet that needs to be discarded, the Bluetooth chip can discard the scanned broadcast packet. When the scanned broadcast packet is not a broadcast packet that needs to be discarded, the Bluetooth chip can report the scanned broadcast packet to the application processor of the electronic device. By setting the direct discard command, the Bluetooth chip can directly discard the broadcast packet of the black device, thereby shielding the black device.
[0197] The rolling update command can be used to instruct the Bluetooth chip to roll over the old matching broadcast packet to the new matching broadcast packet when it scans and detects a broadcast packet that matches a filter. Therefore, when the Bluetooth chip receives a broadcast packet acquisition command from the electronic device's application processor, it will return the latest matching broadcast packet to the electronic device's application processor. Specifically, when the Bluetooth chip detects a broadcast packet, it will determine whether the scanned broadcast packet matches the filter. If the scanned broadcast packet matches the filter, the Bluetooth chip may not report the matching broadcast packet to the electronic device's application processor. The Bluetooth chip can then continue scanning and, upon rescanning a broadcast packet, determine whether the rescanned broadcast packet matches the filter. If the rescanned broadcast packet matches the filter, the Bluetooth chip can overwrite the old matching broadcast packet with the new matching broadcast packet, replacing the previously matching broadcast packet with the rescanned broadcast packet. Afterwards, the Bluetooth chip can continue scanning until it receives a broadcast packet acquisition command sent by the application processor of the electronic device, so that the Bluetooth chip can report the last matched broadcast packet (i.e., the latest matched broadcast packet) to the application processor of the electronic device. By setting a rolling update command, power consumption of the electronic device can be saved.
[0198] It should be noted that the broadcast packet acquisition command can be a command based on the adaptive protocol control field (APCF). The APCF command can be used to instruct the Bluetooth chip to roll over the old matching broadcast packet to the new matching broadcast packet when the scanned broadcast packet matches the filter.
[0199] The broadcast packet acquisition command can also be used for the Bluetooth chip to return multiple cached broadcast packets that match the filter to the application processor of the electronic device. That is, after the Bluetooth chip receives the rolling update command, when the Bluetooth chip scans the broadcast packet and the scanned broadcast packet matches the filter, the Bluetooth chip will cache the scanned broadcast packet. After that, the Bluetooth chip can continue to scan, and when the broadcast packet is rescanned, the Bluetooth chip will determine whether the rescanned broadcast packet matches the filter. The old matching broadcast packet is rolled to a new matching broadcast packet, and the new matching broadcast packet is cached at the same time. After the Bluetooth chip receives the broadcast packet acquisition command sent by the application processor of the electronic device, the Bluetooth chip can report the multiple cached broadcast packets that match the filter to the application processor of the electronic device.
[0200] The reply broadcast packet command can be used to instruct the Bluetooth chip to reply to the corresponding Bluetooth device with broadcast packet information when it scans for a broadcast packet that matches a filter. This information can be used to instruct the corresponding Bluetooth device on the interval and duration of broadcast packet transmissions. By setting the reply broadcast packet command, the heartbeat broadcast packet proxy function can be implemented using the Protocol Data Unit (PDU) content.
[0201] The command to discard broadcast packets after connection can be used to indicate that when the Bluetooth chip scans a broadcast packet of a Bluetooth device and the scanned broadcast packet matches a filter, the electronic device establishes a Bluetooth connection with the Bluetooth device based on the scanned broadcast packet of the Bluetooth device. When the Bluetooth chip scans a broadcast packet that matches the filter again, the Bluetooth chip can discard the broadcast packet that matches the filter. That is, when the Bluetooth chip subsequently scans a broadcast packet that matches the filter, the Bluetooth chip can discard the broadcast packet that matches the filter, so that the Bluetooth chip will not continue to report the broadcast packet that matches the filter to the application processor of the electronic device. By setting the command to discard broadcast packets after connection, the number of times the application processor is woken up can be reduced, thereby saving power consumption of the electronic device.
[0202] In some examples, the filter command can be set via the delivery mode field (ie, delivery_mode, 1 octet) in the APCF protocol.
[0203] For example, when the delivery mode field delivery_mode is 0x00, it can be expressed as an immediate reporting command, i.e., immediate. When the delivery mode field delivery_mode is 0x02, it can be expressed as a batch reporting command, i.e., batched. When the delivery mode field delivery_mode is 0x03, it can be expressed as a direct discard command, i.e., discard. When the delivery mode field delivery_mode is 0x04, it can be expressed as a rolling update command, i.e., cached & rolling update. When the delivery mode field delivery_mode is 0x05, it can be expressed as a reply broadcast packet command, i.e., PDU-Reply. When the delivery mode field delivery_mode is 0x06, it can be expressed as a discard broadcast packet command after connection, i.e., discard when connected.
[0204] In some examples, the application processor of the electronic device sets the filter command of the filter corresponding to the Bluetooth third-party application, which can be used to set the filter command of the filter corresponding to the Bluetooth third-party application for the Bluetooth protocol stack in the application processor of the electronic device (the Bluetooth protocol stack in the embodiment of the present application may also be referred to as a Bluetooth protocol module).
[0205] That is, after the electronic device constructs at least one filter corresponding to the first application, the Bluetooth protocol module of the electronic device may generate a filter command corresponding to the at least one filter. The filter command may include an immediate report command, a batch report command, a direct discard command, a rolling update command, a reply broadcast packet command, or a discard broadcast packet command after connection. The Bluetooth protocol module of the electronic device may then transmit the filter command to the Bluetooth chip of the electronic device.
[0206] For example, combined with Figure 6 As shown, after the filter manager in the Bluetooth application in the application processor of the electronic device assigns a corresponding filter identifier to the filter corresponding to the Bluetooth three-party application, the filter manager can send the filter identifier of the filter corresponding to the Bluetooth three-party application and the filter corresponding to the Bluetooth three-party application to the Bluetooth protocol stack in the application processor of the electronic device, so that the Bluetooth protocol stack can set the corresponding filter command according to the filter identifier of the filter corresponding to the Bluetooth three-party application.
[0207] S707: The Bluetooth chip of the electronic device receives the filter and filter identifier corresponding to the Bluetooth third-party application and creates a filter list.
[0208] After the application processor of the electronic device sends the filter and filter identifier corresponding to the Bluetooth three-party application to the Bluetooth chip, the Bluetooth chip of the electronic device may receive the filter and filter identifier corresponding to the Bluetooth three-party application. The Bluetooth chip of the electronic device may then create a filter list based on the received filter and filter identifier corresponding to the Bluetooth three-party application. After the Bluetooth chip of the electronic device creates the filter list, the Bluetooth chip of the electronic device may store the filter list.
[0209] The filter list may include filters and filter identifiers corresponding to Bluetooth third-party applications. Therefore, when the Bluetooth chip of an electronic device scans a broadcast packet from a Bluetooth device, the Bluetooth chip can match the scanned broadcast packet with the filters in the filter list, thereby determining the filter that matches the broadcast packet and the filter identifier corresponding to the filter.
[0210] In some examples, the Bluetooth chip of the electronic device receives the filter and filter identifier corresponding to the Bluetooth three-party application and establishes a filter list. The broadcast packet matching module in the Bluetooth chip of the electronic device receives the filter and filter identifier corresponding to the Bluetooth three-party application and establishes a filter list based on the filter and filter identifier corresponding to the Bluetooth three-party application.
[0211] For example, combined with Figure 6 As shown, the Bluetooth chip of an electronic device receives filters and filter identifiers corresponding to Bluetooth third-party applications and creates a filter list. This can be done by, for example, assigning filter identifiers to filters corresponding to the Bluetooth third-party applications by a filter manager in the Bluetooth application in the application processor of the electronic device. The filter manager can then send the filter identifiers and filters corresponding to the Bluetooth third-party applications to a broadcast packet matching module in the Bluetooth chip of the electronic device. The broadcast packet matching module in the Bluetooth chip can then construct a filter list based on the filters and filter identifiers corresponding to the Bluetooth third-party applications.
[0212] S708: The Bluetooth three-party application of the electronic device sends a scan request to the Bluetooth chip.
[0213] After the electronic device's Bluetooth chip receives the filters and filter identifiers corresponding to the Bluetooth third-party application and creates a filter list, the electronic device's application processor sends a scan request to the Bluetooth chip. The scan request can be used to instruct the electronic device's Bluetooth chip to enable the scanning function to scan for advertising packets from Bluetooth devices.
[0214] In some examples, the Bluetooth third-party application of the electronic device sends a scan request to the Bluetooth chip, and the Bluetooth third-party application of the electronic device may send a scan request to a modem in the Bluetooth chip.
[0215] For example, combined with Figure 6 As shown, the Bluetooth three-party application of the electronic device sends a scan request to the Bluetooth chip. After the broadcast packet matching module in the Bluetooth chip of the electronic device constructs a filter list based on the filter and filter identifier corresponding to the Bluetooth three-party application, the Bluetooth three-party application of the electronic device can send a scan request to the modem in the Bluetooth chip, so that the modem in the Bluetooth chip can start the scanning function to scan the broadcast packet of the Bluetooth device.
[0216] S709: The Bluetooth chip of the electronic device receives the scan request and performs scanning based on the scan request.
[0217] S710: The Bluetooth chip of the electronic device scans a first broadcast packet and determines whether the first broadcast packet matches based on a filter list.
[0218] After the Bluetooth chip of the electronic device turns on the scanning function, the Bluetooth chip of the electronic device can scan a broadcast packet (such as a first broadcast packet). That is, the first broadcast packet can be a broadcast packet of the Bluetooth device (i.e., a BLE broadcast packet). The Bluetooth device can be an electronic device such as a smart watch, a smart bracelet, or a body fat scale. The specific type of Bluetooth device is not limited in the embodiments of the present application.
[0219] It should be noted that a Bluetooth device's advertising packet (i.e., a BLE advertising packet) typically includes the following: advertising header, access address, advertising length, advertising data, advertising data scan response, and CRC checksum. The advertising header (Preamble) is the initial portion of the advertising packet, used to synchronize receiving devices and identify the beginning of the advertising packet. The access address (Access Address) is a fixed address value used to identify the advertising packet as a BLE data packet. The advertising length (Length) indicates the length of the advertising data portion. The advertising data (Advertising Data) contains device-related information, such as the device name, service UUID (which identifies the services provided by the device), device type, and transmission power level. The advertising data scan response (Scan Response Data) is the scan response data sent by a device in response to a scan request for an advertising packet. The scan response data typically contains more detailed information, such as the device's full name and additional service UUIDs. The CRC checksum verifies the integrity of the advertising packet to ensure that the data has not been corrupted during transmission.
[0220] After the Bluetooth chip of the electronic device scans the broadcast packet (i.e., the first broadcast packet), the Bluetooth chip of the electronic device can determine whether the first broadcast packet matches based on the filter list. That is, the Bluetooth chip of the electronic device can match the first broadcast packet with the filters in the filter list to determine whether there is a filter in the filter list that matches the broadcast packet. When there is a filter in the filter list that matches the broadcast packet, the Bluetooth chip of the electronic device can determine that the first broadcast packet matches. When there is no filter in the filter list that matches the broadcast packet, the Bluetooth chip of the electronic device can determine that the first broadcast packet does not match.
[0221] If the Bluetooth chip of the electronic device determines that the first broadcast packet does not match based on the filter list, the electronic device may proceed to S711 described below. If the Bluetooth chip of the electronic device determines that the first broadcast packet matches based on the filter list, the electronic device may proceed to S712 described below.
[0222] In some examples, the Bluetooth chip of the electronic device scans for a first advertising packet and determines whether the first advertising packet matches based on a filter list. This can be done by a modem in the Bluetooth chip of the electronic device. The modem can then send the first advertising packet to a advertising packet matching module in the Bluetooth chip of the electronic device, so that the advertising packet matching module in the Bluetooth chip of the electronic device can determine whether the first advertising packet matches based on the filter list.
[0223] For example, combined with Figure 6 As shown, the Bluetooth chip of the electronic device scans the first broadcast packet and determines whether the first broadcast packet matches based on the filter list. After the modem included in the Bluetooth chip of the electronic device scans the first broadcast packet, the modem can send the first broadcast packet to the broadcast packet matching module in the Bluetooth chip of the electronic device, so that the broadcast packet matching module in the Bluetooth chip of the electronic device can determine whether the first broadcast packet matches based on the filter list.
[0224] It should be noted that, if the Bluetooth chip also receives a filter command sent by the application processor of the electronic device, when the Bluetooth chip scans the first broadcast packet, the Bluetooth chip may also execute an action corresponding to the filter command on the first broadcast packet.
[0225] For example, if the Bluetooth chip also receives a filter command sent by the application processor of the electronic device that is an immediate report command, when the Bluetooth chip scans the first broadcast packet, the Bluetooth chip can determine whether the first broadcast packet matches based on the filter list. If the first broadcast packet matches, the Bluetooth chip can immediately report the first broadcast packet to the application processor of the electronic device, that is, the electronic device can immediately execute the following steps S712-S716. In other words, when the filter command is an immediate report command, the electronic device returns a second broadcast packet to the first application, which may include: the Bluetooth chip returns the second broadcast packet to the first application in response to the filter command being an immediate report command.
[0226] If the Bluetooth chip also receives a batch report command from the application processor of the electronic device, upon scanning the first broadcast packet, the Bluetooth chip may determine whether the first broadcast packet matches based on the filter list. When the first broadcast packet matches, the Bluetooth chip does not immediately report the first broadcast packet to the application processor of the electronic device. Instead, when the number of broadcast packets that have been scanned to match reaches a preset number, the Bluetooth chip reports the preset number of broadcast packets that have been scanned to the application processor of the electronic device. That is, when the number of broadcast packets that have been scanned to match reaches a preset number, the Bluetooth chip may report the preset number of broadcast packets (the preset number of broadcast packets including the first broadcast packet) to the application processor of the electronic device, and the electronic device may execute steps S712-S716 below. That is, when the filter command is a batch report command, the electronic device returns the second broadcast packet to the first application, which may include: in response to the filter command being a batch report command, the Bluetooth chip returns the second broadcast packet to the first application if the number of second broadcast packets exceeds a preset threshold.
[0227] If the Bluetooth chip also receives a filter command sent by the application processor of the electronic device that is a direct discard command, when the Bluetooth chip scans the first broadcast packet, the Bluetooth chip can determine whether the first broadcast packet is a preset broadcast packet (such as a broadcast packet of a preset Bluetooth device). When the first broadcast packet is a preset broadcast packet, the Bluetooth chip can discard the first broadcast packet. When the first broadcast packet is not a preset broadcast packet, the Bluetooth chip can determine whether the first broadcast packet matches based on the filter list. That is, when the first broadcast packet matches, the Bluetooth chip can report the first broadcast packet to the application processor of the electronic device, that is, the electronic device can execute the following steps S712-S716. That is, when the filter command is a direct discard command, before the electronic device determines the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the Bluetooth chip of the electronic device responds to the filter command as a direct discard command, and discards the first broadcast packet if the first broadcast packet is a broadcast packet in the blacklist.
[0228] If the Bluetooth chip also receives a rolling update command from the application processor of the electronic device as a filter command, when the Bluetooth chip scans the first broadcast packet, the Bluetooth chip can determine whether the first broadcast packet matches based on the filter list. When the first broadcast packet matches, the Bluetooth chip does not immediately report the first broadcast packet to the application processor of the electronic device, but continues to scan. When a broadcast packet is re-scanned, the Bluetooth chip determines whether the re-scanned broadcast packet matches the filter. When the re-scanned broadcast packet matches the filter, the Bluetooth chip can overwrite the old matching broadcast packet with the new matching broadcast packet, that is, the Bluetooth chip can replace the previous matching broadcast packet with the re-scanned broadcast packet. Afterwards, the Bluetooth chip can continue to scan until the Bluetooth chip receives a broadcast packet acquisition command sent by the application processor of the electronic device, so that the Bluetooth chip can report the last replaced matching broadcast packet (that is, the latest matching broadcast packet) to the application processor of the electronic device, or the Bluetooth chip can report multiple cached broadcast packets that match the filter cached in the Bluetooth chip to the application processor of the electronic device. That is, when the filter command is a rolling update command, before the electronic device determines the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the Bluetooth chip of the electronic device, in response to the filter command being a rolling update command, scans a third broadcast packet from the Bluetooth device, and if a second filter matching the third broadcast packet exists among the filters in the electronic device, the Bluetooth chip of the electronic device may update the first broadcast packet based on the third broadcast packet. The third broadcast packet is a broadcast packet following the first broadcast packet. Subsequently, the Bluetooth protocol module of the electronic device may generate a broadcast packet acquisition command and transmit the broadcast packet acquisition command to the Bluetooth chip. In response to the broadcast packet acquisition command, the Bluetooth chip of the electronic device may determine a fourth broadcast packet based on the third broadcast packet and the filter identifier of the second filter. The fourth broadcast packet may carry the filter identifier of the second filter. Subsequently, the electronic device (i.e., the application processor of the electronic device) may determine the first application corresponding to the filter identifier of the second filter based on the fourth broadcast packet. Subsequently, the electronic device may return the fourth broadcast packet to the first application, enabling the first application to communicate with the Bluetooth device based on the fourth broadcast packet.
[0229] That is, when the Bluetooth chip receives the broadcast packet acquisition command sent by the application processor of the electronic device, the Bluetooth chip can report the cached matching broadcast packet to the application processor of the electronic device, that is, the electronic device can execute the following steps S712-S716.
[0230] If the Bluetooth chip also receives a filter command sent by the application processor of the electronic device as a reply broadcast packet command, when the Bluetooth chip scans the first broadcast packet and the first broadcast packet matches the filter, the Bluetooth chip can reply the broadcast packet specified information to the Bluetooth device corresponding to the first broadcast packet. The broadcast packet specified information can be used to indicate the interval duration of the broadcast packet sent by the Bluetooth device corresponding to the broadcast packet, the duration of sending the broadcast packet, etc. At the same time, the Bluetooth chip can also report the first broadcast packet to the application processor of the electronic device, that is, the electronic device can execute the following steps S712-S716. That is to say, when the filter command is a reply broadcast packet command, the Bluetooth chip of the electronic device responds to the filter command as a reply broadcast packet command, and the electronic device (that is, the Bluetooth chip of the electronic device) can return broadcast information to the Bluetooth device, so that the Bluetooth device broadcasts based on the broadcast information.
[0231] If the Bluetooth chip also receives a command to discard broadcast packets after connection from the application processor of the electronic device, the Bluetooth chip scans the first broadcast packet and the first broadcast packet matches the filter. The Bluetooth chip can report the first broadcast packet to the application processor of the electronic device, that is, the electronic device can execute the following steps S712-S716. Thus, the electronic device can establish a Bluetooth connection with the Bluetooth device corresponding to the first broadcast packet based on the first broadcast packet. Afterwards, when the Bluetooth chip scans again for a broadcast packet that matches the filter that matches the first broadcast packet, the Bluetooth chip can discard the broadcast packet that matches the filter that matches the first broadcast packet. That is, when the filter command is a command to discard broadcast packets after connection, after the electronic device (that is, the first application of the electronic device) establishes a connection with the Bluetooth device, the Bluetooth chip of the electronic device scans the fifth broadcast packet of the Bluetooth device, and there is a third filter in the filter in the electronic device that matches the fifth broadcast packet. In response to the filter command being a command to discard broadcast packets after connection, the Bluetooth chip of the electronic device can discard the fifth broadcast packet.
[0232] S711. The Bluetooth chip of the electronic device continues scanning.
[0233] It should be noted that after the Bluetooth chip of the electronic device continues to scan and detects a broadcast packet, the Bluetooth chip of the electronic device may continue to determine whether the scanned broadcast packet matches based on the filter list. That is, after the Bluetooth chip of the electronic device continues to scan and detects a broadcast packet, the electronic device may continue to execute the above S710.
[0234] S712: The Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet according to the filter list.
[0235] When the Bluetooth chip of the electronic device determines that the first broadcast packet matches based on the filter list, that is, when the Bluetooth chip of the electronic device determines that there is a filter (that is, the first filter) in the filter list that matches the first broadcast packet, the Bluetooth chip of the electronic device can determine the filter identifier corresponding to the first broadcast packet (that is, the filter identifier of the first filter) based on the filter list.
[0236] In some examples, the Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet based on the filter list, and the broadcast packet matching module in the Bluetooth chip of the electronic device can determine the filter identifier corresponding to the first broadcast packet based on the filter list.
[0237] For example, combined with Figure 6 As shown, the Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet based on the filter list. It can be that the broadcast packet matching module included in the Bluetooth chip of the electronic device determines that the first broadcast packet matches based on the filter list, that is, when the broadcast packet matching module determines that there is a filter in the filter list that matches the first broadcast packet, the broadcast packet matching module can determine the filter identifier corresponding to the first broadcast packet (that is, the filter identifier of the filter that matches the first broadcast packet) based on the filter list.
[0238] S713: The Bluetooth chip of the electronic device determines a second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet, where the second broadcast packet includes the filter identifier corresponding to the first broadcast packet.
[0239] After the Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet based on the filter list, the Bluetooth chip of the electronic device can determine a second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet. The second broadcast packet may include the filter identifier corresponding to the first broadcast packet.
[0240] That is, when an electronic device (i.e., a Bluetooth chip in the electronic device) scans a first broadcast packet of a Bluetooth device and a first filter in the electronic device matches the first broadcast packet, a second broadcast packet is determined based on the first broadcast packet and the filter identifier of the first filter. The second broadcast packet may carry the filter identifier of the first filter.
[0241] In some examples, when there are multiple first filters, the electronic device (ie, the Bluetooth chip of the electronic device) may determine the second broadcast packet based on the filter identifier of the most recently constructed first filter among the multiple first filters and the first broadcast packet.
[0242] In some examples, the Bluetooth chip of the electronic device determines the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet. The Bluetooth chip of the electronic device can carry the filter identifier corresponding to the first broadcast packet in the first broadcast packet to obtain the second broadcast packet.
[0243] In some examples, the Bluetooth chip of the electronic device determines a second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet, and the second broadcast packet includes the filter identifier corresponding to the first broadcast packet. The Bluetooth chip of the electronic device can set the reserved field in the first broadcast packet to the filter identifier corresponding to the first broadcast packet, thereby obtaining the second broadcast packet.
[0244] For example, the code corresponding to the first broadcast packet is as follows:
[0245]
[0246]
[0247] As shown in the code corresponding to the above-mentioned first broadcast packet, the code corresponding to the first broadcast packet includes a reserved field, namely, Reserved: 0x000. The Bluetooth chip of the electronic device can set the reserved field in the first broadcast packet (i.e., the value 0x000 corresponding to Reserved) to the filter identifier corresponding to the first broadcast packet, thereby obtaining the second broadcast packet.
[0248] It should be noted that when the Bluetooth chip of the electronic device determines the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet, the Bluetooth chip of the electronic device can set the reserved field in the first broadcast packet (i.e., the value 0x000 corresponding to Reserved) to the filter identifier corresponding to the first broadcast packet, thereby obtaining the second broadcast packet.
[0249] The Bluetooth chip of the electronic device can also set other fields in the first broadcast packet (such as the value 0xff corresponding to Advertising SID, or the value 127dBm corresponding to TX Power) to the filter identifier corresponding to the first broadcast packet, thereby obtaining a second broadcast packet. This is not limited in the embodiments of the present application. In the embodiments of the present application, the Bluetooth chip of the electronic device can set the reserved field (i.e., the value 0x000 corresponding to Reserved) in the first broadcast packet to the filter identifier corresponding to the first broadcast packet, thereby obtaining a second broadcast packet.
[0250] In some examples, the Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet based on the filter list, and the broadcast packet matching module in the Bluetooth chip of the electronic device can determine the filter identifier corresponding to the first broadcast packet based on the filter list.
[0251] For example, combined with Figure 6 As shown, the Bluetooth chip of the electronic device determines the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet. After the broadcast packet matching module included in the Bluetooth chip of the electronic device determines the filter identifier corresponding to the first broadcast packet (i.e., the filter identifier of the filter matching the first broadcast packet) according to the filter list, the broadcast packet matching module can determine the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet. The second broadcast packet can include the filter identifier corresponding to the first broadcast packet.
[0252] S714: The Bluetooth chip of the electronic device returns a second broadcast packet to the application processor.
[0253] After the Bluetooth chip of the electronic device determines the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet, the Bluetooth chip of the electronic device returns the second broadcast packet to the application processor.
[0254] In some examples, the Bluetooth chip of the electronic device returns the second broadcast packet to the application processor, and the broadcast packet matching module in the Bluetooth chip of the electronic device can return the second broadcast packet to the Bluetooth protocol stack in the Bluetooth application in the application processor of the electronic device.
[0255] For example, combined with Figure 6 As shown, the Bluetooth chip of the electronic device returns the second broadcast packet to the application processor. This can be done by: the broadcast packet matching module included in the Bluetooth chip of the electronic device determines the second broadcast packet based on the filter identifier corresponding to the first broadcast packet and the first broadcast packet. After the second broadcast packet may include the filter identifier corresponding to the first broadcast packet, the broadcast packet matching module may return the second broadcast packet to the Bluetooth protocol stack in the Bluetooth application in the application processor of the electronic device.
[0256] S715: The application processor of the electronic device determines the application identifier corresponding to the Bluetooth three-party application based on the second broadcast packet and the first corresponding relationship.
[0257] After the Bluetooth chip of the electronic device returns the second broadcast packet to the application processor, the application processor of the electronic device can determine the application identifier corresponding to the Bluetooth three-party application based on the second broadcast packet and the first correspondence. The application processor of the electronic device can then return the second broadcast packet to the determined Bluetooth three-party application.
[0258] That is, the electronic device may determine the first application corresponding to the filter identifier of the first filter based on the second broadcast packet.
[0259] In some examples, the application processor of the electronic device determines the application identifier corresponding to the Bluetooth three-party application based on the second broadcast packet and the first correspondence, and the application manager in the Bluetooth application of the electronic device determines the application identifier corresponding to the Bluetooth three-party application based on the second broadcast packet and the first correspondence.
[0260] For example, combined with Figure 6 As shown, the application processor of the electronic device determines the application identifier corresponding to the Bluetooth three-party application based on the second broadcast packet and the first corresponding relationship. This can be done by, after the broadcast packet matching module included in the Bluetooth chip of the electronic device returns the second broadcast packet to the Bluetooth protocol stack in the Bluetooth application in the application processor of the electronic device, the Bluetooth protocol stack in the Bluetooth application in the application processor of the electronic device can piece together the second broadcast packet and send the pieced-together second broadcast packet to the application manager in the Bluetooth application of the electronic device. Afterwards, the application manager in the Bluetooth application of the electronic device can perform filter ID matching, that is, the application manager in the Bluetooth application of the electronic device can determine the application identifier corresponding to the Bluetooth three-party application based on the filter identifier corresponding to the first broadcast packet included in the second broadcast packet and the first corresponding relationship (that is, the application identifier corresponding to the Bluetooth three-party application corresponding to the filter identifier corresponding to the first broadcast packet).
[0261] S716: The application processor of the electronic device returns a second broadcast packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application.
[0262] After the application processor of the electronic device determines the application identifier corresponding to the Bluetooth three-party application based on the second advertising packet and the first correspondence, the application processor of the electronic device may return the second advertising packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application. In other words, the application processor of the electronic device may return the second advertising packet to the Bluetooth three-party application corresponding to the application identifier.
[0263] In some examples, the application processor of the electronic device returns a second broadcast packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application, and the application manager in the Bluetooth application of the electronic device returns the second broadcast packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application.
[0264] For example, combined with Figure 6As shown, the application processor of the electronic device returns a second broadcast packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application. It can be that the application manager in the Bluetooth application of the electronic device determines the application identifier corresponding to the Bluetooth three-party application (that is, the application identifier corresponding to the Bluetooth three-party application corresponding to the filter identifier corresponding to the first broadcast packet) based on the filter identifier corresponding to the first broadcast packet included in the second broadcast packet and the first correspondence. Then, the application manager in the Bluetooth application of the electronic device returns the second broadcast packet to the Bluetooth three-party application based on the application identifier corresponding to the Bluetooth three-party application.
[0265] S717: The Bluetooth three-party application of the electronic device receives the second broadcast packet, and establishes a Bluetooth connection with the Bluetooth device corresponding to the second broadcast packet based on the second broadcast packet.
[0266] After the Bluetooth three-party application of the electronic device receives the second broadcast packet, the Bluetooth three-party application of the electronic device may establish a Bluetooth connection with the Bluetooth device corresponding to the second broadcast packet based on the second broadcast packet.
[0267] That is, after the electronic device determines the first application, the electronic device may return a second broadcast packet to the first application, so that the first application communicates with the Bluetooth device based on the second broadcast packet.
[0268] It should be noted that after the Bluetooth three-party application of the electronic device receives the second broadcast packet, the Bluetooth three-party application of the electronic device can also establish a pairing with the Bluetooth device corresponding to the second broadcast packet based on the second broadcast packet. The Bluetooth device corresponding to the second broadcast packet is the Bluetooth device corresponding to the first broadcast packet.
[0269] After the Bluetooth three-party application of the electronic device receives the second broadcast packet, the Bluetooth three-party application of the electronic device may also display a prompt message based on the second broadcast packet. The prompt message may be used to prompt the user of a Bluetooth device that can establish a Bluetooth connection with the electronic device.
[0270] In the solution of the present application, after the Bluetooth chip of the electronic device successfully matches the scanned first broadcast packet, it carries the filter identifier of the filter corresponding to the first broadcast packet in the broadcast packet (i.e., the second broadcast packet), so that the application manager of the electronic device does not need to match the first broadcast packet with the filter corresponding to the Bluetooth three-party application again. That is, when the electronic device of the solution of the present application scans the first broadcast packet, the Bluetooth chip of the electronic device matches the scanned broadcast packet once, which can avoid the waste of resources of the electronic device when the electronic device establishes a Bluetooth connection with other electronic devices based on the scanned BLE broadcast packet.
[0271] Furthermore, since the Bluetooth chip of the electronic device carries the filter identifier of the filter corresponding to the first broadcast packet in the broadcast packet (i.e., the second broadcast packet), the application manager of the electronic device can determine the Bluetooth three-party application corresponding to the first broadcast packet based on the filter identifier and the correspondence between the filter identifier of the filter and the application identifier of the Bluetooth three-party application. Thus, the application manager of the electronic device can accurately call back the first broadcast packet to its corresponding Bluetooth three-party application, thereby preventing the application manager of the electronic device from calling back the broadcast packet to other Bluetooth three-party applications, thereby further avoiding waste of resources of the electronic device.
[0272] It should be understood that the division of units or modules (hereinafter referred to as units) in the above devices is merely a division of logical functions. In actual implementation, they may be fully or partially integrated into a single physical entity, or physically separated. Furthermore, the units in the device may be implemented entirely in the form of software called through processing elements; entirely in the form of hardware; or partially in the form of software called through processing elements, and partially in the form of hardware.
[0273] For example, each unit can be a separately established processing element, or it can be integrated into a certain chip of the device for implementation. In addition, it can also be stored in a memory in the form of a program, and called by a certain processing element of the device to execute the function of the unit. In addition, all or part of these units can be integrated together, or they can be implemented independently. The processing element described here can also be called a processor, which can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above units can be implemented by the integrated logic circuit of the hardware in the processor element or in the form of software called by the processing element.
[0274] In one example, the units in the above apparatus may be one or more integrated circuits configured to implement the above method, such as one or more ASICs, or one or more DSPs, or one or more FPGAs, or a combination of at least two of these integrated circuit forms.
[0275] For another example, when the units in the device can be implemented in the form of a processing element scheduling program, the processing element can be a general-purpose processor, such as a CPU or other processor that can call programs. For another example, these units can be integrated together and implemented in the form of a system on a chip (SOC).
[0276] In one implementation, the units implementing the corresponding steps of the above methods in the apparatus described above may be implemented in the form of a processing element scheduling program. For example, the apparatus may include a processing element and a storage element, with the processing element invoking a program stored in the storage element to execute the method described in the above method embodiments. The storage element may be a storage element on the same chip as the processing element, i.e., an on-chip storage element.
[0277] In another implementation, the program for executing the above method may be stored in a memory element on a different chip from the processing element, i.e., an off-chip memory element. In this case, the processing element calls the program from the off-chip memory element or displays it on the on-chip memory element to call and execute the method described in the above method embodiment.
[0278] For example, embodiments of the present application may also provide an apparatus, such as an electronic device, which may include a processor and a memory for storing instructions executable by the processor. When the processor is configured to execute the instructions, the electronic device implements the Bluetooth communication method described in the aforementioned embodiments. The memory may be located within or outside the electronic device. The processor may include one or more.
[0279] In another implementation, the unit of the apparatus implementing each step of the above method may be configured as one or more processing elements, which may be provided on the corresponding electronic device. The processing elements may be integrated circuits, such as one or more ASICs, one or more DSPs, one or more FPGAs, or a combination of these integrated circuits. These integrated circuits may be integrated together to form a chip.
[0280] For example, embodiments of the present application further provide a chip that can be used in the aforementioned electronic device. The chip includes one or more interface circuits and one or more processors; the interface circuits and processors are interconnected via circuits; the processors receive and execute computer instructions from the electronic device's memory via the interface circuits to implement the methods described in the aforementioned method embodiments.
[0281] An embodiment of the present application also provides a computer program product, including computer instructions executed by the above-mentioned electronic device.
[0282] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0283] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0284] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0285] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0286] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, such as a program. The software product is stored in a program product, such as a computer-readable storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks or optical disks.
[0287] For example, embodiments of the present application may further provide a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by an electronic device, the electronic device implements the Bluetooth communication method described in the aforementioned method embodiment.
[0288] The above is only a specific embodiment of the present application, but the scope of protection of this application is not limited to this. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A Bluetooth communication method, characterized in that: Applied to an electronic device, the electronic device includes a first application, and the method includes: receiving a user's opening operation of the first application; In response to the start operation, start the scanning function; When a first broadcast packet of a Bluetooth device is scanned and a first filter matching the first broadcast packet exists among filters in the electronic device, determining a second broadcast packet based on the first broadcast packet and a filter identifier of the first filter; the second broadcast packet carries the filter identifier of the first filter; determining, based on the second broadcast packet, the first application corresponding to the filter identifier of the first filter; The second advertising packet is returned to the first application, so that the first application communicates with the Bluetooth device based on the second advertising packet.
2. The method according to claim 1, characterized in that The determining, based on the second broadcast packet, the first application corresponding to the filter identifier of the first filter includes: Determining, based on the second broadcast packet and the first correspondence, a first application identifier corresponding to the filter identifier of the first filter; the first correspondence includes a correspondence between the application identifiers of multiple applications and the filter identifiers of the filters corresponding to the respective applications; Based on the first application identifier, the first application is determined.
3. The method according to claim 2, characterized in that Before starting the scanning function, the method further includes: Allocating the first application program identifier to the first application program; constructing at least one filter corresponding to the first application based on the first application identifier; assigning a corresponding filter identifier to each of the at least one filters; The first corresponding relationship is determined based on the first application identifier and the at least one filter identifier.
4. The method according to claim 3, characterized in that After constructing at least one filter corresponding to the first application, the method further includes: The Bluetooth protocol module of the electronic device generates a filter command corresponding to the at least one filter; the filter command includes an immediate report command, a batch report command, a direct discard command, a rolling update command, a reply broadcast packet command, or a discard broadcast packet command after connection; The Bluetooth protocol module of the electronic device transmits the filter command to the Bluetooth chip of the electronic device.
5. The method according to claim 4, characterized in that The returning the second broadcast packet to the first application comprises: In response to the filter command being the immediate reporting command, the Bluetooth chip returns the second broadcast packet to the first application.
6. The method according to claim 4, characterized in that The returning the second broadcast packet to the first application comprises: In response to the filter command being the batch reporting command, the Bluetooth chip returns the second broadcast packet to the first application when the number of the second broadcast packets is greater than a preset threshold.
7. The method according to claim 4, characterized in that Before determining the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the method further includes: In response to the filter command being the direct discard command, the Bluetooth chip discards the first broadcast packet if the first broadcast packet is a broadcast packet in the blacklist.
8. The method according to claim 4, characterized in that Before determining the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter, the method further includes: In response to the filter command being the rolling update command, the Bluetooth chip updates the first broadcast packet based on the third broadcast packet when scanning a third broadcast packet of the Bluetooth device and a second filter matching the third broadcast packet exists in the filter of the electronic device; the third broadcast packet is a broadcast packet subsequent to the first broadcast packet; The Bluetooth protocol module of the electronic device generates a broadcast packet acquisition command and transmits the broadcast packet acquisition command to the Bluetooth chip; In response to the broadcast packet acquisition command, the Bluetooth chip determines a fourth broadcast packet based on the third broadcast packet and the filter identifier of the second filter; the fourth broadcast packet carries the filter identifier of the second filter; determining, based on the fourth broadcast packet, the first application corresponding to the filter identifier of the second filter; The fourth advertising packet is returned to the first application, so that the first application communicates with the Bluetooth device based on the fourth advertising packet.
9. The method according to claim 4, characterized in that The method further comprises: In response to the filter command being the reply broadcast packet command, the Bluetooth chip returns broadcast information to the Bluetooth device, so that the Bluetooth device broadcasts based on the broadcast information.
10. The method according to claim 4, characterized in that After the first application establishes a connection with the Bluetooth device, the method further includes: When the fifth broadcast packet of the Bluetooth device is scanned and there is a third filter matching the fifth broadcast packet in the filter of the electronic device, the Bluetooth chip discards the fifth broadcast packet in response to the filter command being the discard broadcast packet after connection command.
11. The method according to any one of claims 1 to 10, characterized in that The determining the second broadcast packet based on the first broadcast packet and the filter identifier of the first filter includes: In the case that there are multiple first filters, the second broadcast packet is determined based on the filter identifier of the most recently constructed first filter among the multiple first filters and the first broadcast packet.
12. A wearable electronic device, characterized in that: The wearable electronic device includes a processor and a memory for storing instructions executable by the processor; when the processor is configured to execute the instructions, the wearable electronic device implements the method according to any one of claims 1 to 11.
13. A computer-readable storage medium having computer program instructions stored thereon; characterized in that: When the computer program instructions are executed by the wearable electronic device, the wearable electronic device is enabled to implement the method according to any one of claims 1 to 11.