Bluetooth connection method and device, electronic equipment and storage medium

By instantly establishing Bluetooth connections within the scanning time slot of Bluetooth devices, the problem of low Bluetooth connection efficiency in the prior art is solved, the efficiency of Bluetooth scanning and connection is improved and resources are saved.

CN119893739APending Publication Date: 2025-04-25BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311376610.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-23
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

Existing Bluetooth devices need to scan before connecting to determine the connectable peripheral devices, resulting in inefficient connections.

Method used

Scan the Bluetooth broadcast information in a predetermined scanning slot, and instantly establish a Bluetooth connection with the detected target device within the same time slot to avoid waiting for the next scanning slot.

Benefits of technology

Improves the efficiency of Bluetooth scanning and connection, reduces resource waste, and enables Bluetooth connection during scanning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119893739A_ABST
    Figure CN119893739A_ABST
Patent Text Reader

Abstract

The invention relates to a Bluetooth connection method and device, electronic equipment and a storage medium. The method comprises the following steps: scanning Bluetooth broadcast information in a predetermined scanning time slot; and based on the Bluetooth broadcast information, in response to a to-be-connected target device detected in the scanning time slot, establishing a Bluetooth connection with the target device in the scanning time slot. Through the method, the efficiency of Bluetooth scanning and connection is improved, and resources of the electronic equipment are further saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of Bluetooth communication, and in particular to a Bluetooth connection method and device, an electronic device, and a storage medium. Background Art

[0002] As people's lives become more modernized, the demand for communication technology is also increasing. Bluetooth data transmission technology, which is characterized by low cost and short distance, has gradually gained market favor and has been widely used in the field of wireless communications. In related technologies, Bluetooth devices need to scan before connecting, so as to determine the connectable peer device by listening to the broadcast information of peripheral devices, and then connect to the peer device. This has the problem of low connection efficiency of Bluetooth devices. Summary of the invention

[0003] The present invention provides a Bluetooth connection method and device, an electronic device, and a storage medium.

[0004] According to a first aspect of an embodiment of the present disclosure, a Bluetooth connection method is provided, including:

[0005] Scanning for Bluetooth broadcast information within a predetermined scanning time slot;

[0006] Based on the Bluetooth broadcast information, in response to detecting a target device to be connected within the scanning time slot, establishing a Bluetooth connection with the target device within the scanning time slot.

[0007] In some embodiments, the scanning time slot includes a scanning time window, and the establishing a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information includes:

[0008] In response to detecting the target device within the scanning time slot, detecting the communication channel of the target device within the scanning time window of scanning the Bluetooth broadcast information; wherein the duration of the scanning time window is less than the duration of the scanning time slot;

[0009] A Bluetooth connection is established with the target device within the scanning time slot based on the communication channel of the target device.

[0010] In some embodiments, establishing a Bluetooth connection with the target device within the scanning time slot based on the communication channel of the target device includes:

[0011] A Bluetooth connection is established with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device.

[0012] In some embodiments, establishing a Bluetooth connection with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device includes:

[0013] In a time window outside the scanning time window, sending a connection request to the target device based on the communication channel of the target device;

[0014] A Bluetooth connection is established with the target device based on the connection request.

[0015] In some embodiments, the ratio between the duration of the scanning time window and the duration of the scanning time slot is greater than a preset ratio threshold.

[0016] In some embodiments, the Bluetooth broadcast information carries connection status information, and the method further includes:

[0017] In response to the connection state information in the Bluetooth broadcast information being characterized as being to be connected, outputting a device identifier of a broadcasting device of the Bluetooth broadcast information;

[0018] In response to detecting a selection instruction for any device identification, the broadcasting device indicated by the selection instruction is determined as the target device.

[0019] In some embodiments, scanning Bluetooth broadcast information within a predetermined scanning time slot includes:

[0020] The Bluetooth broadcast information is scanned based on a preset scanning method within the scanning time slot; wherein the preset scanning method includes: active scanning or passive scanning.

[0021] According to a second aspect of an embodiment of the present disclosure, there is provided a Bluetooth connection device, comprising:

[0022] A scanning module, used for scanning Bluetooth broadcast information within a predetermined scanning time slot;

[0023] A connection module is configured to establish a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information.

[0024] In some embodiments, the connection module is also used to detect the communication channel of the target device within the scanning time window for scanning the Bluetooth broadcast information in response to detecting the target device within the scanning time slot; wherein the duration of the scanning time window is less than the duration of the scanning time slot; and based on the communication channel of the target device, establish a Bluetooth connection with the target device within the scanning time slot.

