A connection method for a device

By initiating reconnection when the Bluetooth device is disconnected from the electronic device, and sending broadcast signals through a determined broadcast channel at a determined moment, the problem of long re-establishment time of the Bluetooth connection is solved and the user experience is improved.

CN118139214BActive Publication Date: 2024-09-20HONOR DEVICE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410555072.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-07
Publication Date
2024-09-20
Estimated Expiration
2044-05-07

AI Technical Summary

Technical Problem

It takes a long time to re-establish the Bluetooth connection between the Bluetooth device and the electronic device, resulting in long waiting time for the user and poor user experience.

Method used

By initiating reconnection when the Bluetooth device is disconnected from the electronic device, the Bluetooth device sends a broadcast signal through a determined broadcast channel at a determined moment, eliminating the impact of random factors on the reconnection delay, and determining the scanning time and channel of the electronic device in advance. Ensures that directed broadcast signals are sent during electronic device scanning to quickly reestablish connections.

Benefits of technology

It significantly shortens the time for re-establishing a connection between a Bluetooth device and an electronic device, improves user experience, and reduces user waiting time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118139214B
    Figure CN118139214B
Patent Text Reader

Abstract

The present application provides a connection method for a device, which is applied to the field of wireless communication technology. The method is applied to a Bluetooth device, and a Bluetooth connection (for example, a BLE connection) is established between the Bluetooth device and the electronic device. The method includes: when the Bluetooth device and the electronic device are disconnected from the Bluetooth connection, start the reconnection (for example, reestablish the BLE connection); send a broadcast signal through a first broadcast channel at a first moment; the first moment is any moment during the period during which the electronic device performs a signal scan predicted in advance by the Bluetooth device, and the first broadcast channel is a channel for the electronic device to perform a signal scan predicted in advance by the Bluetooth device; receive a connection request from the electronic device through the first broadcast channel; and establish a first connection based on the connection request. This can eliminate the influence of various random factors in the process of Bluetooth device reconnection, speed up the reconnection speed between the Bluetooth device and the electronic device, and reduce the waiting time for users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of wireless communication technology, and in particular, to a connection method for devices. Background Art

[0002] Bluetooth (BT) technology is an open global specification for wireless data communication. It is based on low-cost short-range wireless connections and establishes a special wireless connection for the communication environment between devices. After the Bluetooth connection between the electronic device and the external device is successfully established, the external device can implement the corresponding functions. For example, when the external device is a Bluetooth headset, the external device can play music in the electronic device. When the Bluetooth connection between the electronic device and the external device is disconnected, the external device can initiate a back connection to the electronic device so that the electronic device and the external device can re-establish the Bluetooth connection. However, it takes a long time to re-establish the Bluetooth connection between the electronic device and the external device, resulting in a long waiting time for the user and a poor user experience. Summary of the invention

[0003] The present application provides a method for connecting devices, which can accelerate the speed of re-establishing a Bluetooth connection between a Bluetooth device and an electronic device when the electronic device re-establishes a Bluetooth connection with the Bluetooth device, thereby shortening the user's waiting time and improving the user experience.

[0004] In a first aspect, the present application provides a method for connecting a device, the method being applied to a Bluetooth device, a Bluetooth connection being established between the Bluetooth device and an electronic device, the method comprising:

[0005] In the case where the Bluetooth device and the electronic device are disconnected from the Bluetooth connection, reconnection is initiated, and reconnection refers to re-establishing the Bluetooth connection; a broadcast signal is sent through the first broadcast channel at a first moment; the first moment is any moment in the first time period; the first time period is the duration of the electronic device performing signal scanning on the first broadcast channel in the first scanning cycle; a connection request is received from the electronic device through the first broadcast channel, and the connection request is sent by the electronic device when the broadcast signal sent by the Bluetooth device is scanned; based on the connection request, the Bluetooth connection is re-established with the electronic device.

[0006] The present application can prepare for re-establishing a Bluetooth connection between a Bluetooth device and an electronic device by starting a reconnection through a Bluetooth device when the Bluetooth device and the electronic device disconnect the Bluetooth connection (for example, a Bluetooth low energy connection). Based on this, the Bluetooth device can send a broadcast signal through the first broadcast channel at the first moment, so that a directional broadcast signal is sent through the first broadcast channel determined in advance at the first moment, which can eliminate the reconnection delay caused by various random factors (for example, the randomness of the broadcast cycle of the Bluetooth device, the random selection of the broadcast channel by the Bluetooth device, and the random selection of the scanned channel by the electronic device, etc.). In addition, the first moment is any moment during the scanning cycle of the electronic device (for example, the first scanning cycle), when the electronic device performs a signal scan on the first broadcast channel, which can ensure that the Bluetooth device can send a directional broadcast signal through the first broadcast channel while the electronic device can scan the broadcast signal through the first broadcast channel, thereby speeding up the reconnection speed between the Bluetooth device and the electronic device. Further, after the Bluetooth device sends a broadcast signal in a directional manner, a connection request from the electronic device can be received through the first broadcast channel. On this basis, the Bluetooth device can re-establish a Bluetooth connection with the electronic device based on the connection request.

[0007] Thus, the Bluetooth device can predict in advance the time when the electronic device starts scanning next time and the channel to be scanned, so that the Bluetooth device can send a directional broadcast signal through a determined broadcast channel at any time during the electronic device's signal scanning, which can eliminate the influence of various random factors on the reconnection time, speed up the speed of the Bluetooth device and the electronic device to re-establish the Bluetooth connection, reduce the user's waiting time, and improve the user experience. Compared with relying on near field communication (NFC) between Bluetooth devices and electronic devices to speed up the reconnection speed of Bluetooth devices and electronic devices, this application is not limited by spatial distance.

[0008] In a possible implementation of the first aspect, before sending a broadcast signal through a first broadcast channel at a first moment, the method also includes: determining a first duration; the first duration refers to the time interval between the start moment when the electronic device performs a signal scan and the end moment when the electronic device performs a signal scan; the first duration is less than or equal to the duration corresponding to the first scanning cycle.

[0009] In a possible implementation of the first aspect, determining the first duration includes: determining a third moment based on a second moment and a preset mapping relationship; the second moment is the time when the Bluetooth device starts to reconnect; the preset mapping relationship is used to represent the corresponding relationship between the synchronization time between the electronic device and the Bluetooth device; the third moment is the time corresponding to the electronic device when the Bluetooth device starts to reconnect; determining a start moment based on the third moment and a first scanning cycle; determining an end moment based on the third moment, the first scanning cycle and the scanning window; and determining the first duration based on the start moment and the end moment.

[0010] In summary, the Bluetooth device determines the first duration before sending the broadcast signal through the first broadcast channel at the first moment, so that the Bluetooth device can send a directional broadcast signal through the first broadcast channel at any moment in the first duration, that is, at the first moment, thereby eliminating the reconnection delay caused by the randomness of the broadcast cycle of the Bluetooth device and providing a time data basis for the Bluetooth device to send broadcast signals in a directional manner.

[0011] In a possible implementation of the first aspect, before determining the first duration, the method also includes: acquiring multiple first time data pairs; each first time data pair includes a fourth moment and a fifth moment; the fourth moment is the time corresponding to the Bluetooth device when the Bluetooth device receives data information from the electronic device; the fifth moment is the time corresponding to the electronic device when the electronic device sends data information; the multiple first time data pairs are acquired when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected; based on the multiple first time data pairs, a preset mapping relationship is generated.

[0012] In a possible implementation manner of the first aspect, the preset mapping relationship is generated by the Bluetooth device using an average method or a linear regression method.

[0013] Based on the relevant description of the above-mentioned preset mapping relationship, the Bluetooth device generates a preset mapping relationship when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected. Therefore, when the Bluetooth connection between the Bluetooth device and the electronic device is disconnected, the Bluetooth device can achieve time synchronization between the Bluetooth device and the electronic device based on the pre-generated preset mapping relationship, and provide a data basis for the Bluetooth device to determine the time to send the broadcast signal.

[0014] In a possible implementation manner of the first aspect, before sending the broadcast signal through the first broadcast channel at the first moment, the method further includes: determining the first broadcast channel.

[0015] In a possible implementation of the first aspect, determining the first broadcast channel includes: determining the first broadcast channel based on a first value and a first algorithm; the first value is an initial value used by the electronic device to determine the first broadcast channel; the first algorithm is a pseudo-random algorithm used by the electronic device to determine the first broadcast channel. Therefore, by determining the first broadcast channel before sending a broadcast signal through the first broadcast channel at the first moment, the reconnection delay caused by the random selection of the broadcast channel by the Bluetooth device and the random selection of the scanned channel by the electronic device can be eliminated, and a data basis is provided for the Bluetooth device to send the broadcast signal in a directional manner.

[0016] In some possible implementations, the broadcast signal includes one or more of the following: the name of the Bluetooth device, the address of the Bluetooth device, the name of the electronic device, and the address of the electronic device. Therefore, when the Bluetooth device initiates a back connection, the information included in the broadcast signal enables the electronic device to quickly identify the Bluetooth device and prepare for the Bluetooth device to re-establish a Bluetooth connection with the electronic device.

[0017] In a second aspect, the present application provides a method for connecting a device, the method being applied to an electronic device, a Bluetooth connection being established between the electronic device and a Bluetooth device, the method comprising:

[0018] When the electronic device disconnects the Bluetooth connection from the Bluetooth device, scans the first broadcast channel within a first duration based on a first scanning cycle; the first duration is the duration during which the electronic device performs signal scanning on the first broadcast channel in the first scanning cycle; when a broadcast signal sent by the Bluetooth device is scanned on the first broadcast channel, a connection request is sent to the Bluetooth device; the broadcast signal is sent by the Bluetooth device through the first broadcast channel at a first moment; the first moment is any moment in the first duration; and the Bluetooth connection is re-established with the Bluetooth device.

[0019] In a possible implementation of the second aspect, when the electronic device disconnects the Bluetooth connection with the Bluetooth device, the method further includes: adjusting the first scanning cycle to the second scanning cycle; the duration corresponding to the second scanning cycle is less than the duration corresponding to the first scanning cycle; based on the second scanning cycle, scanning the first broadcast channel within the second duration; the second duration is the duration of the electronic device performing signal scanning on the first broadcast channel in the second scanning cycle; the second duration is less than or equal to the duration corresponding to the second scanning cycle. Therefore, by adjusting the scanning cycle of the electronic device from the first scanning cycle to the second scanning cycle with a shorter duration, the electronic device can increase the scanning frequency of the electronic device, so that the electronic device can scan the directional broadcast signal sent by the Bluetooth device through the first broadcast channel more quickly, further reduce the delay of the Bluetooth device reconnection, and speed up the reconnection speed between the electronic device and the Bluetooth device, thereby further shortening the waiting time for the user.

[0020] In a possible implementation of the second aspect, the ratio of the second duration to the duration corresponding to the second scanning cycle is equal to the ratio of the first duration to the duration corresponding to the first scanning cycle. Therefore, when the ratio of the second duration to the duration corresponding to the second scanning cycle is equal to the ratio of the first duration to the duration corresponding to the first scanning cycle, it can be ensured that the average scanning time of the electronic device before and after adjusting the scanning cycle remains unchanged, and further it can be ensured that the electronic device does not increase additional power consumption after adjusting the scanning cycle.

[0021] In a possible implementation of the second aspect, after re-establishing the Bluetooth connection with the Bluetooth device, the method further includes: adjusting the second scanning period to the first scanning period. Therefore, by adjusting the second scanning period to the first scanning period with a longer duration, the electronic device can reduce the scanning frequency of the electronic device, thereby saving energy consumption of the electronic device.

[0022] In a third aspect, the present application provides a method for connecting a device, the method being applied to a system including a Bluetooth device and an electronic device, wherein a Bluetooth connection is established between the Bluetooth device and the electronic device; the method comprising:

[0023] When a Bluetooth device is disconnected from an electronic device, the Bluetooth device initiates reconnection, and reconnection refers to reestablishing the Bluetooth connection; the Bluetooth device sends a broadcast signal through a first broadcast channel at a first moment; the first moment is any moment in a first duration; the first duration is the duration during which the electronic device performs signal scanning on the first broadcast channel in a first scanning cycle; when the electronic device scans the broadcast signal sent by the Bluetooth device, it sends a connection request to the Bluetooth device through the first broadcast channel; the electronic device reestablishes the Bluetooth connection with the Bluetooth device.

[0024] In some possible implementations, the type of the Bluetooth connection is a Bluetooth low energy connection, and reconnection refers to reestablishing a Bluetooth low energy connection. The device connection method of the present application can speed up the speed of reestablishing a Bluetooth low energy connection between a Bluetooth device and an electronic device.

[0025] In a fourth aspect, the present application provides a Bluetooth device, comprising: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the Bluetooth device to execute the connection method for the device in the first aspect and any possible design of the first aspect.

[0026] In a fifth aspect, the present application provides an electronic device, comprising: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the connection method for the device in the second aspect and any possible design of the second aspect.

[0027] In a sixth aspect, the present application provides a chip system, which is applied to a Bluetooth device or an electronic device; the chip system includes one or more processors; the one or more processors are used to call computer instructions so that the Bluetooth device executes the first aspect and any possible design of the first aspect in the connection method for the device; or, the one or more processors are used to call computer instructions so that the electronic device executes the second aspect and any possible design of the second aspect in the connection method for the device.

