Bluetooth connection method and electronic device

By sending random numbers or starting timers between Bluetooth connected devices, Bluetooth connection conflicts can be resolved, ensuring that there is only one connection request, improving connection speed and success rate, and enhancing user experience.

CN115811719BActive Publication Date: 2025-10-10HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111081114.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-15
Publication Date
2025-10-10
Estimated Expiration
2041-09-15

AI Technical Summary

Technical Problem

Bluetooth connection conflicts cause connection slowdown or failure, affecting user experience.

Method used

Conflicts are resolved by sending random numbers between electronic devices or starting a timer to ensure that there is only one Bluetooth connection request.

Benefits of technology

Effectively eliminate Bluetooth connection conflicts, increase connection speed and success rate, and enhance user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115811719B_ABST
    Figure CN115811719B_ABST
Patent Text Reader

Abstract

The application discloses a Bluetooth connection method and an electronic device, relates to the technical field of electronics, and can solve the Bluetooth connection conflict. The method comprises the following steps: first, a first Bluetooth connection request is sent to the electronic device at a first time. Then, if a second Bluetooth connection request sent by the electronic device is received at the first time, a first random number is sent to the electronic device, and a second random number sent by the electronic device is received. Then, if the first random number is smaller than the second random number, the first Bluetooth connection request is cancelled, and a Bluetooth connection is established with the electronic device according to the second Bluetooth connection request.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electronics, and in particular to a Bluetooth connection method and an electronic device. BACKGROUND

[0002] Bluetooth is a wireless radio technology that supports short-range communication between devices. With the development of science and technology, there are more and more electronic devices with Bluetooth function in people's daily life. Bluetooth technology is often used in all-scene full-connection services. Through Bluetooth technology, various electronic devices (such as mobile phones, tablets, personal computers, home appliances, and wearable devices) can be connected together.

[0003] In all-scene full-connection services, Bluetooth connection between electronic devices is frequent, and Bluetooth connection conflicts also occur more frequently. Bluetooth connection conflicts can cause Bluetooth connection to slow down or even fail, which greatly affects user experience. SUMMARY

[0004] The present application provides a Bluetooth connection method and an electronic device, which can solve the Bluetooth connection conflict. To achieve the above purpose, the present application adopts the following technical solutions:

[0005] In a first aspect, the present application provides a Bluetooth connection method, which comprises: first sending a first Bluetooth connection request to an electronic device at a first time. Then, if a second Bluetooth connection request sent by the electronic device is received at the first time, a first random number is sent to the electronic device and a second random number sent by the electronic device is received. Then, if the first random number is smaller than the second random number, the first Bluetooth connection request is cancelled and a Bluetooth connection is established with the electronic device according to the second Bluetooth connection request.

[0006] As can be seen, in the present application, if two electronic devices produce a Bluetooth connection conflict (i.e. two electronic devices send Bluetooth connection requests to each other at the first time), the Bluetooth conflict between the two electronic devices is solved by mutual sending of random numbers, that is, the party sending the smaller random number among the two electronic devices cancels the Bluetooth connection request and establishes a Bluetooth connection based on the Bluetooth connection request sent by the opposite party, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict between the two electronic devices due to the existence of multiple Bluetooth connection requests, thus solving the Bluetooth connection conflict.

[0007] In a possible implementation manner, the method further comprises: if the first random number is greater than the second random number, establishing a Bluetooth connection with the electronic device according to the first Bluetooth connection request.

[0008] In a possible implementation manner, the above sending of the first random number to the electronic device can comprise: sending a first target signaling to the electronic device, wherein the first target signaling comprises the first random number.

[0009] It can be seen that the first random number can be sent through signaling in the present application.

[0010] Optionally, the first target signaling can be logical link control and adaptation protocol echo (L2CAP ECHO) signaling.

[0011] In a possible implementation, the receiving of the second random number sent by the electronic device can include: receiving second target signaling sent by the electronic device, the second target signaling including the second random number.

[0012] Optionally, the second target signaling can be L2CAP ECHO signaling.

[0013] In a second aspect, the present application further provides another Bluetooth connection method, which includes: first, a first electronic device sends a first Bluetooth connection request to a second electronic device at a first time. Then, if the first electronic device receives a second Bluetooth connection request sent by the second electronic device at the first time, the first electronic device starts a first target timer, the first target timer and a second target timer have different timing ranges, and the second target timer is a timer started by the second electronic device. If the first target timer expires and the second electronic device does not cancel the second Bluetooth connection request, the first electronic device cancels the first Bluetooth connection request and establishes Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0014] It can be seen that, in the present application, if two electronic devices generate Bluetooth connection conflicts, the two electronic devices can solve the Bluetooth connection conflicts by starting timers with different timing ranges, that is, after the two electronic devices start the timers, the electronic device whose timer expires first cancels the Bluetooth connection request sent by the electronic device and establishes Bluetooth connection based on the Bluetooth connection request sent by the opposite electronic device, thereby solving the Bluetooth connection conflicts.

[0015] In a possible implementation, the method can further include: if the first target timer does not expire and the second electronic device cancels the second Bluetooth connection request, the first electronic device establishes Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0016] In a possible implementation, the asynchronous link (ACL) exists between the first electronic device and the second electronic device, and starting the first target timer can include starting the first target timer according to role information. The role information is used to indicate a role of the first electronic device in the ACL.

[0017] In a possible implementation, starting the first target timer according to the role information can include starting a first random timer if the first electronic device is a master in the ACL, and starting a second random timer if the first electronic device is a slave in the ACL. The first random timer and the second random timer have different timing ranges.

[0018] Optionally, the timing range of the first random timer is 2 to 11 seconds, and the timing range of the second random timer can be 0 to 1 second.

[0019] In a third aspect, the application further provides another Bluetooth connection method, which includes: a first electronic device sending a first Bluetooth connection request to a second electronic device at a first time; if the first electronic device receives a second Bluetooth connection request sent by the second electronic device at the first time, the first electronic device sends a first random number to the second electronic device; if the first electronic device receives a second random number sent by the second electronic device and the first random number is smaller than the second random number, the first electronic device cancels the first Bluetooth connection request and establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; if the first electronic device does not receive the second random number sent by the second electronic device, the first electronic device starts a first target timer and establishes a Bluetooth connection according to a timeout condition of the first target timer. The first target timer and a second target timer have different timing ranges, and the second target timer is a timer started by the second electronic device.

[0020] It can be seen that, in the application, if Bluetooth connection conflicts occur between two electronic devices (i.e., the two electronic devices send Bluetooth connection requests to each other at the first time), the two electronic devices can solve the Bluetooth connection conflicts by exchanging random numbers in the case that the first electronic device can normally exchange random numbers with the peer electronic device (i.e., the case that the first electronic device can receive the random number sent by the peer electronic device). That is, the party sending a smaller random number between the two electronic devices cancels the Bluetooth connection request and establishes a Bluetooth connection based on the Bluetooth connection request sent by the peer electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflicts between the two electronic devices due to multiple Bluetooth connection requests, and thus solving the Bluetooth connection conflicts.