[0025] In some embodiments, the connection module is further configured to establish a Bluetooth connection with the target device within a time window outside the scanning time window within the scanning time slot based on a communication channel of the target device.

[0026] In some embodiments, the connection module is further used to send a connection request to the target device based on the communication channel of the target device in a time window outside the scanning time window; and establish a Bluetooth connection with the target device based on the connection request.

[0027] In some embodiments, the connection module is further configured to set the ratio between the duration of the scanning time window and the duration of the scanning time slot to be greater than a preset ratio threshold.

[0028] In some embodiments, the Bluetooth broadcast information carries connection status information, and the Bluetooth connection device also includes: a determination module, which is used to output the device identification of the broadcasting device of the Bluetooth broadcast information in response to the connection status information in the Bluetooth broadcast information being characterized as to be connected; in response to detecting a selection instruction for any device identification, determine the broadcasting device indicated by the selection instruction as the target device.

[0029] In some embodiments, the scanning module is further used to scan the Bluetooth broadcast information based on a preset scanning method within the scanning time slot; wherein the preset scanning method includes: active scanning or passive scanning.

[0030] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0031] A processor; a memory for storing processor executable instructions; wherein the processor is configured to execute the Bluetooth connection method as described in the first aspect above.

[0032] According to a fourth aspect of an embodiment of the present disclosure, there is provided a storage medium, including:

[0033] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the Bluetooth connection method as described in the first aspect above.

[0034] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0035] In the embodiment of the present disclosure, the electronic device executes a Bluetooth scanning event and a Bluetooth connection event within the same scanning time slot, so that when a target device to be connected is detected within the scanning time slot, the Bluetooth connection can be immediately established, thereby realizing the Bluetooth connection during the scanning process; in addition, there is no need to scan the Bluetooth broadcast information after the scanning time slot of the Bluetooth connection, and thus the efficiency of the Bluetooth scanning and connection is improved through the method of the embodiment of the present disclosure, thereby saving the resources of the electronic device.

[0036] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0038] Figure 1 It is a schematic diagram of Bluetooth scanning and connection in the related art.

[0039] Figure 2 This is an example diagram of a Bluetooth connection method flow chart shown in an embodiment of the present disclosure.

[0040] Figure 3 It is a schematic diagram of the relationship between a scanning time slot and a scanning time window shown in an embodiment of the present disclosure.

[0041] Figure 4 It is a schematic diagram of a scanning time slot for Bluetooth scanning and connection shown in an embodiment of the present disclosure.

[0042] Figure 5 It is a schematic diagram of a process of connecting an electronic device with a target device shown in an embodiment of the present disclosure.

[0043] Figure 6 It is a schematic diagram of a process of performing passive scanning by an electronic device shown in an embodiment of the present disclosure.

[0044] Figure 7 It is a schematic diagram of a process of performing active scanning by an electronic device shown in an embodiment of the present disclosure.

[0045] Figure 8 It is a flow chart of a Bluetooth connection method shown in an embodiment of the present disclosure.

[0046] Fig. 9 is a diagram of a Bluetooth connection device shown in an embodiment of the present disclosure.

[0047] Fig.10 It is a block diagram of an electronic device 800 shown in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0048] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0049] Figure 1 It is a schematic diagram of Bluetooth scanning and connection in related technologies, such as Figure 1 As shown, the scanning time slots of the Bluetooth scanning event and the Bluetooth connection event are set alternately. In the scanning time slot of the Bluetooth scanning event, the electronic device only scans and reports the information of surrounding devices. Even if it scans the opposite device that needs to be connected, it will not perform the Bluetooth connection task in the current scanning time slot, and it needs to wait for the next scanning time slot (the scanning time slot of Bluetooth connection) to arrive; and in the scanning time slot of the Bluetooth connection event, the electronic device only scans and connects the target device. Even if it scans other devices besides the target device, it will not report the device information in the current scanning time slot, and it needs to wait for the next scanning time slot (the scanning time slot of Bluetooth scanning).

[0050] In the related art, scanning time slots for scanning and connecting Bluetooth events are set alternately, resulting in scanning events and connection events being performed completely independently, which can easily cause connection delays and / or untimely reporting of scanning results, thereby causing low efficiency of Bluetooth scanning and connection, and causing great waste of electronic equipment resources.

[0051] In this regard, the present disclosure provides a Bluetooth connection method. Figure 2 is a flow chart of a Bluetooth connection method shown in an embodiment of the present disclosure, comprising Figure 2 It can be seen that the following steps are included:

[0052] S11, scanning Bluetooth broadcast information within a predetermined scanning time slot;

[0053] S12: Based on the Bluetooth broadcast information, in response to detecting a target device to be connected within the scanning time slot, establishing a Bluetooth connection with the target device within the scanning time slot.