[0028] Among them, the chip system may include one chip or multiple chips; when the chip system includes multiple chips, this application does not limit parameters such as the type and quantity of the chips.

[0029] In a seventh aspect, the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on a Bluetooth device, the Bluetooth device executes the connection method for the device in the first aspect and any possible design of the first aspect; or, when the instructions are executed on an electronic device, the electronic device executes the connection method for the device in the second aspect and any possible design of the second aspect.

[0030] In an eighth aspect, the present application provides a computer program product, which, when running on a computer, enables the computer to execute the connection method for a device in the first aspect and any possible design of the first aspect, or enables the computer to execute the connection method for a device in the second aspect and any possible design of the second aspect.

[0031] It can be understood that the beneficial effects of the second to eighth 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

[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0033] Figure 1A schematic block diagram of the structure of a Bluetooth connection system provided in one embodiment of the present application;

[0034] Figure 2 A schematic diagram of the principle of establishing a Bluetooth connection between an electronic device and a Bluetooth device provided in one embodiment of the present application;

[0035] Figure 3 A schematic diagram of a principle of data exchange between an electronic device and a Bluetooth device provided in an embodiment of the present application;

[0036] Figure 4 A schematic diagram of an application scenario of a method for connecting devices provided in one embodiment of the present application;

[0037] Figure 5 A schematic diagram of a principle for re-establishing a Bluetooth connection between an electronic device and a Bluetooth device provided in one embodiment of the present application;

[0038] Figure 6 A signaling interaction diagram of a method for connecting a device provided in an embodiment of the present application;

[0039] Figure 7 A schematic diagram of a principle for re-establishing a Bluetooth connection between an electronic device and a Bluetooth device provided in one embodiment of the present application;

[0040] Figure 8 A flowchart of generating a preset mapping relationship for a Bluetooth device provided in an embodiment of the present application;

[0041] Fig. 9 A schematic diagram of data interaction between an electronic device and a Bluetooth device provided in one embodiment of the present application;

[0042] Fig.10 A schematic diagram of a principle for re-establishing a Bluetooth connection between an electronic device and a Bluetooth device provided in one embodiment of the present application;

[0043] Fig.11 A schematic diagram of a software system of a Bluetooth device and a software system of an electronic device provided in an embodiment of the present application;

[0044] Fig.12 A schematic diagram of the software architecture of a Bluetooth protocol stack provided in one embodiment of the present application;

[0045] Fig.13 A schematic diagram of a hardware system of an electronic device provided in one embodiment of the present application;

[0046] Fig.14 A schematic diagram of a hardware system of a Bluetooth device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0047] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0048] In the following, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", and "third" may explicitly or implicitly include one or more of the features.

[0049] In order to facilitate the introduction of the solutions of the embodiments of the present application, before introducing the embodiments of the present application, the terms or concepts involved in the embodiments of the present application are first explained.

[0050] 1. Bluetooth low energy (BLE) technology

[0051] Bluetooth low energy technology, also known as low-power Bluetooth technology, is a personal area network technology designed and sold by the Bluetooth Technology Alliance that supports broadcast communication. Bluetooth low energy technology has the characteristics of short messages, high-efficiency encoding, and short connection establishment time.

[0052] As a wireless communication technology standard, Bluetooth low energy technology can be widely used in devices that do not need to continuously transmit large amounts of data, such as audio devices, IoT devices, health and fitness devices, smart home devices, sensors, and wearable smart devices.

[0053] In the use scenario of Bluetooth low energy technology, it usually includes a master device and a slave device. The master device is the device that actively initiates a connection request during the communication process. The master device is used to maintain the Bluetooth connection and manage connection parameters (such as connection interval, etc.).

[0054] A slave device is a device that responds to a connection request from a master device. In broadcast mode, a slave device can send a broadcast signal through a broadcast channel, thereby enabling the master device to discover and identify surrounding slave devices.

[0055] It should be understood that the master device may also be referred to as a host, a central device, a scanner, or a connector, etc. The slave device may also be referred to as a slave, a broadcaster, or a connected device, etc. In order to facilitate the introduction of the technical solution of the embodiment of the present application, the embodiment of the present application uniformly adopts the master device and the slave device for description.

[0056] It should also be understood that the master device can establish a Bluetooth low energy connection with one or more slave devices, so that each slave device can exchange data with the master device via the Bluetooth low energy protocol. In actual use, the role selection of the master device and the slave device can be determined according to the device type or application scenario.

[0057] In some embodiments, the master device may be an electronic device, and the slave device may be a Bluetooth device. When both the electronic device and the Bluetooth device support Bluetooth low energy connection, the electronic device may establish a Bluetooth low energy connection with the Bluetooth device, so that the electronic device and the Bluetooth device may exchange data through the Bluetooth low energy protocol.

[0058] It should be noted that the above Bluetooth technology is only an example. With the evolution of Bluetooth technology, the above Bluetooth technology, or wireless connection method, may include more Bluetooth connection methods. For example, basic rate (BR) technology may also be called traditional Bluetooth, standard Bluetooth or classic Bluetooth, which is not limited in the present application.

[0059] 2. Bluetooth back-connection technology

[0060] Bluetooth back-connection technology means that after a Bluetooth connection is established between Bluetooth devices, if the Bluetooth connection is interrupted, the Bluetooth devices can automatically reconnect. The implementation principle of Bluetooth back-connection technology is achieved through signal transmission between devices.

[0061] 3. Pseudorandom numbers

[0062] Pseudo-random numbers refer to a series of numbers that look like random numbers, but are actually a series of seemingly random numbers generated by a deterministic algorithm according to certain rules. Pseudo-random numbers are predictable and periodic. Pseudo-random numbers are used in many fields, such as simulation, encryption, statistical sampling, and game design.

[0063] Pseudo-random algorithms are a family of mathematical methods. Pseudo-random algorithms are used to generate sequences of numbers that appear random but are actually completely deterministic. Pseudo-random algorithms are usually based on an initial value (or seed) and a mathematical formula or a series of operations to generate the sequence.

[0064] 4. Bluetooth Standard

[0065] The Bluetooth standard is a series of specifications developed by the Bluetooth Special Interest Group (Bluetooth SIG) to ensure that Bluetooth devices produced by different manufacturers can be compatible and communicate with each other. The Bluetooth standard covers multiple aspects from the physical layer to the application layer, including radio frequency, modulation technology, data transmission protocol, security features, etc.

[0066] The device connection method provided in the embodiment of the present application is applicable to the scenario of re-establishing a Bluetooth connection (e.g., a Bluetooth low energy connection) between an electronic device (or a master device) and a Bluetooth device (or a slave device). In some embodiments, the re-establishment of the Bluetooth connection between the electronic device and the Bluetooth device can be a reconnection automatically initiated by the Bluetooth device, or a reconnection initiated by the Bluetooth device in response to a user operation (e.g., the user opens the cover of the Bluetooth device or the user long presses the switch button on the Bluetooth device, etc.).

[0067] It should be noted that the Bluetooth device may include one or more. In the case where the Bluetooth device includes multiple Bluetooth devices, the multiple Bluetooth devices need to re-establish Bluetooth connections with the electronic device in sequence. The order in which the multiple Bluetooth devices re-establish Bluetooth connections with the electronic device may be the order in which the multiple Bluetooth devices automatically initiate reconnection. For example, the multiple Bluetooth devices include a bracelet and a headset. If the bracelet automatically initiates reconnection first and the headset automatically initiates reconnection later, the electronic device first re-establishes a Bluetooth connection with the bracelet, and then re-establishes a Bluetooth connection with the headset. Alternatively, the order in which the multiple Bluetooth devices re-establish Bluetooth connections with the electronic device may be the urgency of the user using the multiple Bluetooth devices. For example, the multiple Bluetooth devices include a bracelet and a headset. When the electronic device receives an incoming call, the urgency of the user using the headset to answer the call is higher than the urgency of the user using the bracelet. At this time, the electronic device first re-establishes a Bluetooth connection with the headset, and then re-establishes a Bluetooth connection with the bracelet.

[0068] Optionally, in some embodiments, the electronic device may be an electronic device with display hardware and corresponding software support. For example, the electronic device may be a mobile phone, a folding screen, a smart screen, a tablet computer, an in-vehicle electronic device, an augmented reality (AR) device, a virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a home appliance, a projector, etc. The embodiments of the present application do not impose any restrictions on the specific type of the electronic device.

[0069] Optionally, in some embodiments, the Bluetooth device may be a Bluetooth device with Bluetooth function. The Bluetooth device may be a wearable electronic device (such as a bracelet, a watch or a headset, etc.), an in-vehicle electronic device, an augmented reality (AR) device, a virtual reality (VR) device, a personal digital assistant (PDA), a home appliance, a projector, etc. The embodiments of the present application do not impose any restrictions on the specific type of the Bluetooth device.

[0070] See also Figure 1 , Figure 1 A schematic structural block diagram of a Bluetooth connection system provided in an embodiment of the present application is shown.

[0071] like Figure 1 As shown, the Bluetooth connection system 100 provided in the embodiment of the present application may include an electronic device 200 and a Bluetooth device 300. When the electronic device 200 and the Bluetooth device 300 are not connected, the electronic device 200 may establish a Bluetooth connection (eg, a Bluetooth low energy connection) with the Bluetooth device 300.

[0072] The electronic device 200 establishing a Bluetooth connection with the Bluetooth device 300 can be understood as the electronic device 200 and the Bluetooth device 300 being able to discover and identify each other, and the electronic device 200 and the Bluetooth device 300 being able to start data exchange.

[0073] It should be noted that before the electronic device 200 establishes a Bluetooth connection with the Bluetooth device 300, the user needs to ensure that the Bluetooth function of the electronic device 200 is turned on, and the Bluetooth function of the Bluetooth device 300 is turned on. For example, the electronic device 200 can automatically turn on the Bluetooth function after being turned on, or the electronic device 200 can turn on the Bluetooth function of the electronic device 200 in response to the user turning on the Bluetooth switch in the setting application. The Bluetooth device 300 can turn on the Bluetooth function of the Bluetooth device 300 in response to the user triggering the switch on the Bluetooth device 300.

[0074] See also Figure 2 , Figure 2 A schematic diagram showing the principle of establishing a Bluetooth connection between an electronic device and a Bluetooth device provided in an embodiment of the present application is shown.

[0075] Optionally, in some embodiments, the Bluetooth connection established between the electronic device 200 and the Bluetooth device 300 may be a Bluetooth low energy connection.

[0076] It should be noted that the radio frequency band used by Bluetooth low energy connection is 2.4GHz. The available frequency range of this band is 2400MHz-2483.5MHz. The Bluetooth standard stipulates that the establishment of Bluetooth low energy connection needs to divide the 2.4GHz band into 40 channels for different communication purposes. Each of the 40 channels has a unique index identifier and frequency range.

[0077] It should also be noted that the above 40 channels include broadcast channels and data channels. The broadcast channel is mainly used for the initial broadcast before the electronic device 200 and the Bluetooth device 300 establish a Bluetooth low energy connection, so that the electronic device 200 and the Bluetooth device 300 can discover each other. The data channel is mainly used for data interaction after the electronic device 200 and the Bluetooth device 300 establish a Bluetooth low energy connection, which can provide a stable communication environment for the electronic device 200 and the Bluetooth device 300.

[0078] Optionally, in some embodiments, when the 40 channels are numbered 0-39, the Bluetooth low energy connection calls the channels corresponding to the three channels numbered 37, 38 and 39 broadcast channels, and calls the channels corresponding to the 37 channels numbered 0-36 data channels.

[0079] like Figure 2 As shown, the specific implementation process of the electronic device 200 and the Bluetooth device 300 in the embodiment of the present application establishing a Bluetooth low energy connection is as follows:

[0080] The Bluetooth device 300 may periodically send broadcast packets through a broadcast channel based on a broadcast cycle, so that other Bluetooth devices (eg, the electronic device 200 ) may discover the Bluetooth device 300 and choose to connect to the Bluetooth device 300 .

[0081] Optionally, in some embodiments, the broadcast period is used to indicate the time interval between two adjacent groups of broadcasts sent by the Bluetooth device 300.

[0082] It should be noted that the broadcast period is not a fixed time value. The broadcast period is the sum of the time value of the initial period and the random time value specified in the Bluetooth standard. The initial period is a time value pre-set in the Bluetooth device 300. The range of random time values ​​specified in the Bluetooth standard is 0 milliseconds (ms)-10ms. Exemplarily, when the initial period is set to 1000ms and the random time value of the first broadcast is 5ms, the broadcast period of the first broadcast of the Bluetooth device 300 is 1005ms. When the random time value of the second broadcast is 8ms, the broadcast period of the second broadcast of the Bluetooth device 300 is 1008ms.