[0021] In the case that the opposite end electronic device cannot normally interact with the random number (i.e. the case that the first electronic device fails to receive the random number sent by the opposite end electronic device), the Bluetooth connection conflict between the two electronic devices is solved by starting the timers with different timing ranges, i.e. after the two electronic devices start the timers, the electronic device whose timer expires first cancels the Bluetooth connection request sent by the local end and establishes the Bluetooth connection based on the Bluetooth connection request sent by the opposite end electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict between the two electronic devices due to the existence of multiple Bluetooth connection requests, and thus the Bluetooth connection conflict is solved.

[0022] In a possible implementation, the method can further include: if the first electronic device receives the second random number sent by the second electronic device and the first random number is greater than the second random number, the first electronic device establishes the Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0023] In a possible implementation, the Bluetooth connection establishment according to the timeout of the first target timer can include: if the first target timer expires and the second electronic device does not cancel the second Bluetooth connection request, the first electronic device cancels the first Bluetooth connection request and establishes the Bluetooth connection with the second electronic device according to the second Bluetooth connection request; if the first target timer does not expire and the second electronic device cancels the second Bluetooth connection request, the first electronic device establishes the Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0024] In a possible implementation, there is an ACL between the first electronic device and the second electronic device, and the starting of the first target timer can include: starting the first target timer according to role information, the role information being used to indicate the role of the first electronic device in the ACL.

[0025] In a possible implementation, the starting of the first target timer according to the role information can include: if the first electronic device is a master in the ACL, starting a first random timer; if the first electronic device is a slave in the ACL, starting a second random timer, the timing range of the first random timer being different from that of the second random timer.

[0026] In a fourth aspect, the present application provides an electronic device, comprising a processor and a memory coupled to the processor, the processor being configured to: send a first Bluetooth connection request to a second electronic device at a first time; if a second Bluetooth connection request sent by the second electronic device is received at the first time, send a first random number to the second electronic device and receive a second random number sent by the second electronic device; if the first random number is smaller than the second random number, cancel the first Bluetooth connection request and establish a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0027] In a possible implementation, the processor is further configured to: if the first random number is greater than the second random number, establish a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0028] In a possible implementation, the processor is specifically configured to: send first target signaling to the second electronic device, the first target signaling comprising the first random number.

[0029] Optionally, the first target signaling can be L2CAP ECHO signaling.

[0030] In a possible implementation, the processor is specifically configured to: receive second target signaling sent by the second electronic device, the second target signaling comprising the second random number.

[0031] Optionally, the second target signaling is L2CAP ECHO signaling.

[0032] In a fifth aspect, the present application provides another electronic device, comprising a processor and a memory coupled to the processor, the processor being configured to: send a first Bluetooth connection request to a second electronic device at a first time; if a second Bluetooth connection request sent by the second electronic device is received at the first time, start a first target timer, the first target timer having a different timing range from a second target timer, the second target timer being a timer started by the second electronic device; if the first target timer expires and the second electronic device does not cancel the second Bluetooth connection request, cancel the first Bluetooth connection request and establish a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0033] In a possible implementation, the processor is further configured to: if the first target timer does not expire and the second electronic device cancels the second Bluetooth connection request, establish a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0034] In a possible implementation, the electronic device and the second electronic device have an ACL, and the processor is specifically configured to start the first target timer according to role information, the role information being used to indicate a role of the electronic device in the ACL.

[0035] In a possible implementation, the processor is specifically configured to start a first random timer if the electronic device is a master in the ACL, and start a second random timer if the electronic device is a slave in the ACL, the first random timer and the second random timer having different timing ranges.

[0036] Optionally, the first random timer has a timing range of 2 to 11 seconds, and the second random timer has a timing range of 0 to 1 second.

[0037] In a sixth aspect, the present application further provides another electronic device, which comprises a processor and a memory coupled to the processor, and the processor is configured to: send a first Bluetooth connection request to a second electronic device at a first time; if a second Bluetooth connection request sent by the second electronic device is received at the first time, send a first random number to the second electronic device; if a second random number sent by the second electronic device is received and the first random number is smaller than the second random number, cancel the first Bluetooth connection request and establish a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; if the second random number sent by the second electronic device is not received, start a first target timer and establish a Bluetooth connection according to a timeout condition of the first target timer, the first target timer and a second target timer having different timing ranges, the second target timer being a timer started by the second electronic device.

[0038] In a possible implementation, the processor is further configured to: if the second random number sent by the second electronic device is received and the first random number is greater than the second random number, establish a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0039] In a possible implementation, the processor is specifically configured to: if the first target timer times out and the second electronic device does not cancel a second Bluetooth connection request, cancel the first Bluetooth connection request and establish a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; if the first target timer does not time out and the second electronic device cancels the second Bluetooth connection request, establish a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0040] In a possible implementation, the electronic device and the second electronic device have an ACL, and the processor is specifically configured to start the first target timer according to role information, the role information being used to indicate a role of the electronic device in the ACL.

[0041] In a possible implementation, the processor is specifically configured to start a first random timer if the electronic device is a master in the ACL, and start a second random timer if the electronic device is a slave in the ACL, the first random timer and the second random timer having different timing ranges.

[0042] In a seventh aspect, the present application provides an electronic device, which comprises at least one processor, and the at least one processor implements the method in the first aspect or any possible implementation manner of the first aspect when executing program code or instructions.

[0043] Optionally, the electronic device further comprises at least one memory configured to store the program code or the instructions.

[0044] In an eighth aspect, the present application provides a chip, which comprises an input interface, an output interface, and at least one processor. Optionally, the chip further comprises a memory. The at least one processor is configured to execute code in the memory, and the chip implements the method in the first aspect or any possible implementation manner of the first aspect when the at least one processor executes the code.

[0045] Optionally, the chip can be an integrated circuit.

[0046] In a ninth aspect, the present application provides a terminal, which comprises the electronic device or the chip.

[0047] In a tenth aspect, the present application provides a computer readable storage medium configured to store a computer program, the computer program comprising instructions for implementing the method in the first aspect or any possible implementation manner of the first aspect.

[0048] In an eleventh aspect, the present application provides a computer program product comprising instructions which, when executed on a computer, cause the computer to carry out the method in the first aspect or any possible implementation manner of the first aspect.

[0049] The electronic device, the computer storage medium, the computer program product and the chip provided in the embodiments have the same beneficial effects as the Bluetooth connection method provided above, and thus the beneficial effects of the Bluetooth connection method are not repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of these drawings.