[0054] In the embodiments of the present disclosure, the execution subject may be an electronic device that can perform Bluetooth scanning and connection, such as user equipment (UE), mobile device, user terminal, mobile phone, tablet computer, personal digital assistant (PDA), handheld device, computing device, vehicle-mounted device, wearable device, etc. In some possible implementations, the Bluetooth connection method may be implemented by a processor in an electronic device calling a computer-readable instruction stored in a memory.

[0055] In step S11, the electronic device scans the Bluetooth broadcast information in a predetermined scanning time slot. The predetermined scanning time slot may refer to a scanning duration, and the electronic device may scan the Bluetooth broadcast information in the scanning time slot. The exemplary electronic device may divide the scanning time slot into a scanning time window and a non-scanning time window. The electronic device scans the Bluetooth broadcast information in the scanning time window and sleeps or performs other Bluetooth tasks in the non-scanning time window. The number of scanning time windows or non-scanning time windows may be set to one or more.

[0056] In the disclosed embodiments, the electronic device may support different types of Bluetooth, such as Bluetooth Low Energy (BLE), dual-mode Bluetooth, etc. The electronic device may directly use the default scanning time slot corresponding to each type of Bluetooth to perform Bluetooth scanning, or may first set the Bluetooth scanning time slot, and then use the set scanning time slot to perform Bluetooth scanning.

[0057] In the disclosed embodiment, the electronic device can set the scanning time slot, scanning time window, etc. when the electronic device scans through the scanning parameter setting command (LE Set ScanParameters). For example, the electronic device can set the scanning time slot according to different device types, setting the scanning time slot of wearable devices to be relatively short, and setting the scanning time slot of mobile phones, computers and other devices to be longer; the electronic device can also set the scanning time slot according to different applications using Bluetooth scanning, setting the Bluetooth scanning time slot of video software to be longer, and setting the Bluetooth scanning time of audio software to be shorter.

[0058] Figure 3 FIG. 1 is a schematic diagram showing the relationship between a scanning time slot and a scanning time window in an embodiment of the present disclosure. Figure 3 As shown, the scanning time slot includes a scanning time window, and the duration of the scanning time window is set to be shorter than the duration of the scanning time slot, so that the electronic device can sleep or perform other Bluetooth tasks other than Bluetooth scanning in a time window outside the scanning time window.

[0059] In addition, in the embodiments of the present disclosure, the electronic device may also set scanning parameters such as the scanning mode and scanning filtering strategy of the electronic device through scanning parameter setting instructions to control the scanning behavior of the electronic device during the scanning process.

[0060] In the disclosed embodiment, the scanning mode of the electronic device includes passive scanning and active scanning. The electronic device can directly use the default scanning mode corresponding to each type of Bluetooth to perform Bluetooth scanning; or the scanning mode can be set by scanning parameter setting instructions first, and then the set scanning mode is used to perform Bluetooth scanning. For example, the electronic device can control the specific mode of Bluetooth scanning by setting the value of the scanning mode identifier type. If "type = 0", it indicates that the electronic device uses a passive scanning mode, and if "type = 1", it indicates that the electronic device uses an active scanning mode.

[0061] In an embodiment of the present disclosure, an electronic device scans Bluetooth broadcast information sent by a broadcasting device. The Bluetooth broadcast information may include device information, connection status information, etc. of the broadcasting device. The device information may be a device name, a device type, etc.; the connection status information indicates whether the broadcasting device is a connectable device. For example, if the connection status information is "1", it indicates that the device is connectable; if the connection status information is "0", it indicates that the device is not connectable.

[0062] In the disclosed embodiment, the electronic device can report the scanned Bluetooth broadcast information to the application that calls the Bluetooth scan in the electronic device, so that the application can understand the situation of the surrounding Bluetooth devices in real time and perform corresponding processing. For example, the mobile phone can report the scanned Bluetooth devices to the Bluetooth setting program, so that the Bluetooth setting program can display the connectable and / or unconnectable Bluetooth devices in the user interface, and then the mobile phone user can connect, pair, etc. to each Bluetooth device.

[0063] In the disclosed embodiment, the electronic device can report the information of some or all of the scanned Bluetooth devices, and the electronic device can set the scan filter policy parameters through the scan parameter setting instruction, so as to filter the reported information. For example, if the electronic device sets the scan filter policy to only accept the broadcast data of the whitelisted devices, then only the broadcast data of the whitelisted devices will be reported, and the broadcast data of other devices not in the whitelist can be automatically filtered out; if the electronic device sets the scan filter policy to accept the broadcast data of all devices, then the broadcast data of all the scanned devices can be reported.