[0083] It should be noted that, in actual applications, for Bluetooth devices 300 that are frequently used by users (such as headphones or bracelets, etc.), or for Bluetooth devices 300 that need to frequently interact with electronic devices 200, the Bluetooth device 300 can set the initial period to a smaller time value (such as 500ms) to reduce the broadcast period of the Bluetooth device 300, thereby increasing the probability that the Bluetooth device 300 is scanned by other Bluetooth devices. In addition, for Bluetooth devices 300 that are less frequently used by users (such as smart home devices, etc.), or for Bluetooth devices 300 that interact with electronic devices 200 less frequently, the Bluetooth device 300 can set the initial period to a larger time value (such as 2 seconds (s)) to increase the broadcast period of the Bluetooth device 300, thereby reducing the energy consumption of the Bluetooth device 300.

[0084] Optionally, in some embodiments, when the electronic device 200 establishes a Bluetooth low energy connection with the Bluetooth device 300 for the first time, the advertising packet is used to provide necessary information related to the Bluetooth device 300 so that other Bluetooth devices (such as the electronic device 200) can discover the Bluetooth device 300. Exemplarily, the advertising packet may include the address of the Bluetooth device 300, the name of the Bluetooth device 300, the transmission power information of the Bluetooth device 300, and the advertising period of the Bluetooth device 300.

[0085] It should be noted that the specific content in the above broadcast packet is only for exemplary description, and the embodiments of the present application are not limited thereto. In actual applications, the specific content in the broadcast packet may include more information than the above content depending on the actual application scenario and the capabilities of the Bluetooth device 300.

[0086] For example, in order to distinguish Bluetooth devices produced by different manufacturers, the broadcast packet of the Bluetooth device may also include specific data defined by the manufacturer, etc. For another example, when the Bluetooth device 300 starts a back connection, the broadcast packet may also include the address of the electronic device 200 and the name of the electronic device 200, etc., so that the electronic device 200 and the Bluetooth device 300 can quickly discover and identify each other and re-establish the Bluetooth low energy connection.

[0087] like Figure 2 As shown, a group of broadcasts of the Bluetooth device 300 includes the Bluetooth device 300 sending broadcast packets to a channel numbered 37, a channel numbered 38, and a channel numbered 39 in sequence. After the Bluetooth device 300 sends a broadcast packet to any broadcast channel, the Bluetooth device 300 needs to receive information for a certain length of time (for example, 6ms) through the broadcast channel so as to be able to receive information such as a connection request sent by the electronic device 200 in a timely manner.

[0088] It should be noted that the order of the three channels in the above-mentioned group of broadcasts is only for illustrative purposes and is not limited in the embodiments of the present application. For example, the order of the three channels in a group of broadcasts of the Bluetooth device 300 may also be that the channel numbered 38 is in the front, the channel numbered 37 is in the middle, and the channel numbered 39 is in the back. For another example, the order of the three channels in a group of broadcasts of the Bluetooth device 300 may also be that the channel numbered 37 is in the front, the channel numbered 39 is in the middle, and the channel numbered 38 is in the back.

[0089] The electronic device 200 may periodically scan the three broadcast channels based on a scanning cycle (or a scanning interval). The electronic device 200 periodically scanning the three broadcast channels means that in the first scanning cycle, the electronic device 200 scans any one of the three broadcast channels (for example, channel numbered 37, channel numbered 38, or channel numbered 39); in the second scanning cycle, the electronic device 200 scans one of the three broadcast channels except for the already scanned broadcast channels; in the third scanning cycle, the electronic device 200 scans the unscanned broadcast channels of the three broadcast channels. After completing one scan of the three broadcast channels, the electronic device 200 may continue to periodically scan the three broadcast channels.

[0090] Illustratively, in the first scanning cycle, the electronic device 200 scans channel numbered 37; in the second scanning cycle, the electronic device 200 scans channel numbered 38; in the third scanning cycle, the electronic device 200 scans channel numbered 39; in the fourth scanning cycle, the electronic device 200 scans channel numbered 37.

[0091] It should be noted that the numbering and order of the channels that the electronic device 200 starts scanning are only exemplary, and the embodiments of the present application are not limited thereto. In practical applications, the numbering of the channels that the electronic device 200 scans in each cycle can be determined by an initial random number and a pseudo-random algorithm pre-stored in the electronic device 200.

[0092] Optionally, in some embodiments, the scanning period is used to indicate the time interval between the start times of two adjacent signal scans performed by the electronic device 200. The scanning period is a time value preset in the electronic device 200. Exemplarily, the scanning period can be set to 100 ms.

[0093] like Figure 2 As shown, the electronic device 200 can perform an operation of scanning a broadcast channel (eg, channel numbered 38) within a scan window.

[0094] Optionally, in some embodiments, the scanning window is used to indicate the duration of the signal scanning performed by the electronic device 200 in the scanning cycle. The scanning window is a time value preset in the electronic device 200. Exemplarily, the scanning window can be set to 10 ms.

[0095] Optionally, in some embodiments, the time value corresponding to the scanning window pre-set in the electronic device 200 is less than or equal to the time value corresponding to the scanning cycle, which can reduce the power consumption of the electronic device 200, avoid the problem of high power consumption of the electronic device 200 due to the electronic device 200 always performing signal scanning, and ensure that the electronic device 200 has enough time to receive broadcast packets.

[0096] It should be noted that, by setting the time value corresponding to the scanning window to be less than or equal to the time value corresponding to the scanning period, the electronic device 200 can perform data exchange tasks with other Bluetooth devices (i.e., Bluetooth devices other than the Bluetooth device 300 currently scanned by the electronic device 200) during the scanning period except for the scanning window. For example, when the scanning period is set to 100ms and the scanning window is set to 10ms, it means that the electronic device 200 will perform a scan every 100ms, and each scan lasts for 10ms, and the remaining 90ms can perform data exchange tasks with other Bluetooth devices (such as wristbands).

[0097] It should also be noted that the specific time values ​​corresponding to the above-mentioned scanning period and the specific time values ​​corresponding to the scanning window are only used as exemplary illustrations, and the embodiments of the present application are not limited thereto. In practical applications, those skilled in the art can adjust the specific time values ​​corresponding to the scanning period and the specific time values ​​corresponding to the scanning window according to the actual scanning frequency and energy consumption. For example, the electronic device 200 can set the scanning period to 50ms and the scanning window to 5ms to increase the scanning frequency of the electronic device 200, so that the electronic device 200 can discover other Bluetooth devices (for example, Bluetooth device 300) around it more quickly.

[0098] like Figure 2 As shown, the electronic device 200 scans the broadcast channel (for example, the channel numbered 38), and correspondingly, the Bluetooth device 300 executes the second group broadcast, and the Bluetooth device 300 sends a broadcast packet through the channel numbered 38. At this time, the electronic device 200 and the Bluetooth device 300 can discover each other, and then prepare for the electronic device 200 and the Bluetooth device 300 to establish a Bluetooth low energy connection.

[0099] like Figure 2As shown, when the electronic device 200 scans a broadcast packet in a broadcast channel (eg, channel numbered 38), the electronic device 200 can send a connection request to the Bluetooth device 300 through the broadcast channel (eg, channel numbered 38).

[0100] like Figure 2 As shown, after the Bluetooth device 300 receives a connection request sent from the electronic device 200 through a broadcast channel (for example, channel numbered 38), after a preset time (or a time threshold specified in the Bluetooth standard), the electronic device 200 will attempt to exchange data with the Bluetooth device 300.

[0101] It should be noted that, before the electronic device 200 attempts to exchange data with the Bluetooth device 300, if the Bluetooth device 300 has not completed the current set of broadcasts, the Bluetooth device 300 may complete the current set of broadcasts. Figure 2 As shown, before the electronic device 200 attempts to exchange data with the Bluetooth device 300, the Bluetooth device 300 has received a connection request from the electronic device 200 through the channel numbered 38. At this time, the Bluetooth device 300 also needs to continue to send broadcast packets to the channel numbered 39 and receive information of a certain length through the channel numbered 39 to complete the current set of broadcasts.

[0102] Optionally, in some embodiments, Figure 2 As shown, the electronic device 200 can send the first data to the Bluetooth device 300. After the Bluetooth device 300 receives the first data, the second data can be sent to the electronic device 200. When the electronic device 200 receives the second data, it indicates that the Bluetooth low energy connection between the electronic device 200 and the Bluetooth device 300 is successfully established.

[0103] Optionally, in another embodiment, after the Bluetooth device 300 receives the first data, the Bluetooth device 300 does not send the second data to the electronic device 200 (or does not reply to the electronic device 200), indicating that the Bluetooth low energy connection between the electronic device 200 and the Bluetooth device 300 fails to be established. At this time, the electronic device 200 can re-execute the periodic scanning process.

[0104] It should be noted that the first data and the second data may be empty data, or may be audio data, image data or video data in the communication between the electronic device 200 and the Bluetooth device 300, and this embodiment of the present application does not limit this.

[0105] After the Bluetooth low energy connection is successfully established between the electronic device 200 and the Bluetooth device 300 , the electronic device 200 can perform normal wireless communication with the Bluetooth device 300 to achieve data exchange between the electronic device 200 and the Bluetooth device 300 .

[0106] like Figure 3 As shown, the electronic device 200 and the Bluetooth device 300 exchange data based on a connection period (or connection interval), which can ensure normal communication between the electronic device 200 and the Bluetooth device 300.

[0107] Optionally, in some embodiments, the connection period is used to represent the time interval for data exchange between the electronic device 200 and the Bluetooth device 300. The connection period is a time value negotiated in advance between the electronic device 200 and the Bluetooth device 300. Exemplarily, the connection period can be set to 200ms.

[0108] It should be noted that, in actual applications, the connection period after each successful establishment of a Bluetooth low energy connection between the electronic device 200 and the Bluetooth device 300 can be a fixed time value. When the user needs to speed up the frequency of data interaction between the electronic device 200 and the Bluetooth device 300, the electronic device 200 and the Bluetooth device 300 can also reduce the duration corresponding to the connection period through negotiation, which is not limited in the embodiments of the present application.