[0051] Figure 1 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 1.

[0052] Figure 2 A software structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 2.

[0053] Figure 3 A flowchart of a Bluetooth connection method provided by an embodiment of the present application is shown in FIG. 3.

[0054] Figure 4 A flowchart of an electronic device interaction provided by an embodiment of the present application is shown in FIG. 4.

[0055] Figure 5 A flowchart of another Bluetooth connection method provided by an embodiment of the present application is shown in FIG. 5.

[0056] Figure 6 A flowchart of another electronic device interaction provided by an embodiment of the present application is shown in FIG. 6.

[0057] Figure 7 A flowchart of another Bluetooth connection method provided by an embodiment of the present application is shown in FIG. 7.

[0058] Figure 8 A structural schematic diagram of an apparatus provided by an embodiment of the present application is shown in FIG. 8.

[0059] Figure 9 A structural schematic diagram of another apparatus provided by an embodiment of the present application is shown in FIG. 9.

[0060] Figure 10 A structural schematic diagram of a chip provided by an embodiment of the present application is shown in FIG. 10. DETAILED DESCRIPTION

[0061] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0062] The term "and / or" in this document is only used to describe associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone.

[0063] The terms "first" and "second" and the like in the description of the present application and the drawings are used to distinguish different objects, or to distinguish different treatments of the same object, and are not used to describe the specific order of the objects.

[0064] In addition, the terms "include" and "have" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but can optionally include other steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.

[0065] It should be noted that in the description of the embodiments of the present application, the words "exemplarily" or "for example" are used to represent as an example, illustration or explanation. Any embodiment or design scheme described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the words "exemplarily" or "for example" are intended to present the relevant concept in a specific manner.

[0066] In the description of the present application, unless otherwise specified, the meaning of "a plurality of" is two or more.

[0067] In a certain all-scene service of a user, a first electronic device (such as a mobile phone) and a second electronic device (such as a tablet computer) need to be quickly connected to a radio frequency communications protocol (RFCOMM) data channel. The first electronic device initiates a Bluetooth connection to the second electronic device, and at the same time, the second electronic device also initiates a Bluetooth connection to the first electronic device. After the ACL connection is established, the first electronic device and the second electronic device simultaneously initiate a RFCOMM connection to each other at a logical link control and adaptation protocol (L2CAP) layer. Since only one RFCOMM channel identified by a channel identity document (ID) can be established between the two devices, the simultaneous initiation of the first electronic device and the second electronic device to connect to each other will cause a connection conflict (Bluetooth connection conflict) at the L2CAP layer. The Bluetooth connection conflict will cause the Bluetooth connection to be slow or even fail, which greatly affects the user experience.

[0068] To this end, the embodiments of the present application provide a Bluetooth connection method, which can solve the Bluetooth connection conflict. The Bluetooth connection method provided by the embodiments of the present application can be applied to electronic devices with Bluetooth functions, such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), and the like. The embodiments of the present application do not make any limitation on the specific type of the electronic device.

[0069] Exemplarily, Figure 1Fig. 1 is a structural schematic diagram of an electronic device 100 provided by an embodiment of the present application. The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0070] It can be understood that the structure illustrated by the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than those illustrated, or combine certain components, or split certain components, or different arrangement of components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0071] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units can be independent devices, or can be integrated in one or more processors.

[0072] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching instructions and executing instructions.

[0073] The processor 110 can also be provided with a memory for storing instructions and data. In some embodiments, the processor 110 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0074] The I2C interface is a bidirectional synchronous serial bus, and the processor 110 can be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface to realize the touch function of the electronic device 100. The MIPI interface can be used to connect the processor 110 and peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display screen serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface to realize the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device 100.

[0075] It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative and does not constitute a structural limitation of the electronic device 100. In some other embodiments of the present application, the electronic device 100 can also use different interface connection methods or combinations of multiple interface connection methods in the above embodiments.

[0076] The charging management module 140 is configured to receive charging input from a charger. The charger can be a wireless charger or a wired charger. The power management module 141 is configured to connect the battery 142 and the charging management module 140. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160.

[0077] The electronic device 100 implements a display function through a GPU, the display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is configured to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs that execute program instructions to generate or change display information.

[0078] The display screen 194 is configured to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.

[0079] The electronic device 100 can implement a photographing function through an ISP, the camera 193, a touch sensor, a video codec, a GPU, a display screen 194, and an application processor.

[0080] The ISP is configured to process data fed back by the camera 193. For example, when taking a photo, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye. The ISP can also optimize algorithms for image noise, brightness, and skin color. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be disposed in the camera 193.

[0081] The camera 193 is used to capture still images or videos. An object projects an optical image through a lens to a photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into a standard image signal in RGB, YUV, or the like format. It should be understood that, in the description of the embodiments of the present application, an image in RGB format is taken as an example for illustration, and the embodiments of the present application do not limit the image format. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1.

[0082] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.

[0083] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.

[0084] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area.

[0085] The electronic device 100 can realize audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor, etc. For example, music playing, recording, etc.

[0086] The buttons 190 include a power button, a volume button, etc. The button 190 can be a mechanical button. It can also be a touch button. The electronic device 100 can receive button input and generate key signal input related to the user settings and function control of the electronic device 100. The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, the motor 191 can also correspond to different vibration feedback effects. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power changes, and can also be used to indicate messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect a SIM card.

[0087] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present application, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.

[0088] Figure 2 This is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application. A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other via software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0089] The application layer can include a series of application packages. Figure 2 As shown, the application package may include applications such as camera, photo album, music, and settings.

[0090] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, and the like.

[0091] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.

[0092] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0093] The view system includes visual controls, such as controls that display text, controls that display pictures, and the like. The view system can be used to build an application. A display interface can be composed of one or more views. For example, a display interface that includes a short message notification icon can include a view that displays text and a view that displays a picture.

[0094] The resource manager provides various resources for an application, such as localized strings, icons, pictures, layout files, video files, and the like.

[0095] The notification manager enables an application to display notification information in a status bar, which can be used to convey a message of an informing type, and the notification information in the status bar can automatically disappear after a short stay, such as a message reminder for informing a user of a download completion, and the like. The notification manager can also be a notification that appears in a top status bar of a system in a form of a graph or a scrolling bar text, such as a notification of an application running in the background, and can also be a notification that appears on a screen in a form of a dialog window. For example, the notification manager can prompt text information in a status bar, or can also issue a prompt sound, such as a vibration of an electronic device, a blinking of an indicator light, and the like.

[0096] The Android runtime includes a core library and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system. The core library includes two parts: one part is a function function that the java language needs to call, and the other part is the core library of Android.

[0097] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the application framework layer into binary files. The virtual machine is used to perform functions such as management of object life cycle, stack management, thread management, security and exception management, and garbage collection.