[0064] In step S12, the electronic device establishes a Bluetooth connection with the target device in the scanning time slot in response to detecting the target device to be connected in the scanning time slot based on the Bluetooth broadcast information. In the disclosed embodiment, the electronic device can establish a Bluetooth connection with the target device immediately in the scanning time window when the target device is detected; or it can establish a Bluetooth connection with the target device in the non-scanning time window in the scanning time slot after the scanning task of the scanning time window of the scanning time slot is completed. The target device is a device that needs to establish a Bluetooth connection with the electronic device, for example, it can be a device selected by the user after the electronic device displays the connectable Bluetooth devices in the user interface.

[0065] It should be noted that, if the electronic device scans other Bluetooth devices in the scanning time slot after establishing a connection with the Bluetooth device, the electronic device may also report the Bluetooth broadcast information of the other newly scanned devices.

[0066] It can be understood that in the embodiments of the present disclosure, the electronic device executes a Bluetooth scanning event and a Bluetooth connection event within the same scanning time slot, so that a target device to be connected is detected within the scanning time slot and the Bluetooth connection can be immediately established, thereby realizing the Bluetooth connection during the scanning process; in addition, there is no need to scan the Bluetooth broadcast information after the scanning time slot of the Bluetooth connection, and thus, through the method of the embodiments of the present disclosure, the efficiency of Bluetooth scanning and connection is improved, thereby saving the resources of the electronic device.

[0067] In some embodiments, the scanning time slot includes a scanning time window, and the establishing a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information includes:

[0068] In response to detecting the target device within the scanning time slot, detecting the communication channel of the target device within the scanning time window of scanning the Bluetooth broadcast information; wherein the duration of the scanning time window is less than the duration of the scanning time slot;

[0069] A Bluetooth connection is established with the target device within the scanning time slot based on the communication channel of the target device.

[0070] In the disclosed embodiment, since the duration of the scanning time window is less than the duration of the scanning time slot, it can be known that the scanning time slot of the electronic device includes the scanning time window and the non-scanning time window. In the disclosed embodiment, the electronic device scans the Bluetooth broadcast information within the scanning time window before determining the target device.

[0071] It should be noted that after the electronic device determines the target device to be connected, it is necessary to perform a connection scan before establishing a Bluetooth connection with the target device. Since the broadcast information is sent by frequency hopping broadcast on broadcast channels of different frequency bands, for example, the target device may send Bluetooth broadcasts by frequency hopping on channels 37, 38, and 39, but Bluetooth communication can only be performed in one channel. Therefore, the electronic device needs to perform a connection scan to determine the current communication channel of the target device before establishing a Bluetooth connection with the target device. In the disclosed embodiment, the electronic device detects the communication channel of the target device within the scanning time window. Since the scanning of Bluetooth broadcast information is also in the scanning time window, it can be understood that the scanning of Bluetooth broadcast information and the connection scan share the same scanning time window in the scanning time slot. In addition, since the target device needs to be determined before the communication channel to the target device is determined after the Bluetooth broadcast information is scanned, it can be seen that the detection of the target device can also occur within the scanning time window.

[0072] Figure 4 is a schematic diagram of a scanning time slot for Bluetooth scanning and connection shown in an embodiment of the present disclosure, such as Figure 4 As shown, the Bluetooth scanning and connection of the electronic device share the same scanning time slot, and the electronic device can simultaneously perform the scanning task of the scanning event (i.e., scanning of Bluetooth broadcast information) and the scanning task of the connection event (i.e., connection scanning) through the scanning time window within the scanning time slot, that is, the scanning of Bluetooth broadcast information and the connection scanning share the same time window.

[0073] In the disclosed embodiment, the electronic device can send a data packet of a connection request to the target device through the communication channel of the target device, and a Bluetooth connection can be established after the target device passes the verification. It should be noted that in the disclosed embodiment, after determining the communication channel, the timing of the Bluetooth connection can occur within the scanning time window or within the non-scanning time window, and the disclosed embodiment does not limit this.

[0074] In the disclosed embodiment, when the target device is detected, the electronic device performs a connection scan for the Bluetooth connection by scanning the scanning time window of the Bluetooth broadcast information to determine the communication channel of the Bluetooth connection, thereby connecting the electronic device to the target device based on the communication channel of the target device. Since the disclosed embodiment reuses the scanning time window to scan the Bluetooth broadcast information and the connection scan (detection of the communication channel of the target device), on the basis of the aforementioned implementation of the Bluetooth connection during the scanning process, the method of multiplexing the scanning time window makes it unnecessary to wait for the connection scan in the non-scanning time window, and thus the efficiency of the Bluetooth connection can be further improved by this method.