[0109] In the case where the amount of data that needs to be exchanged between the electronic device 200 and the Bluetooth device 300 is small, the electronic device 200 and the Bluetooth device 300 may only exchange data once (for example, Figure 3 In the case where there is a lot of data to be exchanged between the electronic device 200 and the Bluetooth device 300, the electronic device 200 and the Bluetooth device 300 may exchange data multiple times in succession (for example, Figure 3 Three data exchanges during the second connection cycle shown).

[0110] It should be noted that, within a connection cycle, the electronic device 200 and the Bluetooth device 300 need to exchange data at least once. Figure 3 The purpose is only to illustrate the number of times the electronic device 200 and the Bluetooth device 300 exchange data, and the data exchanged between the electronic device 200 and the Bluetooth device 300 each time can be determined according to the actual usage, and the embodiments of the present application do not limit this. For example, the data exchanged between the electronic device 200 and the Bluetooth device 300 can be empty data. For another example, when the electronic device 200 is a mobile phone and the Bluetooth device 300 is a headset, the data exchanged between the electronic device 200 and the Bluetooth device 300 can be real-time audio data.

[0111] Optionally, in some embodiments, after successfully establishing a Bluetooth low energy connection between the electronic device 200 and the Bluetooth device 300, the electronic device 200 may exchange information registration (e.g., a short-term key or a long-term key, etc.) with the Bluetooth device 300 to complete the pairing process. By exchanging information registration, the electronic device 200 and the Bluetooth device 300 can facilitate the electronic device 200 and the Bluetooth device 300 to quickly identify each other when re-establishing a Bluetooth low energy connection later.

[0112] It should be noted that the specific process of completing the pairing between the electronic device 200 and the Bluetooth device 300 can be found in the description of the relevant technology and will not be described in detail here.

[0113] In actual use, when the Bluetooth device 300 enters a power-saving sleep state, the distance between the Bluetooth device 300 and the electronic device 200 exceeds the Bluetooth communication distance, or a signal that causes strong interference to the Bluetooth signal of the Bluetooth device 300 appears, the Bluetooth low-power connection established between the Bluetooth device 300 and the electronic device 200 will be disconnected.

[0114] It should be noted that the power-saving dormant state of the Bluetooth device 300 refers to a low energy consumption mode, or low power mode, or standby mode. In the low energy consumption mode, the Bluetooth device 300 temporarily turns off or reduces its wireless communication function to reduce energy consumption and extend the battery life of the Bluetooth device 300.

[0115] It should also be noted that the power-saving sleep state of the Bluetooth device 300 is a temporary state, which is applicable to scenarios where continuous communication is not required. That is, when the Bluetooth device 300 does not need to continuously communicate with the electronic device 200, the Bluetooth device 300 can automatically enter the power-saving sleep state based on the set sleep parameters. Correspondingly, when the Bluetooth device 300 needs to communicate with the electronic device 200, the Bluetooth device 300 can automatically exit the power-saving sleep state based on the set wake-up parameters.

[0116] When the Bluetooth low energy connection between the Bluetooth device 300 and the electronic device 200 is disconnected, if the user needs to continue to use the Bluetooth device 300 to interact with the electronic device 200 for data, the Bluetooth device 300 and the electronic device 200 need to re-establish the Bluetooth low energy connection.

[0117] It should be noted that the Bluetooth low energy connection between the Bluetooth device 300 and the electronic device 200 may be disconnected automatically by the Bluetooth device 300 to save power consumption, or it may be disconnected in response to a corresponding operation of the user in the electronic device 200, and this embodiment of the present application is not limited to this.

[0118] It should also be noted that the above description is based on the example of the electronic device 200 and the Bluetooth device 300 establishing a Bluetooth low energy connection. The electronic device 200 and the Bluetooth device 300 may also establish other types of Bluetooth connections (e.g., classic Bluetooth connections), which are not limited in the present embodiment of the application. The process of the electronic device 200 and the Bluetooth device 300 establishing a classic Bluetooth connection can be found in the description of the relevant technology, which will not be described in detail here.

[0119] Combine the following Figure 4 and Figure 6 , taking the electronic device 200 as a mobile phone and the Bluetooth device 300 as a headset as an example, the specific implementation process of re-establishing a Bluetooth low energy connection between the mobile phone and the headset is described.

[0120] It should be noted that when the mobile phone and the headset are not connected, the specific implementation process of establishing a Bluetooth low energy connection between the mobile phone and the headset for the first time can be found in Figure 2 The relevant description is not repeated here.

[0121] See also Figure 4 , Figure 4 A schematic diagram of an application scenario of a method for connecting devices provided in an embodiment of the present application is shown.

[0122] In the event that the Bluetooth low energy connection between the phone and the headset is disconnected, the headset can initiate a reconnection. Figure 4 As shown, in response to the user opening the cover, the headset can start the back connection. Figure 5 As shown, the time for the earphone to start reconnection is t.

[0123] It should be noted that the above reconnection can also be automatically initiated by the headset. For example, if the Bluetooth low energy connection between the headset and the mobile phone is disconnected because the distance between the headset and the mobile phone exceeds the Bluetooth communication distance, the headset can automatically start the reconnection when the distance between the headset and the mobile phone returns to the Bluetooth communication distance.

[0124] After starting the reconnection, the headset can periodically send broadcast packets through three broadcast channels based on the broadcast cycle. Since the method of re-establishing a connection between devices specified in the Bluetooth standard still requires the mobile phone to scan the broadcast channels in order to find the headset. That is to say, while the headset periodically sends broadcast packets through three broadcast channels, the mobile phone can periodically scan one of the three broadcast channels based on the scanning cycle. This allows the headset and the mobile phone to discover and identify each other, preparing for the mobile phone and the headset to re-establish a Bluetooth low-power connection.

[0125] However, since the headset's advertising cycle is random, the order in which the headset sends advertising packets through the three channels (such as Figure 5As shown in the figure, the number of broadcast channels scanned by the mobile phone in a scanning cycle (such as Figure 5 As a result, the process of re-establishing the Bluetooth low energy connection between the headset and the mobile phone is greatly affected by random factors. It is impossible to ensure that the broadcast channel scanned by the mobile phone in the scanning window is exactly the broadcast channel where the headset sends the broadcast packet. As a result, it takes a long time (for example, 3s or 5s) to re-establish the Bluetooth low energy connection between the mobile phone and the headset, which leads to a poor user experience.

[0126] For example, Figure 5 As shown in the figure, at time t, the mobile phone is not in the scanning state, so the broadcast packet sent by the headset through channel numbered 37 after starting the back connection cannot be scanned by the mobile phone. At this time, the headset needs to continue to send broadcast packets through the three broadcast channels periodically based on the broadcast cycle. At the same time, the mobile phone continues to periodically scan one of the three broadcast channels based on the scanning cycle (such as Figure 5 The mobile phone continues to scan for channel 38 (such as Figure 5 In the case of the scanning window shown in the figure), only the broadcast packets sent by the headset through channel numbered 38 can be scanned (such as Figure 5 The time T shown is T>t). It can be seen that the implementation principle of re-establishing a Bluetooth low energy connection between the mobile phone and the headset is similar to Figure 2 The implementation principle of establishing a Bluetooth low energy connection between the electronic device 200 and the Bluetooth device 300 is similar. The randomness of the broadcast channel for the headset to send broadcast packets and the randomness of the mobile phone scanning the broadcast channel will cause a delay in the connection back between the headset and the mobile phone, resulting in a longer time for re-establishing the Bluetooth low energy connection between the mobile phone and the headset.

[0127] Considering that there can be multiple devices that establish a Bluetooth low energy connection with the mobile phone (for example, Figure 4 The headset and bracelet shown in the figure, etc.), and the headset and bracelet use the same broadcast channel. Therefore, when the mobile phone scans the headset's broadcast packet, it may also scan other Bluetooth devices (for example, Figure 4The mobile phone may scan the broadcast packet of the headset (such as the bracelet shown in the figure), or scan the signal of the wifi device with the same frequency band as the Bluetooth low energy connection. At this time, due to the interference of the broadcast packet of other Bluetooth devices or the signal of the wifi device with the same frequency band as the Bluetooth low energy connection, the mobile phone may not be able to scan the broadcast packet of the headset, which will cause the mobile phone to take longer to re-establish the Bluetooth low energy connection between the mobile phone and the headset. It can be seen that the current method of re-establishing the Bluetooth connection (such as the Bluetooth low energy connection) between the electronic device and the Bluetooth device is highly random. Under the interference of various random factors, it takes a long time to re-establish the Bluetooth connection between the electronic device and the Bluetooth device, resulting in a poor user experience. Especially in the scenario where the user urgently needs to use the Bluetooth device (for example, the user urgently needs to use the headset to answer the phone), the user experience will be greatly reduced.

[0128] In view of this, the connection method for devices provided in the embodiment of the present application can significantly reduce the time overhead for the Bluetooth device to re-establish the Bluetooth connection with the electronic device based on the time synchronization and pairing binding relationship between the Bluetooth device and the electronic device when the Bluetooth connection between the electronic device and the Bluetooth device is disconnected. Furthermore, based on information such as the synchronization time and the scanning cycle of the electronic device, the Bluetooth device can predict the time when the electronic device starts scanning and the broadcast channel to be scanned. Based on this, the Bluetooth device can send a broadcast packet through a specific broadcast channel at a specific time, thereby eliminating the influence of various random factors when the Bluetooth device re-establishes a Bluetooth low-power connection with the electronic device, further shortening the time for the Bluetooth device to re-establish a Bluetooth low-power connection with the electronic device, and greatly improving the user experience.

[0129] Combination of the above Figures 1 to 3 , describes in detail the implementation process of establishing a Bluetooth connection between the electronic device 200 and the Bluetooth device 300 in the embodiment of the present application, and Figure 4 and Figure 5 The application scenarios of the embodiments of the present application are introduced below. Figures 6 to 10 , describes in detail the connection method for devices in the embodiment of the present application. The connection method for devices in the embodiment of the present application is applied to Figure 1 The Bluetooth connection system shown in the figure establishes a Bluetooth connection between the electronic device and the Bluetooth device.

[0130] See also Figure 6 , Figure 6 FIG. 1 shows a signaling interaction diagram of a method for connecting a device provided in an embodiment of the present application. Figure 6 As shown, the connection method for a device in an embodiment of the present application includes the following steps:

[0131] S101: When the Bluetooth device is disconnected from the electronic device, the Bluetooth device starts reconnection.

[0132] Optionally, in some embodiments, the back-connection refers to re-establishing the Bluetooth connection. In the case where the type of the Bluetooth connection is a Bluetooth low energy connection, the back-connection refers to re-establishing the Bluetooth low energy connection.

[0133] It should be noted that the backconnection may be automatically initiated by the Bluetooth device, or may be initiated by the Bluetooth device in response to a trigger operation by the user, which is not limited in the embodiments of the present application.

[0134] It should also be noted that the time when the Bluetooth device starts the backlink and the time when the electronic device performs the signal scan can be the same or different. In other words, the time when the Bluetooth device starts the backlink can be the time when the electronic device performs the signal scan (for example, Figure 5 Alternatively, the time when the Bluetooth device initiates the backlink may also be the time when the electronic device does not perform signal scanning (for example, Figure 5 The time outside the scanning window in the scanning cycle shown in the figure is not limited to this in the embodiment of the present application.

[0135] When the Bluetooth device is disconnected from the electronic device, the Bluetooth device can initiate a reconnection based on the current communication needs (e.g. Figure 5 or Figure 7 By initiating a back connection, the Bluetooth device can prepare for re-establishing a Bluetooth connection with the electronic device.

[0136] S102, determining a first duration and a first broadcast channel.

[0137] Optionally, in some embodiments, the first duration is the duration of the electronic device performing signal scanning on the first broadcast channel in the first scanning cycle. The first scanning cycle is equivalent to Figure 5 The scanning cycle shown, the first duration is equivalent to Figure 2 or Figure 5 , as shown in the scanning window. Figure 7 As shown, the first duration is the duration during which the electronic device performs signal scanning on channel numbered 39 in the first scanning cycle.

[0138] Optionally, in some embodiments, the first scanning period is used to represent the time interval between the start times of two adjacent signal scans performed by the electronic device. Figure 7 As shown, the first scanning cycle is the time interval from when the electronic device starts scanning the channel numbered 38 to when it starts scanning the channel numbered 39.

[0139] Optionally, in some embodiments, the first duration and the first scanning period are both pre-set times in the electronic device. The first duration is less than or equal to the duration corresponding to the first scanning period. By setting the first duration to be less than or equal to the duration corresponding to the first scanning period, the electronic device can avoid being in a scanning state all the time, thereby reducing the power consumption of the electronic device. In addition, the electronic device can also perform data exchange tasks with other Bluetooth devices (such as a wristband) during the first scanning period except for the first duration.

[0140] Optionally, in some embodiments, the first broadcast channel is a channel on which the electronic device performs signal scanning. Optionally, the first broadcast channel may be channel numbered 37, channel numbered 38, or channel numbered 39. For example, Figure 7 As shown, when the Bluetooth device starts backconnection, the first broadcast channel is channel numbered 39.

[0141] Optionally, in some embodiments, the broadcast signal may include one or more of the following: the name of the Bluetooth device, the address of the Bluetooth device, the name of the electronic device, and the address of the electronic device. The broadcast signal is equivalent to a broadcast packet sent by the Bluetooth device through a broadcast channel when the Bluetooth device re-establishes a Bluetooth connection (e.g., a Bluetooth low energy connection) with the electronic device.

[0142] It should be noted that the address of the Bluetooth device and the address of the electronic device can be a media access control address (media access control address), also known as a local area network address, MAC address, Ethernet address or physical address, or a Bluetooth address, which is not limited in this application.

[0143] Optionally, in some embodiments, after the Bluetooth device starts the reconnection, the Bluetooth device may determine a first duration. By determining the first duration, the Bluetooth device can send a broadcast signal within a specific time range (i.e., the first duration), thereby preparing for the Bluetooth device to quickly reestablish a Bluetooth connection with the electronic device.

[0144] Optionally, in some embodiments, after the Bluetooth device initiates the backlink, the Bluetooth device may also determine the first broadcast channel (eg, Figure 7 By determining the first broadcast channel, the Bluetooth device can send a directional broadcast signal through a specific broadcast channel, thereby preparing for the Bluetooth device to quickly re-establish a Bluetooth connection with the electronic device.

[0145] It should be noted that in S102, there is no time sequence or order for the Bluetooth device to determine the first duration and the first broadcast channel. That is, the Bluetooth device may first determine the first duration and then determine the first broadcast channel; or, first determine the first broadcast channel and then determine the first duration; or, determine the first duration and the first broadcast channel at the same time.

[0146] S103: The Bluetooth device sends a broadcast signal through a first broadcast channel at a first moment.

[0147] Optionally, in some embodiments, the first moment is any moment in the first duration. In other words, the first moment may be the start moment of the electronic device performing signal scanning, or the first moment may be the end moment of the electronic device performing signal scanning, or the first moment may be any moment between the start moment and the end moment of the electronic device performing scanning. For example, Figure 7 As shown, the first moment is the starting moment when the electronic device performs signal scanning.

[0148] After determining the first duration and the first broadcast channel, the Bluetooth device may send a broadcast signal (for example, Figure 7 As shown in FIG. 1 , a directional broadcast signal is sent to a channel numbered 39). Thus, during the time when the electronic device continuously performs signal scanning, the Bluetooth device sends a directional broadcast to the first broadcast channel determined in advance. Figure 5 In the manner shown, the influence of uncertain delay time caused by random selection of broadcast channels by Bluetooth devices and random selection of scanning channels by electronic devices is eliminated, which can speed up the process of re-establishing Bluetooth connection between electronic devices and Bluetooth devices, reduce user waiting time, and improve user experience.

[0149] Optionally, in another embodiment, the first moment may also be a moment before the first duration. That is, the Bluetooth device may send a broadcast signal through the first broadcast channel in advance before the electronic device starts to perform signal scanning, to ensure that the broadcast signal can be scanned after the electronic device starts to perform signal scanning.

[0150] S104: The electronic device scans a first broadcast channel within a first duration based on a first scanning cycle.

[0151] It should be understood that there is no sequence or order between S104 and S103, that is, S104 and S103 can be executed simultaneously, or they can be executed in the order that the electronic device executes S103 first and the Bluetooth device executes S104 later, or they can be executed in the order that the Bluetooth device executes S104 first and the electronic device executes S103 later. The embodiments of the present application are not limited to this.

[0152] It should be noted that, according to the order that the electronic device executes S104 first and the Bluetooth device executes S103 later, it can be ensured that the electronic device will not miss the broadcast signal sent by the Bluetooth device through the first broadcast channel.

[0153] When the Bluetooth device and the electronic device are disconnected from the Bluetooth connection, the electronic device can periodically scan any one of the three broadcast channels based on a pre-set first scanning cycle. Specifically, the electronic device can scan the first broadcast channel within a first duration based on the first scanning cycle. By scanning the first broadcast channel, the electronic device can prepare for discovering the broadcast signal sent by the Bluetooth device through the first broadcast channel, and because the first broadcast channel is determined in advance by the Bluetooth device, it can indirectly eliminate the influence of the uncertain delay duration caused by the electronic device randomly selecting the scanned channel, further speeding up the speed of re-establishing the Bluetooth connection between the Bluetooth device and the electronic device, and reducing the user's waiting time.

[0154] S105: When the electronic device scans a broadcast signal sent by a Bluetooth device on the first broadcast channel, the electronic device sends a connection request to the Bluetooth device.

[0155] When the electronic device scans the broadcast signal sent by the Bluetooth device on the first broadcast channel, the electronic device can send a connection request to the Bluetooth device via the first broadcast channel. Figure 7 As shown, in the case where the first broadcast channel is channel numbered 39, after the electronic device scans the directional broadcast signal sent by the Bluetooth device through channel numbered 39, the electronic device can send a connection request to the Bluetooth device through channel numbered 39, so as to prepare for the electronic device to re-establish a Bluetooth connection with the Bluetooth device. After the electronic device sends a connection request to the Bluetooth device through the first broadcast channel, the Bluetooth device can connect to the Bluetooth device through the first broadcast channel (for example, Figure 7 The electronic device receives a connection request through the Bluetooth device (channel numbered 39 as shown), thereby preparing to re-establish a Bluetooth connection between the electronic device and the Bluetooth device.

[0156] S106, the electronic device re-establishes a Bluetooth connection with the Bluetooth device.

[0157] Optionally, in some embodiments, after receiving the connection request, the Bluetooth device may send a feedback signal to the electronic device to inform the electronic device that the Bluetooth device has received the connection request. For the electronic device, after receiving the feedback signal from the Bluetooth device, the electronic device may determine that the Bluetooth device has received the connection request. At this time, the electronic device may attempt to exchange data with the Bluetooth device to re-establish the Bluetooth connection. If the electronic device and the Bluetooth device can successfully exchange data, it means that the electronic device and the Bluetooth device have successfully re-established the Bluetooth connection.

[0158] Optionally, in another embodiment, after executing S105, the electronic device may directly re-establish a Bluetooth connection with the Bluetooth device.

[0159] It should be noted that when the type of Bluetooth connection is Bluetooth low energy connection, the specific implementation principle of the electronic device attempting to exchange data with the Bluetooth device is the same as Figure 2 The specific implementation principle of data exchange in the first establishment of a Bluetooth low energy connection between the electronic device and the Bluetooth device shown is similar, please refer to the relevant description above, and will not be repeated here. For the Bluetooth device, after receiving a connection request from the electronic device, the Bluetooth device can re-establish a Bluetooth connection with the electronic device based on the connection request. By re-establishing a Bluetooth connection between the Bluetooth device and the electronic device, wireless communication between the Bluetooth device and the electronic device can be restored.

[0160] In summary, the Bluetooth device can complete the back-connection process with the electronic device. At this time, the Bluetooth device and the electronic device can exchange data at least once based on the connection cycle (such as Figure 3 as shown).

[0161] Optionally, in some embodiments, after the electronic device successfully re-establishes the Bluetooth connection with the Bluetooth device, the Bluetooth device may achieve time synchronization with the electronic device during data exchange with the electronic device to prepare for the next reconnection initiated by the Bluetooth device.

[0162] It should be noted that, during the data exchange process between the Bluetooth device and the electronic device, the time synchronization of the electronic device can be achieved during the first data exchange process in each connection cycle, or during each data exchange process in each connection cycle. The embodiment of the present application is not limited to this.

[0163] In the connection method for devices in the embodiment of the present application, when the Bluetooth device and the electronic device disconnect the Bluetooth connection (for example, the Bluetooth low energy connection), the Bluetooth device starts the back connection, which can prepare for re-establishing the Bluetooth connection between the Bluetooth device and the electronic device. Based on this, the Bluetooth device can send a broadcast signal through the first broadcast channel at the first moment, so that the Bluetooth device sends a directional broadcast signal through the first broadcast channel determined in advance at the first moment in advance, which can eliminate the back connection delay caused by various random factors (for example, the randomness of the broadcast cycle of the Bluetooth device, the random selection of the broadcast channel by the Bluetooth device, and the random selection of the scan channel by the electronic device, etc.). In addition, the first moment is any moment during the scanning cycle of the electronic device (for example, the first scanning cycle), during which the electronic device performs signal scanning on the first broadcast channel, which can ensure that the Bluetooth device can scan the broadcast signal through the first broadcast channel while sending the broadcast signal through the first broadcast channel, thereby speeding up the back connection speed between the Bluetooth device and the electronic device. Further, after the Bluetooth device sends the broadcast signal in a directional manner, a connection request from the electronic device can be received through the first broadcast channel. On this basis, the Bluetooth device can re-establish the Bluetooth connection with the electronic device based on the connection request.

[0164] Therefore, the Bluetooth device can predict in advance the next time the electronic device starts scanning and the scanning channel, so that the Bluetooth device can send a directional broadcast signal through a determined broadcast channel at any time during the signal scanning of the electronic device, thereby eliminating the influence of various random factors on the reconnection time, speeding up the reconnection speed between the Bluetooth device and the electronic device, reducing the time users wait for the Bluetooth device to reconnect, and improving the user experience.

[0165] In addition, compared with relying on near-field communication between Bluetooth devices and electronic devices to speed up the reconnection speed between Bluetooth devices and electronic devices, the device connection method in the embodiment of the present application is not limited by spatial distance and can be implemented without the Bluetooth device and the electronic device being close to each other, and is applicable to more scenarios.

[0166] Considering that crystal oscillators (or crystal oscillators) are installed in Bluetooth devices and electronic devices. Crystal oscillators are used to provide accurate clock signals for devices (including Bluetooth devices and electronic devices). Stable clock signals are used to ensure accurate transmission and processing of data between devices, thereby reducing the power consumption of devices. However, as the device is used for a longer time, the deviation of the device's clock will become larger and larger, and regular calibration or synchronization is required to maintain accuracy.

[0167] Due to the difference between the accuracy of the crystal oscillator installed in the electronic device and the accuracy of the crystal oscillator installed in the Bluetooth device, there is a certain deviation between the clock of the electronic device and the clock of the Bluetooth device. Therefore, after the electronic device and the Bluetooth device establish a Bluetooth connection, they need to maintain time synchronization through regular interaction to ensure that data between the electronic device and the Bluetooth device can be accurately transmitted.

[0168] Optionally, in some embodiments, when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected, the Bluetooth device may generate a preset mapping relationship, so that the Bluetooth device can achieve time synchronization between the Bluetooth device and the electronic device based on the generated preset mapping relationship.

[0169] It should be noted that the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected, which may refer to the Bluetooth connection established between the Bluetooth device and the electronic device for the first time, or any Bluetooth connection established after the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected, and the present application embodiment does not limit this. For example, the specific implementation process of establishing a Bluetooth connection between an electronic device and a Bluetooth device can be referred to. Figure 2 The relevant description is not repeated here.

[0170] Combine the following Figure 8 and Fig. 9 , describes in detail a possible implementation method in which a Bluetooth device generates a preset mapping relationship before determining the first duration in an embodiment of the present application.

[0171] See also Figure 8 , Figure 8 A flowchart of a Bluetooth device generating a preset mapping relationship in an embodiment of the present application is shown.

[0172] like Figure 8 As shown, before determining the first duration, the specific implementation process of the Bluetooth device generating a preset mapping relationship includes:

[0173] S201, obtaining a plurality of first time data pairs.

[0174] Optionally, in some embodiments, each first time data pair includes a fourth moment and a fifth moment. The fourth moment is the time corresponding to the Bluetooth device (or the local time of the Bluetooth device) when the Bluetooth device receives data information (or data packet) from the electronic device. The fifth moment is the time corresponding to the electronic device when the electronic device sends data information.

[0175] Optionally, when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected, the electronic device and the Bluetooth device may periodically exchange data based on the connection period (eg, Figure 3As shown), the Bluetooth device can obtain multiple first time data pairs, providing a data basis for generating a preset mapping relationship.

[0176] For example, Fig. 9 As shown, when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected, the electronic device sends data packet 1 (i.e., the first data packet in connection cycle 1) to the Bluetooth device within connection cycle 1. When data packet 1 is received, the Bluetooth device records and stores time 1 (i.e., the time when the Bluetooth device receives data packet 1) and time 2 (i.e., the time corresponding to the electronic device carried in data packet 1). The electronic device sends data packet 2 (i.e., the first data packet in connection cycle 2) to the Bluetooth device within connection cycle 2. When data packet 2 is received, the Bluetooth device records and stores time 3 (i.e., the time when the Bluetooth device receives data packet 2) and time 4 (i.e., the time corresponding to the electronic device carried in data packet 2). When the Bluetooth device obtains multiple first time data pairs (for example, Fig. 9 After the 10 first time data pairs (time 1 and time 2, time 3 and time 4, time 5 and time 6, and time 19 and time 20) are generated, a data basis can be provided for the Bluetooth device to generate a preset mapping relationship.

[0177] It should be noted that the above description uses the example of a Bluetooth device recording the time of the first data packet in each connection cycle (including the time when the electronic device sends and the time when the Bluetooth device receives). The embodiments of the present application are not limited to this. For example, the Bluetooth device can also record the time of each data packet in each connection cycle as the data basis for the Bluetooth device to generate a preset mapping relationship.

[0178] S202: Generate a preset mapping relationship based on multiple first time data pairs.

[0179] Optionally, in some embodiments, the preset mapping relationship is used to represent the corresponding relationship of the synchronization time between the electronic device and the Bluetooth device.

[0180] Optionally, in some embodiments, the preset mapping relationship is a synchronization time correspondence relationship generated by the Bluetooth device using an average method or a linear regression method.

[0181] After obtaining multiple first time data pairs, the Bluetooth device can generate a preset mapping relationship based on the multiple first time data pairs, that is, based on multiple fourth moments and multiple fifth moments. Exemplarily, the expression of the preset mapping relationship is as follows:

[0182] y = f(x);

[0183] Wherein, x is used to represent the time of the Bluetooth device, and y represents the time of the electronic device predicted by the Bluetooth device.

[0184] Assume that x is used to represent the fourth moment and y is used to represent the fifth moment. Fig. 9 The obtained 10 first time data pairs are shown in Table 1 below.

[0185]

[0186] Table 1

[0187] Optionally, in some embodiments, when the Bluetooth device uses the average method to generate a preset mapping relationship, the Bluetooth device can calculate multiple time differences between the electronic device and the Bluetooth device based on multiple fourth moments and multiple fifth moments. After determining the multiple time differences between the electronic device and the Bluetooth device, the Bluetooth device can calculate multiple time differences per unit time (for example, 10ms) based on the multiple time differences between the electronic device and the Bluetooth device. After obtaining the multiple time differences per unit time, the average value of the multiple time differences per unit time can be calculated. When the Bluetooth device disconnects the Bluetooth connection with the electronic device, the Bluetooth device can use the average value of the time difference per unit time as the preset mapping relationship to achieve time synchronization between the Bluetooth device and the electronic device.

[0188] Exemplarily, when the Bluetooth device uses the 10 fourth moments and 10 fifth moments in Table 1 above to generate a preset mapping relationship, the multiple time differences between the electronic device and the Bluetooth device and the time difference per unit time are obtained as shown in Table 2 below.

[0189]

[0190] Table 2

[0191] Based on the data in Table 2, it can be obtained that the average value of the time difference within every 10ms is 5us. That is to say, within every 10ms of the electronic device, the time deviation added by the Bluetooth device is 5us. For example, when the Bluetooth device disconnects the Bluetooth connection with the electronic device, and the disconnection duration is 1000ms, the time that the Bluetooth device needs to compensate is 500us, calculated based on the average value of the time difference within every 10ms. If the current time of the Bluetooth device is 999500us, then the Bluetooth device can predict that the current corresponding time of the electronic device is 999500+500=1000000us.

[0192] Optionally, in some embodiments, when the Bluetooth device uses a linear regression method to generate a preset mapping relationship, the Bluetooth device may calculate the average values ​​of multiple fourth moments and the average values ​​of multiple fifth moments. After obtaining the average values ​​of multiple fourth moments and the average values ​​of multiple fifth moments, the Bluetooth device may calculate the correlation coefficient in the linear regression method by the least square method based on the average values ​​of multiple fourth moments and the average values ​​of multiple fifth moments. After obtaining the correlation coefficient in the linear regression method, the Bluetooth device may obtain the preset mapping relationship.

[0193] Exemplarily, the expression of the preset mapping relationship is as follows:

[0194] ;

[0195] ;

[0196] ;

[0197] in, Used to indicate the fifth moment, represents the fourth moment, represents the average value of the fourth moment, represents the average value at the fifth moment, i is a positive integer greater than or equal to 1 and less than or equal to n, n=10.

[0198] When the Bluetooth device generates the preset mapping relationship using the 10 fourth moments and the 10 fifth moments in Table 1 above, the average value of the fourth moment is 49975.333333333336us, and the average value of the fifth moment is 50000us. The coefficient a is calculated to be a=1.0005060522243923, and the parameter b=-0.6234619314127485.

[0199] When the current time of the Bluetooth device is 999500us, the Bluetooth device can predict that the current corresponding time of the electronic device is 1000005.1757363487us. 999500*a+b=999500 * 1.0005060522243923 -0.6234619314127485 = 1000005.1757363487us.

[0200] It should be noted that Fig. 9 Only 10 first time data pairs are taken as an example for illustrative explanation. In actual applications, the number of first time data pairs can be more (for example, 100). The more first time data pairs there are, the more accurate the preset mapping relationship generated by the Bluetooth device is, and the more accurate the time of the electronic device predicted by the Bluetooth device based on the preset mapping relationship is.

[0201] Optionally, in some embodiments, after generating the preset mapping relationship, the Bluetooth device may store the generated preset mapping relationship in the memory of the Bluetooth device, so that the Bluetooth device can compensate for the time difference between the Bluetooth device and the electronic device based on the stored preset mapping relationship.

[0202] It should be noted that, when the Bluetooth device has stored a preset mapping relationship, if the Bluetooth device enters low-power mode, or the communication distance between the Bluetooth device and the electronic device exceeds the communication distance of the Bluetooth connection (for example, Bluetooth low-power connection), the Bluetooth device can be based on the stored preset mapping relationship to synchronize the time of the Bluetooth device and the electronic device for a certain period of time (for example, 24 hours). In addition, when the Bluetooth device is completely powered off, the Bluetooth device cannot continue to synchronize the time between the Bluetooth device and the electronic device based on the preset mapping relationship. Moreover, due to the limitation of the accuracy of the Bluetooth device's prediction, when the Bluetooth connection between the Bluetooth device and the electronic device is disconnected for too long (for example, 48 hours), the Bluetooth device cannot accurately predict the time of the electronic device based on the time of the Bluetooth device and the preset mapping relationship.

[0203] Based on the above description, when a Bluetooth device re-establishes a Bluetooth connection with an electronic device (for example, the Bluetooth device starts reconnecting after waking up from a power-saving sleep state or the Bluetooth device starts reconnecting after the Bluetooth connection between the Bluetooth device and the electronic device is disconnected), the Bluetooth device can ensure time synchronization between the Bluetooth device and the electronic device based on the stored preset mapping relationship, thereby ensuring the accuracy of data transmitted between the Bluetooth device and the electronic device.

[0204] Before executing S103, the Bluetooth device may determine the first duration. In the embodiment of the present application, the Bluetooth device may determine the first duration in a variety of possible implementations. A possible implementation of the Bluetooth device determining the first duration is described in detail below.

[0205] Optionally, in some embodiments, the Bluetooth device can determine the third time based on the second time and the preset mapping relationship stored in the Bluetooth device. In this way, when the Bluetooth device disconnects the Bluetooth connection with the electronic device, the time corresponding to the electronic device when the Bluetooth device starts to reconnect can be accurately predicted, ensuring that the time of the Bluetooth device and the electronic device remains synchronized, and preparing for the subsequent re-establishment of the Bluetooth connection between the Bluetooth device and the electronic device.

[0206] Optionally, in some embodiments, the second time is the time when the Bluetooth device starts the back connection. The third time is the time corresponding to the electronic device predicted by the Bluetooth device when the Bluetooth device starts the back connection.

[0207] Optionally, in some embodiments, after obtaining the third moment, the Bluetooth device may determine the starting moment for the electronic device to perform signal scanning based on the third moment and the first scanning cycle.

[0208] Optionally, in another embodiment, the Bluetooth device may determine the termination time of the electronic device performing the signal scanning based on the third time, the first scanning cycle and the scanning window.

[0209] Optionally, in some embodiments, the first scanning period and the scanning window are both time values ​​pre-set in the electronic device. The first scanning period and the scanning window are both sent by the electronic device to the Bluetooth device through a custom Bluetooth service in the electronic device when the Bluetooth connection (e.g., the first Bluetooth connection) between the Bluetooth device and the electronic device is not disconnected. After the electronic device sends the first scanning period and the scanning window through the custom Bluetooth service, the Bluetooth device can receive them through the custom Bluetooth service in the Bluetooth device. The custom Bluetooth service is a data service in a configuration file pre-stored in a device (e.g., an electronic device or a Bluetooth device).

[0210] It should also be noted that in addition to the first scanning cycle and the scanning window, the electronic device can also send the start time and end time of the electronic device scanning to the Bluetooth device through the custom Bluetooth service in the electronic device, and the embodiments of the present application are not limited to this.

[0211] After determining the start time and the end time of the electronic device performing the signal scan, the Bluetooth device can determine the first duration (i.e., the time interval between the start time and the end time of the electronic device performing the signal scan) based on the start time and the end time of the electronic device performing the signal scan.

[0212] In summary, the Bluetooth device obtains the time range, i.e., the first duration, during which the Bluetooth device sends the broadcast signal through the first broadcast channel. By determining the first duration in advance, the Bluetooth device can ensure that when the Bluetooth device sends the broadcast signal through the first broadcast channel at the first moment, the electronic device is performing a signal scanning operation, thereby eliminating the influence of random factors and speeding up the speed at which the Bluetooth device reestablishes the Bluetooth connection with the electronic device.

[0213] Before executing S103, the Bluetooth device may also determine the first broadcast channel. In the embodiment of the present application, the Bluetooth device may determine the first broadcast channel in a variety of possible implementations. A possible implementation of the Bluetooth device determining the first broadcast channel is described in detail below.

[0214] Optionally, in some embodiments, when the Bluetooth connection between the electronic device and the Bluetooth device is not disconnected, the Bluetooth device may obtain the first numerical value and the first algorithm pre-stored in the electronic device through a custom Bluetooth service.

[0215] Optionally, the first value is an initial value (or seed) used by the electronic device to determine the first broadcast channel. The first value is equivalent to the initial random number mentioned above. Exemplarily, the first value is 1.

[0216] Optionally, the first algorithm is a pseudo-random algorithm used by the electronic device to determine the first broadcast channel. Exemplarily, the pseudo-random algorithm may use a linear congruential generator (LCG) or a square midpoint method.

[0217] After acquiring the first value and the first algorithm, the Bluetooth device can store the first value and the first algorithm in the memory of the Bluetooth device, so that when the Bluetooth device re-establishes the Bluetooth connection with the electronic device, the Bluetooth device can determine the first broadcast channel based on the stored first value and the first algorithm.

[0218] Exemplarily, when the first value is 1 and the first algorithm is the linear congruential method, the expression for calculating the pseudo-random number is as follows:

[0219] ;

[0220] in, Represents the next pseudo-random number, It means the first value and mod means remainder.

[0221] exist =1, =65539. =65539, we get =393225. ==393225, get =1769499. Repeating the calculation multiple times can produce a pseudo-random number sequence.

[0222] Assume that the range of the pseudo-random number set in the electronic device is 0-5. Pseudo-random number 0 indicates that the electronic device scans the broadcast channels in the order of channel number 37, channel number 38, and channel number 39. Pseudo-random number 1 indicates that the electronic device scans the broadcast channels in the order of channel number 37, channel number 39, and channel number 38. Pseudo-random number 2 indicates that the electronic device scans the broadcast channels in the order of channel number 38, channel number 39, and channel number 37. Pseudo-random number 3 indicates that the electronic device scans the broadcast channels in the order of channel number 38, channel number 37, and channel number 39. Pseudo-random number 4 indicates that the electronic device scans the broadcast channels in the order of channel number 39, channel number 38, and channel number 37. Pseudo-random number 5 indicates that the electronic device scans the broadcast channels in the order of channel number 39, channel number 37, and channel number 38.

[0223] After obtaining the pseudo-random number sequence, the Bluetooth device may further perform modulo on multiple pseudo-random numbers in the pseudo-random number sequence to obtain multiple pseudo-random numbers that meet the range of pseudo-random numbers set in the electronic device. Exemplarily, when the pseudo-random number is 65539, the Bluetooth device may perform modulo on 65539, 65539 mod 6=1, at which point the Bluetooth device may determine that the order in which the electronic device scans the broadcast channels is channel numbered 37, channel numbered 39, and channel numbered 38. Alternatively, when the pseudo-random number is 393225, the Bluetooth device may perform modulo on 393225, 393225 mod 6=3, at which point the Bluetooth device may determine that the order in which the electronic device scans the broadcast channels is channel numbered 38, channel numbered 37, and channel numbered 39.

[0224] In summary, when the Bluetooth device starts the reconnection, it can predict the order in which the electronic device scans the broadcast channels based on the first value and the first algorithm stored in the Bluetooth device. In addition, based on the start time of the electronic device scanning, the first scanning cycle (or scanning cycle) and the first duration (or scanning window) stored in the Bluetooth device, the Bluetooth device can predict the time when the electronic device performs the signal scan next time, so that the Bluetooth device can send a broadcast signal to the broadcast channel scanned by the electronic device in a direction within the scanning window closest to the Bluetooth device initiating the reconnection. This can eliminate the influence of the uncertainty time caused by the random selection of the broadcast channel by the Bluetooth device and the random selection of the scanned channel by the electronic device, so that the Bluetooth device can quickly and accurately complete the reconnection with the electronic device, thereby improving the user experience.

[0225] Considering that in actual applications, in order to save power consumption of the electronic device, the duration of the first scanning cycle pre-set in the electronic device may be relatively long, that is, the scanning frequency of the electronic device is relatively low. Therefore, when the electronic device is disconnected from the Bluetooth device, the electronic device scans the broadcast channel based on the first scanning cycle, and there will be a problem of a relatively long reconnection delay and a slow reconnection speed between the electronic device and the Bluetooth device due to the low scanning frequency.

[0226] Optionally, in some embodiments, when the electronic device disconnects the Bluetooth connection with the Bluetooth device, the electronic device may adjust the first scanning period to a smaller second scanning period to increase the scanning frequency of the electronic device, further reduce the delay in the Bluetooth device reconnecting, speed up the re-establishment of the Bluetooth low-power connection between the electronic device and the Bluetooth device, and further shorten the user's waiting time.

[0227] Optionally, in some embodiments, the duration corresponding to the second scanning cycle is shorter than the duration corresponding to the first scanning cycle.

[0228] After adjusting the first scanning cycle to the second scanning cycle, the electronic device can scan the first broadcast channel within the second duration based on the second scanning cycle, thereby increasing the scanning frequency of the electronic device, thereby ensuring that after the Bluetooth device initiates a backlink, the electronic device can more quickly scan the directional broadcast signal sent by the Bluetooth device through the first broadcast channel, thereby avoiding the user waiting too long.

[0229] Optionally, in some embodiments, the second duration is the duration of the electronic device performing signal scanning on the first broadcast channel in the second scanning cycle. The second duration is less than or equal to the duration corresponding to the second scanning cycle.

[0230] Optionally, in some embodiments, the ratio of the second duration to the duration corresponding to the second scanning cycle is equal to the ratio of the first duration to the duration corresponding to the first scanning cycle. In other words, the average scanning time of the electronic device before and after adjusting the scanning cycle remains unchanged, thereby ensuring that the electronic device does not increase additional power consumption after adjusting the scanning cycle, and avoiding the problem of increased power consumption of the electronic device scanning due to the high proportion of the second duration in the second scanning cycle.

[0231] Optionally, in some embodiments, the second duration is shorter than the first duration. Since the time of the Bluetooth device is synchronized with the time of the electronic device, the electronic device does not need to perform a long scanning time when the Bluetooth device reconnects, and the signal scanning is performed within the shorter second duration, which can also ensure that the Bluetooth connection between the Bluetooth device and the electronic device is successfully reestablished.

[0232] like Fig.10As shown, when the Bluetooth device starts to connect back, the electronic device uses the first scanning cycle and the first duration to scan the broadcast channel. At this time, since the time when the Bluetooth device starts to connect back is the time when the electronic device does not perform signal scanning, the Bluetooth device cannot immediately send a broadcast signal through a specific broadcast channel, but needs to wait for the end of the current first scanning cycle, and in the next first scanning cycle closest to the current first scanning cycle, the electronic device starts scanning at the time when the electronic device scans the channel (such as Fig.10 The electronic device sends a directional broadcast signal on the channel numbered 39, so that the electronic device can scan the broadcast signal on the channel numbered 39, preparing for the electronic device to re-establish a Bluetooth connection with the Bluetooth device.

[0233] like Fig.10 As shown, when the Bluetooth device starts to connect back, the electronic device uses the second scanning period and the second duration to scan the broadcast channel. At this time, since the scanning frequency of the electronic device is accelerated, the time when the Bluetooth device starts to connect back is the time when the electronic device performs signal scanning. Therefore, the Bluetooth device can directly connect to the channel scanned by the electronic device (such as Fig.10 39 as shown) sends a directional broadcast signal without waiting for the current second scanning cycle to end, so that the electronic device can scan the broadcast signal in the channel numbered 39 more quickly, preparing for the electronic device to quickly re-establish the Bluetooth connection with the Bluetooth device.

[0234] In summary, by adjusting the first scanning cycle to a second scanning cycle with a shorter duration, the electronic device can increase the scanning frequency of the electronic device, thereby reducing the delay when the Bluetooth device reconnects, speeding up the speed of re-establishing the Bluetooth connection between the electronic device and the Bluetooth device, and further improving the user experience.

[0235] It should be noted that Fig.10 The figure is only for intuitively showing the influence of the scanning frequency of the electronic device on the connection method for the device in the embodiment of the present application after the scanning frequency of the electronic device is increased. The specific process of the Bluetooth device and the electronic device in re-establishing the Bluetooth connection (for example, the Bluetooth device sends a broadcast signal through the channel numbered 39, and the electronic device sends a connection request to the Bluetooth device through the channel numbered 39 after scanning the broadcast signal, etc.) can be seen in Figure 7 The relevant description is not repeated here.

[0236] It should also be noted that Fig.10 The order of channels scanned by the electronic device shown is for exemplary purposes only, and the embodiments of the present application are not limited thereto. For example, the order of channels scanned by the electronic device may also be channel numbered 38, channel numbered 37, and channel numbered 39.

[0237] Optionally, in some embodiments, after the Bluetooth device successfully re-establishes the Bluetooth connection with the electronic device, the Bluetooth device may adjust the second scanning period to the first scanning period, thereby saving energy consumption of the electronic device by reducing the scanning frequency of the electronic device.

[0238] The above describes in detail the connection method for a device applied to the Bluetooth connection system. The following describes the software system of the Bluetooth device 300 and the software system of the electronic device 200 in the Bluetooth connection system. The software system may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture or a cloud architecture. The embodiment of the present application takes the layered architecture as an example to exemplarily describe the software system of the Bluetooth device 300 and the software system of the electronic device 200.

[0239] See also Fig.11 , Fig.11 A schematic diagram of a software system of a Bluetooth device and a software system of an electronic device provided in an embodiment of the present application is shown.

[0240] The software system of the Bluetooth device 300 can be divided into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, Fig.11 As shown, the software system of the Bluetooth device 300 is composed of an application layer (APP), a service layer (service layer), a protocol layer (protocol layer) and a driver layer (driver) from top to bottom.

[0241] The application layer may include applications such as Bluetooth applications. Bluetooth applications may include profiles, etc. Profiles are used to provide Bluetooth standard services and customized Bluetooth services for Bluetooth applications.

[0242] Optionally, in some embodiments, the service layer may include an application programming interface. The application layer can call the application programming interface in the service layer to implement the functions of the application layer (eg, audio processing and call control, etc.).

[0243] Optionally, in another embodiment, the service layer may further include discovery and pairing logic. The discovery and pairing logic is used to establish a Bluetooth connection with other Bluetooth devices (eg, the electronic device 200).

[0244] Optionally, in some embodiments, the protocol layer is used to provide various protocols defined in the Bluetooth standard. The protocol layer may include a Bluetooth low energy protocol and / or a classic Bluetooth protocol.

[0245] It should be noted that the device connection method in the embodiment of the present application does not modify the protocol layer, and therefore can be generally applicable to different Bluetooth devices and has better compatibility.

[0246] Optionally, in another embodiment, the protocol layer is also used to manage communications between devices (eg, the Bluetooth device 300 and the electronic device 200 ) (eg, transmission of data packets, establishment and maintenance of Bluetooth connections, etc.).

[0247] The driver layer is an abstract layer between hardware and software. The driver layer can include Bluetooth driver, audio driver, sensor driver, etc.

[0248] Optionally, the Bluetooth driver is used to ensure that the Bluetooth device 300 can identify and use the Bluetooth chip, and provide an application program interface to other Bluetooth devices (eg, the electronic device 200 ) so that the electronic device 200 and the Bluetooth device 300 can send and receive data via Bluetooth.

[0249] Optionally, the audio driver is used to process the input and output of audio data and add sound effects such as mixing to the audio data.

[0250] Optionally, the sensor driver is used to collect sensor data and provide the data to a corresponding application in the application layer.

[0251] It should be understood that Fig.11 The layered architecture of the software system of the Bluetooth device 300 shown is only for exemplary purposes, and the embodiments of the present application are not limited thereto. In another embodiment of the present application, the software system of the Bluetooth device 300 may include: Fig.11 The layered architecture shown in the figure may be more or less than the architecture shown. For example, the software system of the Bluetooth device 300 may also include an operating system layer and a power management layer. Alternatively, each layer of the software system of the Bluetooth device 300 may include more than Fig.11 The structure shown may include more or fewer structures. For example, the driver layer may also include a driver for an audio codec.

[0252] like Fig.11 As shown, the software system in the electronic device 200 can be divided into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, Fig.11As shown, the software system of the electronic device 200 is respectively an application layer (application, APP), an application framework layer (applicationframework), a hardware abstraction layer (hardware abstraction layer, HAL) and a driver layer (driver) from top to bottom.

[0253] The application layer may include multiple applications. For example, the multiple applications may be a Bluetooth application, a setting application, a calendar application, a music application, etc. It is understood that the multiple applications in the application layer may be third-party applications installed by the user or system applications.

[0254] The application framework layer is a framework layer used to support the operation of multiple applications in the application layer. The application framework layer includes standard Android application programming interface (API) and Bluetooth application programming interface (Bluetooth framework API), etc. Multiple interfaces can be called by multiple applications in the application layer.

[0255] It should be noted that the application framework layer may also include core services, etc. Core services are used to provide core functions of the software system (for example, data storage, etc.).

[0256] The language used in the hardware abstraction layer is a language used to define the hardware abstraction layer interface (HALinterface definition language, HIDL). The language in the hardware abstraction layer is used to describe the interface and functions of the hardware components. The HIDL framework is the HAL framework provided by native Android.

[0257] The hardware abstraction layer includes a native Bluetooth interface and an extended driver interface. For example, the native Bluetooth interface may include a Bluetooth interface defined in a language of the hardware abstraction layer interface (bluetooth HIDL interface), etc. The extended driver interface may include an operation driver interface (vendor HAL) provided by a Bluetooth chip manufacturer, etc.

[0258] like Fig.11 As shown in Figure 1, the driver layer is an abstract layer between hardware and software. The driver layer includes Fig.11 The Bluetooth driver, hardware interface driver, audio driver, sensor driver, etc. are shown.

[0259] Optionally, the Bluetooth driver is used to ensure that the electronic device 200 can identify and use the Bluetooth chip, and provide an application program interface to other Bluetooth devices (eg, the Bluetooth device 300 ), so that the electronic device 200 and the Bluetooth device 300 can send and receive data via Bluetooth.

[0260] Optionally, the hardware interface driver includes a hardware connection driver between the Bluetooth chip and the processor. Specifically, the hardware interface driver can be a universal serial bus (USB) interface driver. Alternatively, the hardware interface driver can also be a universal asynchronous receiver / transmitter (UART) interface driver. Thus, the electronic device 200 can be connected to the corresponding hardware through different hardware driver interfaces.

[0261] It should be noted that the functions implemented by the audio driver and sensor driver in the driver layer of the electronic device 200 are the same as those implemented by the audio driver and sensor driver in the driver layer of the Bluetooth device 300. Please refer to the relevant description above and no further details will be given here.

[0262] It should be understood that Fig.11 The hierarchical structure shown does not constitute a specific limitation on the software system of the electronic device 200. In other embodiments of the present application, the software system of the electronic device 200 may include: Fig.11 The layered architecture shown may be more or less than the architecture shown. For example, the software system of the electronic device 200 may also include a hardware layer (hardware), etc. The hardware layer is used to define the connection hardware between the Bluetooth chip and the Bluetooth and the processor. Alternatively, each layer of the software system of the electronic device 200 may include more than Fig.11 The component structures shown may be more or less structures, and the embodiments of the present application are not limited thereto.

[0263] like Fig.11 As shown, after the Bluetooth device 300 and the electronic device 200 successfully establish a Bluetooth connection (eg, a Bluetooth connection established for the first time), the Bluetooth device 300 and the electronic device 200 may perform wireless communication based on the Bluetooth protocol stack through their respective Bluetooth applications.

[0264] Optionally, in some embodiments, after the Bluetooth device 300 successfully establishes a Bluetooth connection with the electronic device 200, the Bluetooth device 300 and the electronic device 200 may perform time synchronization and generate a preset mapping relationship.

[0265] Optionally, in another embodiment, after the Bluetooth device 300 successfully establishes a Bluetooth connection with the electronic device 200, the Bluetooth device 300 can obtain the first algorithm and the first value pre-stored in the electronic device 200 through a custom Bluetooth service, and obtain the first scanning cycle (or scanning cycle), the first duration (or scanning window), and the time to start scanning of the electronic device 200. This can provide a data basis for predicting the time when the electronic device 200 starts scanning next time and the channel to be scanned when the Bluetooth device 300 starts reconnecting.

[0266] Optionally, the layered structure of the Bluetooth protocol stack can ensure that devices (eg, the electronic device 200 and the Bluetooth device 300 ) communicate with each other in a standardized manner, thereby achieving interoperability between devices from different manufacturers.

[0267] like Fig.12 As shown in the figure, the Bluetooth protocol stack is composed of the profile layer, host layer and controller layer from top to bottom.

[0268] Optionally, in some embodiments, the profile layer may include Bluetooth standard services, custom Bluetooth services, battery, and media control. The battery is used to manage the power consumption of devices (e.g., the electronic device 200 and the Bluetooth device 300). The media control is used to manage the transmission of audio or video.

[0269] Optionally, in another embodiment, the profile layer may further include operations of the Bluetooth device in specific applications, such as heart rate monitoring, location services, and phone alerts.

[0270] The host layer may include generic attribute profile (GATT), generic access profile (GAP), attribute protocol (ATT), secure manager protocol (SMP) and logic link control and adaptation protocol (L2CAP), etc.

[0271] Optionally, the common attribute profile is used to define the functions and characteristics of the device. The common attribute profile is used to standardize the data in the attributes of Bluetooth, and by standardizing the data in the attributes of Bluetooth, Bluetooth devices can be compatible with each other.

[0272] Optionally, the Generic Access Profile is used to control the controller layer before a Bluetooth connection is established between Bluetooth devices. The Generic Access Profile defines how to broadcast, scan, and establish a Bluetooth connection, etc.

[0273] Optionally, the attribute protocol defines user commands and the data on which the commands operate.

[0274] Optionally, the security management protocol is used to manage security authentication and key exchange between devices to ensure encryption and security of the Bluetooth connection.

[0275] Optionally, the logical link control and adaptation protocol is used to distinguish between encrypted and non-encrypted connections, manage the connection cycle of the device, etc.

[0276] The controller layer is used to manage the basic operations of the device, such as frequency hopping and power control. The controller layer may include the host controller interface (HCI), link layer (LL) and physical layer (PHY).

[0277] Optionally, the physical layer is used to transmit and receive radio signals. The link layer is responsible for the Bluetooth connection between two devices, including authentication and encryption of the link. The link layer is also used to transfer data between two devices. The link layer is used to provide more efficient data transmission and lower energy consumption. The host controller interface is the interface between the physical layer and the link layer, which is used to transfer data.

[0278] The connection method for devices in the embodiment of the present application occurs in the application layer of the Bluetooth device and the application layer of the electronic device. When the Bluetooth device starts to connect back, the Bluetooth device can use the scanning start time, scanning cycle, scanning window, pseudo-random algorithm and initial value of the electronic device obtained in advance by the custom Bluetooth service to predict the subsequent start scanning time of the electronic device and the scanned channel. After obtaining the subsequent start scanning time and the scanned channel of the electronic device, the Bluetooth device can send a directional broadcast signal through a specific broadcast channel (for example, the first broadcast channel) at a specific time (for example, the first moment), avoiding the connection delay caused by the random selection of the broadcast channel by the Bluetooth device and the random selection of the scanned channel by the electronic device, so that the connection speed between the Bluetooth device and the electronic device is faster, the user waiting time is shorter, and the user experience is greatly improved.

[0279] The above describes in detail the device connection method applied to the Bluetooth connection system, as well as the software system of the Bluetooth device 300 and the software system of the electronic device 200 in the Bluetooth connection system. The following introduces the hardware system of the electronic device 200 and the hardware system of the Bluetooth device 300.

[0280] See also Fig.13 , Fig.13 A hardware system schematic diagram of an electronic device provided in an embodiment of the present application is shown.

[0281] like Fig.13 As shown, the electronic device 200 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface, namely a USB interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface, namely a SIM card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L and a bone conduction sensor 180M, etc.

[0282] It should be noted that Fig.13 The structure shown does not constitute a specific limitation on the hardware system of the electronic device 200. In other embodiments of the present application, the hardware system of the electronic device 200 may include: Fig.13 The components shown are more or less than the components shown, or the hardware system of the electronic device 200 may include Fig.13 A combination of some of the components shown, or a hardware system of the electronic device 200 may include Fig.13 Subcomponents of some of the components shown. For example, Fig.13 The illustrated proximity light sensor 180G may be optional. Fig.13 The components shown may be implemented in hardware, software, or a combination of software and hardware.

[0283] The processor 110 may include one or more processing units. For example, the processor 110 may include at least one of the following processing units: an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and a neural-network processing unit (NPU). Different processing units may be independent devices or integrated devices.

[0284] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0285] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0286] Fig.13 The connection relationship between the modules shown is only a schematic illustration and does not constitute a limitation on the connection relationship between the modules of the electronic device 200. Optionally, the modules of the electronic device 200 may also adopt a combination of multiple connection modes in the above embodiments.

[0287] The wireless communication module 160 can provide wireless communication solutions including wireless local area network (for example, wireless fidelity (Wi-Fi) network), Bluetooth, global navigation satellite system (GNSS), frequency modulation (FM), nearfield communication (NFC), infrared (IR), etc., which are applied to the electronic device 200. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0288] The electronic device 200 can implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information. The display screen 194 can be used to display images or videos. In some embodiments, the unfolded state of the display screen 194 can be as follows: Figure 4 The interface of the electronic device 200 is shown in FIG.

[0289] Optionally, in some embodiments, the processor 110 is used to scan the first broadcast channel within the first duration based on the first scanning cycle when the electronic device 200 is disconnected from the Bluetooth device 300, and further, in the case of scanning the broadcast signal sent by the Bluetooth device 300 on the first broadcast channel, send a connection request to the Bluetooth device 300, and then, after determining that the Bluetooth device 300 has received the connection request, re-establish the Bluetooth connection with the Bluetooth device 300. This ensures that the electronic device 200 can quickly receive the directional broadcast signal sent by the Bluetooth device 300 through the first broadcast channel, eliminates the influence of the electronic device 200 randomly selecting the scanned channel, speeds up the reconnection speed between the Bluetooth device 300 and the electronic device 200, reduces the waiting time of the user, and improves the user experience.

[0290] See also Fig.14 , Fig.14 A hardware system schematic diagram of a Bluetooth device provided in an embodiment of the present application is shown.

[0291] like Fig.14As shown, the Bluetooth device 300 of the embodiment of the present application may include: a processor 301, a memory 302, a communication interface 303, a bus 304 and a Bluetooth chip 305. The processor 301, the memory 302 and the communication interface 303 communicate through the bus 304, and can also communicate through the wireless transmission of the Bluetooth chip 305. The memory 302 is used to store instructions, and the processor 301 is used to execute the instructions stored in the memory 302. The memory 302 stores program codes, and the processor 301 can call the program codes stored in the memory 302 to execute Figure 6 A connection method for devices on the Bluetooth device 300 side shown in FIG.

[0292] It should be noted that Fig.14 The Bluetooth chip 305 is independently provided in the Bluetooth device 300 for illustration, but the embodiments of the present application are not limited thereto. For example, the Bluetooth chip 305 can also be integrated into the processor 301 in the form of a software algorithm or a software module.

[0293] Optionally, in some embodiments, the processor 301 is used to send a broadcast signal through a predetermined first broadcast channel at a predetermined first moment when the Bluetooth device 300 is disconnected from the electronic device 200, and further receive a connection request from the electronic device through the first broadcast channel, and then re-establish a Bluetooth connection with the electronic device based on the connection request. This can eliminate the randomness of the broadcast cycle of the Bluetooth device during the reconnection process between the Bluetooth device and the electronic device and the influence of the random selection of the broadcast channel by the Bluetooth device, speed up the reconnection speed between the Bluetooth device and the electronic device, and greatly improve the user experience.

[0294] It should be understood that in the embodiment of the present application, the processor 301 may be a CPU, and the processor 301 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.

[0295] The memory 302 may include a read-only memory and a random access memory, and provides instructions and data to the processor 301. The memory 302 may also include a nonvolatile random access memory. The memory 302 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.

[0296] Optionally, in some embodiments, the memory 302 is used to store a preset mapping relationship, a first value, a first algorithm, etc.

[0297] Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache.

[0298] By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data date SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM), and direct rambus RAM (direct rambus RAM, DR RAM).

[0299] In addition to the data bus, the bus 304 may also include a power bus, a control bus, and a status signal bus. Fig.14 Various buses are labeled as bus 304.

[0300] It is understandable that the structure of the above-mentioned Bluetooth device 300 is only for exemplary purposes. The Bluetooth device 300 of the embodiment of the present application may also include other hardware in addition to the processor 301, the memory 302, the communication interface 303 and the bus 304, and the embodiment of the present application does not limit this.

[0301] Exemplarily, the present application provides a computer-readable storage medium, the computer-readable storage medium including instructions, when the instructions are executed on a Bluetooth device, the Bluetooth device executes the following Figure 6 or, when the instruction is executed on the electronic device, the electronic device is caused to execute the following Figure 6 The connection method for the device on the electronic device side shown in .

[0302] Exemplarily, the present application provides a chip system, which is applied to a Bluetooth device or an electronic device; the chip system includes one or more processors; the one or more processors are used to call computer instructions to enable the Bluetooth device to execute the following steps: Figure 6 The method for connecting a device on the Bluetooth device side shown in ; or, one or more processors are used to call computer instructions to enable the electronic device to execute the following Figure 6 The connection method for the device on the electronic device side shown in .

[0303] Exemplarily, the present application provides a computer program product, which, when executed on a computer, enables a Bluetooth device to execute the following Figure 6 The method for connecting a device on the Bluetooth device side shown in the figure, or, when the computer program product is run on a computer, the electronic device executes the following Figure 6 The connection method for the device on the electronic device side shown in .

[0304] It should be noted that the minimum unit that can be implemented by the device connection method in the embodiment of the present application is a Bluetooth chip, which can be integrated in a device that supports the Bluetooth protocol (for example, Fig.14 In the Bluetooth device shown in the figure), it can also be set independently, and the embodiments of the present application are not limited to this.

[0305] In the above embodiments, all or part of the functions can be implemented by software, hardware, or a combination of software and hardware. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer codes or instructions. When the computer program code or instructions are loaded and executed on the computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer code or instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be accessed by the computer or a data storage device such as a server or a data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0306] A person skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

Claims

1. A method for connecting a device, characterized in that: The method is applied to a Bluetooth device, a Bluetooth connection is established between the Bluetooth device and an electronic device, and the method includes: In the case where the Bluetooth device and the electronic device are disconnected from the Bluetooth connection, starting a reconnection, wherein the reconnection refers to reestablishing the Bluetooth connection; A broadcast signal is sent through a first broadcast channel at a first moment; the first moment is any moment in a first duration; the first duration is the duration of the electronic device performing signal scanning on the first broadcast channel in a first scanning cycle; the first duration is the duration predicted by the Bluetooth device based on the synchronization time and the scanning cycle of the electronic device before sending the broadcast signal; the first broadcast channel is the channel predicted by the Bluetooth device to be scanned by the electronic device before sending the broadcast signal; receiving a connection request from the electronic device through the first broadcast channel, wherein the connection request is sent by the electronic device when scanning the broadcast signal sent by the Bluetooth device; Based on the connection request, the Bluetooth connection is re-established with the electronic device.

2. The method according to claim 1, characterized in that Before sending the broadcast signal through the first broadcast channel at the first moment, the method further includes: Determine the first duration; the first duration refers to the time interval between the start time when the electronic device performs signal scanning and the end time when the electronic device performs signal scanning; the first duration is less than or equal to the duration corresponding to the first scanning cycle.

3. The method according to claim 2, characterized in that The determining the first duration includes: Determine a third moment based on the second moment and the preset mapping relationship; the second moment is the time when the Bluetooth device starts the backconnection; the preset mapping relationship is used to represent the corresponding relationship of synchronization time between the electronic device and the Bluetooth device; the third moment is the time corresponding to the electronic device when the Bluetooth device starts the backconnection; Determining the starting time based on the third time and the first scanning period; Determining the termination time based on the third time, the first scanning period and the scanning window; The first duration is determined based on the start time and the end time.

4. The method according to claim 1, characterized in that: Before sending the broadcast signal through the first broadcast channel at the first moment, the method further includes: The first broadcast channel is determined.

5. The method according to claim 4, characterized in that The determining the first broadcast channel includes: The first broadcast channel is determined based on a first value and a first algorithm; the first value is an initial value used by the electronic device to determine the first broadcast channel; the first algorithm is a pseudo-random algorithm used by the electronic device to determine the first broadcast channel.

6. The method according to claim 3, characterized in that Before determining the first duration, the method further includes: Acquire multiple first time data pairs; each of the first time data pairs includes a fourth moment and a fifth moment; the fourth moment is the time corresponding to the Bluetooth device when the Bluetooth device receives data information from the electronic device; the fifth moment is the time corresponding to the electronic device when the electronic device sends the data information; the multiple first time data pairs are acquired when the Bluetooth connection between the Bluetooth device and the electronic device is not disconnected; The preset mapping relationship is generated based on the multiple first time data pairs.

7. The method according to claim 6, characterized in that The preset mapping relationship is generated by the Bluetooth device using an average method or a linear regression method.

8. The method according to any one of claims 1 to 7, characterized in that The broadcast signal includes one or more of the following: a name of the Bluetooth device, an address of the Bluetooth device, a name of the electronic device, and an address of the electronic device.

9. The method according to any one of claims 1 to 7, characterized in that The type of the Bluetooth connection is a Bluetooth low energy connection, and the reconnection refers to re-establishing the Bluetooth low energy connection.

10. A method for connecting a device, characterized in that: The method is applied to an electronic device, a Bluetooth connection is established between the electronic device and a Bluetooth device, and the method includes: When the electronic device disconnects the Bluetooth connection with the Bluetooth device, based on a first scanning cycle, scans a first broadcast channel within a first duration; the first duration is a duration during which the electronic device performs signal scanning on the first broadcast channel in the first scanning cycle; In the case where a broadcast signal sent by the Bluetooth device is scanned on the first broadcast channel, a connection request is sent to the Bluetooth device; the broadcast signal is sent by the Bluetooth device through the first broadcast channel at a first moment; the first moment is any moment in the first time period; the first time period is a time period predicted by the Bluetooth device based on the synchronization time and the scanning cycle of the electronic device before sending the broadcast signal; the first broadcast channel is a channel predicted by the Bluetooth device to be scanned by the electronic device before sending the broadcast signal; Re-establish the Bluetooth connection with the Bluetooth device.

11. The method according to claim 10, characterized in that In the case where the electronic device disconnects the Bluetooth connection with the Bluetooth device, the method further includes: Adjusting the first scanning cycle to a second scanning cycle; the duration corresponding to the second scanning cycle is shorter than the duration corresponding to the first scanning cycle; Based on the second scanning cycle, the first broadcast channel is scanned within a second duration; the second duration is the duration during which the electronic device performs signal scanning on the first broadcast channel in the second scanning cycle; the second duration is less than or equal to the duration corresponding to the second scanning cycle.

12. The method according to claim 11, characterized in that The ratio of the second duration to the duration corresponding to the second scanning cycle is equal to the ratio of the first duration to the duration corresponding to the first scanning cycle.

13. The method according to claim 11, characterized in that After re-establishing the Bluetooth connection with the Bluetooth device, the method further includes: The second scanning period is adjusted to the first scanning period.

14. A method for connecting a device, characterized in that: Applicable to a system including a Bluetooth device and an electronic device, wherein a Bluetooth connection is established between the Bluetooth device and the electronic device; the method includes: When the Bluetooth device is disconnected from the electronic device, the Bluetooth device starts reconnection, where the reconnection refers to reestablishing the Bluetooth connection; The Bluetooth device sends a broadcast signal through a first broadcast channel at a first moment; the first moment is any moment in a first duration; the first duration is the duration of the electronic device performing signal scanning on the first broadcast channel in a first scanning cycle; the first duration is the duration predicted by the Bluetooth device based on the synchronization time and the scanning cycle of the electronic device before sending the broadcast signal; the first broadcast channel is the channel predicted by the Bluetooth device for the electronic device to perform scanning before sending the broadcast signal; When the electronic device scans the broadcast signal sent by the Bluetooth device, the electronic device sends a connection request to the Bluetooth device through the first broadcast channel; The electronic device re-establishes the Bluetooth connection with the Bluetooth device.

15. A Bluetooth device, characterized in that: The Bluetooth device comprises: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions to enable the Bluetooth device to execute the method as described in any one of claims 1 to 9.

16. An electronic device, characterized in that: The electronic device comprises: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the electronic device executes the method as described in any one of claims 10 to 13.

17. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes instructions, which, when executed on a Bluetooth device, cause the Bluetooth device to execute the method as described in any one of claims 1 to 9; or, when executed on an electronic device, cause the electronic device to execute the method as described in any one of claims 10 to 13.

18. A chip system, characterized in that: The chip system is applied to a Bluetooth device or an electronic device; the chip system includes one or more processors; the one or more processors are used to call computer instructions so that the Bluetooth device executes the method as described in any one of claims 1 to 9; or, the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 10 to 13.

Citation Information

Patent Citations

  • Equipment reconnection method, electronic equipment, storage medium and chip

    CN117956546A

  • Bluetooth beacon transmission

    US20150382150A1

  • Bluetooth switching method and apparatus, and bluetooth device and computer-readable medium

    WO2024060777A1