[0098] The system library can include a plurality of functional modules. For example: a surface manager, media libraries, a three-dimensional graphics processing library (for example: OpenGL ES), a 2D graphics engine (for example: SGL), and the like.

[0099] The surface manager is used to manage a display subsystem, and provides fusion of 2D and 3D layers for a plurality of applications.

[0100] The media library supports playback and recording of a plurality of commonly used audio, video formats, and static image files, and the like. The media library can support a plurality of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, and the like.

[0101] The three-dimensional graphics processing library is used to realize three-dimensional graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.

[0102] The kernel layer is a layer between hardware and software. The kernel layer can include hardware driver modules such as display drivers, camera drivers, sensor drivers, and the like, and the application framework layer can call the hardware driver modules of the kernel layer.

[0103] For ease of understanding, the following embodiments of the present application will take an electronic device with the structure shown in Figure 1 and Figure 2 as an example to introduce the Bluetooth connection process of the electronic device.

[0104] The technical solutions involved in the following embodiments can be implemented in the electronic device 100 with the hardware architecture and software architecture described above.

[0105] The Bluetooth connection method provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings, such as Figure 3 The Bluetooth connection method provided by the embodiments of the present application includes:

[0106] S301, the first electronic device sends a first Bluetooth connection request to the second electronic device at a first time.

[0107] For example, the mobile phone (first electronic device) sends an L2CAP RFCOMM connection request to the tablet computer (second electronic device) at 10:30:50:20 (first time).

[0108] S302, the first electronic device determines whether a second Bluetooth connection request sent by the second electronic device is received at the first time. If yes, S303 is performed; if no, S306 is performed.

[0109] Correspondingly, if the second electronic device also sends a second Bluetooth connection request to the first electronic device at the first time, the second electronic device determines whether a first Bluetooth connection request sent by the first electronic device is received at the first time.

[0110] For example, the mobile phone determines whether an L2CAP RFCOMM connection request sent by the tablet computer is received at 10:30:50:20. If yes, S303 is performed; if no, S306 is performed. At the same time, the tablet computer determines whether an L2CAP RFCOMM connection request sent by the mobile phone is received at 10:30:50:20.

[0111] In one possible implementation, the first electronic device can also determine whether a Bluetooth connection request sent by the second electronic device is received within a target time range. If yes, S303 is performed; if no, S306 is performed.

[0112] Optionally, the target time range is (the first time instant-time threshold) to (the first time instant+time threshold). For example, the time threshold can be 50 milliseconds, the first time instant is 10:30:50:00, and the target time range is 10:30:49:10 to 10:30:50:50.

[0113] It should be noted that, since the first electronic device has sent the first Bluetooth connection request to the second electronic device at the first time instant, if the first electronic device receives the second Bluetooth connection request sent by the second electronic device at the first time instant, it indicates that the first electronic device and the second electronic device both send Bluetooth connection requests to each other at the same time instant. At present, only one Bluetooth connection can be established between two electronic devices, so the first electronic device and the second electronic device send Bluetooth connection requests to each other at the same time instant will cause Bluetooth connection conflict, and S303 needs to be executed to solve the Bluetooth connection conflict. If the first electronic device does not receive the second Bluetooth connection request sent by the second electronic device at the first time instant, it indicates that the first electronic device and the second electronic device do not send Bluetooth connection requests to each other at the first time instant, so the first electronic device and the second electronic device do not cause Bluetooth connection conflict, and S303 does not need to be executed to solve the Bluetooth connection conflict, but S306 can be directly executed to make the first electronic device and the second electronic device establish Bluetooth connection.

[0114] S303, the first electronic device sends a first random number to the second electronic device.

[0115] The first random number can be generated by the first electronic device or by other devices (such as a server), and the embodiments of the present application do not limit the first random number, which can also be referred to as a conflict arbitration first random number.

[0116] Correspondingly, the second electronic device sends a second random number to the first electronic device.

[0117] In one possible implementation, the first electronic device sending the first random number to the second electronic device can include: the first electronic device sending first target signaling to the second electronic device. The first target signaling includes the first random number.

[0118] Optionally, the first target signaling may be L2CAP ECHO signaling. Table 1 shows the format of L2CAP ECHO signaling (L2CAP ECHO Request). As shown in Table 1, L2CAP ECHO signaling includes a Code segment, an Identifier segment, a Length segment, and a Data segment. The Code segment is used to indicate the signal command type. For example, Code = 0x08 indicates L2CAP ECHO Request signaling, and Code = 0x09 indicates L2CAP ECHO Response signaling. The Identifier segment is used to match requests and responses. The Length segment is used to indicate the length of the data. The Data segment can be used to fill in the first random number.

[0119] Table 1

[0120]

[0121] Exemplarily, the mobile phone sends an L2CAP ECHORequest signaling with the Data segment filled with 5414 (the first random number) to the tablet computer.

[0122] It should be noted that the time it takes for the first electronic device and the second electronic device to exchange random numbers through L2CAP ECHO signaling is in the millisecond level. Therefore, the first electronic device and the second electronic device can quickly exchange random numbers through L2CAP ECHO signaling, thereby reducing the time required to resolve Bluetooth connection conflicts and improving user experience.

[0123] S304: The first electronic device receives a second random number sent by the second electronic device.

[0124] The second random number may be generated by the second electronic device or by other devices (such as a server), and this embodiment of the present application does not limit this. The second random number may also be referred to as a conflict arbitration second random number.

[0125] In a possible implementation, the first electronic device receiving the second random number sent by the second electronic device may include: the first electronic device receiving a second target signaling sent by the second electronic device, wherein the second target signaling includes the second random number.

[0126] Optionally, the second target signaling may be an L2CAP ECHO signaling (L2CAP ECHO Response). The first random number may be filled in a Data segment of the L2CAP ECHO signaling.

[0127] Exemplarily, after receiving the L2CAP ECHO Request signaling with the Data segment filled with 5414 (the first random number) sent by the mobile phone, the tablet sends the L2CAP ECHO Response signaling with the Data segment filled with 821 (the second random number) to the mobile phone in response to the ECHO Request signaling.

[0128] S305, the first electronic device determines whether the first random number is greater than the second random number. If yes, S306 is executed, and if no, S307 is executed.