[0075] In the embodiment of the present disclosure, the establishing a Bluetooth connection with the target device within the scanning time slot based on the communication channel of the target device includes:

[0076] A Bluetooth connection is established with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device.

[0077] It should be noted that if the electronic device establishes a Bluetooth connection with the target device within the scanning time window, the Bluetooth connection will occupy the scanning time window (the time to execute the Bluetooth scanning task). It is easy to miss some Bluetooth broadcast information due to executing the connection task within the scanning time window, resulting in Bluetooth scanning delays and low scanning efficiency.

[0078] In the disclosed embodiment, the electronic device establishes a Bluetooth connection with the target device only within a time window outside the scanning time window within the scanning time slot (non-scanning time window), which can reduce the occurrence of the Bluetooth connection task occupying the time window of the Bluetooth scanning task, and help improve the efficiency of Bluetooth scanning.

[0079] In some embodiments, establishing a Bluetooth connection with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device includes:

[0080] In a time window outside the scanning time window, sending a connection request to the target device based on the communication channel of the target device;

[0081] A Bluetooth connection is established with the target device based on the connection request.

[0082] In the disclosed embodiment, the electronic device sends a connection request (CONNECT_REQ) to the target device through the communication channel of the target device in a time window outside the scanning time window, and waits for the target device to respond to the connection request. The connection request may include the device identification of the target device, connection parameters, etc.

[0083] In the disclosed embodiment, after receiving the connection response packet sent by the target device, the electronic device establishes a connection interaction with the target device on the communication channel of the target device, that is, the electronic device and the target device enter a connection state, so that data packets can be transmitted between the electronic device and the target device.

[0084] In the disclosed embodiment, the two devices entering the connection state will play different roles respectively. Usually, the electronic device sending the connection request will become the communication host, and the electronic device receiving the connection request will become the communication slave. The communication host can set the parameters of the connection event, and then the communication host and the communication slave will transmit data packets based on the set connection parameters. Among them, the connection parameters may include connection interval, connection delay, etc. Figure 5 is a schematic diagram of a process of connecting an electronic device to a target device according to an embodiment of the present disclosure, such as Figure 5As shown, device 2 is sending a broadcast, device 1 starts a connection with device 2, and then device 1 and device 2 perform data transmission on the communication channel where the connection is established. In step S501, host 1 of device 1 (electronic device) sends a command to create a connection to the controller of link layer 1, so that in step S502, the controller of link layer 1 controls device 1 to enter a command state to wait for the response broadcast of device 2. In step S503, after device 1 receives the response broadcast sent by device 2, in step S504, device 1 establishes a connection interaction with device 2, so that in steps S505 and S506, the connection between device 1 and device 2 is completed, and then in steps S507-S510, device 1 can send and receive multiple transmission protocol data units with device 2 on the data physical channel.

[0085] In the disclosed embodiment, the electronic device sends a connection request to establish a Bluetooth connection with the target device during a non-scanning time window, thereby reducing conflicts between Bluetooth connection and Bluetooth scanning, and helping to improve the stability of Bluetooth scanning and connection.

[0086] In some embodiments, the ratio between the duration of the scanning time window and the duration of the scanning time slot is greater than a preset ratio threshold.

[0087] In the disclosed embodiment, the ratio between the duration of the scanning time window and the duration of the scanning time slot represents the proportion of the duration of the actual execution of the Bluetooth scanning task in the scanning time slot. For example, the ratio between the duration of the scanning time window and the duration of the scanning time slot can be set to 30%.

[0088] It should be noted that if the duration of the scanning time slot of the electronic device used to perform the Bluetooth scanning task is too short, on the one hand, it is easy for the scanning time window to be insufficient, resulting in the inability to scan all Bluetooth devices around the electronic device, resulting in poor scanning stability; on the other hand, when the target device is detected, the scanning time window may be insufficient to determine the corresponding communication channel, resulting in the inability to establish a Bluetooth connection with the target device, resulting in an unstable Bluetooth connection.

[0089] In the disclosed embodiment, the electronic device sets the ratio of the scanning time window to the scanning time slot to be greater than a preset ratio threshold value, so as to reduce the occurrence of insufficient Bluetooth scanning or failure to smoothly perform Bluetooth connection scanning, thereby affecting Bluetooth connection, and improves the stability of Bluetooth scanning and connection of the electronic device. In addition, the increase in the duration ratio of the scanning time window allows the electronic device to have more scanning time, so that it can scan the surrounding Bluetooth devices or devices to be connected as early as possible, which is conducive to improving the speed of Bluetooth scanning and Bluetooth connection.

