A Bluetooth networking method, electronic device, storage medium and program product
By receiving Bluetooth heartbeat packets after the external power supply to the electronic device to maintain a long Bluetooth connection, the problem of Bluetooth networking interruption when the device enters power-saving mode is solved, enabling continuous business interaction between devices and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-10-23
- Publication Date
- 2026-06-09
Smart Images

Figure CN120434608B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a Bluetooth networking method, electronic device, storage medium, and program product. Background Technology
[0002] With the development of electronic devices, more and more electronic devices can connect to each other via Bluetooth networking, enabling data transmission and sharing of hardware and software resources among multiple devices. For example, mobile phones, tablets, and laptops can connect to each other via Bluetooth networking, allowing users to control their mobile phones and tablets using the laptop's keyboard and mouse.
[0003] When multiple electronic devices successfully connect to each other via Bluetooth networking, they rely on Bluetooth broadcasting to maintain the connection. However, when an electronic device (such as a laptop) is disconnected from its external power source, it switches to power-saving mode by default. In power-saving mode, some Bluetooth functions are disabled, resulting in the inability to maintain Bluetooth networking and conduct business interactions between devices. Summary of the Invention
[0004] This application provides a Bluetooth networking method, electronic device, storage medium, and program product. After the first device disconnects from the external power supply, if a long Bluetooth connection with the second device is determined to exist, the Bluetooth networking with the second device is maintained. This allows the first device to continue Bluetooth networking with the second device and continue business interaction with the second device even when the first device is in power-saving mode.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, a Bluetooth networking method is provided, the method comprising: applying to a first device, the Bluetooth networking method comprising:
[0007] The first device receives a Bluetooth broadcast from the second device and establishes a Bluetooth long connection with the second device. After that, the first device and the second device establish a Bluetooth network. The first device receives a first Bluetooth heartbeat packet from the second device every preset time interval to maintain the Bluetooth network between the first device and the second device. After the first device disconnects the external power supply, if the first device does not receive the first Bluetooth heartbeat packet within the preset time interval, and if the first device determines that there is a Bluetooth long connection with the second device, the first device maintains the Bluetooth network with the second device.
[0008] It is understood that the first device maintains the Bluetooth network with the second device by receiving the first Bluetooth heartbeat packet from the second device. After the first device disconnects the external power, it continues to maintain the Bluetooth network with the second device if it is determined that there is a long Bluetooth connection with the second device, so as to realize the business interaction between devices in the Bluetooth network.
[0009] In one possible implementation of the first aspect, the Bluetooth networking method described above may further include:
[0010] After the first device disconnects from the external power supply, the first device stops Bluetooth scanning;
[0011] After the first device maintains Bluetooth networking with the second device, the first device continues Bluetooth scanning.
[0012] It is understandable that after the first device is disconnected from the external power supply, it stops performing Bluetooth scanning to reduce power consumption and extend battery life. Only after the first device confirms that it is maintaining Bluetooth networking with the second device will it resume Bluetooth scanning to receive the first Bluetooth heartbeat packet sent by the second device, thus maintaining Bluetooth networking with the second device.
[0013] In another possible implementation of the first aspect, the Bluetooth networking method described above may further include:
[0014] After the first device disconnects from the external power supply, the first device stops sending the second Bluetooth heartbeat packet to the second device. The second Bluetooth heartbeat packet is used by the first device and the second device to maintain Bluetooth networking.
[0015] After the first device maintains Bluetooth networking with the second device, the first device continues to send a second Bluetooth heartbeat packet to the second device.
[0016] It is understandable that after the first device disconnects from the external power supply, it stops sending the second Bluetooth heartbeat packet to reduce its power consumption and extend its battery life. After the first device confirms that it is maintaining the Bluetooth network with the second device, it continues to send the second Bluetooth heartbeat packet to maintain the Bluetooth network with the second device, so that the first device and the second device can subsequently conduct business interactions.
[0017] In another possible implementation of the first aspect, after the first device and the second device establish a Bluetooth network, the Bluetooth networking method may further include:
[0018] The first device displays the target interface. This target interface includes the devices in the Bluetooth network and the services supported by those devices.
[0019] In other words, after the first device and the second device establish a Bluetooth network, the interface of the first device can display the devices in the Bluetooth network and the services they support. This allows users to intuitively identify the devices in the Bluetooth network and the services they support from the first device's interface, improving the user experience.
[0020] For example, such as Figure 9 The interface 910 shows a laptop 901, a mobile phone 902, and a tablet 903 in a Bluetooth network, as well as the services supported by the devices in the Bluetooth network, namely screen sharing and keyboard and mouse sharing.
[0021] In another possible implementation of the first aspect, the first device determines that a Bluetooth long connection has been established with the second device, including:
[0022] If the first device determines that the first identification information exists in the preset storage location, then the first device determines that a Bluetooth long connection has been established with the second device. The first identification information is used to indicate that a Bluetooth long connection exists between the first device and the second device.
[0023] It is understandable that after the first device and the second device establish a Bluetooth long connection, the first device stores the first identification information in a preset storage location. After the first device and the second device disconnect the Bluetooth long connection, the first device deletes the first identification information in the preset storage location. Thus, the first device can determine whether the Bluetooth long connection between the first device and the second device exists based on whether the first identification information is stored in the preset storage location.
[0024] In another possible implementation of the first aspect, Bluetooth long-lived connectivity includes either low-power BLE long-lived connectivity or classic BR long-lived connectivity.
[0025] This can be understood as follows: when the system version of the second device is different, the type of Bluetooth long connection supported will also be different. Therefore, the Bluetooth long connection between the first device and the second device can be either a BLE long connection or a BR long connection.
[0026] In another possible implementation of the first aspect, there are multiple second devices, including a third device and a fourth device. The first device receives a first Bluetooth heartbeat packet sent from the second device every preset time interval, including:
[0027] The first device receives a third Bluetooth heartbeat packet from the third device every preset first time interval; or, the first device receives a fourth Bluetooth heartbeat packet from the fourth device every preset second time interval.
[0028] When the first device does not receive the first Bluetooth heartbeat packet within a preset time period, if the first device determines that a long Bluetooth connection exists with the second device, the first device maintains the Bluetooth network with the second device, including:
[0029] If the first device does not receive a third Bluetooth heartbeat packet within a first time period, and if the first device determines that a BLE long connection has been established with the third device, then the first device maintains the Bluetooth networking with the third device; or,
[0030] If the first device does not receive the fourth Bluetooth heartbeat packet within the second time period, and if the first device determines that a long BR connection has been established with the fourth device, then the first device maintains the Bluetooth networking with the fourth device.
[0031] It is understandable that the first device maintains the Bluetooth network with the third device by periodically receiving the third Bluetooth heartbeat packet from the third device. After the first device disconnects the external power, it continues to maintain the Bluetooth network with the third device if it is determined that there is a long BLE connection with the third device, so as to realize the service interaction between devices in the Bluetooth network.
[0032] The first device maintains its Bluetooth network with the fourth device by periodically receiving the fourth Bluetooth heartbeat packet from the fourth device. After the first device disconnects its external power, it continues to maintain its Bluetooth network with the fourth device if it confirms that a long BR connection exists between the two devices, so as to enable service interaction between devices in the Bluetooth network.
[0033] Secondly, this application provides a Bluetooth networking method applied to a second device, the method comprising:
[0034] The second device sends a Bluetooth broadcast to the first device, establishes a long Bluetooth connection with the first device, and then establishes a Bluetooth network with the first device. The second device receives a second Bluetooth heartbeat packet from the first device every preset time interval. The second Bluetooth heartbeat packet is used by the second device and the first device to maintain the Bluetooth network. If the second device does not receive a second Bluetooth heartbeat packet from the first device within the preset time interval, and if the second device determines that a long Bluetooth connection has been established with the first device, then the second device maintains the Bluetooth network with the first device.
[0035] It is understood that the second device maintains the Bluetooth network with the first device by receiving the second Bluetooth heartbeat packet from the first device. After the first device disconnects the external power, if the second device does not receive the second Bluetooth heartbeat packet within a preset time, and the second device determines that there is a long Bluetooth connection with the first device, it continues to maintain the Bluetooth network with the first device to realize the service interaction between devices in the Bluetooth network.
[0036] In one possible implementation of the second aspect, the second device determines that a Bluetooth long connection has been established with the second device, including:
[0037] If the second device determines that the second identification information exists in the preset storage location, then the second device determines that a Bluetooth long connection has been established with the first device. The second identification information is used to indicate that a Bluetooth long connection exists between the second device and the first device.
[0038] Therefore, the second device can directly determine whether there is a long Bluetooth connection with the first device based on whether the second identifier information exists in the preset storage location, thus avoiding the situation where the second device cannot determine whether there is a long Bluetooth connection with the first device in time, which would cause the Bluetooth networking between the first device and the second device to be disconnected.
[0039] In another possible implementation of the second aspect, after the second device maintains Bluetooth networking with the first device, the Bluetooth networking method may further include:
[0040] Send a first instruction message to the first device, the first instruction message being used to instruct the first device to maintain Bluetooth networking with the second device.
[0041] It is understandable that after the second device and the first device maintain Bluetooth networking, the second device sends a first instruction message to the first device, so that after the first device receives the first instruction message, it continues to maintain Bluetooth networking with the second device in order to realize business interaction with the second device.
[0042] In another possible implementation of the second aspect, after the second device maintains Bluetooth networking with the first device, the Bluetooth networking method may further include:
[0043] Send a second instruction message to the first device. The second instruction message is used to instruct the first device to continue Bluetooth scanning and to continue sending a second Bluetooth heartbeat packet to the second device.
[0044] It is understandable that after the second device and the first device maintain Bluetooth networking, the second device sends a second instruction message to the first device, so that after the first device receives the second instruction message, it continues to perform Bluetooth scanning and continues to send a second Bluetooth heartbeat packet. The second device continues to maintain Bluetooth networking with the first device based on the second Bluetooth heartbeat packet from the first device, so as to realize business interaction between the second device and the first device.
[0045] Thirdly, this application provides a Bluetooth networking system, which includes a first device and a second device.
[0046] The second device is used to send a Bluetooth broadcast to the first device; the first device is used to receive the Bluetooth broadcast and establish a Bluetooth long connection with the second device; a Bluetooth network is established between the first device and the second device; the second device is also used to send a first Bluetooth heartbeat packet to the first device at preset intervals, the first Bluetooth heartbeat packet is used by the second device and the first device to maintain the Bluetooth network; the first device is also used to maintain the Bluetooth network with the second device if it determines that a Bluetooth long connection has been established with the second device after the first device disconnects its external power and does not receive the first Bluetooth heartbeat packet within a preset interval.
[0047] Fourthly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the Bluetooth networking method described in any one of the first aspects above, or to implement the Bluetooth networking method described in any one of the second aspects above.
[0048] Fifthly, this application provides a computer-readable storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the Bluetooth networking method described in any one of the first aspects.
[0049] In a sixth aspect, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the Bluetooth networking method described in any one of the first aspects.
[0050] It is understood that the electronic device described in the fourth aspect, the computer-readable storage medium described in the fifth aspect, and the computer program product described in the sixth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here. Attached Figure Description
[0051] Figure 1 Example diagram of the user account login interface provided in this application embodiment;
[0052] Figure 2 This is a schematic diagram of the Bluetooth networking method in related technologies;
[0053] Figure 3 This is an example diagram of Bluetooth networking methods in related technologies;
[0054] Figure 4 An architecture diagram of a Bluetooth networking system provided in this application embodiment;
[0055] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0056] Figure 6 A software structure diagram of an electronic device provided in an embodiment of this application.
[0057] Figure 7 Interface example of the first device provided in the embodiments of this application Figure 1 ;
[0058] Figure 8 Interface example of the first device provided in the embodiments of this application Figure 2 ;
[0059] Figure 9 An example interface diagram of the Bluetooth connection process provided in the embodiments of this application;
[0060] Figure 10 Example diagram of the interface after a laptop establishes a Bluetooth network with other devices, provided in the embodiments of this application;
[0061] Figure 11 Example diagrams of the interface after establishing a Bluetooth network for other devices provided in the embodiments of this application;
[0062] Figure 12 Interface example of the first device provided in the embodiments of this application Figure 3 ;
[0063] Figure 13 A flowchart illustrating a Bluetooth networking method provided in an embodiment of this application;
[0064] Figure 14 A schematic diagram illustrating the process of establishing a BLE long connection between the first device and device 1, provided in an embodiment of this application;
[0065] Figure 15 A schematic diagram illustrating the process of establishing a long BR connection between the first device and device 1 provided in this application embodiment;
[0066] Figure 16 This is another structural schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0067] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0068] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this application, unless otherwise stated, "a plurality of" means two or more.
[0069] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0070] Currently, multiple Bluetooth-enabled electronic devices can form a Bluetooth network to enable inter-device communication. For example, devices in a Bluetooth network can send and receive data, share screens, share keyboards and mice, and send super notifications.
[0071] Among these, "Super Keyboard and Mouse" refers to a user's ability to control multiple devices using a single mouse or keyboard. For example, after a laptop and a mobile phone establish a Bluetooth connection, the user can control the phone through the laptop's keyboard, or vice versa. "Super Notification" refers to the ability to simultaneously display notification messages on multiple Bluetooth-connected devices. For instance, notifications on a mobile phone can be instantly displayed on the laptop screen.
[0072] In some implementations, multiple electronic devices can log in to the same account and form a Bluetooth network. After the multiple electronic devices successfully form a Bluetooth network, business interaction between the devices in the Bluetooth network can be realized.
[0073] Electronic devices have account functionality, meaning users can register accounts and log in on electronic devices. At the same time, the registered accounts can also be used to log in on other electronic devices to enable services such as sharing user information between electronic devices.
[0074] For example, such as Figure 1As shown, taking a mobile phone as an example, the phone's settings page has a "Login Account" control 101. After the user clicks this control, the phone can redirect to the account login page 102 in response to the user's click operation. On the account login page 102, the user can enter the account and password set during registration. If the verification is successful, the phone can complete the login process. Alternatively, if the user's account is a mobile phone number, the login process can also be completed using the mobile phone number and SMS verification code. Alternatively, the phone can also complete the login process using the user's biometric information, such as facial recognition or fingerprint.
[0075] When multiple electronic devices log into the same user account, they trigger Bluetooth broadcasts to establish a Bluetooth network. After successfully establishing a network, the devices periodically send heartbeat packets to maintain the Bluetooth connection. However, when an electronic device (e.g., a laptop) decides to disconnect from the power supply, it switches to power-saving mode by default. In power-saving mode, the device stops Bluetooth broadcasting and scanning, and no longer sends heartbeat packets. Other devices, not receiving heartbeat packets from this device within a preset time, disconnect from its Bluetooth connection. Ultimately, this prevents the device from maintaining a Bluetooth connection in power-saving mode, hindering inter-device communication.
[0076] For example, such as Figure 2 As shown, taking a laptop and a mobile phone as examples, both devices have Bluetooth enabled. Assuming the same user account is logged in on both devices, the laptop scans for nearby connectable devices via Bluetooth broadcast. When the laptop detects the Bluetooth broadcast signal from the mobile phone, a Bluetooth Low Energy (BLE) short connection is established between them. Then, the laptop and mobile phone pair. For example, the laptop generates a pairing password. If the pairing password received by the mobile phone matches the password generated by the laptop, the pairing is successful. After successful pairing, the laptop sends a connection request to the mobile phone, establishing a communication link, i.e., a Bluetooth connection. Once the communication link is established, the mobile phone becomes online on the laptop side, and the laptop also becomes online on the mobile phone side. This allows the laptop and mobile phone to perform data transmission and reception, screen sharing, keyboard and mouse sharing, and super notifications.
[0077] The Bluetooth connection established between a laptop and a mobile phone can be either a basic rate (BR) Bluetooth connection or a BLE long connection, depending on the Bluetooth version of the mobile phone. A classic Bluetooth connection refers to modules below Bluetooth 4.0, generally used for large data transfers. A BLE long connection refers to Bluetooth 4.0 or higher, a short-range, low-cost, interoperable wireless technology characterized by low power consumption, short message length, high-efficiency encoding, and short connection establishment time.
[0078] After a laptop and a mobile phone establish a Bluetooth connection, a Bluetooth network is created between them. The laptop and phone send Bluetooth heartbeat packets to each other at preset intervals to maintain the network. For example, the laptop sends a Bluetooth heartbeat packet to the phone every 30 seconds, and the phone sends a Bluetooth heartbeat packet to the laptop every 30 seconds. If the laptop does not receive a Bluetooth heartbeat packet from the phone within the preset time, the laptop disconnects the BLE connection with the phone, thus ending the Bluetooth network connection. Similarly, if the phone does not receive a Bluetooth heartbeat packet from the laptop within the preset time, the phone disconnects the BLE connection with the laptop, thus ending the Bluetooth network connection.
[0079] During the process of establishing a Bluetooth network between the laptop and the mobile phone, the laptop switches to power-saving mode after confirming that the external power connection has been disconnected.
[0080] In power-saving mode, the laptop stops sending Bluetooth heartbeat packets and also stops performing Bluetooth scans.
[0081] When a laptop is in power-saving mode, if the phone does not receive a Bluetooth heartbeat from the laptop within a preset time, the phone disconnects from the Bluetooth network between the two devices. Similarly, if the laptop also does not receive a Bluetooth heartbeat from the phone within a preset time, the laptop disconnects from the Bluetooth network between the two devices, preventing them from interacting with each other. This includes services such as data transmission and reception, screen sharing, keyboard and mouse sharing, and super notifications.
[0082] For example, such as Figure 3 As shown in (a), when the laptop is connected to an external power source 330, after a Bluetooth network is established between the laptop 310 and the mobile phone 320, the laptop's display shows the devices in the Bluetooth network, namely the laptop 310 and the mobile phone 320. When the laptop is disconnected from the external power source 330 and switches to power-saving mode, the Bluetooth network between the laptop 310 and the mobile phone 320 is disconnected, and the mobile phone 320 is no longer displayed on the laptop's display. Figure 3 As shown in (b), the laptop computer's display interface only shows the laptop computer 310, and the laptop computer 310 is unable to interact with the mobile phone 320.
[0083] Therefore, this application provides a Bluetooth networking method applied to a Bluetooth networking system, which may include a first device and at least one second device. The second device is used to send Bluetooth broadcasts to the first device. The first device is used to receive the Bluetooth broadcasts, and after establishing a Bluetooth long connection with the second device, a Bluetooth network is established between the first device and the second device. The second device is also used to send a first Bluetooth heartbeat packet to the first device at preset intervals. The first Bluetooth heartbeat packet is used by the second device to maintain the Bluetooth network with the first device. Furthermore, after the first device is powered off, if the first device does not receive the first Bluetooth heartbeat packet within the preset interval, and if the first device determines that a Bluetooth long connection exists with the second device, then the first device determines to maintain the Bluetooth network with the second device.
[0084] In one scenario, the Bluetooth networking method provided in this application is applied to a first device. The method may include: the first device receiving a Bluetooth broadcast from a second device; establishing a Bluetooth long connection with the second device; and then establishing a Bluetooth network between the first device and the second device. The first device then receives a first Bluetooth heartbeat packet from the second device every preset time interval. The first Bluetooth heartbeat packet is used to maintain the Bluetooth network between the first device and the second device. After the first device disconnects its external power, if the first device does not receive the first Bluetooth heartbeat packet within the preset time interval, and if the first device determines that a Bluetooth long connection exists with the second device, then the first device maintains the Bluetooth network with the second device. Therefore, after the first device disconnects its external power, and if a Bluetooth long connection is determined to exist, the Bluetooth network with the second device is maintained, ensuring that the first device is in power-saving mode and avoiding the problem of the Bluetooth network breaking down after the first device disconnects its external power.
[0085] In another scenario, the Bluetooth networking method provided in this application is applied to a second device. The method may include: the second device sending a Bluetooth broadcast to the first device, establishing a Bluetooth long connection with the first device, and then establishing a Bluetooth network with the first device; the second device receiving a second Bluetooth heartbeat packet from the first device every preset time interval; the second Bluetooth heartbeat packet being used by the second device to maintain the Bluetooth network with the first device; and if the second device does not receive a second Bluetooth heartbeat packet from the first device within the preset time interval, and if the second device determines that a Bluetooth long connection has been established with the first device, then the second device determines to maintain the Bluetooth network with the first device.
[0086] For example, Figure 4 This is an architecture diagram of a Bluetooth networking system provided in an embodiment of this application. Figure 4 As shown, the Bluetooth networking system 40 may include a first device 410, a second device 420, and a second device 430.
[0087] In this setup, the first device 410, the second device 420, and the second device 430 establish a Bluetooth network, enabling them to communicate with each other via Bluetooth technology. For example, a BLE long-lived connection is established between the first device 410 and the second device 420, a BR long-lived connection is established between the first device 410 and the second device 430, and a BR long-lived connection is also established between the second devices 420 and 430.
[0088] It needs to be explained that, Figure 4 The Bluetooth connection type established between the first device 410, the second device 420, and the second device 430 in this application is just an example. This application does not limit the type of Bluetooth connection established between the first device 410, the second device 420, and the second device 430. For example, the first device 410, the second device 420, and the second device 430 may all establish a BLE long connection or a BR long connection.
[0089] Figure 4 Taking a laptop computer as an example, a tablet computer as an example, and a mobile phone as an example, the second device 410 can also be a mobile phone, a laptop computer, or other terminal device that supports Bluetooth functionality. Similarly, the second device 430 can also be a tablet computer, a laptop computer, or other terminal device that supports Bluetooth functionality. Furthermore, the second device 420 and the second device 430 can also be personal computers (PCs), personal digital assistants (PDAs), smartwatches, netbooks, wearable electronic devices, augmented reality (AR) devices, virtual reality (VR) devices, in-vehicle devices, smart cars, smart speakers, or other electronic devices with Bluetooth functionality. This application embodiment does not impose any limitations on these aspects.
[0090] The structure and software architecture of the electronic device in the embodiments of this application will be described below. For example... Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0091] Electronic device 500 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0092] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 500. In other embodiments of this application, the electronic device 500 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0093] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0094] The controller can be the nerve center and command center of the electronic device 500. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.
[0095] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0096] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0097] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 500. In other embodiments of this application, the electronic device 500 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0098] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 500. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0099] In this embodiment, when the external power source of the electronic device 500 is connected, the charging management module 140 receives charging input from the charger to charge the battery 142. When the external power source of the electronic device 500 is disconnected, the charging management module 140 no longer receives charging input from the charger, and the electronic device 500 relies on the battery 142 for continued operation.
[0100] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0101] The wireless communication function of electronic device 500 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.
[0102] Antennas 1 and 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 500 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0103] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 500. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0104] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 500, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0105] In this embodiment, the wireless communication module 160 can be used to establish a Bluetooth long connection between the electronic device 500 and other electronic devices, so as to establish a Bluetooth network with other electronic devices.
[0106] In some embodiments, antenna 1 of electronic device 500 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 500 to communicate with networks and other devices via wireless communication technology. Wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. GNSS can include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0107] Electronic device 500 implements display functions through a GPU, display screen 194, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU performs mathematical and geometric calculations and is used for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0108] Electronic device 500 can achieve shooting function through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0109] Electronic device 500 can implement audio functions such as music playback and recording through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0110] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to illustrate the software structure of an electronic device.
[0111] Figure 6 This is a software structure diagram of an electronic device provided in an embodiment of this application.
[0112] Understandably, a layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system may include an application layer (referred to as the application layer), an application framework layer (referred to as the framework layer), system libraries, and a kernel layer.
[0113] The application layer described above may include a series of application packages.
[0114] like Figure 6 As shown, the application package may include system applications. System applications refer to applications installed on the electronic device before it leaves the factory. For example, system applications may include programs such as Bluetooth, camera, gallery, calendar, music, SMS, and weather.
[0115] Application packages can also include third-party applications, which are applications that users download and install from app stores (or app markets). Examples include map applications, food delivery applications, reading applications (such as e-books), social networking applications, and travel applications.
[0116] The application framework layer described above provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0117] like Figure 6 As shown, the application framework layer may include a Bluetooth service module, an input service module, etc.
[0118] The Bluetooth service module provides a set of interfaces for applications or other software modules to control Bluetooth. For example, electronic devices can use the Bluetooth control module to turn Bluetooth on or off, search for and pair with other devices, and establish Bluetooth long-term connections.
[0119] The input service module is used to monitor the input modules (such as touchscreen drivers) of electronic device 500, and convert the parameters input by the input modules into usable events, which are then passed to the relevant upper-layer modules. For example, the input service module is used to monitor the touchscreen of electronic device 500 through the touchscreen driver, and convert the touch parameters generated by the touchscreen input into usable events, which are then passed to the upper-layer application.
[0120] For example, in this embodiment of the application, in response to a user triggering an operation in the first device to establish a Bluetooth connection with other electronic devices, the input service module sends a command to Bluetooth. In response to this command, the Bluetooth call interface triggers the Bluetooth service module to establish a Bluetooth connection with other devices through the wireless communication module.
[0121] The application framework layer may also include: window manager, content provider, view system, phone manager, resource manager, notification manager, etc. Figure 6 (Not shown in the text).
[0122] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0123] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.
[0124] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0125] A phone manager is used to provide communication functions for electronic devices. For example, it manages call status (including connection and disconnection).
[0126] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0127] The notification manager allows applications to display notification information in the status bar. It can be used to convey informational messages and can disappear automatically after a short time without user interaction.
[0128] The Android Runtime consists of core libraries and a virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.
[0129] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0130] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0131] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), and the Android runtime, etc.
[0132] The kernel layer is the layer between hardware and software. The kernel layer includes at least the display driver, camera driver, audio driver, and sensor driver.
[0133] Based on the electronic device with the structure shown above, the following uses the Bluetooth networking method provided in the embodiments of this application applied to a laptop computer as an example. The interface process of the Bluetooth networking method provided in the embodiments of this application will be described in conjunction with the accompanying drawings and application scenarios.
[0134] In this application, both the laptop and other electronic devices support intelligent interconnection (i.e., trust loop functionality), meaning that when the laptop and other electronic devices are logged into the same user account, seamless connection and operation can be achieved between different devices. For example, the laptop's keyboard and mouse can operate applications and documents on mobile phones and tablets, and even drag and drop images and files across screens. Furthermore, the trust loop functionality also supports keyboard and mouse sharing, screen sharing, super notifications, automatic location recognition, cross-device office work, and cross-screen notification / call transfer, greatly improving the convenience and efficiency of user operation across different devices.
[0135] For ease of description, the laptop computer will be referred to as the first device, and other electronic devices as the second device. When the laptop computer is intelligently interconnected with multiple electronic devices, there can be multiple second devices. That is to say, this application does not limit the number of second devices.
[0136] For example, in such Figure 7 On the interface shown, if the first device has the smart interconnection function enabled, the first device can search for the second device and establish a communication connection with the second device to realize the trust loop function.
[0137] In one scenario, after the first device detects the second device, it can establish a communication connection with the second device to achieve a trust loop function.
[0138] In another scenario, the first device may be unable to find the second device. In this case, the first device cannot establish a communication connection with the second device, and the trust loop function cannot be implemented. This is because the second device is not logged into the same account as the first device, the "Smart Connect" function is not enabled, or the second device does not have Bluetooth and Wi-Fi (WLAN) enabled, or is not connected to a network. For example, as shown... Figure 7 The display area 701 shown indicates possible reasons why the laptop did not detect other devices.
[0139] It should be noted that, Figure 7 The reason why the first device did not find the second device, shown in display area 701, is only an example. There may be other reasons why the first device cannot find other devices. For example, the second device may be too far away from the first device, causing the first device to be unable to find the second device.
[0140] In this application, if the communication connection between the first device and the second device is a Bluetooth connection, both the first device and the second device need to turn on the Bluetooth switch in advance before establishing the communication connection so that the device itself can be scanned by other devices.
[0141] For example, after detecting a user's action to display the settings interface, the first device displays the settings interface in response to the user's action. The first device detects a user's action to trigger a Bluetooth device within the settings interface and displays the Bluetooth settings interface, such as... Figure 8 Interface 801. The first device detects the user's trigger operation on control 802, and in response to the user's operation, the first device turns on the Bluetooth switch.
[0142] The second device detects the user's triggered action on the settings application and, in response to the user's action, displays the device application as follows: Figure 9 The settings interface 901 is shown in (a). The second device detects the user's trigger operation on control 903, and in response to the user's operation, turns on the Bluetooth switch and displays... Figure 9 The Bluetooth settings interface 902 is shown in (b). It can be seen that if the second device has Bluetooth turned on, paired and available devices will be displayed.
[0143] In this context, "paired device" refers to a device that has already established a Bluetooth connection with the second device, while "available device" refers to a device currently detected via Bluetooth signal but not yet connected to the second device. If the first device has Bluetooth enabled, its device information (e.g., device name, device model) can be displayed in the available devices list of the second device.
[0144] Still Figure 8 As shown, when the first device detects a user's trigger operation on the add device control 803, in response to the user's operation, a list of available devices is displayed on the first device's Bluetooth settings interface. Assume that the list of available devices displayed on the first device's Bluetooth settings page includes a second device. On this page, if the first device detects that the user has selected the second device, the first device can send a pairing request to the second device to establish a Bluetooth connection. Correspondingly, the pairing request will be displayed on the second device, such as... Figure 9 As shown in (c), a pairing request prompt box 904 can pop up on the second device. If the second device detects the user's triggering operation on the "Yes" control, the Bluetooth connection process between the first device and the second device is completed.
[0145] After the first device and the second device establish a Bluetooth connection, the first device will display the second device as one of its paired devices. Similarly, the second device will display the first device as one of its paired devices on its Bluetooth settings page.
[0146] In some embodiments, when both the Bluetooth switches of the first device and the second device are turned on, and the smart interconnection switches of the first device and the second device are turned on, when the first device and the second device are logged into the same user account, a Bluetooth connection is established between the first device and the second device, and a Bluetooth network is formed between them (i.e., a trust loop is constructed) to realize the trust loop function. In this case, the trust loop management interface can be displayed on the display interfaces of the first device and the second device. The trust loop management interface includes the first device and the second device that have formed the trust loop, as well as the target services supported between the first device and the second device. At this time, the first device is connected to an external power source.
[0147] For example, such as Figure 10As shown in (a), the laptop is connected to an external power supply 1000. When a trust loop is established between the laptop, mobile phone, and tablet, the trust loop management interface 1010 of the laptop displays product icons for the laptop 1001, mobile phone 1002, and tablet 1003, allowing the user to intuitively identify the devices that have established the trust loop based on the product icons. Furthermore, the trust loop management interface 1010 also displays the trust loop functions supported between the laptop 1001, mobile phone 1002, and tablet 1003, such as screen sharing and keyboard / mouse sharing. After the laptop detects a user's trigger operation on the mobile phone's product icon 1002, in response to the user's trigger operation, screen sharing and keyboard / mouse sharing are implemented between the laptop and the mobile phone.
[0148] In addition, the laptop can respond to user actions and configure permissions for target services supported between devices. For example, if the laptop detects that the user has disabled keyboard and mouse sharing, keyboard and mouse sharing will no longer be supported between the laptop and other devices.
[0149] When a trust loop is established between a laptop, mobile phone, and tablet, the trust loop management interface of the mobile phone and tablet will also display the product icons of laptop 1001, mobile phone 1002, and tablet 1003, as well as the supported trust loop functions. For example, as shown below... Figure 11 Figures (a) and (b) show the Trust Ring Management interface displayed on the mobile phone and tablet, respectively.
[0150] It needs to be explained that the above Figure 10 and Figure 11 The trust ring features shown include screen sharing and keyboard / mouse sharing, which are only examples; not all trust ring features are shown here. Furthermore, Figure 10 and Figure 11 The trust loops between laptops, mobile phones, and tablets shown are merely examples.
[0151] After establishing a Bluetooth network between the first and second devices, they can maintain this network by periodically sending Bluetooth heartbeat packets (e.g., every 30 or 40 seconds), enabling a trust loop function between them. The Bluetooth heartbeat packets are used to maintain the network. Specifically, if both devices periodically receive Bluetooth heartbeat packets from each other, the network remains active. For example, the first device can send a heartbeat packet to the second device every 30 seconds, and the second device can send one every 30 seconds. If the first device receives a heartbeat packet from the second device every 30 seconds, it confirms the second device is online and maintains the network. Similarly, if the second device receives a heartbeat packet from the first device every 30 seconds, it confirms the first device is online and maintains the network.
[0152] In some implementations, if the first device does not receive a Bluetooth heartbeat packet from the second device within a preset time period, the first device determines that the second device is offline and disconnects the Bluetooth network between the first and second devices. In other words, the trust loop established between the first and second devices is broken, and the trust loop function cannot be supported between the first and second devices. For example, suppose... Figure 10 If the laptop 1001 shown in (a) does not receive a Bluetooth heartbeat packet from the tablet 1003 within 30 seconds, the laptop 1001 will disconnect the Bluetooth long connection with the tablet 1003, and the product icon of the tablet 1003 will no longer be displayed in the trust ring management interface. That is, the trust ring management interface displayed on the laptop will be changed from... Figure 10 Interface 1010 shown in (a) switches to Figure 10 Interface 1020 is shown in (b).
[0153] After the first device and the second device establish a Bluetooth network, when the first device detects that the external power supply has been disconnected, the first device switches to power-saving mode. A prompt message is displayed on the first device's screen to inform the user that the first device has disconnected the external power supply and switched to power-saving mode.
[0154] For example, such as Figure 12As shown, after the laptop disconnects from the external power supply 1000, when the laptop detects the disconnection, the control 1202 in front of the power saving mode in the trust ring management interface 1201 is selected, and the laptop's display shows a prompt message 1203 to inform the user that the laptop has switched to power saving mode. When the laptop detects that the power supply is reconnected, it switches from power saving mode to normal mode. Alternatively, when the laptop detects that the user has turned off power saving mode, it turns off power saving mode. When the laptop detects that the user has selected control 1204, and the laptop switches from normal mode back to power saving mode, the laptop no longer displays a prompt message, i.e., it no longer reminds the user that the laptop has switched to power saving mode. When the laptop detects that the user has triggered control 1205, the prompt message 1203 stops being displayed on the laptop's display.
[0155] In this application, after the first device detects that the external power supply is disconnected and switches to power-saving mode, if the first device determines that a Bluetooth long connection exists with the second device within a preset time period, the first device continues to maintain the Bluetooth network with the second device. That is, the first device does not disconnect the Bluetooth long connection with the second device, and continues to send Bluetooth heartbeat packets to the second device to maintain the Bluetooth network. In other words, the trust loop function is still supported between the first device and the second device.
[0156] For example, continue as follows Figure 12 As shown, in Figure 12 After the laptop switches to power-saving mode, if it does not receive heartbeat packets from the phone and tablet within a preset time, the laptop confirms that the established Bluetooth long connections with the phone and tablet still exist. The laptop continues to send Bluetooth heartbeat packets to the phone and tablet to maintain the Bluetooth network connection. Throughout this process, the established Bluetooth network between the laptop, phone, and tablet remains active and does not affect the trust loop function between them.
[0157] Based on the interface operation process of the Bluetooth networking method described above, the implementation flow of the Bluetooth networking method will be explained in detail below. Taking the example of a second device including Device 1 and Device 2, where Device 1 supports BLE connection and Device 2 supports BR connection, we will combine... Figure 13 The Bluetooth networking process described above will be explained in detail. Figure 13 This is a flowchart illustrating a Bluetooth networking method provided in an embodiment of this application. Figure 13 As shown, the method may include:
[0158] Step 1301: The first device is connected to an external power source. After receiving the first operation triggered by the user to log in to the user account, it successfully logs in to the user account.
[0159] Similarly, after receiving the user's first action to log in to the user account, device 1 successfully logs in to the user account; after receiving the user's first action to log in to the user account, device 2 successfully logs in to the user account.
[0160] The first operation can be a user-triggered device login verification operation, i.e., triggering the first device to log in. Optionally, before receiving the user-triggered first operation, the first device can also receive the user's input of a user account to log in, or the first device can automatically read the phone number corresponding to the SIM card set in the device as the user account.
[0161] It's important to clarify that the user accounts logged into Device 1, Device 2, and Device 1 are the same. In other words, the same user account is logged in on all three devices. When Device 1, Device 1, and Device 2 successfully log into the same user account, these three devices can form a Bluetooth network and establish a trust loop to achieve trust loop functionality. For example, when one device receives a notification message, it can be displayed on all three devices simultaneously. Alternatively, the mouse on Device 1 can control Device 1 and Device 2. This significantly improves the convenience and efficiency of user operation across different devices.
[0162] It should be noted that during the execution of steps 1301 to 1306 by the first device, the external power supply of the first device is connected.
[0163] Step 1302: After receiving the second operation triggered by the user to enable smart interconnection, the first device enables smart interconnection. Similarly, after receiving the second operation triggered by the user to enable smart interconnection, device 1 also enables smart interconnection; after receiving the second operation triggered by the user to enable smart interconnection, device 2 also enables smart interconnection.
[0164] The second operation can be a trigger operation received by the first device from the user on the smart interconnection switch control, that is, triggering the first device to enable the smart interconnection function in order to establish a trust loop with other devices.
[0165] Step 1303: Establish a Bluetooth network between the first device, device 1 and device 2.
[0166] This can be understood as follows: Device 1, Device 2, and Device 1 all have smart interconnection capabilities. When the smart interconnection capability of these three devices is enabled and all three devices successfully log in to the same account, a Bluetooth network is established between Device 1, Device 1, and Device 2. Thus, after successfully establishing Bluetooth connectivity between these three devices, a trust loop is successfully formed, enabling the three devices to support the trust loop function.
[0167] In one possible implementation, the communication connection established between the first device, device 1, and device 2 is a Bluetooth connection, that is, a Bluetooth network is established between the three devices. For example, the communication connection established between the first device and device 1 can be a BLE long connection, the communication connection established between the first device and device 2 can be a BR long connection, and the communication connection established between device 1 and device 2 can also be a BR long connection.
[0168] Optionally, after the first device and device 1 receive each other's Bluetooth broadcasts, a BLE short connection is established between them. After authentication data exchange (i.e., device pairing) via the BLE short connection, a BLE long connection is established between them, meaning Bluetooth networking between the first device and device 1 is successful. At this point, after the first device and device 1 receive a Bluetooth broadcast from device 2, a BR short connection is established between them, and a BR short connection is also established between device 1 and device 2. Then, after authentication data exchange (i.e., device pairing) via the BLE short connection, a BR long connection is established between the first device and device 2, meaning Bluetooth networking between the first device and device 2 is successful. Similarly, after authentication data exchange (i.e., device pairing) via the BR short connection, a BR long connection is established between device 1 and device 2, meaning Bluetooth networking between device 1 and device 2 is successful. In this scenario, a Bluetooth network is established between the first device, device 1, and device 2, and the three devices send Bluetooth heartbeat packets to maintain the Bluetooth network. Subsequently, the first device periodically performs Bluetooth scanning to receive Bluetooth heartbeat packets from both device 1 and device 2 in order to maintain Bluetooth networking with both device 1 and device 2.
[0169] In other words, the first device receives a Bluetooth broadcast from the second device, establishes a long Bluetooth connection with the second device, and then the first device and the second device establish a Bluetooth network. Since the devices in the Bluetooth network can perform service interactions, service interactions between the first device and the second device are thus realized.
[0170] In this application, the process of establishing a Bluetooth networking BLE long connection between the first device and device 1 can be found in the subsequent description. Figure 13 The process of establishing a long BR connection between the first device and the second device can be found in the subsequent section. Figure 14 The process of establishing a long BR connection between device 1 and device 2 will not be detailed here. Furthermore, the process of establishing a long BR connection between device 1 and device 2 can be found in the subsequent section on establishing a long BR connection between the first device and device 2, which will not be detailed here.
[0171] It should be explained that steps 1301-1303 are just one way for the first device, device 1 and device 2 to form a Bluetooth network or establish a trust ring. There are other ways, and it is not necessary to go through steps 1301-1303 to establish a trust ring.
[0172] In one implementation, after establishing a Bluetooth network between the first device, device 1, and device 2, a target interface is displayed on the first device. This target interface includes the devices in the established Bluetooth network and the services supported by those devices. In other words, after the first device and the second device establish a Bluetooth network, the first device can display a target interface that includes the devices in the Bluetooth network and the services they support, allowing the user to intuitively identify the devices in the Bluetooth network and the services they support from the target interface.
[0173] For example, such as Figure 12 As shown, Figure 12 The image shows the interface 1201 of the first device, which includes a laptop 1001, a mobile phone 1002, and a tablet 1003 that have established a Bluetooth network. The interface 1201 also includes the services supported between the laptop 1001, the mobile phone 1002, and the tablet 1003, namely screen sharing and keyboard and mouse sharing.
[0174] Step 1304: After the first device establishes a BLE long connection with device 1, it sends a heartbeat packet 1 to device 1 every preset time interval 1 and receives a heartbeat packet 2 sent by device 1 every preset time interval 2.
[0175] Heartbeat packet 1 is a data packet sent by the first device to the first device after the first device and the first device 1 have established a Bluetooth network. It is used by the first device to maintain the connection and detect whether the first device is online. In other words, after the first device and the first device 1 have established a Bluetooth network, they maintain the Bluetooth network by periodically sending and receiving Bluetooth heartbeat packets.
[0176] Optionally, the first device can send a heartbeat packet 1 to device 1 every preset time interval 1. Device 1 performs a Bluetooth scan. After receiving the heartbeat packet 1 sent by the first device, device 1 can return an acknowledgment packet to the first device, thus enabling device 1 to confirm that the first device is online based on the heartbeat packet 1. If the first device receives the acknowledgment packet returned by device 1 within the preset time interval 1, the first device can determine that device 1 is online and can continue to transmit Bluetooth data with device 1. If the first device does not receive the acknowledgment packet returned by device 1 within the preset time interval 1, the first device can determine that the Bluetooth network with device 1 is disconnected. In this case, the first device can re-establish the Bluetooth network with device 1, or determine that device 1 is offline and disconnect device 1.
[0177] Similarly, after the first device establishes a Bluetooth network with device 1, device 1 also sends a heartbeat packet 2 to the first device every time interval 2. If the first device does not receive the heartbeat packet 2 sent by device 1 within the preset time interval 2, the first device can re-establish the Bluetooth network with device 1, or determine that device 1 is offline, disconnect device 1, and break the Bluetooth network with device 1.
[0178] In other words, after the first device and the second device establish a Bluetooth network, the first device receives a first Bluetooth heartbeat packet from the second device at preset intervals to maintain the Bluetooth network connection. It can be understood that when the first device receives the first Bluetooth heartbeat packet from the second device, it indicates that the second device is still in the Bluetooth network, and the first device can continue to maintain the Bluetooth network connection with the second device to perform business interactions.
[0179] Step 1305: After the first device establishes a long BR connection with the second device, it sends a heartbeat packet 3 to the second device every preset time interval 3 and receives a heartbeat packet 4 sent by the second device every preset time interval 4.
[0180] In the application, after establishing a long BR connection between the first device and the second device, the first device and the second device maintain the established Bluetooth network by periodically sending and receiving heartbeat packets. The specific process can be referred to in step 1303 above, and will not be repeated here.
[0181] Step 1306: After establishing a long BR connection between device 1 and device 2, device 1 sends a heartbeat packet 5 to device 2 every preset time interval 5, and receives a heartbeat packet 6 sent by device 2 every preset time interval 6.
[0182] In the application, after establishing a long BR connection between Device 1 and Device 2, Device 1 and Device 2 can maintain the established Bluetooth network by periodically sending and receiving heartbeat packets. The specific process can be referred to in step 1303 above, and will not be repeated here.
[0183] It should be explained that the implementation process of steps 1304-1306 above is not a sequential process. For example, these three steps can also be executed in parallel, which is not limited here.
[0184] Step 1307: The first device detects that the external power supply is disconnected and switches to energy-saving mode.
[0185] In this application, because the battery life of the first device is limited, the first device automatically switches to power-saving mode when it detects that the external power supply is disconnected. Compared to normal mode, in power-saving mode, the first device stops Bluetooth scanning and stops sending Bluetooth broadcasts and Bluetooth heartbeat packets, thereby reducing power consumption and extending battery life.
[0186] Understandably, in power-saving mode, the first device not only stops Bluetooth scanning, stops sending Bluetooth broadcasts and Bluetooth heartbeat packets, but also reduces screen brightness, reduces processor speed, reduces read and write operations on storage devices, closes background applications and services, etc., in order to reduce the power consumption of the first device and extend battery life.
[0187] In this application, when the first device detects that the external power supply is disconnected, the first device automatically switches to power-saving mode. In power-saving mode, the first device stops sending Bluetooth heartbeat packets and Bluetooth broadcasts, and stops the Bluetooth scanning process, in order to reduce device power consumption and extend battery life.
[0188] In other words, after the first device disconnects its external power, it switches to power-saving mode. To conserve power, the first device stops sending Bluetooth heartbeat packets and stops Bluetooth scanning. After confirming that it is maintaining a Bluetooth network with the second device, the first device continues to send a second Bluetooth heartbeat packet to the second device to maintain the Bluetooth network connection. Furthermore, the first device continues Bluetooth scanning to receive Bluetooth heartbeat packets from the second device, confirming that the second device is still online, thus enabling subsequent business interactions between the two devices.
[0189] Step 1308: When the first device does not receive the heartbeat packet 2 sent by the device 1 within the preset time period 2, if it is determined that there is a BLE long connection established with the device 1, then the Bluetooth networking between the device and the device 1 is maintained.
[0190] Step 1309: The first device sends a heartbeat packet 1 to device 1 to maintain Bluetooth networking with device 1.
[0191] This can be understood as follows: When the first device is in power-saving mode, it stops sending heartbeat packet 1 to device 1, and also stops Bluetooth broadcasting and Bluetooth scanning, so that the first device also cannot receive heartbeat packet 2 from device 1. To avoid the situation where the first device does not receive heartbeat packet 2 from device 1 within a preset time period of 2, resulting in the direct disconnection of the established BLE long connection with device 1 and the inability to support the trust loop function between the first device and device 1, after the first device switches to power-saving mode, if the first device does not receive heartbeat packet 2 from device 1 within the preset time period of 2, the first device can detect whether a BLE long connection exists between the first device and device 1. If the first device determines that a BLE long connection exists with device 1, it maintains the Bluetooth networking with device 1. In this case, the first device can continue to send heartbeat packet 1 to device 1 to maintain the Bluetooth networking with device 1.
[0192] In other words, after the first device disconnects its external power, if it does not receive a first heartbeat packet within a preset time period, and if the first device determines that a long Bluetooth connection exists with the second device, then the first device maintains its Bluetooth network with the second device. Specifically, if the first device is in power-saving mode and does not receive a heartbeat packet 2 from device 1 within a preset time period 2, the first device determines that a long BLE connection exists with device 1 and maintains its Bluetooth network with device 1. After the first device disconnects its external power, and if it determines that a long Bluetooth connection exists with the second device, it continues to maintain its Bluetooth network with the second device, enabling it to continue Bluetooth networking and business interaction with the second device even when in power-saving mode. In one implementation, if the first device determines that identification information 1 exists in a preset storage location (e.g., the first device's data structure), then the first device determines that a long BLE connection exists with device 1. Here, identification information 1 indicates that a long BLE connection exists between the first device and device 1.
[0193] In other words, if the first device determines that the first identification information exists in the preset storage location, then the first device determines that a Bluetooth long connection has been established with the second device. The first identification information indicates the existence of a Bluetooth long connection between the first device and the second device. Therefore, the first device determines whether a Bluetooth long connection exists between the first device and the second device based on whether the first identification information is stored in the preset storage location, and thus determines whether to maintain the Bluetooth network connection with the second device.
[0194] It should be explained that when a BLE long connection is successfully established between the first device and device 1, the first device stores identification information 1 in a preset storage location. When the BLE long connection between the first device and device 1 is broken, the first device deletes the identification information 1 stored in the preset storage location. Thus, the first device can no longer find identification information 1 in the preset storage location. Therefore, in this application, the first device can determine whether a BLE long connection exists between the first device and device 1 based on whether identification information 1 can be found in the preset storage location.
[0195] For example, after the first device switches to power-saving mode, if it does not receive a heartbeat packet 2 from device 1 within 30 seconds, and if the first device finds the identifier information 1 for establishing a BLE connection with device 1 in a preset data structure, then the first device determines that the established BLE long connection with device 1 still exists. In this case, the first device continues to send heartbeat packets 1 to device 1 to maintain the Bluetooth networking between them, and the first device and device 1 can perform normal business interactions. This avoids the problem of the first device directly disconnecting the BLE long connection with device 1 if it does not receive a heartbeat packet 2 from device 1 within a preset time period of 1, which would prevent the trust loop function from being supported between the first device and device 1. It ensures that even if the first device does not receive a heartbeat packet 2 from device 1 within a preset time period of 1 in power-saving mode, it can still maintain the BLE long connection with device 1, allowing the trust loop function to continue to be supported between the first device and device 1 in power-saving mode.
[0196] After the first device determines that it will continue to maintain the Bluetooth network with device 1, the first device continues to perform Bluetooth scanning to scan for heartbeat packets sent by device 1 in order to continue to maintain the Bluetooth network with device 1.
[0197] Step 1310: If the first device does not receive the heartbeat packet 4 sent by the device 2 within the preset time period 4, and if it is determined that there is a long BR connection established with the device 2, then the Bluetooth networking between the first device and the device 2 is maintained.
[0198] Step 1311: The first device sends a heartbeat packet 3 to the second device to maintain Bluetooth networking with the second device.
[0199] When the first device is in power-saving mode, it stops sending heartbeat packets 3 to device 2, and also stops Bluetooth broadcasting and scanning, so it also cannot receive heartbeat packets 4 from device 2. To prevent the first device from directly disconnecting the established long-lived BR connection with device 2 after not receiving heartbeat packets 4 from device 2 within a preset time period of 4, thus preventing the trust loop function from being supported between the first and device 2, after the first device switches to power-saving mode, if it does not receive heartbeat packets 4 from device 2 within the preset time period of 4, the first device can detect whether a long-lived BR connection exists between it and device 2. If the first device determines that a long-lived BR connection exists with device 1, it continues to send heartbeat packets 3 to device 2 to maintain the Bluetooth network connection. Therefore, even if the first device does not receive heartbeat packets 4 from device 2 within the preset time period of 4, it can still maintain the Bluetooth network connection with device 2, thus ensuring that the first device's service interaction between devices is not affected in power-saving mode. In one implementation, when the first device finds the identification information 2 in a preset storage location (e.g., the data structure of the first device), the first device determines that a long-lived BR connection exists between the first device and the second device. The identification information 2 is used to indicate the existence of a long-lived BR connection between the first device and the second device.
[0200] It should be explained that when a long-term BR connection is successfully established between the first device and device 2, the first device stores identification information 2 in a preset storage location. When the long-term BR connection between the first device and device 2 is broken, the first device can delete the identification information 2 stored in the preset storage location. Thus, the first device will no longer be able to find identification information 2 in the preset storage location. Therefore, in this application, the first device can determine whether a BR connection exists between the first device and device 2 based on whether identification information 2 can be found in the preset storage location.
[0201] Furthermore, the aforementioned first device's determination of whether a BLE long-lived connection or a BR long-lived connection exists is actually a determination of whether a Bluetooth physical connection exists. That is, a Bluetooth physical connection includes both BLE long-lived connections and BR long-lived connections.
[0202] It should be noted that this application does not limit the execution order of steps 1308-1309 and steps 1310-1311. They can be executed in a specific order, or steps 1310-1311 can be executed first and then steps 1308-1309 can be executed, or steps 1308-1309 and steps 1310-1311 can be executed simultaneously.
[0203] The above Figure 13This example uses two devices, Device 1 and Device 2, where Device 1 supports BLE connectivity and Device 2 supports BR connectivity. Of course, there can be only one second device, which can support either BLE or BR connectivity; this is not limited here. There can also be multiple second devices. When there are multiple second devices, they can support the same or different Bluetooth types. For example, all of them can support BLE connectivity, or they can all support BR connectivity; this is not limited here.
[0204] For example, the first device can be a laptop computer, and device 1 and device 2 can be mobile phones with different system versions. For instance, device 1 is a mobile phone with a system version that supports BLE connection, and device 2 is a mobile phone with a system version that supports BR connection.
[0205] In one scenario, the second device may include a third and a fourth device. When the first device is connected to an external power source, a BLE long connection is established between the first and third devices to form a Bluetooth network. The first device receives a third Bluetooth heartbeat packet from the third device every preset first time interval to maintain the Bluetooth network and enable service interaction. After the first device disconnects from the external power source, if it does not receive the third Bluetooth heartbeat packet within the first time interval, and if it determines that the BLE long connection with the third device exists, it maintains the Bluetooth network with the third device. This avoids the problem of the first device disconnecting from the third device after disconnecting from the external power source, and achieves the goal of maintaining the Bluetooth network with the third device for service interaction even when the first device is in power-saving mode.
[0206] After establishing a long-lived BR connection between the first and third devices, the first device establishes a Bluetooth network with the fourth device. Following this network establishment, the first device receives a fourth Bluetooth heartbeat packet from the fourth device every preset second time interval to maintain the Bluetooth network connection and enable service interaction. If the first device does not receive a fourth Bluetooth heartbeat packet within the second time interval after its external power is disconnected, and if the first device determines that a long-lived BR connection exists with the fourth device, it maintains the Bluetooth network connection. This avoids the problem of the first device losing the Bluetooth network connection with the fourth device after its external power is disconnected, achieving the goal of maintaining the Bluetooth network connection with the fourth device for service interaction even when the first device is in power-saving mode.
[0207] In some implementations, after the second device establishes a Bluetooth long connection with the first device to form a Bluetooth network, the second device receives a second Bluetooth heartbeat packet from the first device at preset intervals to maintain the Bluetooth network. If the second device does not receive a second Bluetooth heartbeat packet from the first device within the preset interval, and if the second device determines that a Bluetooth long connection exists, it maintains the Bluetooth network with the first device. That is, after the first device disconnects its external power, it stops sending second Bluetooth heartbeat packets. The second device may not receive a second Bluetooth heartbeat packet from the first device within the preset interval. If the second device determines that a Bluetooth long connection exists, it continues to maintain the Bluetooth network with the first device, allowing it to continue Bluetooth networking and business interaction with the first device even when the first device is in power-saving mode.
[0208] In some embodiments, if the second device determines that second identification information exists in a preset storage location, the second device determines that a Bluetooth long connection has been established with the first device. The second identification information indicates the existence of a Bluetooth long connection between the second device and the first device. Therefore, the second device directly determines whether a Bluetooth long connection exists with the first device based on the presence of the second identification information in the preset storage location, avoiding the situation where the second device cannot promptly determine the existence of a Bluetooth long connection with the first device, leading to a disconnection of the Bluetooth network between the first and second devices.
[0209] In this embodiment of the application, after the second device maintains Bluetooth networking with the first device, the second device can send a first instruction message to the first device to instruct the first device to maintain Bluetooth networking with the second device.
[0210] It is understandable that after the second device and the first device maintain Bluetooth networking, the second device sends a first instruction message to the first device, so that after the first device receives the first instruction message, it continues to maintain Bluetooth networking with the second device in order to realize business interaction with the second device.
[0211] Furthermore, after the second device maintains Bluetooth networking with the first device, the second device can send a second instruction message to the first device to instruct the first device to continue Bluetooth scanning and continue sending a second Bluetooth heartbeat packet to the second device, so that the second device can continue to maintain Bluetooth networking with the first device based on the second Bluetooth heartbeat packet from the first device, thereby realizing business interaction between the second device and the first device.
[0212] It is understandable that before establishing a trust loop between the first device and device 1, a BLE long connection needs to be established between the first device and device 1. The process of establishing a BLE long connection between the first device and device 1 is as follows: Figure 14 As shown, it may include:
[0213] Step 10: The first device performs a Bluetooth scan and sends a first broadcast signal; correspondingly, device 1 receives the first broadcast signal.
[0214] Bluetooth scanning refers to the process by which the first device searches for available Bluetooth devices in the vicinity.
[0215] After the first device responds to the user's trigger and activates the Bluetooth function, it performs a Bluetooth scan and sends broadcast information to nearby Bluetooth devices. For example, the first device sends a first broadcast signal to device 1. The first broadcast signal carries the media access control (MAC) address of the first device. Each device has a unique MAC address; that is, the MAC address of the first device is fixed.
[0216] Step 11: Device 1 sends a second broadcast signal to the first device; correspondingly, the first device receives the second broadcast signal.
[0217] After receiving the first broadcast signal sent by the first device, device 1 responds to the first device with a query signal (i.e., a second broadcast signal). The second broadcast signal may carry information such as the device name, device type, and signal strength of device 1.
[0218] Step 12: The interface of the first device displays a list of available devices.
[0219] The list of available devices includes devices that the first device has searched for via Bluetooth signals but have not yet established a Bluetooth connection with it.
[0220] Step 13: The first device receives the third operation from the user selecting device 1.
[0221] Step 14: The first device sends a first connection request to device 1; correspondingly, device 1 receives the first connection request sent by the first device.
[0222] Step 15: Device 1 sends confirmation message 1 to the first device.
[0223] Step 16: The first device receives confirmation message 1 and establishes a BLE short connection with device 1.
[0224] The BLE short connection is used for data transmission during the pairing process between the first device and device 1. After the pairing process is completed, the BLE short connection between the first device and device 1 is disconnected.
[0225] Step 17: The first device sends a pairing request carrying the first pairing key to device 1; accordingly, device 1 receives the pairing request sent by the first device.
[0226] Step 18: Device 1 sends confirmation information 2 to the first device.
[0227] Step 19: The first device receives confirmation message 2, and a BLE long connection is established between the first device and device 1.
[0228] During the pairing process between Device 1 and Device 2, they exchange device information, including their MAC addresses. Upon successful pairing, this information is stored in the device pairing list for automatic reconnection. Once paired, Device 1 and Device 2 can establish a BLE persistent connection using the stored MAC addresses. During the establishment of the BLE persistent connection, Device 1 and Device 2 identify and connect based on each other's MAC addresses.
[0229] It should be noted that the process of establishing a BLE long connection between the first device and device 1 is not limited to... Figure 14 The example shown is acceptable as long as a BLE long connection can be established; this application does not impose any restrictions on this.
[0230] It is understandable that before establishing a trust loop between the first device and the second device, a long-lived BR connection needs to be established between them. The process of establishing a long-lived BR connection is as follows: Figure 15 As shown, it includes:
[0231] Step 20: The first device performs a Bluetooth scan and sends a first broadcast signal to the second device; correspondingly, the first device receives the first broadcast signal.
[0232] The first broadcast signal sent by the first device to the second device also carries the MAC address of the first device.
[0233] Step 21: Device 2 sends a third broadcast signal to the first device; correspondingly, the first device receives the third broadcast signal.
[0234] Step 22: The interface of the first device displays a list of available devices.
[0235] Step 23: The first device receives the fourth operation from the user who selected device 2.
[0236] Step 24: The first device sends a second connection request to the second device; correspondingly, the second device receives the second connection request sent by the first device.
[0237] Step 25: Device 2 sends confirmation information 3 to the first device.
[0238] Step 26: The first device receives confirmation message 3 and establishes a BR short connection with the second device.
[0239] Step 27: The first device sends a pairing request carrying a second pairing key to the second device; correspondingly, the second device receives the pairing request sent by the first device.
[0240] Step 28: Device 2 sends confirmation information 4 to the first device.
[0241] Step 29: The first device receives confirmation message 4 and establishes a long BR connection between the first device and device 2.
[0242] During the pairing process between Device 1 and Device 2, they exchange device information, including their MAC addresses. Upon successful pairing, this information is stored in the device pairing list for automatic reconnection. Once paired, Device 1 and Device 2 can establish a long-lived BR connection using the stored MAC addresses. During the establishment of this BR connection, Device 1 and Device 2 identify and connect based on each other's MAC addresses.
[0243] It should be noted that the process of establishing a long BR connection between the first device and the second device is not limited to... Figure 15 The example shown is acceptable as long as a long BR connection can be established; this application does not impose any restrictions on this.
[0244] In summary, the Bluetooth networking method of this application, after the first device and the second device establish a Bluetooth network, the first device receives a first Bluetooth heartbeat packet from the second device at preset intervals to maintain the Bluetooth network connection. Even after the first device disconnects its external power, if the first device determines that a long Bluetooth connection exists with the second device, it continues to maintain the Bluetooth network connection. This allows the first device to continue Bluetooth networking and service interaction with the second device even when it is in power-saving mode. Compared to the prior art, where disconnecting the external power and switching to power-saving mode disconnects the Bluetooth network connection between the first device and the second device, preventing service interaction, this application ensures that the first device can continue Bluetooth networking with the second device even after switching to power-saving mode, without affecting service interaction.
[0245] like Figure 16As shown in the illustration, this application discloses an electronic device, which can be the aforementioned mobile phone. Specifically, the electronic device may include: a touchscreen 1601, which includes a touch sensor 1606 and a display screen 1607; one or more processors 1602; a memory 1603; one or more application programs (not shown); and one or more computer programs 1604. These components can be connected via one or more communication buses 1605. The one or more computer programs 1604 are stored in the memory 1603 and configured to be executed by the one or more processors 1602. The one or more computer programs 1604 include instructions that can be used to perform the relevant steps in the above embodiments.
[0246] It is understood that the aforementioned electronic devices, etc., include hardware structures and / or software modules corresponding to the execution of each function in order to achieve the above-mentioned functions. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, the embodiments of this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by 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, but such implementation should not be considered beyond the scope of the embodiments of this invention.
[0247] This application embodiment can divide the above-mentioned electronic device into functional modules according to the method example described above. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0248] When each functional module is divided according to its corresponding function, the above embodiments illustrate a possible composition of the electronic device, which may include a display unit, a transmission unit, and a processing unit. It should be noted that all relevant content regarding the steps in the above method embodiments can be referenced from the functional descriptions of the corresponding functional modules, and will not be repeated here.
[0249] This application also provides an electronic device, including one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer program code, including computer instructions. When the one or more processors execute the computer instructions, the electronic device performs the aforementioned method steps to implement the Bluetooth networking method in the above embodiments.
[0250] Embodiments of this application also provide a computer-readable storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the Bluetooth networking method in the above embodiments.
[0251] Embodiments of this application also provide a computer program product, which includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the aforementioned method steps to implement the Bluetooth networking method in the above embodiments.
[0252] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to enable the apparatus to perform the Bluetooth networking method executed by the electronic device in the above method embodiments.
[0253] In this embodiment, the electronic device, computer-readable storage medium, computer program product or device are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0254] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0255] In the embodiments of this application, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0256] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.
[0257] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A Bluetooth networking method, characterized in that, Applied to a first device, the method includes: Receive Bluetooth broadcasts from the second device and establish a long Bluetooth connection with the second device; After the first device and the second device log in to the same user account, they establish a Bluetooth network; the first device receives a first Bluetooth heartbeat packet from the second device at preset intervals; the first Bluetooth heartbeat packet is used by the first device and the second device to maintain the Bluetooth network. After the first device disconnects the external power supply, the first device stops sending the second Bluetooth heartbeat packet to the second device and stops Bluetooth scanning. The second Bluetooth heartbeat packet is used by the first device and the second device to maintain the Bluetooth network. If the first device does not receive the first Bluetooth heartbeat packet within the preset time period, and if the first device determines that there is a Bluetooth long connection with the second device based on the first identification information stored in the preset storage location that indicates the existence of the Bluetooth long connection, then the first device maintains the Bluetooth networking with the second device.
2. The method according to claim 1, characterized in that, The method further includes: After the first device maintains the Bluetooth network with the second device, the first device continues the Bluetooth scan.
3. The method according to claim 1 or 2, characterized in that, The method further includes: After the first device maintains the Bluetooth network with the second device, the first device continues to send the second Bluetooth heartbeat packet to the second device.
4. The method according to any one of claims 1-3, characterized in that, After the first device and the second device establish a Bluetooth network, the method further includes: The first device displays a target interface, which includes the devices in the Bluetooth network and the services supported by the devices in the Bluetooth network.
5. The method according to any one of claims 1-4, characterized in that, The Bluetooth long connection includes low-power BLE long connection or classic BR long connection.
6. The method according to claim 5, characterized in that, The second device comprises multiple devices, including a third device and a fourth device. The first device receives a first Bluetooth heartbeat packet sent from the second device at preset intervals, including: The first device receives a third Bluetooth heartbeat packet from the third device every preset first time interval; or... The first device receives a fourth Bluetooth heartbeat packet from the fourth device every preset second time interval; When the first device does not receive the first Bluetooth heartbeat packet within the preset time period, if the first device determines that a long Bluetooth connection exists with the second device, the first device maintains the Bluetooth network with the second device, including: If the first device does not receive the third Bluetooth heartbeat packet within the first time period, and if the first device determines that a BLE long connection has been established with the third device, then the first device maintains the Bluetooth networking with the third device; or... If the first device does not receive the fourth Bluetooth heartbeat packet within the second time period, and if the first device determines that there is a long BR connection established with the fourth device, then the first device maintains the Bluetooth networking with the fourth device.
7. A Bluetooth networking system, characterized in that, The system includes a first device and a second device. The second device is used to send a Bluetooth broadcast to the first device; The first device is used to receive the Bluetooth broadcast and establish a Bluetooth long connection with the second device; the first device and the second device establish a Bluetooth network. The second device is also used to send a first Bluetooth heartbeat packet to the first device at preset intervals, the first Bluetooth heartbeat packet being used by the second device and the first device to maintain the Bluetooth network; The first device is further configured to stop sending the second Bluetooth heartbeat packet to the second device and stop Bluetooth scanning after the first device disconnects the external power supply. The second Bluetooth heartbeat packet is used by the first device and the second device to maintain the Bluetooth network. When the first device does not receive the first Bluetooth heartbeat packet within the preset time period, if the first device determines that there is a Bluetooth long connection established with the second device according to the first identification information stored in the preset storage location that indicates the existence of the Bluetooth long connection, then the first device maintains the Bluetooth network with the second device. The second device is also configured to receive a second Bluetooth heartbeat packet from the first device at preset intervals; the second Bluetooth heartbeat packet is used by the second device and the first device to maintain the Bluetooth network. If the second device does not receive a second Bluetooth heartbeat packet from the first device within the preset time period, and if the second device determines that there is a Bluetooth long connection established with the first device based on the existence of a second identification information in a preset storage location that indicates the existence of the Bluetooth long connection, then the second device maintains the Bluetooth networking with the first device.
8. The system according to claim 7, characterized in that, While the second device maintains the Bluetooth network with the first device, the second device is further configured to send a first indication message to the first device, the first indication message being used to instruct the first device to maintain the Bluetooth network with the second device.
9. The system according to claim 7 or 8, characterized in that, While the second device maintains the Bluetooth network with the first device, the second device is also used to send a second instruction message to the first device, the second instruction message being used to instruct the first device to continue performing Bluetooth scanning and to continue sending the second Bluetooth heartbeat packet to the second device.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method of any one of claims 1-6.
11. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the method of any one of claims 1-6.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the method of any one of claims 1-6.