[0129] Correspondingly, the second electronic device determines whether the first random number is greater than the second random number. If the first random number is greater than the second random number, the second electronic device cancels the second Bluetooth connection request and establishes the Bluetooth connection with the first electronic device according to the first Bluetooth connection request. If the first random number is less than the second random number, the second electronic device establishes the Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0130] Exemplarily, taking the first random number 5414 and the second random number 821 as examples. After the first electronic device and the second electronic device exchange the random numbers, it is determined that the first random number 5414 is greater than the second random number 821 by comparing the first random number and the second random number. The second electronic device cancels the second Bluetooth connection request. After the second Bluetooth connection request is canceled, there is only the first Bluetooth connection request between the first electronic device and the second electronic device. The Bluetooth connection conflict between the first electronic device and the second electronic device is eliminated because there are multiple Bluetooth connection requests. The first electronic device establishes the Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0131] It should be noted that the random number in the embodiments of the present application includes but is not limited to an integer, and can also be other numbers (such as negative numbers, decimal numbers, fractions, etc.) that have a size relationship. The embodiments of the present application do not limit this. The size relationship between the random numbers determines whether the first electronic device and the second electronic device use the connection request of the first electronic device or the connection request of the second electronic device, which is not limited in the present application. Alternatively, it is determined by negotiation between the first electronic device and the second electronic device.

[0132] S306, the first electronic device establishes the Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0133] Correspondingly, the second electronic device cancels the second Bluetooth connection request and accepts the first Bluetooth connection request sent by the first electronic device to establish the Bluetooth connection with the first electronic device.

[0134] S307, the first electronic device cancels the first Bluetooth connection request.

[0135] It should be noted that after the first electronic device cancels the first Bluetooth connection request, the Bluetooth connection conflict between the first electronic device and the second electronic device is eliminated due to the existence of multiple Bluetooth connection requests, and therefore the first electronic device can accept the second Bluetooth connection request sent by the second electronic device to establish a Bluetooth connection with the second electronic device by performing S308.

[0136] S308, the first electronic device establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0137] Correspondingly, the second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0138] It can be seen that in the embodiments of the present application, if two electronic devices generate a Bluetooth connection conflict (i.e., the two electronic devices send Bluetooth connection requests to each other at the first time), the Bluetooth connection conflict between the two electronic devices is solved by mutual transmission of random numbers, that is, the party with a smaller random number among the two electronic devices cancels the Bluetooth connection request and establishes a Bluetooth connection based on the Bluetooth connection request sent by the opposite electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict between the two electronic devices due to the existence of multiple Bluetooth connection requests, thereby solving the Bluetooth connection conflict.

[0139] Optionally, the above plurality of steps constitute an optional embodiment, which is not limited by the present application, and other embodiments composed of one or more steps are also covered.

[0140] The following will be described in detail Figure 4 The communication interaction between the first electronic device and the second electronic device in the Bluetooth connection method provided by the embodiments of the present application will be described in detail, and the communication interaction between the first electronic device and the second electronic device specifically includes the following steps.

[0141] S401, the first electronic device sends a first Bluetooth connection request to the second electronic device at the first time. Optionally, the first Bluetooth connection request is an L2CAP RFCOMM connection request.

[0142] S402, the second electronic device sends a second Bluetooth connection request to the first electronic device at the first time. Optionally, the second Bluetooth connection request is an L2CAP RFCOMM connection request.

[0143] S403, the first electronic device judges whether the second Bluetooth connection request sent by the second electronic device is received at the first time? If yes, S405 is performed; if not, S409 is performed.

[0144] S404: The second electronic device determines whether it has received the first Bluetooth connection request sent by the first electronic device at the first moment. If so, execute S406; if not, execute S414.

[0145] S405: The first electronic device sends a first random number to the second electronic device. The random number can be generated by Figure 3 The present application does not limit the solutions shown in the associated text.

[0146] Accordingly, the second electronic device receives the first random number.

[0147] S406: The second electronic device sends a second random number to the first electronic device. The random number can be generated by Figure 3 The present application does not limit the solutions shown in the associated text.

[0148] Accordingly, the first electronic device receives the second random number.

[0149] S407: The first electronic device determines whether the first random number is greater than the second random number. If so, execute S409; if not, execute S410 and S411.

[0150] S408: The second electronic device determines whether the first random number is greater than the second random number. If so, execute S412 and S413; if not, execute S414.

[0151] S409: The first electronic device establishes a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0152] S410: The first electronic device cancels the first Bluetooth connection request.

[0153] S411: The first electronic device establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0154] S412: The second electronic device cancels the second Bluetooth connection request.

[0155] S413: The second electronic device establishes a Bluetooth connection with the first electronic device according to the first Bluetooth connection request.

[0156] S414: The second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0157] Optionally, the above-mentioned multiple steps constitute an optional embodiment, which is not limited in this application, and also covers embodiments composed of one or more steps recombined.

[0158] The present application embodiment also provides another Bluetooth connection method, such as Figure 5 As shown, the method includes:

[0159] S501, the first electronic device sends a first Bluetooth connection request to the second electronic device at a first time.

[0160] S502, the first electronic device judges whether a second Bluetooth connection request sent by the second electronic device is received at the first time. If yes, S503 is executed; if no, S505 is executed.

[0161] Correspondingly, if the second electronic device also sends a second Bluetooth connection request to the first electronic device at the first time, the second electronic device judges whether a first Bluetooth connection request sent by the first electronic device is received at the first time.

[0162] S503, the first electronic device starts a first target timer.

[0163] Correspondingly, the second electronic device starts a second target timer, wherein the timing range of the first target timer is different from that of the second target timer.

[0164] In a possible implementation, the first electronic device starting the first target timer can include: the first electronic device starting the first target timer according to role information. The role information is used to indicate the role of the first electronic device in the ACL.

[0165] Specifically, if the first electronic device is a master in the ACL, the first electronic device starts a first random timer; if the first electronic device is a slave in the ACL, the first electronic device starts a second random timer. The timing range of the first random timer is different from that of the second random timer.

[0166] In a possible implementation, the second electronic device starting the second target timer can include: the second electronic device starting the second target timer according to second role information. The second role information is used to indicate the role of the second electronic device in the ACL. Specifically, if the second electronic device is a master in the ACL, the second electronic device starts a first random timer; if the second electronic device is a slave in the ACL, the second electronic device starts a second random timer.

[0167] Optionally, the timing range of the first random timer is 2-11 seconds, and the timing range of the second random timer is 0-1 second.

[0168] Exemplarily, the first electronic device starts a first target timer with a timing duration of 4 seconds, and the second electronic device starts a second target timer with a timing duration of 1 second.

[0169] S504, the first electronic device judges whether the second electronic device cancels the second Bluetooth connection request before the first target timer expires; if yes, S505 is executed; if no, S506 is executed.

[0170] Correspondingly, the second electronic device judges whether the first electronic device cancels the first Bluetooth connection request before the second target timer expires; if yes, the second electronic device establishes the Bluetooth connection with the first electronic device according to the second Bluetooth connection request; if no, the second electronic device cancels the second Bluetooth connection request and establishes the Bluetooth connection with the first electronic device according to the first Bluetooth connection request.