[0090] In some embodiments, the Bluetooth broadcast information carries connection status information, and the method further includes:

[0091] In response to the connection state information in the Bluetooth broadcast information being characterized as being to be connected, outputting a device identifier of a broadcasting device of the Bluetooth broadcast information;

[0092] In response to detecting a selection instruction for any device identification, the broadcasting device indicated by the selection instruction is determined as the target device.

[0093] In the disclosed embodiment, the Bluetooth broadcast information received by the electronic device carries connection status information, which is used to indicate whether the broadcasting device sending the Bluetooth broadcast is the device to be connected. In the disclosed embodiment, the connection status in the Bluetooth broadcast information indicates that the device currently sending the Bluetooth broadcast is the device to be connected, and the electronic device can output the device identification of the broadcasting device. In the case of multiple devices to be connected, the electronic device can output the device identifications of some or all of the devices to be connected in the form of a list. For example, the electronic device can display the list of devices to be connected to the user through the Bluetooth setting interface so that the user can select the target device to be connected.

[0094] In the disclosed embodiment, the electronic device detects a selection instruction of any device identification and determines the selected broadcast device as the target device. For example, if the electronic device detects that the user clicks on a device in the list of devices to be connected, the device selected by the user can be determined as the target device to be connected by Bluetooth.

[0095] In the real-time example disclosed herein, the electronic device determines whether the broadcasting device is a device to be connected through the connection status information carried in the Bluetooth broadcast information, and determines the target device by detecting the selection instruction of the device to be connected, which is simple and easy to implement.

[0096] In some embodiments, scanning Bluetooth broadcast information within a predetermined scanning time slot includes:

[0097] The Bluetooth broadcast information is scanned based on a preset scanning method within the scanning time slot; wherein the preset scanning method includes: active scanning or passive scanning.

[0098] In the disclosed embodiment, the electronic device can scan Bluetooth broadcast information by active scanning or passive scanning, wherein the Bluetooth broadcast information can be sent by one or more surrounding Bluetooth devices. When the electronic device performs passive scanning, it can obtain and report the Bluetooth broadcast information sent by the surrounding devices; when the electronic device performs active scanning, it can not only scan the Bluetooth broadcast information of the surrounding devices, but also send a scan request (SCAN_REQ) to capture the scan response information of the opposite device, and report the Bluetooth broadcast information and the scan response information.

[0099] Figure 6FIG. 1 is a flow chart of an electronic device performing passive scanning according to an embodiment of the present disclosure. Figure 6 As shown, device 2 is sending a Bluetooth broadcast, and device 1 is performing a Bluetooth scan in a passive scanning mode. In step S601, host 1 of device 1 sends a command to set the scan parameters to the controller of link layer 1, wherein the scan mode is set to passive scanning; in step S602, the controller of link layer 1 feeds back a command to complete the command to host 1, thereby completing the setting of the Bluetooth scan parameters. In step S603, host 1 of device 1 sends a start scan command to link layer 1; in step S604, the controller of link layer 1 feeds back a command to complete the command to host 1, thereby completing the start of the Bluetooth scan, and device 1 enters the passive scanning mode. In step S605, device 1 receives the broadcast data packet in link layer 2; in step S606, the controller of link layer 1 reports the broadcast report to host 1, wherein the reported information may be a broadcast data packet; in steps S607 and S608, device 1 may continuously scan the broadcast and report the broadcast report; in step S609, host 1 sends a stop scanning instruction to link layer 1, and in step S610, after the link layer 1 feedback command is completed, device 1 stops Bluetooth scanning.

[0100] Figure 7 FIG. 1 is a flow chart of an electronic device performing active scanning according to an embodiment of the present disclosure. Figure 7 As shown, device 2 is sending a Bluetooth broadcast, and device 1 is performing a Bluetooth scan in an active scanning mode. In step S701, host 1 of device 1 sends a command to set the scan parameters to the controller of link layer 1, wherein the scan mode is set to active scanning; in step S702, the controller of link layer 1 feeds back a command to complete the command to host 1, thereby completing the setting of the Bluetooth scan parameters. In step S703, host 1 of device 1 sends a start scan command to link layer 1; in step S704, the controller of link layer 1 feeds back a command to complete the command to host 1, thereby completing the start of the Bluetooth scan, and device 1 enters the active scanning mode. In step S705, device 1 receives the broadcast data packet in link layer 2; in step S706, device 1 sends a scan request (SCAN_REQ) to the other device (device 2); in step S707, device 1 receives the scan response sent by device 2; in step S709, the controller of link layer 1 reports the broadcast report to host 1, wherein the reported information may be a broadcast data packet and / or scan response data; in steps S709-S711, device 1 may repeatedly initiate a scan request to device 2 to obtain and report the broadcast report of the active scan as described above; in step S712, host 1 sends a stop scan instruction to link layer 1, and in step S713, after the link layer 1 feedback command is completed, device 1 stops Bluetooth scanning.

[0101] In the disclosed embodiment, the electronic device can scan Bluetooth broadcast information through a variety of scanning methods, so that different types of electronic devices or various applications in the electronic device can flexibly select the required scanning method, thereby improving the intelligence and usability of the electronic device.

[0102] Figure 8 is a flowchart of a Bluetooth connection method shown in an embodiment of the present disclosure, device 1 is the electronic device in the embodiment of the present disclosure, device 2 is the target device in the embodiment of the present disclosure, such as Figure 8 As shown, the Bluetooth connection method includes the following steps:

[0103] In S801, host 1 of device 1 sends a command to set scanning parameters to link layer 1;

[0104] In this embodiment, the host 1 of the device 1 sends a command for setting scanning parameters to the controller of the link layer 1. The scanning parameters include the scanning interval (i.e., the scanning time slot in the embodiment of the present disclosure), the scanning window (i.e., the scanning time window in the embodiment of the present disclosure), the scanning mode, the scanning filtering strategy, etc. The above scanning parameters will determine the behavior of the device during scanning.

[0105] S802, link layer 1 command of device 1 is completed;

[0106] In this embodiment, the controller in the link layer 1 of the device 1 completes the execution of the command for setting the scanning parameters, thereby completing the setting of the Bluetooth scanning parameters.

[0107] S803, host 1 of device 1 sends a command for setting start scanning to link layer 1;

[0108] In this embodiment, the host 1 of the device 1 sends a scan start instruction to the controller of the link layer 1, and controls whether to start the scan through the scan enable parameter (LE_Scan_Enable), for example, "LE_Scan_Enable=1" indicates starting the scan; "LE_Scan_Enable=0" indicates stopping the scan.

[0109] S804, command completed;

[0110] In this embodiment, the device 1 completes the execution of the scan start command, and the device 1 performs Bluetooth scanning to scan the surrounding Bluetooth devices.

[0111] S805, device 1 scans the target broadcast sent by device 2;

[0112] In this embodiment, device 1 scans the target broadcast sent by device 2, that is, in the embodiment of the present disclosure, the communication channel of the target device is detected within the scanning time window of scanning Bluetooth broadcast information.

[0113] S806, device 1 receives the broadcast report;

[0114] S807, host 1 of device 1 sends a create connection command to the controller of link layer 1;

[0115] S808, the controller of link layer 1 feeds back a command completion instruction to host 1;

[0116] In this embodiment, device 1 sends a connection request to device 2 by creating a connection command, thereby waiting for the connection response broadcast of device 2. If the target broadcast sent by device 2 is received again, a Bluetooth connection can be established with device 2. That is, in the embodiment of the present disclosure, the electronic device sends a connection request to the target device based on the communication channel of the target device in a time window outside the scanning time window, and establishes a Bluetooth connection with the target device based on the connection request.

[0117] S809, device 1 scans other broadcasts;

[0118] In this embodiment, device 1 scans broadcast information of other Bluetooth devices other than the target device and can report the broadcast.

[0119] S810, the link layer 1 of the device 1 reports the scanned broadcast report to the host 1;

[0120] In this embodiment, if the device 1 is in the passive scanning mode, it can report a broadcast data packet; if it is in the active scanning mode, it can report a broadcast data packet and the requested response data of the opposite device.

[0121] S811, device 1 scans the target broadcast;

[0122] In this embodiment, device 1 receives the target broadcast sent by the target device again, that is, receives the response broadcast sent by the target device.

[0123] S812, device 1 establishes a connection interaction with device 2;

[0124] S813, device 1 connection completed;

[0125] S814, device 2 connection completed;

[0126] In this embodiment, after the connection between device 1 and device 2 is completed, data transmission can be performed based on the connected communication channel.

[0127] In the disclosed embodiment, when the electronic device is performing Bluetooth scanning, if a target device is detected, it can perform a connection scan for the Bluetooth connection by scanning the scanning time window of the Bluetooth broadcast information to determine the communication channel of the Bluetooth connection, and then the electronic device and the target device are connected based on the communication channel of the target device. Since the scanning time window is multiplexed for scanning of the Bluetooth broadcast information and the connection scan, while the Bluetooth connection can be achieved during the scanning process, the multiplexing of the scanning time window eliminates the need to wait for the connection scan in the non-scanning time window. Therefore, the efficiency of the Bluetooth connection can be further improved by this method.