[0171] Exemplarily, the phone cancels the second Bluetooth connection request 1 second after starting the first target timer with a timing duration of 4 seconds, and the tablet executes S505.

[0172] Exemplarily, the phone cancels the second Bluetooth connection request 1 second after starting the first target timer with a timing duration of 1 second, the first target timer expires and the tablet does not cancel the second Bluetooth connection request, and the phone executes S506.

[0173] It should be noted that in the case of Bluetooth connection conflict between the two electronic devices, the two electronic devices start timers with different timing ranges, and after the two electronic devices start the timers, the electronic device whose timer expires first cancels the Bluetooth connection request sent by the local end by executing S506 and S507, and establishes the Bluetooth connection based on the Bluetooth connection request sent by the opposite electronic device. Correspondingly, the electronic device whose timer does not expire (later expires) establishes the Bluetooth connection with the opposite electronic device according to the Bluetooth connection request sent by itself after the opposite electronic device cancels the Bluetooth connection request by executing S505. Thus, there is only one Bluetooth connection request between the two electronic devices, and the Bluetooth connection conflict between the two electronic devices due to multiple Bluetooth connection requests is eliminated, thereby solving the Bluetooth connection conflict.

[0174] In a possible implementation, the first electronic device can also determine whether to execute S505 or S506 and S507 according to the role information. For example, if the first electronic device is the master in the ACL, the first electronic device executes S505; if the first electronic device is the slave in the ACL, the first electronic device executes S506 and S507. For another example, if the first electronic device is the master in the ACL, the first electronic device executes S506 and S507; if the first electronic device is the slave in the ACL, the first electronic device executes S505. In this way, the Bluetooth connection conflict can be eliminated only by determining the roles of the first electronic device and the second electronic device in the ACL.

[0175] S505, the first electronic device establishes the Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0176] Correspondingly, the second electronic device cancels the second Bluetooth connection request and accepts the first Bluetooth connection request sent by the first electronic device to establish a Bluetooth connection with the first electronic device.

[0177] S506: The first electronic device cancels the first Bluetooth connection request.

[0178] S507: The first electronic device establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0179] Correspondingly, the second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0180] It can be seen that in an embodiment of the present application, if a Bluetooth connection conflict occurs between two electronic devices, the two electronic devices resolve the Bluetooth conflict by starting timers with different timing ranges. That is, after the two electronic devices start the timers, the electronic device whose timer times out first cancels the Bluetooth connection request sent by the local end and establishes a Bluetooth connection based on the Bluetooth connection request sent by the other electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict caused by the existence of multiple Bluetooth connection requests between the two electronic devices, thereby resolving the Bluetooth connection conflict.

[0181] Optionally, the above-mentioned multiple steps constitute an optional embodiment, which is not limited in this application, and also covers other embodiments composed of one or more steps recombined.

[0182] The following combination Figure 6 The communication interaction between the first electronic device and the second electronic device in the Bluetooth connection method provided in an embodiment of the present application is described in detail. The communication interaction between the first electronic device and the second electronic device specifically includes the following steps.

[0183] S601: A first electronic device sends a first Bluetooth connection request to a second electronic device at a first moment.

[0184] S602: The second electronic device sends a second Bluetooth connection request to the first electronic device at a first moment.

[0185] S603: The first electronic device determines whether it has received a second Bluetooth connection request sent by the second electronic device at the first moment. If so, execute S605; if not, execute S609.

[0186] S604: The second electronic device determines whether it has received the first Bluetooth connection request sent by the first electronic device at the first moment. If so, execute S606; if not, execute S612.

[0187] S605: The first electronic device starts a first target timer.

[0188] S606: The second electronic device starts a second target timer.

[0189] S607: The first electronic device determines whether the second electronic device cancels the second Bluetooth connection request before the first target timer expires. If so, execute S609; if not, execute S610 and S611.

[0190] S608: The second electronic device determines whether the first electronic device cancels the first Bluetooth connection request before the second target timer expires. If so, execute S612; if not, execute S613 and S614.

[0191] S609: The first electronic device establishes a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0192] S610: The first electronic device cancels the first Bluetooth connection request.

[0193] S611: The first electronic device establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0194] S612: The second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0195] S613: The second electronic device cancels the second Bluetooth connection request.

[0196] S614: The second electronic device establishes a Bluetooth connection with the first electronic device according to the first Bluetooth connection request.

[0197] Optionally, the above-mentioned multiple steps constitute an optional embodiment, which is not limited in this application, and also covers other embodiments composed of one or more steps recombined.

[0198] The present application embodiment also provides another Bluetooth connection method, such as Figure 7 As shown, the method includes:

[0199] S701: A first electronic device sends a first Bluetooth connection request to a second electronic device at a first moment.

[0200] S702: The first electronic device determines whether it has received a second Bluetooth connection request sent by the second electronic device at the first moment. If so, execute S703; if not, execute S706.

[0201] Correspondingly, if the second electronic device also sends a second Bluetooth connection request to the first electronic device at the first moment, the second electronic device determines whether it has received the first Bluetooth connection request sent by the first electronic device at the first moment.

[0202] S703: The first electronic device sends a first random number to the second electronic device.

[0203] Correspondingly, the second electronic device sends a second random number to the first electronic device.

[0204] S704: The first electronic device determines whether it has received the second random number sent by the second electronic device. If so, execute S705; if not, execute S707.

[0205] The second electronic device determines whether the first random number sent by the first electronic device is received.

[0206] It should be noted that by determining whether the second random number sent by the second electronic device is received, it can be determined whether the first electronic device and the second electronic device can normally exchange random numbers. If the first electronic device does not receive the second random number sent by the second electronic device, it means that the first electronic device and the second electronic device cannot normally exchange random numbers (such as the second electronic device does not support generating or sending random numbers). At this time, it is necessary to start the first target timer by executing S707 to establish a Bluetooth connection according to the timeout of the first target timer; if the first electronic device receives the second random number sent by the second electronic device, it means that the first electronic device and the second electronic device can normally exchange random numbers. At this time, the Bluetooth connection conflict between the first electronic device and the second electronic device can be eliminated by comparing the size of the random number by executing S705.

[0207] S705: The first electronic device determines whether the first random number is greater than the second random number. If so, execute S706; if not, execute S709.

[0208] Accordingly, the second electronic device determines whether the first random number is greater than the second random number. If the first random number is greater than the second random number, the second electronic device cancels the second Bluetooth connection request and establishes a Bluetooth connection with the first electronic device according to the first Bluetooth connection request. If the first random number is less than the second random number, the second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0209] S706: The first electronic device establishes a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

[0210] Correspondingly, the second electronic device accepts the first Bluetooth connection request sent by the first electronic device and establishes a Bluetooth connection with the first electronic device.

[0211] S707: The first electronic device starts a first target timer.