[0128] Fig. 9 is a diagram of a Bluetooth connection device shown in an embodiment of the present disclosure, comprising Fig. 9 It is known that, including:

[0129] The scanning module 901 is used to scan the Bluetooth broadcast information in a predetermined scanning time slot;

[0130] The connection module 902 is configured to establish a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information.

[0131] In some embodiments, the connection module 902 is also used to detect the communication channel of the target device within the scanning time window for scanning the Bluetooth broadcast information in response to detecting the target device within the scanning time slot; wherein the duration of the scanning time window is less than the duration of the scanning time slot; and based on the communication channel of the target device, establish a Bluetooth connection with the target device within the scanning time slot.

[0132] In some embodiments, the connection module 902 is further configured to establish a Bluetooth connection with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device.

[0133] In some embodiments, the connection module 902 is further used to send a connection request to the target device based on the communication channel of the target device in a time window outside the scanning time window; and establish a Bluetooth connection with the target device based on the connection request.

[0134] In some embodiments, the connection module 902 is further configured to set the ratio between the duration of the scanning time window and the duration of the scanning time slot to be greater than a preset ratio threshold.

[0135] In some embodiments, the Bluetooth broadcast information carries connection status information, and the Bluetooth connection device also includes: a determination module, which is used to output the device identification of the broadcasting device of the Bluetooth broadcast information in response to the connection status information in the Bluetooth broadcast information being characterized as to be connected; in response to detecting a selection instruction for any device identification, determine the broadcasting device indicated by the selection instruction as the target device.

[0136] In some embodiments, the scanning module 901 is further configured to scan the Bluetooth broadcast information based on a preset scanning method within the scanning time slot; wherein the preset scanning method includes: active scanning or passive scanning.

[0137] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0138] Fig.10 8 is a block diagram of an electronic device 800 shown in an embodiment of the present disclosure. For example, the electronic device 800 may be a mobile phone, a mobile computer, etc.

[0139] Reference Fig.10 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0140] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0141] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0142] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0143] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0144] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0145] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0146] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0147] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0148] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0149] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0150] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the aforementioned Bluetooth connection method.

[0151] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims above.

[0152] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A Bluetooth connection method, characterized in that: The method comprises: Scanning for Bluetooth broadcast information within a predetermined scanning time slot; Based on the Bluetooth broadcast information, in response to detecting a target device to be connected within the scanning time slot, establishing a Bluetooth connection with the target device within the scanning time slot.

2. The method according to claim 1, characterized in that: The scanning time slot includes a scanning time window, and the step of establishing a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information includes: In response to detecting the target device within the scanning time slot, detecting the communication channel of the target device within the scanning time window of scanning the Bluetooth broadcast information; wherein the duration of the scanning time window is less than the duration of the scanning time slot; A Bluetooth connection is established with the target device within the scanning time slot based on the communication channel of the target device.

3. The method according to claim 2, characterized in that The establishing a Bluetooth connection with the target device within the scanning time slot based on the communication channel of the target device includes: A Bluetooth connection is established with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device.

4. The method according to claim 3, characterized in that The establishing a Bluetooth connection with the target device within a time window outside the scanning time window within the scanning time slot based on the communication channel of the target device comprises: In a time window outside the scanning time window, sending a connection request to the target device based on the communication channel of the target device; A Bluetooth connection is established with the target device based on the connection request.

5. The method according to claim 2, characterized in that: The ratio between the duration of the scanning time window and the duration of the scanning time slot is greater than a preset ratio threshold.

6. The method according to any one of claims 1 to 5, characterized in that The Bluetooth broadcast information carries connection status information, and the method further includes: In response to the connection state information in the Bluetooth broadcast information being characterized as being to be connected, outputting a device identifier of a broadcasting device of the Bluetooth broadcast information; In response to detecting a selection instruction for any device identification, the broadcasting device indicated by the selection instruction is determined as the target device.

7. The method according to claim 1, characterized in that The step of scanning the Bluetooth broadcast information within a predetermined scanning time slot includes: The Bluetooth broadcast information is scanned based on a preset scanning method within the scanning time slot; wherein the preset scanning method includes: active scanning or passive scanning.

8. A Bluetooth connection device, characterized in that: The device comprises: A scanning module, used for scanning Bluetooth broadcast information within a predetermined scanning time slot; A connection module is configured to establish a Bluetooth connection with the target device in the scanning time slot in response to detecting a target device to be connected in the scanning time slot based on the Bluetooth broadcast information.

9. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the Bluetooth connection method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the Bluetooth connection method as claimed in any one of claims 1 to 7.