[0212] Accordingly, the second electronic device starts a second target timer.

[0213] S708: The first electronic device determines whether the second electronic device cancels the second Bluetooth connection request before the first target timer expires. If so, execute S709; if not, execute S706.

[0214] Accordingly, the second electronic device determines whether the first electronic device cancels the first Bluetooth connection request before the second target timer expires. If so, the second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request. If not, the second electronic device cancels the second Bluetooth connection request and establishes a Bluetooth connection with the first electronic device according to the first Bluetooth connection request.

[0215] S709: The first electronic device cancels the first Bluetooth connection request.

[0216] S710: The first electronic device establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request.

[0217] Correspondingly, the second electronic device establishes a Bluetooth connection with the first electronic device according to the second Bluetooth connection request.

[0218] Optionally, the above-mentioned multiple steps constitute an optional embodiment, which is not limited in this application, and also covers other embodiments composed of one or more steps recombined.

[0219] It can be seen that in an embodiment of the present application, if a Bluetooth connection conflict occurs between two electronic devices (that is, the two electronic devices send Bluetooth connection requests to each other at the first moment), and the first electronic device can normally exchange random numbers with the opposite electronic device (that is, the first device can receive the random number sent by the opposite electronic device), the two electronic devices resolve the Bluetooth conflict by sending random numbers to each other, that is, the one with the smaller random number sent by the two electronic devices cancels the Bluetooth connection request and establishes a Bluetooth connection based on the Bluetooth connection request sent by the opposite electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict caused by the existence of multiple Bluetooth connection requests between the two electronic devices, thereby resolving the Bluetooth connection conflict.

[0220] In the case that the opposite electronic device cannot exchange random numbers normally (that is, the first device fails to receive the random number sent by the opposite electronic device), the two electronic devices resolve the Bluetooth conflict by starting timers with different timing ranges. That is, after the two electronic devices start the timers, the electronic device whose timer times out first cancels the Bluetooth connection request sent by the local end and establishes a Bluetooth connection based on the Bluetooth connection request sent by the opposite electronic device, so that there is only one Bluetooth connection request between the two electronic devices, thereby eliminating the Bluetooth connection conflict caused by the existence of multiple Bluetooth connection requests between the two electronic devices, thereby resolving the Bluetooth connection conflict.

[0221] The following will be combined Figure 8 and Figure 9 An electronic device for executing the above-mentioned Bluetooth connection method is introduced.

[0222] It is understandable that, in order to implement the above functions, the electronic device includes hardware and / or software modules that perform the corresponding functions. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of this application.

[0223] In the embodiment of the present application, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. In actual implementation, other division methods can be used.

[0224] In the case of dividing each functional module into corresponding functional modules, Figure 8 A possible schematic diagram of the composition of the electronic device involved in the above embodiment is shown. Figure 8 As shown, the apparatus 800 may include: a transceiver unit 801 and a processing unit 802. The processing unit 802 may implement the method performed by the electronic device in the above method embodiment, and / or other processes for the technology described herein.

[0225] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.

[0226] In the case of integrated units, the device 800 may include a processing unit, a storage unit, and a communication unit. The processing unit may be used to control and manage the operation of the device 800, for example, to support the device 800 in executing the steps performed by the above-mentioned units. The storage unit may be used to support the device 800 in executing and storing program codes and / or data. The communication unit may be used to support communication between the device 800 and other devices.

[0227] The processing unit may be a processor or a controller. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processing (DSP) and a microprocessor, and so on. The storage unit may be a memory. The communication unit may specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, or a Wi-Fi chip.

[0228] In a possible implementation, the electronic device involved in the embodiment of the present application may be a Figure 9 The device 900 of the structure shown includes a processor 901 and a transceiver 902. Figure 8 The relevant functions implemented by the transceiver unit 801 and the processing unit 802 can be implemented by the processor 901.

[0229] Optionally, the device 900 may further include a memory 903 , and the processor 901 and the memory 903 communicate with each other via an internal connection path. Figure 8 The related functions implemented by the storage unit in can be implemented by the memory 903.

[0230] An embodiment of the present application also provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the Bluetooth connection method in the above-mentioned embodiment.

[0231] The embodiment of the present application further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the Bluetooth connection method in the above-mentioned embodiment.

[0232] The present application also provides an electronic device, which may be a chip, integrated circuit, component, or module. Specifically, the device may include a connected processor and a memory for storing instructions, or the device may include at least one processor configured to retrieve instructions from an external memory. When the device is running, the processor may execute instructions to cause the chip to perform the Bluetooth connection method described in each of the above method embodiments.

[0233] Figure 10 FIG1 shows a schematic structural diagram of a chip 1000. The chip 1000 includes one or more processors 1001 and an interface circuit 1002. Optionally, the chip 1000 may further include a bus 1003.

[0234] The processor 1001 can be an integrated circuit chip having a processing capability of signals. In implementation, the steps of the Bluetooth connection method described above can be completed by integrated logic circuits of hardware in the processor 1001 or instructions in the form of software.

[0235] Optionally, the processor 1001 described above can be a general processor, a digital signal processing (DSP) device, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The disclosed methods and steps in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor.

[0236] The interface circuit 1002 can be used for sending or receiving data, instructions or information. The processor 1001 can process the data, instructions or other information received by the interface circuit 1002, and can send the processed information out through the interface circuit 1002.

[0237] Optionally, the chip further includes a memory, which can include a read-only memory and a random access memory, and provide operation instructions and data for the processor. Part of the memory can also include a non-volatile random access memory (NVRAM).

[0238] Optionally, the memory stores executable software modules or data structures, and the processor can execute corresponding operations by calling operation instructions stored in the memory (which can be stored in an operating system).

[0239] Optionally, the chip can be used in electronic devices or DOPs related to the embodiments of the present application. Optionally, the interface circuit 1002 can be used to output the execution result of the processor 1001. The Bluetooth connection method provided by one or more embodiments of the present application can refer to the foregoing embodiments, which will not be described here.

[0240] It should be noted that the functions of the processor 1001 and the interface circuit 1002 respectively can be realized by hardware design, software design or a combination of software and hardware, which is not limited here.

[0241] The electronic device, the computer storage medium, the computer program product, or the chip provided in the embodiment are used for executing the corresponding method provided in the above, and thus the beneficial effects achieved by the electronic device, the computer storage medium, the computer program product, or the chip can refer to the beneficial effects of the corresponding method provided in the above, which will not be described here again.

[0242] It should be understood that the size of the sequence number of each process described above in various embodiments of the present application does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0243] Those skilled in the art can appreciate that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0244] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described here again.

[0245] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above-mentioned units is only a logical function division, and actual implementation can have another division manner. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.

[0246] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0247] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.

[0248] If the above functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts of the technical solutions that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the above-mentioned methods of various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0249] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A Bluetooth connection method, characterized in that: include: Sending a first Bluetooth connection request to the electronic device at a first moment; If a second Bluetooth connection request sent by the electronic device is received at the first moment, sending a first random number to the electronic device and receiving a second random number sent by the electronic device; If the first random number is smaller than the second random number, the first Bluetooth connection request is canceled and a Bluetooth connection is established with the electronic device according to the second Bluetooth connection request.

2. The method according to claim 1, characterized in that The method further comprises: If the first random number is greater than the second random number, establishing a Bluetooth connection with the electronic device according to the first Bluetooth connection request.

3. The method according to claim 1 or 2, characterized in that The sending a first random number to the electronic device includes: A first target signaling is sent to the electronic device, where the first target signaling includes the first random number.

4. The method according to claim 3, characterized in that The first target signaling is a Logical Link Control and Adaptation Protocol response L2CAP ECHO signaling.

5. The method according to claim 1 or 2, characterized in that The receiving a second random number sent by the electronic device includes: A second target signaling sent by the electronic device is received, where the second target signaling includes the second random number.

6. The method according to claim 5, characterized in that The second target signaling is L2CAP ECHO signaling.

7. A Bluetooth connection method, characterized in that: include: The first electronic device sends a first Bluetooth connection request to the second electronic device at a first moment; If the first electronic device receives the second Bluetooth connection request sent by the second electronic device at the first moment, the first electronic device sends a first random number to the second electronic device; If the first electronic device receives the second random number sent by the second electronic device and the first random number is smaller than the second random number, the first electronic device cancels the first Bluetooth connection request and establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; If the first electronic device does not receive the second random number sent by the second electronic device, it starts the first target timer and establishes a Bluetooth connection based on the timeout of the first target timer. The timing range of the first target timer and the second target timer are different. The second target timer is the timer started by the second electronic device.

8. The method according to claim 7, characterized in that The method further comprises: If the first electronic device receives the second random number sent by the second electronic device and the first random number is greater than the second random number, the first electronic device establishes a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

9. The method according to claim 7 or 8, characterized in that The establishing of the Bluetooth connection according to the timeout of the first target timer includes: If the first target timer times out and the second electronic device does not cancel the second Bluetooth connection request, the first electronic device cancels the first Bluetooth connection request and establishes a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; If the first target timer has not timed out and the second electronic device cancels the second Bluetooth connection request, the first electronic device establishes a Bluetooth connection with the second electronic device according to the first Bluetooth connection request.

10. The method according to claim 7 or 8, characterized in that An ACL exists between the first electronic device and the second electronic device, and starting the first target timer includes: The first target timer is started according to role information, where the role information is used to indicate a role of the first electronic device in the ACL.

11. The method according to claim 10, characterized in that The starting the first target timer according to the role information includes: If the first electronic device is a master in the ACL, starting a first random timer; If the first electronic device is a slave in the ACL, a second random timer is started, and the timing ranges of the first random timer and the second random timer are different.

12. An electronic device, characterized in that: The invention comprises a processor and a memory coupled to the processor, wherein the processor is configured to: Sending a first Bluetooth connection request to the second electronic device at a first moment; If a second Bluetooth connection request is received from the second electronic device at the first moment, sending a first random number to the second electronic device and receiving a second random number sent from the second electronic device; If the first random number is smaller than the second random number, the first Bluetooth connection request is canceled and a Bluetooth connection is established with the second electronic device according to the second Bluetooth connection request.

13. The electronic device according to claim 12, wherein: The processor is further configured to: If the first random number is greater than the second random number, a Bluetooth connection is established with the second electronic device according to the first Bluetooth connection request.

14. The electronic device according to claim 12 or 13, characterized in that: The processor is specifically configured to: A first target signaling is sent to the second electronic device, where the first target signaling includes the first random number.

15. The electronic device according to claim 14, characterized in that The first target signaling is L2CAP EC HO signaling.

16. The electronic device according to claim 12 or 13, characterized in that: The processor is specifically configured to: A second target signaling sent by the second electronic device is received, where the second target signaling includes the second random number.

17. The electronic device according to claim 16, wherein: The second target signaling is L2CAP EC HO signaling.

18. An electronic device, characterized in that: The invention comprises a processor and a memory coupled to the processor, wherein the processor is configured to: Sending a first Bluetooth connection request to the second electronic device at a first moment; If a second Bluetooth connection request sent by the second electronic device is received at the first moment, sending a first random number to the second electronic device; If a second random number sent by the second electronic device is received and the first random number is smaller than the second random number, canceling the first Bluetooth connection request and establishing a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; If the second random number sent by the second electronic device is not received, the first target timer is started and a Bluetooth connection is established according to the timeout of the first target timer. The timing range of the first target timer and the second target timer are different. The second target timer is the timer started by the second electronic device.

19. The electronic device according to claim 18, wherein: The processor is further configured to: If the second random number sent by the second electronic device is received and the first random number is greater than the second random number, a Bluetooth connection is established with the second electronic device according to the first Bluetooth connection request.

20. The electronic device according to claim 18 or 19, characterized in that: The processor is specifically configured to: If the first target timer times out and the second electronic device does not cancel the second Bluetooth connection request, canceling the first Bluetooth connection request and establishing a Bluetooth connection with the second electronic device according to the second Bluetooth connection request; If the first target timer has not timed out and the second electronic device cancels the second Bluetooth connection request, a Bluetooth connection is established with the second electronic device according to the first Bluetooth connection request.

21. The electronic device according to claim 18 or 19, characterized in that: There is an ACL between the electronic device and the second electronic device, and the processor is specifically configured to: The first target timer is started according to role information, where the role information is used to indicate a role of the electronic device in the ACL.

22. The electronic device according to claim 21, characterized in that: The processor is specifically configured to: If the electronic device is a master in the ACL, starting a first random timer; If the electronic device is a slave in the ACL, a second random timer is started, and the timing ranges of the first random timer and the second random timer are different.

23. A chip device comprising at least one processor and an interface circuit, wherein the at least one processor and the interface circuit are coupled, wherein: The at least one processor executes a program or instruction stored in the memory, so that the chip device implements the method of any one of claims 1 to 6 or any one of claims 7 to 11.

24. A computer-readable storage medium for storing a computer program, characterized in that: The computer program comprises instructions for implementing the method of any one of claims 1 to 6 or any one of claims 7 to 11 above.

25. A computer program product comprising instructions, characterized in that: When the instructions are executed on a computer or a processor, the computer or the processor is caused to implement the method according to any one of claims 1 to 6 or any one of claims 7 to 11.

Citation Information

Patent Citations

  • Bluetooth reconnection method and related device

    CN112399390A

  • Method and apparatus for bluetooth connection

    US20160360345A1