Communication method, electronic device, and related apparatus
Patent Information
- Application Number
- CN202410946928.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2044-07-12
AI Technical Summary
但因为网络差、或者通信开关关闭等原因,会造成双端设备的上下线状态不对称的问题,影响业务的执行
[0035]在一种可能的实现中,本申请中上述描述的芯片或者芯片系统还包括至少一个存储器,该至少一个存储器中存储有指令。该存储器可以为芯片内部的存储单元,例如,寄存器、缓存等,也可以是该芯片的存储单元(例如,只读存储器、随机存取存储器等)。
Smart Images

Figure CN121397474B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a communication method, electronic device and related apparatus. Background Technology
[0002] With the development of electronic devices, users can own multiple electronic devices such as mobile phones, tablets, and personal computers (PCs). These devices can be interconnected to achieve business collaboration. Examples of business collaboration include notification sharing, keyboard and mouse sharing, and multi-screen collaboration. This enables smart office work, smart living, and media creation across devices, providing users with convenient services.
[0003] Interoperability between electronic devices can be understood as the mutual discovery and connection between them. Currently, after a connection is established, electronic devices store information about the other device's online status. However, due to poor network conditions or communication switches being turned off, an asymmetry in the online / offline status of the two devices can occur, affecting business operations. Summary of the Invention
[0004] This application provides a communication method, an electronic device, and related apparatus that can quickly refresh and enable the first electronic device and the second electronic device to restore their online / offline symmetry.
[0005] Firstly, this application provides a communication method. The executing entity of this method can be a first electronic device or a chip within the first electronic device, as illustrated below using the first electronic device as an example. In this method, while maintaining a heartbeat connection with a second electronic device, and when the first electronic device switches from screen-on to screen-off mode, the first electronic device can send a first broadcast. The first broadcast is used to detect the online status of the second electronic device. The second electronic device, when its screen is off, cannot process the first broadcast. The first broadcast can be understood as broadcast 4.
[0006] Within a third preset time period, if the first electronic device does not receive a second broadcast from the second electronic device in response to the first broadcast, the second electronic device is marked as pre-offline. When the first electronic device switches to screen-on mode, it can periodically send a third broadcast. The third broadcast is used to detect the online status of the second electronic device, and the second electronic device, whether in screen-off or screen-on mode, can handle the third broadcast. Here, the second broadcast can be understood as broadcast 5, and the third broadcast can be understood as broadcast 3.
[0007] Specifically, when the duration of the first moment and the second moment is less than or equal to the fifth preset duration, the second electronic device is marked as online. The first moment is the moment when the second electronic device is marked as pre-offline, and the second moment is the moment when a second broadcast in response to the third broadcast is received from the second electronic device. Conversely, when the duration from the first moment exceeds the fifth preset duration, and no response to the third broadcast is received from the second electronic device, the second electronic device is marked as offline.
[0008] In this embodiment, the first electronic device does not directly mark the second electronic device as offline. This is to avoid the problem that the second electronic device cannot respond to the second broadcast due to the second electronic device frequently turning its screen on and off or the user moving the second electronic device back and forth. If the second electronic device is directly marked as offline, the online and offline states of the two devices will be asymmetrical when the second electronic device turns on its screen or the user moves back to the second electronic device. This application does it in a way that ensures that the online and offline states of the first electronic device and the second electronic device are symmetrical.
[0009] In one possible implementation, while maintaining a heartbeat connection with the second electronic device and with the first electronic device's screen on, when the first electronic device receives a fourth broadcast from the second electronic device, it marks the second electronic device as pre-offline. This fourth broadcast is used to indicate that the second electronic device is offline. The fourth broadcast can be understood as broadcast 2.
[0010] When the first electronic device is on, it can periodically send a third broadcast. This third broadcast is used to detect the online status of the second electronic device. The second electronic device, whether on or off, can process the third broadcast. Specifically, when the duration of the first moment and the second moment is less than or equal to a fifth preset duration, the second electronic device is marked as online. The first moment is the moment when the second electronic device is marked as pre-offline, and the second moment is the moment when the second broadcast in response to the third broadcast is received from the second electronic device. Conversely, if the duration from the first moment exceeds the fifth preset duration and no response to the third broadcast is received from the second electronic device, the second electronic device is marked as offline.
[0011] In this implementation, the first electronic device does not directly mark the second electronic device as offline. This is to avoid the problem that the second electronic device cannot respond to the second broadcast due to the second electronic device frequently turning its Bluetooth or WiFi switch on and off. If the second electronic device is directly marked as offline, the online and offline status of the two devices will be asymmetrical when the second electronic device turns on its Bluetooth or WiFi switch. This application does it in a way that ensures that the online and offline status of the first electronic device and the second electronic device are symmetrical.
[0012] In one possible implementation, when the first electronic device marks the second electronic device as offline, the method further includes: when the first electronic device receives a sixth broadcast from the second electronic device, the first electronic device can perform a corresponding operation based on the connection attribute of the sixth broadcast to enable the online / offline states of the second electronic device and the first electronic device to be symmetrical. The symmetry of the online / offline states of the second electronic device and the first electronic device is used to characterize that the online / offline state of the first electronic device marked by the second electronic device is the same as the online / offline state of the second electronic device marked by the first electronic device.
[0013] Specifically, when the connection attribute of the sixth broadcast is connectable, a connection request is sent to the second electronic device. This connection request triggers the second electronic device to mark the first electronic device as offline. For example, the broadcast can be broadcast 3, broadcast 4, or broadcast 5.
[0014] Specifically, when the connection attribute of the sixth broadcast is "unconnectable," a second broadcast responding to the sixth broadcast is sent to the second electronic device. The second broadcast is used to trigger the second electronic device to mark the first electronic device as offline and to trigger the second electronic device to initiate a connection. For example, the broadcast can be broadcast 1.
[0015] In this implementation, in a scenario where the second electronic device and the first electronic device maintain a heartbeat online, after the first electronic device marks the second electronic device as offline, since the first electronic device does not block the broadcasts from the second electronic device, the first electronic device can process the broadcasts from the second electronic device. Therefore, the first electronic device can perform corresponding operations based on the attributes of the broadcasts from the second electronic device to make the online / offline states of the second electronic device and the first electronic device symmetrical.
[0016] When the first electronic device receives a broadcast with the attribute of being unconnectable (broadcast 1), the first electronic device can send a second broadcast to the second electronic device, enabling the second electronic device to determine that the online / offline status of the two devices is asymmetrical. The second electronic device can then mark the first electronic device as offline, thus making the online / offline status of the second electronic device and the first electronic device symmetrical.
[0017] When the first electronic device receives a broadcast with the attribute of being connectable (broadcast 3, broadcast 4 or broadcast 5), the first electronic device can actively initiate a connection to the second electronic device. Since the second electronic device has marked the first electronic device as online, when the second electronic device receives the connection request, it can determine that the online / offline status of the two devices is asymmetrical. The second electronic device can mark the first electronic device as offline, so that the online / offline status of the second electronic device and the first electronic device is symmetrical.
[0018] In one possible implementation, if the first electronic device marks the second electronic device as offline and the second electronic device marks the first electronic device as offline, the first electronic device and the second electronic device can quickly discover each other and establish a connection.
[0019] Taking the first electronic device initiating a connection as an example, the first electronic device can send a fifth broadcast, which is used to discover electronic devices. For instance, the fifth broadcast can be broadcast 1. In response to the fifth broadcast, the second electronic device can send a second broadcast (broadcast 5) back to the first electronic device.
[0020] In this embodiment of the application, the second electronic device can be set to scan the broadcast all the time, that is, the second electronic device is always scanning the broadcast. Therefore, as long as the first electronic device sends broadcast 1, the second electronic device can receive broadcast 1 and send back broadcast 5 to the first electronic device, which can improve the speed at which the first electronic device discovers the second electronic device.
[0021] A first electronic device and a second electronic device establish a connection. After establishing the connection, the first and second electronic devices can remain online. For example, the first and second electronic devices can maintain an online connection or a heartbeat connection. Based on this online status, the first electronic device can block broadcasts from the second electronic device. In this embodiment, the electronic device can filter received broadcasts and selectively process them based on its online status, thereby reducing the power consumption and broadcast processing load of the electronic device and improving its performance.
[0022] In one possible implementation, upon establishing a connection with the second electronic device, the first electronic device marks the second electronic device as online. The first electronic device sends a handshake message to the second electronic device to indicate that both the first and second electronic devices support maintaining the connection.
[0023] Within a first preset time period, if the first electronic device does not receive an acknowledgment from the second electronic device in response to the handshake message, the first electronic device marks the second electronic device as offline. In this example, similar to the first electronic device, the second electronic device can also send a handshake message to the first electronic device to indicate that both the first and second electronic devices support maintaining the connection. If, within the first preset time period, the second electronic device receives an acknowledgment from the first electronic device in response to the handshake message, the second electronic device marks the first electronic device as online.
[0024] In this situation, the online / offline states of the first electronic device and the second electronic device are asymmetrical. In this embodiment, when the first electronic device remains connected to the second electronic device and marks the second electronic device as offline, the first electronic device can resend handshake information to the second electronic device.
[0025] Within a second preset time period, when the first electronic device receives an acknowledgment message from the second electronic device in response to the handshake information, it marks the second electronic device as online. In this way, both the first and second electronic devices mark each other as online, maintaining a symmetrical online / offline status between them.
[0026] Within a second preset time period, if no confirmation message is received, the first electronic device disconnects from the second electronic device. Disconnecting from the second electronic device triggers the second electronic device to mark the first electronic device as offline. In this way, both the first and second electronic devices mark each other as offline, maintaining a symmetrical online / offline status.
[0027] Secondly, embodiments of this application provide a communication method. The executing entity of this method can be a first electronic device or a chip within the first electronic device, etc. The following description uses the first electronic device as an example. In this method, while maintaining an online connection with the first electronic device, when the first electronic device disconnects from the second electronic device, the second electronic device can mark the first electronic device as offline.
[0028] In one possible implementation, the method further includes: when the second electronic device and the first electronic device maintain a heartbeat online connection, the second electronic device can mark the first electronic device as offline when the second electronic device receives a connection request from the first electronic device.
[0029] In one possible implementation, the method further includes: when the second electronic device and the first electronic device maintain a heartbeat online relationship, the second electronic device can mark the first electronic device as offline when the second electronic device receives a second broadcast from the first electronic device.
[0030] Thirdly, embodiments of this application provide a communication device, which may be an electronic device, or a chip or chip system within an electronic device. The communication device may include a display unit and a processing unit. When the communication device is an electronic device, the display unit may be a display screen. The display unit is used to perform display steps to enable the electronic device to implement a communication method described in the first aspect or any possible implementation of the first aspect. When the communication device is an electronic device, the processing unit may be a processor. The communication device may further include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit to enable the electronic device to implement a communication method described in the first aspect or any possible implementation of the first aspect, and a communication method described in the second aspect or any possible implementation of the second aspect. When the communication device is a chip or chip system within an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit to enable the electronic device to implement a communication method described in the first aspect or any possible implementation of the first aspect. The storage unit can be a storage unit within the chip (e.g., a register, cache, etc.) or a storage unit located outside the chip within the electronic device (e.g., a read-only memory, random access memory, etc.).
[0031] Fourthly, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory is used to store code instructions, and the processor is used to execute the code instructions to perform the methods described in the first aspect or any possible implementation of the first aspect, and the methods described in the second aspect or any possible implementation of the second aspect.
[0032] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program or instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect or any possible implementation thereof, as well as the methods described in the second aspect or any possible implementation thereof.
[0033] Sixthly, embodiments of this application provide a computer program product including a computer program, which, when run on a computer, causes the computer to perform the methods described in the first aspect or any possible implementation of the first aspect, as well as the methods described in the second aspect or any possible implementation of the second aspect.
[0034] Seventhly, this application provides a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in the first aspect or any possible implementation thereof, and the methods described in the second aspect or any possible implementation thereof. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0035] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0036] It should be understood that the second to seventh aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description
[0037] Figure 1 A schematic diagram of a system architecture applicable to the communication method provided in the embodiments of this application;
[0038] Figure 2 A schematic diagram of the interface of the first electronic device provided in an embodiment of this application;
[0039] Figure 3 A flowchart illustrating one embodiment of the communication method provided in this application;
[0040] Figure 4A A flowchart illustrating another embodiment of the communication method provided in this application;
[0041] Figure 4B A flowchart illustrating another embodiment of the communication method provided in this application;
[0042] Figure 5 A flowchart illustrating another embodiment of the communication method provided in this application;
[0043] Figure 6A This is a schematic diagram of an interactive broadcast between electronic device 1 and electronic device 2.
[0044] Figure 6B A schematic diagram illustrating interactive broadcasting between electronic device 1 and electronic device 2 provided in an embodiment of this application;
[0045] Figure 6CAnother schematic diagram illustrating the interactive broadcast between electronic device 1 and electronic device 2 provided in this application embodiment;
[0046] Figure 7 A schematic diagram of the structure of a first electronic device is provided for an embodiment of this application;
[0047] Figure 8A A flowchart illustrating one embodiment of the communication method provided in this application;
[0048] Figure 8B(1) is a schematic diagram of a process for establishing a long connection between a first electronic device and a second electronic device provided in an embodiment of this application;
[0049] Figure 8B(2) is a schematic diagram of an interface of the first electronic device provided in an embodiment of this application;
[0050] Figure 8B(3) is a schematic diagram of an interface of the first electronic device provided in an embodiment of this application;
[0051] Figure 8C A schematic diagram illustrating a process for establishing a short connection between a first electronic device and a second electronic device provided in an embodiment of this application;
[0052] Figure 9 This provides another structural schematic diagram of an electronic device for embodiments of this application. Detailed Implementation
[0053] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms involved in the embodiments of this application are briefly introduced below:
[0054] 1. Screen On: The screen of an electronic device emits light and displays content. In screen-on mode, users can perform various operations on the screen of the electronic device, such as browsing web pages, watching videos, playing games, etc.
[0055] 2. Screen Off: The screen of an electronic device does not emit light and appears black. For example, taking a mobile phone as an example, if the user has not operated the phone for a long time, or if the user actively locks the screen, the phone screen will be turned off.
[0056] 3. Wake-up: In this embodiment, after the electronic device's screen is turned off, it can enter a sleep state. In the sleep state, the central processing unit (CPU) in the electronic device is in a sleep state, with low power consumption. Wake-up refers to waking the electronic device's CPU from the sleep state to the running state. When the CPU is in the running state, the electronic device can interact with other electronic devices, broadcast, and establish connections, etc.
[0057] In some embodiments, when an electronic device is in a screen-on state, its CPU is running. Alternatively, screen-on corresponds to a running state.
[0058] 4. Long connection and short-connection: Long connection and short-connection are two common connection modes in network communication. Their main difference lies in the connection lifecycle and applicable scenarios.
[0059] Long-lived connections are persistent, allowing the two devices to exchange data multiple times within a single connection, reducing the overhead of frequent connection establishment. Short-lived connections, on the other hand, are transient; each communication requires establishing a new connection, meaning each connection only sends one piece of data, and the short connection closes after the data transmission is complete.
[0060] 5. Classic Bluetooth (BR) Connection: Compared to Bluetooth Low Energy (BLE) connection, BR connection has a higher data transfer rate, but its power consumption is also relatively higher. In some embodiments, BR connection can be used in scenarios that transmit large amounts of data or have high real-time requirements.
[0061] 6. BLE Connection: Compared to BR connection, BLE connection consumes less power. In some embodiments, BLE connection can be used in scenarios requiring low power consumption and long battery life.
[0062] 7. BLE Heartbeat Online: This generally refers to the mechanism by which electronic devices maintain their connection by sending heartbeat packets. A heartbeat packet is a small data packet used to tell the other device that it is still online and ready to receive data.
[0063] 8. Online / Offline Status: This includes online and offline status. In some embodiments, offline status may also be referred to as inactive status. The following embodiments will use inactive status as an example for explanation.
[0064] For example, after electronic device 1 and electronic device 2 establish a connection, electronic device 1 will mark (store or record) electronic device 2 as online (or online state), and electronic device 2 will mark electronic device 1 as online (or online state). For electronic device 1, electronic device 2 being online can indicate that electronic device 2 has established a connection with electronic device 1.
[0065] For example, when electronic device 1 and electronic device 2 are connected, taking the connection as a Bluetooth connection as an example, electronic device 2 can disconnect from electronic device 1 if it is turned off or the user turns off the Bluetooth switch of electronic device 2. Electronic device 1 can mark electronic device 2 as offline (or in an offline state), and electronic device 2 can also mark electronic device 1 as offline (or in an offline state).
[0066] 9. Symmetrical online / offline status: Both devices mark the online / offline status of the other device as the same.
[0067] For example, after electronic device 1 and electronic device 2 establish a connection, electronic device 1 will mark electronic device 2 as online, and electronic device 2 will mark electronic device 1 as online. Both devices mark each other as online. In this case, electronic device 1 and electronic device 2 can determine that the other device is online and can interact to perform business.
[0068] For example, after electronic device 1 and electronic device 2 disconnect, electronic device 1 will mark electronic device 2 as offline, and electronic device 2 will mark electronic device 1 as offline. Both devices mark each other as offline. In this case, electronic device 1 and electronic device 2 can determine that the other device is offline, and no connection has been established between them, so no interaction is necessary.
[0069] 10. Asymmetrical online / offline status: The online / offline status of the two devices are marked differently.
[0070] For example, after electronic device 1 and electronic device 2 establish a connection, electronic device 1 will mark electronic device 2 as online, and electronic device 2 will mark electronic device 1 as offline. The two devices mark each other's online / offline status differently, resulting in an asymmetry in online / offline status. In this situation, from electronic device 1's perspective, electronic device 2 is still connected to electronic device 1, and electronic device 1 can send data to electronic device 2. However, from electronic device 2's perspective, electronic device 1 is offline and no longer connected to electronic device 2; therefore, electronic device 2 will discard data from electronic device 1, affecting the normal execution of its services.
[0071] 11. Electronic devices:
[0072] The electronic device in this application embodiment is a device with functions such as discovery and connection. For example, the electronic device can be: a mobile phone, tablet computer, personal computer (PC), handheld computer, laptop computer, mobile internet device (MID), wearable device, virtual reality (VR) device, augmented reality (AR) device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, cellular phone, cordless phone, session initiation protocol (SIP) phone, wireless local loop (WLL) station, personal digital assistant (PDA). The embodiments of this application do not limit this to personal assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, in-vehicle devices, wearable devices, terminal devices in 5G networks or terminal devices in future evolved public land mobile networks (PLMNs).
[0073] By way of example and not limitation, in this embodiment, the electronic device can also be a wearable device. Wearable devices, also known as wearable smart devices, are a general term for devices that utilize wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothing or accessories. Wearable devices are not merely hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are feature-rich, large in size, and can achieve complete or partial functions without relying on a smartphone, such as smartwatches or smart glasses, as well as those that focus on a specific type of application function and require the use of other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0074] Furthermore, in this embodiment of the application, the electronic device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection.
[0075] The electronic devices in the embodiments of this application may also be referred to as: terminal equipment, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent, or user device, etc.
[0076] In this embodiment, the electronic device or various network devices include a hardware layer, an operating system layer running on top of the hardware layer, and an application layer running on top of the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux, Unix, Android, iOS, or Windows. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0077] 12. Other terms:
[0078] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first chip" and "second chip" are used only to distinguish different chips and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0079] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0080] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.
[0081] Figure 1 This is a schematic diagram of a system architecture applicable to the communication method provided in the embodiments of this application. (Refer to...) Figure 1 The system architecture may include: multiple electronic devices, as well as the cloud.
[0082] It should be understood that Figure 1 The example provided uses multiple electronic devices, including a first electronic device (such as a mobile phone), a second electronic device (such as a tablet computer), and a third electronic device (such as a PC). In this embodiment, the first electronic device, the second electronic device, and the third electronic device can establish connections with each other.
[0083] For example, the communication method provided in this application embodiment can be applied to a super terminal scenario. For instance, the first electronic device can establish connections with the second electronic device and the third electronic device respectively. (Refer to...) Figure 1 The mobile phone can connect to a tablet or PC, allowing users to control the tablet or PC from their mobile phone.
[0084] For example, the communication method provided in this application embodiment can also be applied to scenarios where any number of electronic devices are connected. For example, connecting a PC and a tablet can enable smart office work. For instance, connecting a tablet and a mobile phone can enable users to create media.
[0085] For example, in a home setting, a home router can also connect to speakers, smart screens, smart appliances, and mobile phones.
[0086] This application does not exhaustively list the scenarios in which the communication method is applicable.
[0087] The cloud can be viewed as an account management device used to manage multiple electronic devices under the same account. The account can be called a system account or a device account. In some embodiments, the account can be a mobile phone number or email address, etc.
[0088] Figure 1 The cloud is used as an example. In some embodiments, the cloud can also be a server cluster, or a cluster of multiple devices containing intermediate nodes. This application does not limit the form of the cloud.
[0089] In this embodiment, the first electronic device, the second electronic device, and the third electronic device can log in to the same account. After logging in, the electronic device can report its device information to the cloud, and the cloud can push this device information to other electronic devices logged in with the same account. Taking the first account as an example and the first electronic device as an example, the process is explained as follows:
[0090] For example, after logging into the first account, the first electronic device can report its device information to the cloud. The cloud can then push the device information of the first electronic device to the second and third electronic devices. Both the second and third electronic devices are already logged into the first account.
[0091] Understandably, after logging into the first account, the second electronic device can also report its device information to the cloud, and the cloud can also push the second electronic device's device information to both the first and third electronic devices. Similarly, after logging into the first account, the third electronic device can also report its device information to the cloud, and the cloud can also push the third electronic device's device information to both the first and second electronic devices.
[0092] Thus, in this embodiment of the application, electronic devices logged into the first account can obtain device information from other electronic devices. In some embodiments, the electronic devices logged into the first account can be referred to as electronic devices under the first account.
[0093] In some embodiments, electronic devices (such as a first electronic device, a second electronic device, and a third electronic device) can interact with the cloud via a cellular network or a wireless local area network (WLAN), and this application embodiment does not limit this.
[0094] In summary, taking the first electronic device as an example, the first electronic device can obtain device information of other electronic devices under the first account through the cloud. This application embodiment also designs the following five broadcast types, based on which the first electronic device can establish connections with other electronic devices. The broadcasts designed in this application embodiment are described below:
[0095] 1. Broadcast 1
[0096] Broadcast 1 is used by a first electronic device to discover other electronic devices in order to establish a connection with them.
[0097] In some embodiments, the conditions for sending Broadcast 1 can be set as follows: the first electronic device is on, and the first electronic device determines that there are other electronic devices under the first account that have not yet established a connection with the first electronic device. In this example, setting the first electronic device to send Broadcast 1 when the screen is on can reduce the power consumption of the first electronic device.
[0098] In some embodiments, the conditions for broadcasting 1 can be set as follows: the first electronic device determines that there are other electronic devices under the first account that have not established a connection with the first electronic device, and the first electronic device can be either on or off.
[0099] For example, a second electronic device may be logged into a first account, but the second electronic device may not have established a connection with the first electronic device. If the first electronic device is connected to the cloud, it can determine, through device information pushed from the cloud and its own connection status, that there is a second electronic device under the first account that has not yet established a connection with it. The first electronic device can then periodically send broadcast 1 to scan for the second electronic device.
[0100] For example, a second electronic device may be logged into a first account, but the second electronic device may not have established a connection with the first electronic device. When the first electronic device is not connected to the cloud, and a user triggers the first electronic device to establish a connection with another electronic device, the first electronic device may periodically send a broadcast (1) to scan for other electronic devices.
[0101] In some embodiments, the attributes of Broadcast 1 can be configured as: not connectable, require a response, and wakeable. "Not connectable" means that, in response to Broadcast 1, the second electronic device cannot directly initiate a connection to the first electronic device. "Requires a response" means that, in response to Broadcast 1, the second electronic device needs feedback from the first electronic device; for example, the second electronic device can send Broadcast 5 back to the first electronic device. "Wakeable" means that, when the second electronic device is in a sleep state with its screen off, in response to Broadcast 1, the CPU of the second electronic device can switch from sleep to running state, and the second electronic device can send Broadcast 5 back to the first electronic device. Similarly, when the second electronic device is in a light-on state, in response to Broadcast 1, the second electronic device sends Broadcast 5 back to the first electronic device.
[0102] In some embodiments, broadcast 1 may be configured with attribute fields to indicate the attributes of broadcast 1. For example, broadcast 1 may be configured with a first field, a second field, and a third field. The first field indicates that the attribute of broadcast 1 is disconnectable, the second field indicates that the attribute of broadcast 1 is requiring a response, and the third field indicates that the attribute of broadcast 1 is wakeable. For example, broadcast 1 may use numbers and / or letters to represent the first, second, and third fields; this embodiment does not impose limitations on this.
[0103] 2. Broadcast 2
[0104] Broadcast 2, used for offline notification of the first electronic device.
[0105] The conditions for sending Broadcast 2 can be set as follows: when the first electronic device is powered off, or the first electronic device disables its WiFi function or its networking function, the first electronic device does not need to establish a connection with other electronic devices, and the first electronic device can send Broadcast 2.
[0106] In some embodiments, the attributes of Broadcast 2 can be configured as: not connectable, no reply required, and not wake-up. Taking the second electronic device as an example, "not connectable" means that in response to Broadcast 2, the second electronic device cannot directly initiate a connection to the first electronic device. "No reply required" means that in response to Broadcast 2, the second electronic device does not need to send feedback to the first electronic device. "Not wake-up" means that when the second electronic device is on, in response to Broadcast 2, the second electronic device can take the first electronic device offline, that is, mark the first electronic device as offline. When the second electronic device is off and the CPU is in sleep mode, in response to Broadcast 2, the CPU in the second electronic device remains in sleep mode, and the second electronic device does not need to take any action.
[0107] It is understandable that after the first and second electronic devices establish a BLE or BR connection, since neither device needs to process all broadcasts from the other, when the first electronic device sends broadcast 2, the second electronic device will not process it and will not disconnect the first electronic device. However, if the first electronic device disconnects its BLE or BR connection, the second electronic device can disconnect the first electronic device upon detecting the disconnection. Conversely, if the second electronic device disconnects its BLE or BR connection, it can also disconnect the first electronic device.
[0108] In this embodiment, when the first electronic device and the second electronic device maintain a BLE heartbeat online, when the first electronic device sends broadcast 2, and the second electronic device is on, in response to broadcast 2, the second electronic device can disconnect the first electronic device. When the second electronic device is off and its CPU is in sleep mode, in response to broadcast 2, the CPU in the second electronic device remains in sleep mode, and the second electronic device can perform no action.
[0109] In this scenario, when the first and second electronic devices establish a connection (BLE or BR connection), or when the first and second electronic devices maintain a heartbeat connection, both can mark the other device as online. For example, the first electronic device can mark the second electronic device as online, and the second electronic device can mark the first electronic device as online. The online / offline status of the first electronic device can include both online and offline. In some embodiments, offline can also be referred to as offline, and online can also be referred to as online.
[0110] For example, after the first electronic device and the second electronic device establish a connection, the second electronic device can mark the first electronic device as online, and the first electronic device can mark the second electronic device as offline. After the first electronic device and the second electronic device disconnect, the second electronic device can mark the first electronic device as offline, and the first electronic device can mark the second electronic device as offline.
[0111] In some embodiments, broadcast 2 may be configured with attribute fields that indicate the attributes of broadcast 2, as described in broadcast 1.
[0112] 3. Broadcast 3
[0113] Broadcast 3 is used by the first electronic device to quickly refresh the online status of the second electronic device, or to rebuild a long connection, etc.
[0114] The sending conditions for broadcast 3 can be set as follows:
[0115] 1) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, when the first electronic device switches from screen off to screen on, the first electronic device can send a broadcast 3 to the second electronic device to quickly refresh the online status of the second electronic device.
[0116] In the prior art, when a BLE heartbeat is established between a first electronic device and a second electronic device, the first electronic device can periodically send heartbeat packets to the second electronic device. In response to these heartbeat packets, the second electronic device can send feedback information back to the first electronic device. Based on this feedback information, the first electronic device can determine that the second electronic device is online.
[0117] In this embodiment, when the first electronic device and the second electronic device establish a BLE heartbeat online connection, when the first electronic device switches from screen off to screen on, the first electronic device can send a broadcast 3 to the second electronic device. In response to the broadcast 3, the second electronic device can send feedback information back to the first electronic device. In response to this feedback information, the first electronic device can determine that the second electronic device is online. In this example, the first electronic device does not need to wait for the heartbeat packet transmission cycle, but instead uses broadcast 3 to quickly detect the online status of the second electronic device.
[0118] 2) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, if the first electronic device and the second electronic device meet the conditions for a long connection, the first electronic device can send a broadcast 3 to notify the first electronic device and the second electronic device to rebuild the BR connection or BLE connection.
[0119] The condition that the first electronic device and the second electronic device meet the long connection can be understood as: the first electronic device and the second electronic device meet the condition of establishing a BLE connection or a BR connection.
[0120] 3) The first electronic device is on, and a second electronic device is present but not yet offline. The first electronic device can send broadcast 3 to refresh the online status of the second electronic device.
[0121] In some embodiments, the attributes of broadcast 3 can be configured as: connectable, require a response, and wakeable. Taking the second electronic device as an example, connectable means that in response to broadcast 3, the second electronic device can directly initiate a connection to the first electronic device. Require a response means that in response to broadcast 3, the second electronic device needs to send feedback information to the first electronic device; for example, the second electronic device can send broadcast 5 to the first electronic device. Wakeable means that when the second electronic device is in a screen-off state and the CPU is in a sleep state, in response to broadcast 3, the CPU of the second electronic device can switch from a sleep state to a running state, and the second electronic device can send broadcast 5 back to the first electronic device. Similarly, when the second electronic device is in a screen-on state, in response to broadcast 3, the second electronic device sends broadcast 5 back to the first electronic device.
[0122] In some embodiments, broadcast 3 may be configured with an attribute field that indicates the attributes of broadcast 3, as described in broadcast 1.
[0123] 4. Broadcast 4
[0124] Broadcast 4 is used to quickly refresh the online status of the second electronic device when the first electronic device is off.
[0125] The sending conditions for Broadcast 4 can be set as follows:
[0126] 1) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, when the first electronic device switches from screen on to screen off, the first electronic device can send broadcast 4 to quickly refresh the online status of the second electronic device.
[0127] Currently, when the first electronic device and the second electronic device establish a BLE heartbeat connection, the first electronic device can periodically send heartbeat packets to the second electronic device. In response to these heartbeat packets, the second electronic device can send feedback information back to the first electronic device. Based on this feedback information, the first electronic device can determine that the second electronic device is online.
[0128] In this embodiment, when the first electronic device switches from screen-on to screen-off, it can send a broadcast 4. In response to this broadcast 4, the second electronic device can send feedback information back to the first electronic device. In response to this feedback information, the first electronic device can determine that the second electronic device is online. In this example, the first electronic device does not need to wait for the heartbeat packet transmission cycle; instead, it uses broadcast 4 to quickly detect the online status of the second electronic device.
[0129] 2) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, after the first electronic device switches to screen off, the first electronic device can periodically send broadcast 4 to refresh the online status of the second electronic device. In some embodiments, the period during which the first electronic device sends broadcast 4 can be referred to as the first period.
[0130] In some embodiments, the attributes of broadcast 4 can be configured as: connectable, require a response, and cannot be woken up. Taking the second electronic device as an example, "connectable" means that in response to broadcast 4, the second electronic device can directly initiate a connection to the first electronic device. "Requires a response" means that in response to broadcast 4, the second electronic device needs to send feedback information to the first electronic device; for example, the second electronic device can send broadcast 5 to the first electronic device. "Cannot be woken up" means that when the second electronic device is on, in response to broadcast 4, the second electronic device can send broadcast 5 back to the first electronic device. When the second electronic device is off and the CPU is in sleep mode, in response to broadcast 4, the CPU in the second electronic device remains in sleep mode, and the second electronic device does not need to perform any action.
[0131] In some embodiments, broadcast 4 may be configured with an attribute field that indicates the attributes of broadcast 4, as described in broadcast 1.
[0132] 5. Broadcast 5
[0133] Broadcast 5 is used for responding to broadcasts and for notifying the second electronic device of its online status. Notifying the second electronic device of its online status can be understood as informing the second electronic device that it is online.
[0134] The sending conditions for broadcast 5 can be set as follows:
[0135] 1) In response to broadcast 1, broadcast 3 or broadcast 4 from the first electronic device, the second electronic device may send broadcast 5 back to the first electronic device.
[0136] 2) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, and the first electronic device is on, the first electronic device can periodically send broadcast 5 to the second electronic device to refresh the online status of the first electronic device. In this example, when the first electronic device switches between on and off states, the first electronic device can periodically send broadcast 5. In response to this broadcast 5, the second electronic device can determine that the first electronic device is online. In some embodiments, the period during which the first electronic device sends broadcast 5 can be referred to as the second period. The second period is shorter than the first period. For example, the second period is 30 seconds, and the first period is 300 seconds.
[0137] In some embodiments, the attributes of broadcast 5 can be configured as: connectable, no response required, and non-wakeable. Taking the first electronic device as an example, connectable means that in response to broadcast 5, the first electronic device can directly initiate a connection to the second electronic device. No response required means that in response to broadcast 5, the first electronic device does not need to send feedback to the second electronic device. Non-wakeable means that when the first electronic device is on, in response to broadcast 5, the first electronic device can refresh the status of the second electronic device as online. When the second electronic device is off and its CPU is in sleep mode, in response to broadcast 5, the CPU in the second electronic device remains in sleep mode, and the second electronic device does not need to perform any action.
[0138] In some embodiments, broadcast 5 may be configured with an attribute field that indicates the attributes of broadcast 5, as described in broadcast 1.
[0139] Taking the establishment of a Bluetooth connection between a first electronic device and a second electronic device as an example, in some embodiments, the first electronic device and the second electronic device can establish a long connection. In the embodiments of this application, the long connection can be a BLE connection or a BR connection. In some embodiments, the first electronic device and the second electronic device can first establish a short connection, and after the short connection is disconnected, the BLE heartbeat can be kept online.
[0140] In the case where the first electronic device and the second electronic device establish a long connection, it can be said that the first electronic device and the second electronic device remain connected online, that is, the first electronic device and the second electronic device can determine that the other is online based on the long connection between them. In the case where the first electronic device and the second electronic device maintain a BLE heartbeat connection, in this embodiment of the application, the online status of the other party can be determined through broadcasts 3 and 4, or the online status can be informed to the other party through broadcast 5.
[0141] Reference Figure 2 In the case of 'a', when the first electronic device and the second electronic device remain connected online or have their heartbeats online, the interface of the first electronic device can display the identifier 21 of the second electronic device. Figure 2 The example used is a tablet computer as the second electronic device. (Refer to...) Figure 2 For example, if a user turns off the WiFi switch, the first electronic device cannot discover the second electronic device via broadcast, meaning it cannot establish a connection with the second electronic device. The interface of the first electronic device may display a message stating "Wireless local area network (WLAN) needs to be enabled to discover devices."22 It should be understood that... Figure 2 In section b, the absence of the WLAN icon 23 on the interface of the first electronic device indicates that the user has turned off the WiFi switch. (See reference...) Figure 2 In option b, the interface of the first electronic device can also display cancel and enable controls to enable WLAN by allowing the user to operate the controls.
[0142] In some embodiments, while the first electronic device and the second electronic device remain connected online, if the user turns off the Bluetooth switch of the first electronic device, the first electronic device can disconnect from the second electronic device and disconnect the second electronic device. Specifically, the second electronic device can detect the disconnection and disconnect the first electronic device.
[0143] In some embodiments, if the first electronic device and the second electronic device maintain a heartbeat online connection, and the user turns off the Bluetooth switch of the first electronic device, the second electronic device cannot immediately detect this and cannot immediately disconnect the first electronic device.
[0144] In some embodiments, when the first electronic device and the second electronic device remain connected online, the first electronic device can block all broadcasts from the second electronic device, and the second electronic device can also block all broadcasts from the first electronic device. Taking the first electronic device blocking all broadcasts from the second electronic device as an example, blocking all broadcasts from the second electronic device can be understood as: when the first electronic device receives a broadcast from the second electronic device, it does not process that broadcast. This reduces the amount of broadcast processing and power consumption of the first electronic device.
[0145] In some embodiments, when the first electronic device and the second electronic device maintain a heartbeat online connection, the first electronic device may block broadcast 1 from the second electronic device, and the second electronic device may also block broadcast 1 from the first electronic device. Taking the first electronic device blocking broadcast 1 from the second electronic device as an example, when the first electronic device receives broadcast 1 from the second electronic device, it does not process broadcast 1. However, when the first electronic device receives other broadcasts from the second electronic device (such as broadcast 2, broadcast 3, broadcast 4, or broadcast 5), it may process those other broadcasts.
[0146] In some embodiments, when the first electronic device and the second electronic device are not connected, the first electronic device can process all broadcasts from the second electronic device, and the second electronic device can also process all broadcasts from the first electronic device.
[0147] When the first and second electronic devices remain connected online, or when their heartbeats are active, the first electronic device can mark the second electronic device as online, and the second electronic device can also mark the first electronic device as online. However, in some scenarios, the online / offline status of the first and second electronic devices may be asymmetrical. When this asymmetry occurs, it will affect the execution of services by both the first and second electronic devices, and will also increase the broadcast processing load and power consumption of both devices.
[0148] For example, when the first and second electronic devices remain connected online or have their heartbeats connected, the first electronic device marks the second electronic device as online, but the second electronic device marks the first electronic device as offline. This creates an asymmetry in the online / offline status of the first and second electronic devices. In this example, when the first electronic device initiates a service (such as keyboard and mouse sharing) to the second electronic device, the second electronic device will reject the service because it has marked the first electronic device as offline, preventing the service from proceeding smoothly.
[0149] In addition, when the first electronic device and the second electronic device remain connected online, the second electronic device would normally block all broadcasts from the first electronic device. However, due to the asymmetry of online and offline status, the second electronic device marks the first electronic device as offline. Therefore, the second electronic device processes all broadcasts from the first electronic device, resulting in a large amount of broadcast processing and high power consumption for the second electronic device.
[0150] This application provides a communication method in which, when a first electronic device and a second electronic device remain connected online or have their heartbeats connected, the first and second electronic devices can quickly detect an asymmetry in their online / offline states and restore symmetry, that is, the online / offline state of the second electronic device marked by the first electronic device is the same as the online / offline state of the first electronic device marked by the second electronic device. When the online / offline states of the first and second electronic devices are symmetrical, the smooth execution of services by both devices can be guaranteed, and the broadcast processing load and power consumption of both devices can be reduced.
[0151] The communication method provided in this application will be described below with reference to specific embodiments. These embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. It should be understood that the following uses two scenarios—keeping the first and second electronic devices connected online and having a heartbeat online—as examples to introduce the communication method provided in this application.
[0152] Scenario 1: The first and second electronic devices remain connected online.
[0153] Figure 3 This is a flowchart illustrating one embodiment of the communication method provided in this application. (Refer to...) Figure 3 The communication method provided in this application embodiment may include:
[0154] S301, the first electronic device and the second electronic device establish a long connection.
[0155] A persistent connection can include a BR connection or a BLE connection. The process of establishing a persistent connection between the first electronic device and the second electronic device can be described in the following embodiments. Figures 8A-8C The description.
[0156] S302, the first electronic device and the second electronic device undergo device certification.
[0157] The equipment certification process may include the following steps:
[0158] (1) The first electronic device and the second electronic device exchange their respective unique device identifiers (UDIDs). The first electronic device can send its first UDID to the second electronic device, and the second electronic device can send its second UDID to the first electronic device. The first electronic device and the second electronic device complete a handshake based on their respective UDIDs.
[0159] (2) After the first electronic device and the second electronic device complete the handshake, they can initiate a security authentication from one end to the other according to specific rules. After the security authentication is completed, the first electronic device and the second electronic device can negotiate and generate a session key.
[0160] (3) The first electronic device and the second electronic device can perform encrypted transmission according to the key. The transmitted data may include, but is not limited to, device information of both parties, and attribute values indicating whether to maintain a long connection. For example, the first authentication module can send first device information to the second authentication module, and the second authentication module can send second device information to the first authentication module.
[0161] The first device information may include: the identifier of the first electronic device, device type, first media access control (MAC) address, first network ID, and first identity resolving key (IRK). The first network ID is used by other electronic devices to identify the first electronic device during the connection establishment process. In some embodiments, the first electronic device may use a hash algorithm to generate a random number within a preset numerical range based on its MAC address; this random number can be the first network ID. For example, the preset numerical range can be 0-31. The first IRK is used by other electronic devices to resolve the first MAC address of the first electronic device.
[0162] In some embodiments, the first electronic device may generate a first network ID and a first IRK upon power-on.
[0163] Accordingly, the second device information may include: the identifier of the second electronic device, the device type, the second MAC address, the second network ID, and the second IRK.
[0164] (4) In some embodiments, after the first electronic device and the second electronic device complete device authentication, the first authentication module can determine whether the first electronic device can maintain the current long connection, and the second electronic device can also determine whether it can maintain the current long connection. The first electronic device and the second electronic device can exchange information once, such as a close ACK. The close ACK may carry an identifier, which indicates whether the current long connection can be maintained. For example, the first authentication module can send a first close ACK to the second authentication module, which may carry a first identifier, indicating whether the first electronic device can maintain the current long connection. Similarly, the second authentication module can send a second close ACK to the first authentication module, which may carry a second identifier, with the first identifier indicating whether the second electronic device can maintain the current long connection.
[0165] It is understandable that the purpose of the first electronic device determining whether it can maintain the current long connection, and the second electronic device determining whether it can maintain the current long connection, is that: the first electronic device and the second electronic device have already established a long connection, but in a real scenario there are multiple electronic devices. After the device authentication of the two devices is completed, the first electronic device or the second electronic device may establish a connection with other electronic devices and may not be able to maintain the long connection with the other party. Therefore, further determining whether the long connection can be maintained can maintain the connection between the two devices in a more suitable way.
[0166] This explanation uses the example of the first electronic device determining whether it can maintain the current long-term connection.
[0167] 1) When a BLE connection is established between the first electronic device and the second electronic device: if there is at least one available BLE connection when the first electronic device is the master and the second electronic device is the slave, or if there is at least one available BLE connection when the first electronic device is the slave and the second electronic device is the master, the first device authentication module determines that the first electronic device can maintain the current BLE connection.
[0168] In 1), since the first electronic device and the second electronic device have already established a BLE connection, occupying 1 BLE connection resource, it is sufficient to retain at least 1 available BLE connection without affecting the execution of other services.
[0169] 2) When a BR connection is established between the first electronic device and the second electronic device: if there is at least one available BR connection when the first electronic device is the master device (client) and the second electronic device is the slave device (server), or if there is at least one available BR connection when the first electronic device is the server and the second electronic device is the client, the first device authentication module determines that the first electronic device can maintain the current BR connection.
[0170] Similarly to 1), if the first electronic device and the second electronic device have already established a BR connection, the first electronic device and the second electronic device occupy 1 BR connection resource. Therefore, it is sufficient to retain at least 1 available BLE connection without affecting the execution of other services.
[0171] 3) The number of connections established by the first electronic device is less than or equal to a preset number, that is, the sum of the BLE connections and BR connections established by the first electronic device is less than or equal to a preset number. For example, the preset number is 5.
[0172] The second device authentication module determines whether the second electronic device can maintain the current BLE connection or BR connection, which can be referred to in the relevant description of the first electronic device.
[0173] The second electronic device determines whether it can maintain the current long connection, and can refer to the relevant description of the first electronic device.
[0174] Once the first electronic device and the second electronic device have passed authentication, the following steps can be performed:
[0175] S303, the first electronic device sends the first handshake information to the second electronic device.
[0176] The first handshake message is used to instruct the second electronic device to perform a handshake with the first electronic device. After the second electronic device and the first electronic device have completed the handshake, the first and second electronic devices can exchange data and execute business operations.
[0177] S304, within a first preset time period, when the first electronic device receives a first confirmation message from the second electronic device, the first electronic device marks the second electronic device as online.
[0178] The first confirmation message is a response to the first handshake message. In some embodiments, for example, the second preset duration can be 5 seconds.
[0179] The first confirmation information is used to indicate that the second electronic device has received the first handshake information and that the second electronic device agrees to handshake with the first electronic device.
[0180] In some embodiments, within a first preset time period, when the first electronic device receives a first confirmation message from the second electronic device, the first electronic device can bring the second electronic device online. For example, the first electronic device can mark the second electronic device as online, or store the online / offline status of the second electronic device as online, etc.
[0181] In some embodiments, due to unreliable network transmission or low network quality, packet loss may occur during the transmission of the first confirmation information. Thus, if the first electronic device does not receive the first confirmation information from the second electronic device within a first preset time period, the first electronic device can determine that the second electronic device is offline, and the first electronic device maintains the offline state of the other end.
[0182] S305, the second electronic device sends a second handshake message to the first electronic device.
[0183] It should be understood that there is no specific order between S303-S304 and S305-S306, and they can be executed simultaneously.
[0184] S306, within a first preset time period, when the second electronic device does not receive the second confirmation information from the first electronic device, the second electronic device maintains the first electronic device in an offline state.
[0185] Due to unreliable network transmission or low network quality, packet loss may occur during the transmission of the second confirmation information. Therefore, if the second electronic device does not receive the second confirmation information from the first electronic device within the first preset time period, the second electronic device determines itself to be offline and maintains the offline state of the first electronic device. It should be understood that if the first electronic device receives the first confirmation information from the second electronic device within the first preset time period, the first electronic device marks the second electronic device as online.
[0186] In this embodiment of the application, taking the example of the first electronic device marking the second electronic device as online and the second electronic device maintaining the first electronic device as offline, the problem of asymmetry between the online and offline states of the first electronic device and the second electronic device is described, and a solution to this asymmetry is provided.
[0187] In this embodiment of the application, when the second electronic device marks the first electronic device as offline, the following steps can be performed:
[0188] S307, the second electronic device resends the second handshake information to the first electronic device.
[0189] S308, within a second preset time period, when the second electronic device receives the second confirmation information from the first electronic device, the second electronic device marks the first electronic device as online.
[0190] In this embodiment of the application, when the second electronic device marks the first electronic device as offline, since the first electronic device and the second electronic device remain connected online, in order to avoid the problem of asymmetry in the online and offline states of the first electronic device and the second electronic device, the second electronic device can re-request the second confirmation information from the first electronic device so that the second electronic device marks the first electronic device as online.
[0191] For example, the second electronic device can resend the second handshake information to the first electronic device, and in response to the second handshake information, the first electronic device can resend the second confirmation information. In some embodiments, after a second preset time period, when the second electronic device receives the second confirmation information from the first electronic device, the second electronic device marks the first electronic device as online. Thus, the online / offline states of the first and second electronic devices are symmetrical; for example, the first electronic device marks the second electronic device as online, and the second electronic device marks the first electronic device as online.
[0192] In some embodiments, the second preset duration may be equal to or different from the first preset duration. For example, the second preset duration may be 5 seconds.
[0193] S309, after a second preset time period, when the second electronic device does not receive the second confirmation information from the first electronic device, the second electronic device disconnects from the first electronic device.
[0194] The second electronic device requested a second confirmation message from the first electronic device twice but failed to receive it, indicating that poor network quality may have caused packet loss of the second confirmation message. To avoid the problem of asymmetrical online / offline status, the second electronic device can disconnect from the first electronic device.
[0195] S310, the first electronic device marks the second electronic device as offline.
[0196] It should be understood that the second electronic device can be connected to the first electronic device. The first electronic device can detect when the connection with the second electronic device is broken, and therefore the first electronic device can mark the second electronic device as offline. In this way, the online and offline states of the first and second electronic devices can be kept symmetrical.
[0197] In this embodiment of the application, in a scenario where the first electronic device and the second electronic device remain connected online, when the online / offline states of the first and second electronic devices are asymmetrical—for example, when the first electronic device marks the second electronic device as online and the second electronic device marks the first electronic device as offline—the second electronic device can request a second confirmation message from the first electronic device to restore the first electronic device to online status. Specifically, within a second preset time period, when the second electronic device receives the second confirmation message from the first electronic device, the second electronic device marks the first electronic device as online, thus ensuring symmetrical online / offline states for the first and second electronic devices. Conversely, within the second preset time period, if the second electronic device does not receive the second confirmation message from the first electronic device, the second electronic device can disconnect from the first electronic device. The first electronic device, sensing the disconnection, can mark the second electronic device as offline, thus ensuring symmetrical online / offline states for the first and second electronic devices.
[0198] In this embodiment, a first preset duration and a second preset duration can be set. When the electronic device does not receive confirmation information within the first preset duration, the electronic device can request confirmation information again. The electronic device can also perform corresponding operations based on whether confirmation information is received within the second preset duration, so that the first electronic device and the second electronic device can maintain a symmetrical online / offline state.
[0199] Scene 2: Heartbeat Online
[0200] Assuming both the first and second electronic devices maintain an online heartbeat, the following example using the second electronic device illustrates the reasons for the asymmetry in their online / offline status in the following scenario:
[0201] Reason 1: The second electronic device frequently turns its screen on and off. "Turning the screen on and off" can be understood as the screen turning on and off.
[0202] For example, if the first electronic device is off-screen and actively refreshes the online status of the second electronic device, such as when the first electronic device sends broadcast 4, and the second electronic device is off-screen, it cannot process broadcast 4 and therefore will not send broadcast 5 back to the first electronic device. Consequently, if the first electronic device does not receive broadcast 5 from the second electronic device within a preset time, it can mark the second electronic device as offline. However, since the second electronic device maintains a heartbeat connection with the first electronic device, it will mark itself as online, leading to an asymmetry in online / off-screen status.
[0203] Reason 2: Moving the first electronic device back and forth.
[0204] Similar to reason 1, when the second electronic device actively performs heartbeat detection on the first electronic device—for example, when the second electronic device sends a broadcast (4) to the first electronic device—if the user moves the first electronic device away and it is no longer within the near-field range of the second electronic device, the first electronic device cannot receive the fourth broadcast and therefore will not send feedback information to the second electronic device. The first electronic device can then mark the second electronic device as offline. However, for the second electronic device, if the heartbeat between the second and first electronic devices remains online, the second electronic device will mark itself as online, thus creating an asymmetry in online / offline status.
[0205] Figure 4A This is a flowchart illustrating another embodiment of the communication method provided in this application. (Refer to...) Figure 4A The communication method provided in this application embodiment may include:
[0206] S401A, the first electronic device and the second electronic device keep the heartbeat online.
[0207] S402A, the first electronic device marks the second electronic device as online.
[0208] S403A, the second electronic device marks the first electronic device as online.
[0209] While the first electronic device and the second electronic device maintain an online heartbeat, the first electronic device can mark the second electronic device as online, and the second electronic device can mark the first electronic device as online.
[0210] In this embodiment of the application, the electronic device can record the time when the online / offline status of the peer device is refreshed. For example, in S402A, the first electronic device marks the second electronic device as online, and can record the time the second electronic device is online. For example, in S403A, the second electronic device marks the first electronic device as online, and can record the time the first electronic device is online.
[0211] S404A, when the first electronic device switches from screen on to screen off, the first electronic device sends a fourth broadcast.
[0212] S405A, within a third preset time period, when the first electronic device does not receive broadcast 5 from the second electronic device, the first electronic device marks the second electronic device as pre-offline.
[0213] In some embodiments, the third preset duration may be equal to or different from the first preset duration. For example, the third preset duration may be 5 seconds.
[0214] It should be understood that, regarding reason 1: In this embodiment, the purpose of marking the second electronic device as pre-offline by the first electronic device is that, in the case of frequent screen switching of the second electronic device, when the second electronic device is off, even if the second electronic device receives broadcast 4, it will not send broadcast 5 back to the first electronic device. If the first electronic device goes offline, an asymmetry in the online / offline states of both devices will occur. In this embodiment, to tolerate the situation of the second electronic device frequently switching on and off, the first electronic device can mark the second electronic device as pre-offline.
[0215] Furthermore, regarding reason 2: In this embodiment, the purpose of marking the second electronic device as pre-offline by the first electronic device is that when the user moves the second electronic device back and forth, the second electronic device cannot receive broadcast 4 when the user moves it away, and the second electronic device will not send broadcast 5 back to the first electronic device. If the first electronic device goes offline, an asymmetry in the online / offline status of the two devices will occur. In this embodiment, to accommodate the situation where the user moves the second electronic device back and forth, the first electronic device can mark the second electronic device as pre-offline.
[0216] S406A, when the first electronic device switches from screen off to screen on, the second electronic device periodically sends a third broadcast.
[0217] When the first electronic device switches from screen off to screen on, it determines that a second electronic device is pre-offline because it marks the second electronic device as pre-offline. The first electronic device periodically sends a third broadcast to detect whether it is online.
[0218] In some embodiments, for example, the second electronic device may send a third broadcast every fourth preset time interval. For example, the fourth preset time interval may be 30 seconds, and the duration of the third broadcast may be 5 seconds.
[0219] S407A, when the duration of the first time and the second time is less than or equal to the fifth preset duration, the first electronic device marks the second electronic device as online. The first time is: the time when the first electronic device marks the second electronic device as pre-offline, and the second time is: the time when the first electronic device receives the broadcast 5 from the second electronic device.
[0220] Because the first electronic device periodically sends a third broadcast, as long as the second electronic device is within the near-field range of the first electronic device, the second electronic device can receive the third broadcast and, in response to the third broadcast, the second electronic device can send broadcast 5.
[0221] In this embodiment of the application, when the duration of the first moment and the second moment is less than or equal to the fifth preset duration, the first electronic device can receive the broadcast 5 from the second electronic device, indicating that the second electronic device is online. The first electronic device can mark the second electronic device as online, thus avoiding the problem of asymmetry between the online and offline states of the first electronic device and the second electronic device.
[0222] In some embodiments, the fifth preset duration can be 5 minutes. The purpose of this setting is that when the first electronic device is in a screen-off state, the electronic device can send a heartbeat message to the first electronic device every 5 minutes. Setting the fifth preset duration to 5 minutes can maximize the fault tolerance of the first electronic device.
[0223] S408A, when the time elapsed since the first moment exceeds the fifth preset time, and the first electronic device has not yet received the broadcast 5 from the second electronic device, the first electronic device marks the second electronic device as offline.
[0224] In this embodiment of the application, when the time elapsed since the first moment is greater than the fifth preset time elapsed, the first electronic device has not yet received the broadcast 5 from the second electronic device, indicating that the second electronic device has not appeared in the near field of the first electronic device and has not responded with the broadcast 5. Therefore, the first electronic device has reason to believe that the second electronic device has gone offline, that is, the second electronic device marks the first electronic device as offline. Thus, the first electronic device can mark the second electronic device as offline to ensure that the online and offline states of both parties are symmetrical.
[0225] In some embodiments, after S405A, when the first electronic device remains screen-off, it can detect the online status of the second electronic device every 5 minutes. For example, the first electronic device can send a broadcast 4 every 5 minutes. When the duration of the first moment and the second moment is less than or equal to a fifth preset duration, the first electronic device marks the second electronic device as online. When the duration since the first moment exceeds the fifth preset duration, and the first electronic device has not yet received a broadcast 5 from the second electronic device, the first electronic device marks the second electronic device as offline.
[0226] Reason 3: Frequent switching of the Bluetooth or WiFi switch on the second electronic device. A switch can be understood as turning it on and off.
[0227] Similar to reason 1, when the first electronic device actively performs heartbeat detection on the second electronic device—for example, by sending broadcast 3 or broadcast 4—if the second electronic device has its Bluetooth or WiFi switched off, it cannot receive broadcast 3 or broadcast 4 and therefore will not send broadcast 5 back to the first electronic device. Consequently, if the first electronic device does not receive broadcast 5 from the second electronic device within a preset time, it can mark the second electronic device as offline. However, for the second electronic device, if the heartbeat between the two devices remains online, the second electronic device will mark itself as online, leading to an asymmetry in online / offline status.
[0228] This section uses the example of a first electronic device with its screen on to illustrate the communication method provided in the embodiments of this application. (Refer to...) Figure 4B The communication method provided in this application embodiment may include:
[0229] S401B, the first electronic device and the second electronic device keep the heartbeat online.
[0230] S402B, the first electronic device marks the second electronic device as online.
[0231] S403B, the second electronic device marks the first electronic device as online.
[0232] S404B, when the first electronic device is on and receives broadcast 2 from the second electronic device, the first electronic device marks the second electronic device as pre-offline.
[0233] It should be understood that the purpose of marking the second electronic device as pre-offline in this embodiment is to indicate that the second electronic device is offline when the first electronic device is on and receives a broadcast 2 from the second electronic device, for example, when the user turns off the WiFi or Bluetooth switch of the second electronic device. To avoid the second electronic device frequently turning its WiFi or Bluetooth switch on and off, if the first electronic device directly marks the second electronic device offline, then when the user turns on the WiFi or Bluetooth switch of the second electronic device, the second electronic device marks the first electronic device as online, but the first electronic device marks the second electronic device as offline, resulting in an asymmetry in their online / offline states. This application does not directly mark the second electronic device as offline to mitigate this error and avoid the asymmetry in their online / offline states in scenarios where the second electronic device frequently turns its WiFi or network switch on and off, which could affect normal service execution.
[0234] For example, if device A and device B are maintaining a heartbeat connection, and device B is off, and device A turns off its Bluetooth, then device A will disconnect device B. If device A then immediately sets device B to offline mode, device A will only perform the normal networking process after turning on Bluetooth, i.e., device A will send broadcast 1. However, device B, being off-screen and believing device A is still heartbeat connected, will block device A's broadcast 1. This prevents device B from waking up and connecting with device A, thus preventing the service from initiating.
[0235] Therefore, in this embodiment of the application, when device A turns off the Bluetooth switch, device A can mark device B as pre-offline. When device A turns Bluetooth back on, because device A will execute S405B in response to the broadcast 5 fed back by device B, device A can re-establish a heartbeat connection with device B, enabling the online / offline status of both parties to be consistent.
[0236] S405B, the second electronic device periodically transmits a third broadcast.
[0237] S406B, when the duration of the first time and the second time is less than or equal to the fifth preset duration, the first electronic device marks the second electronic device as online. The first time is: the time when the first electronic device marks the second electronic device as pre-offline, and the second time is: the time when the first electronic device receives the broadcast 5 from the second electronic device.
[0238] S407B, when the time elapsed since the first moment exceeds the fifth preset time, and the first electronic device has not yet received the broadcast 5 from the second electronic device, the first electronic device marks the second electronic device as offline.
[0239] In this embodiment, in a scenario where the first electronic device and the second electronic device maintain an online heartbeat, when the first electronic device does not receive a response from the second electronic device to the broadcast, the first electronic device does not directly mark the second electronic device as offline, but instead marks it as pre-offline, thus providing fault tolerance for the second electronic device. Additionally, the first electronic device can record the duration between the first and second moments. When this duration is less than or equal to a fifth preset duration, the first electronic device can mark the second electronic device as online. When the duration since the first moment exceeds the fifth preset duration, and the first electronic device has not yet received a response from the second electronic device, the first electronic device can mark the second electronic device as offline.
[0240] As above, Figure 4A and Figure 4BThe embodiments describe a method for enabling symmetrical online / offline states of the first and second electronic devices in a scenario where the first electronic device and the second electronic device maintain a heartbeat online status. In some embodiments, after the first electronic device marks the second electronic device as offline in S408A or S407B, the first electronic device can receive broadcasts from the second electronic device because it does not need to block the broadcasts from the second electronic device. In this scenario, the first electronic device can maintain symmetrical online / offline states of the first and second electronic devices by initiating a connection or replying to a broadcast.
[0241] Reference Figure 5 The communication method provided in this application embodiment may include:
[0242] S501, the first electronic device and the second electronic device keep the heartbeat online.
[0243] S502, the second electronic device marks the first electronic device as online.
[0244] S501-S502 can be referred to in the descriptions in S401A-S402A.
[0245] S503, the first electronic device marks the second electronic device as offline.
[0246] Reference Figure 4A and Figure 4B As described in S408A or S407B, the first electronic device can mark the second electronic device as offline.
[0247] S504, when the first electronic device receives a broadcast from the second electronic device, the first electronic device performs a corresponding operation according to the attributes of the broadcast, enabling the online / offline states of the second electronic device and the first electronic device to be symmetrical.
[0248] Because the first electronic device marks the second electronic device as offline, it can process any broadcast received from the second electronic device. In this embodiment, the first electronic device can perform corresponding operations based on the broadcast's "connectivity" attribute, enabling symmetry between the online and offline states of the second and first electronic devices. In some embodiments, the broadcast's "connectivity" attribute can be referred to as the broadcast's connectivity attribute, which may include connectability or disconnectability.
[0249] For example, when the second electronic device discovers that there is an offline electronic device (such as the second electronic device) under the first account, the second electronic device can also send a broadcast 1, so that the first electronic device can also receive the broadcast 1. Here, the existence of offline electronic devices under the first account can be understood as: there are still electronic devices under the first account that have not established a connection with the first electronic device.
[0250] Similarly, based on the descriptions in broadcasts 3, 4, and 5, the first electronic device can also receive broadcasts 3, 4, or 5 from the second electronic device. In summary, the first electronic device can receive broadcasts 1, 3, 4, or 5 from the second electronic device.
[0251] Broadcast 2 indicates that the second electronic device has gone offline. At this time, the first electronic device has already marked the second electronic device as offline. When the first electronic device receives Broadcast 2 from the second electronic device, it can determine that the second electronic device is offline. When the second electronic device goes offline, it will mark the first electronic device as offline; therefore, there is no asymmetry in the online / offline states of the two devices.
[0252] In the following embodiments, the operation when the first electronic device receives broadcast 1, broadcast 3, broadcast 4, or broadcast 5 from the second electronic device will be described. Referring to the description in the above embodiments, broadcast 1 is not connectable, while broadcast 3, broadcast 4, and broadcast 5 are connectable.
[0253] In some embodiments, when the first electronic device receives a broadcast with the attribute "unconnectable" (such as broadcast 1), since the first electronic device cannot actively initiate a connection to the second electronic device, S5041-S5042 can be executed:
[0254] S5041, the first electronic device sends a broadcast 5 to the second electronic device.
[0255] For example, when device A replies to broadcast 5 to device B, which is marked as offline, it can include the hash value of device B's UDID (UDIDHash) in broadcast 5. When device B receives broadcast 5, it will determine whether the UIDHash carried in it is its own UIDHash. If it is, and device B and device A are in a heartbeat online state, device B can mark device A as offline.
[0256] In this embodiment, when the first electronic device marks the second electronic device as offline, in response to broadcast 1 from the second electronic device, the first electronic device can send broadcast 5 to the second electronic device, which carries the UDIDHash of the second electronic device. In response to broadcast 5, the second electronic device can determine whether the UDIDHash carried in broadcast 5 is its own UDIDHash. If the UDIDHash carried in broadcast 5 is its own UDIDHash, because the second electronic device marks the first electronic device as online, and the second electronic device and the first electronic device maintain a heartbeat connection, the second electronic device can mark the first electronic device as offline.
[0257] S5042, in response to broadcast 5, the second electronic device marks the first electronic device as offline.
[0258] When the second electronic device receives broadcast 5 from the first electronic device, it signifies that the first electronic device agrees to establish a connection with the second electronic device. However, because the second electronic device has already marked the first electronic device as online, yet still receives the second broadcast from the first electronic device, the second electronic device can determine that the online / offline status of both devices is asymmetrical. Therefore, to resolve this asymmetrical online / offline status, the second electronic device can mark the first electronic device as offline. In this way, the first electronic device marks the second electronic device as offline, and the second electronic device marks the first electronic device as offline, achieving symmetrical online / offline status between the two devices.
[0259] In some embodiments, when the first electronic device receives a broadcast with the attribute "connectable" (such as broadcast 3, broadcast 4, or broadcast 5), since the first electronic device can actively initiate a connection to the second electronic device, S5043-S5044 can be executed:
[0260] S5043, the first electronic device requests the second electronic device to establish a connection.
[0261] S5044, after the first electronic device and the second electronic device establish a connection, the first electronic device marks the second electronic device as online.
[0262] In this embodiment of the application, based on the attributes of broadcast 3, broadcast 4 or broadcast 5, the first electronic device can actively initiate a connection to the second electronic device. Therefore, the first electronic device can send a connection request to the second electronic device to request to establish a connection with the second electronic device.
[0263] Because the second electronic device has marked the first electronic device as online, when the second electronic device receives a connection request from the first electronic device, it can establish a connection with the first electronic device in response to the connection request. After the first and second electronic devices establish a connection, the first electronic device can bring the second electronic device online, and the second electronic device can bring the first electronic device online. Thus, the first electronic device marks the second electronic device as online, and the second electronic device marks the first electronic device as online; the online / offline statuses of the second and first electronic devices are symmetrical.
[0264] In this embodiment of the application, in a scenario where the second electronic device and the first electronic device maintain an online heartbeat, after the first electronic device marks the second electronic device as offline, since the first electronic device does not block the broadcasts from the second electronic device, the first electronic device can process the broadcasts from the second electronic device. Therefore, the first electronic device can perform corresponding operations based on the attributes of the broadcasts from the second electronic device to make the online / offline states of the second electronic device and the first electronic device symmetrical.
[0265] When the first electronic device receives a broadcast with the attribute of being unconnectable (broadcast 1), the first electronic device can send a second broadcast to the second electronic device, enabling the second electronic device to determine that the online / offline status of the two devices is asymmetrical. The second electronic device can then mark the first electronic device as offline, thus making the online / offline status of the second electronic device and the first electronic device symmetrical.
[0266] When the first electronic device receives a broadcast with the attribute of "connectable" (broadcast 3, broadcast 4, or broadcast 5), the first electronic device can actively initiate a connection to the second electronic device. In response to this connection request, the second electronic device and the first electronic device can establish a connection. After the first and second electronic devices establish a connection, the first electronic device can bring the second electronic device online, and the second electronic device can bring the first electronic device online. Thus, the first electronic device marks the second electronic device as online, and the second electronic device marks the first electronic device as online, making their online / offline status symmetrical.
[0267] In some embodiments, after S5042 and after S5044, the first electronic device and the second electronic device may re-establish a connection to mark each other as online in order to collaboratively perform business.
[0268] This section uses the example of establishing a connection between electronic device 1 and electronic device 2 to illustrate the current process of establishing connections between electronic devices:
[0269] Establishing a connection between electronic device 1 and electronic device 2 may involve two steps: scanning and connecting. Scanning is used to discover electronic devices. For example, electronic device 1 can discover electronic device 2 through scanning. After discovering electronic device 2, electronic device 1 can establish a connection with it.
[0270] In some embodiments, electronic devices can detect surrounding electronic devices by sending and receiving signals. For example, the signals can be broadcast or probe signals.
[0271] Taking a broadcast signal as an example, electronic device 1 can send a broadcast to detect nearby electronic devices. Electronic device 2, receiving the broadcast from electronic device 1, can send a response signal back to electronic device 1. This response signal may include information such as the device identifier and device type of electronic device 2. Upon receiving this response signal, electronic device 1 can display the information of the scanned electronic device 2, indicating that electronic device 1 has detected electronic device 2.
[0272] After electronic device 1 discovers electronic device 2, a connection can be established between electronic device 1 and electronic device 2. In some embodiments, for example, electronic device 1 can initiate a connection request to electronic device 2. In response to the connection request, a connection can be established between electronic device 1 and electronic device 2. After the connection is established, electronic device 1 and electronic device 2 can exchange data through the connection to perform business operations.
[0273] Taking the establishment of a Bluetooth connection between electronic devices as an example, the following will combine... Figure 6A This section details the process by which electronic device 1 discovers electronic device 2:
[0274] Electronic device 1 can send a broadcast every time interval t1. In some embodiments, the time during which electronic device 1 sends the broadcast can be referred to as the sending window. When electronic device 2's Bluetooth function is not enabled, electronic device 2 will not scan for Bluetooth broadcasts, meaning electronic device 2 will not receive broadcasts from electronic device 1. When electronic device 2's Bluetooth function is enabled, for example, starting from time T0, electronic device 2 can receive a broadcast every time interval t2. In some embodiments, the time during which electronic device 2 receives the broadcast can be referred to as the scanning window or the receiving window.
[0275] Reference Figure 6AElectronic device 2 not only needs to have Bluetooth enabled, but its scanning window also needs to match the sending window of electronic device 1 for it to receive broadcasts from electronic device 1. However, the matching of the scanning window of electronic device 2 and the sending window of electronic device 1 is a probabilistic event, therefore, electronic device 2 receiving broadcasts from electronic device 1 is also a probabilistic event. Currently, electronic device 1 needs to send multiple broadcasts for electronic device 2 to receive them. After receiving a broadcast from electronic device 1, electronic device 2 can send a response signal back to electronic device 1, allowing electronic device 1 to detect electronic device 2. (Refer to...) Figure 6A Within the scanning window starting at time T1, electronic device 2 receives a broadcast from electronic device 1. Currently, electronic device 1 detects that electronic device 2 is slow, resulting in a slow connection establishment between electronic device 1 and electronic device 2.
[0276] As users acquire more electronic devices, the time it takes for these devices to discover each other and the speed at which connections are established between them will increase, thus impacting the user experience.
[0277] In order to improve the speed of discovering electronic devices and thus the speed of establishing connections between electronic devices, in some embodiments, while keeping the duration of the scanning window of electronic device 2 unchanged, the scanning frequency of electronic device 2 can be increased, that is, the time interval between two adjacent scanning windows of electronic device 2 can be reduced. This can increase the number of times electronic device 2 scans the broadcasts from electronic device 1, increase the number of times electronic device 2 receives the broadcasts from electronic device 1, and thus increase the speed at which electronic device 1 discovers electronic device 2.
[0278] For example, in the prior art, such as Figure 6A As shown, the scanning frequency of electronic device 2 is a first frequency, and the time interval between two adjacent scanning windows of electronic device 2 is t2, meaning that electronic device 2 receives a broadcast every time t2. In this embodiment, the scanning frequency of electronic device 2 can be a second frequency, which is greater than the first frequency. (Refer to...) Figure 6B For example, starting from time T0, the time interval between two consecutive scanning windows of electronic device 2 is t3, meaning electronic device 2 receives a broadcast every t3 seconds. Here, t3 is less than t2. (Refer to...) Figure 6B At time T2, electronic device 2 can receive the broadcast from electronic device 1; time T2 is earlier than time T1. Compared to Figure 6A Electronic device 2 can receive broadcasts from electronic device 1 more quickly, which can improve the speed at which electronic device 1 detects electronic device 2.
[0279] In some embodiments, electronic device 2 can be configured with a full-time scanning window, meaning that electronic device 2 can continuously receive broadcasts. It should be understood that, for example, starting from time T0, Figure 6C In the example where electronic device 2 is constantly receiving broadcasts, because electronic device 2 is always receiving broadcasts, it can receive any broadcast sent by electronic device 1. (See reference...) Figure 6C At time T3, electronic device 2 receives a broadcast from electronic device 1. Time T3 is earlier than time T1, and time T3 is earlier than time T2. Compared to Figure 6A and Figure 6B Electronic device 2 can receive broadcasts from electronic device 1 more quickly, which can improve the speed at which electronic device 1 detects electronic device 2.
[0280] In a scenario where electronic device 2 has a continuous scanning window, on the one hand, after electronic device 2 establishes a connection with electronic device 1, electronic device 1 will also periodically send broadcasts because it will also establish connections with other electronic devices. Since electronic device 2 is constantly receiving broadcasts, it will continuously receive broadcasts from electronic device 1, and will also process and respond to these broadcasts, resulting in high broadcast processing load and high power consumption for electronic device 2, thus affecting its performance. On the other hand, in actual scenarios, electronic device 3 may also establish a connection with electronic device 1, or electronic device 3 may establish a connection with electronic device 4. Electronic device 3 will also send broadcasts. Because electronic device 2 is constantly receiving broadcasts, it will also receive broadcasts from electronic device 3, and will also process and respond to these broadcasts, resulting in high broadcast processing load and high power consumption for electronic device 2, further impacting its performance.
[0281] Therefore, in the scenario where electronic device 2 sets a scanning window for all times, this application embodiment provides a communication method in which electronic device 2 can filter received broadcasts and selectively process them. This not only improves the discovery speed between electronic devices, but also reduces the power consumption and broadcast processing volume of electronic device 2, thereby improving the performance of electronic device 2. For details, please refer to the description in the above embodiments.
[0282] This section first introduces the structure of the electronic device. Taking the first electronic device as an example, refer to... Figure 7 The first electronic device may include: a first logical network module, a first communication module, a first far-field module, and a first device authentication module. It should be understood that... Figure 1 The structures of the second and third electronic devices shown can be described with reference to the structure of the first electronic device.
[0283] A first communication module is used to enable communication between a first electronic device and other electronic devices. For example, the first communication module may include, but is not limited to, a WiFi chip, a Bluetooth chip, etc.
[0284] A first far-field module is used to enable communication between a first electronic device and the cloud. In some embodiments, the first far-field module can also communicate with the cloud via a communication module (such as a WiFi chip). In some embodiments, the far-field module can also communicate with the cloud via a cellular network chip, etc. In some embodiments, the first far-field module can communicate directly with the cloud, and this application embodiment does not limit this. In the following embodiments, the example of the first far-field module communicating directly with the cloud is used for illustration.
[0285] The first device authentication module is used for device authentication between the first electronic device and other electronic devices. It should be understood that after the first electronic device establishes a connection with other electronic devices, it can use the first device authentication module to perform device authentication with them, thereby improving the security of the connection between devices.
[0286] The first logical network module is a crucial module for the first electronic device to implement the communication method provided in the embodiments of this application. This first logical network module can be used to set a continuous scanning window for the first electronic device, enabling it to continuously scan and thus improving the speed of mutual discovery between electronic devices, thereby increasing the connection speed between devices. Furthermore, the first logical network module can selectively process received broadcasts, reducing the power consumption and broadcast processing load of the first electronic device and improving its performance. Specific implementation methods can be found in the descriptions of the following embodiments.
[0287] In some embodiments, the first electronic device may further include a first service module. The first service module is used to initiate services, which may include, but are not limited to: transferring data such as files and images, or services such as notification sharing, keyboard and mouse sharing, and multi-screen collaboration. For example, the first service module may be an application or a service within an application.
[0288] The communication method provided in this application will be described below with reference to specific embodiments. These embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0289] It should be understood that the following description uses the establishment of a connection between a first electronic device and a second electronic device as an example to illustrate the communication method provided in the embodiments of this application. The establishment of a connection between multiple electronic devices can be referred to the description in the following embodiments.
[0290] In some embodiments, when a user uses Bluetooth to transfer data (such as pictures, files, etc.), the user can turn on the Bluetooth switch of the first electronic device. After the first electronic device scans and discovers the second electronic device, it can display the identifier of the second electronic device on the interface. The user can click on the identifier of the second electronic device to trigger a connection between the first and second electronic devices. After the connection is established, in response to the user's action, the first electronic device can send data to the second electronic device.
[0291] In this example, refer to Figure 6A As described in the text, the first electronic device is slow to detect the second electronic device, and the connection between the first and second electronic devices is slow, which affects data transmission.
[0292] In some embodiments, refer to Figure 6B and Figure 6C The description suggests that reducing the scanning cycle of the first electronic device or setting the first electronic device to scan at all times can improve the speed at which the first electronic device can detect the second electronic device, thereby increasing the speed at which the first electronic device and the second electronic device can establish a connection.
[0293] In the embodiments of this application, reference is made to Figure 2 As described, the first and second electronic devices can generate a network ID and IRK upon power-on. When both devices are logged into a first account, they can access information about all devices under that account. In this example, before a user triggers a service, the first electronic device can pre-discover the second device under the same account and pre-establish a connection (e.g., a long or short connection) with it. This allows both devices to maintain an online connection or heartbeat. When a user needs to transmit data from the first device to the second device, the data can be transmitted based on the pre-maintained online status, reducing the impact of latency caused by scanning and connection delays on the service.
[0294] For example, in cases where the first electronic device and the second electronic device can maintain a connection online or a heartbeat online, refer to Figure 2 In the case of 'a', the interface of the first electronic device can display the identifier 21 of the second electronic device.
[0295] Reference Figure 7The first electronic device may include: a first logical network module, a first communication module, a first far-field module, and a first device authentication module. Similarly, the second electronic device may include: a second logical network module, a second communication module, a second far-field module, and a second device authentication module. The descriptions of the second logical network module, the second communication module, the second far-field module, and the second device authentication module can be referenced respectively to the descriptions of the first logical network module, the first communication module, the first far-field module, and the first device authentication module.
[0296] In one possible scenario: a first electronic device logs into a first account, a second electronic device logs into the first account, and both the first and second electronic devices can access the cloud. In this scenario, refer to... Figure 8A The communication method provided in this application embodiment may include:
[0297] S801, the first logical network module logs in to the first account.
[0298] In some embodiments, a user can trigger the first logical network module to log in to a first account. In this embodiment, after logging in to the first account, the first logical network module can access the cloud and use the services provided by the cloud.
[0299] S802, the first logic network module sends a first message to the first far-field module. The first message is used to instruct the first logic network module to log in to the first account.
[0300] S803, the first far-field module reports the first device information of the first electronic device to the cloud.
[0301] In some embodiments, the first logical network module can generate a first network ID and a first IRK for the first electronic device. The method by which the first logical network module generates the first network ID and the first IRK can be referred to the description in the above embodiments. In this example, the first message may carry the first network ID and the first IRK.
[0302] In some embodiments, other modules in the first electronic device may generate a first network ID and a first IRK, and the first far-field module may obtain the first network ID and the first IRK from these other modules.
[0303] The first device information may include: the identifier of the first electronic device, the device type, the first MAC address, the first network ID, and the first IRK.
[0304] S804, the cloud sends the second device information of the second electronic device to the first far-field module.
[0305] In response to the first electronic device logging into the first account, the cloud can send device information of the electronic devices under the first account to the first electronic device. In this embodiment, the electronic devices under the first account include a second electronic device as an example. The cloud can send second device information of the second electronic device to the first far-field module. In some embodiments, the second device information may include: the identifier of the second electronic device, device type, second MAC address, second network ID, and second IRK.
[0306] It is conceivable that when the electronic devices under the first account also include a third electronic device and a fourth electronic device, the cloud can also send the third device information of the third electronic device and the fourth device information of the fourth electronic device to the first far-field module.
[0307] S805, the first far-field module sends the second device information to the first logic network module.
[0308] S806, with the communication function enabled, the first logical network module sets a scanning window for all times.
[0309] The communication function may include, but is not limited to, WiFi communication or Bluetooth communication. In some embodiments, the first logic network module can detect whether the communication function is enabled by detecting the state of the communication switch of the first electronic device. For example, taking Bluetooth communication as an example, if the Bluetooth communication switch of the first electronic device is in the enabled state, the first logic network module determines that the Bluetooth communication function is enabled. If the Bluetooth communication switch of the first electronic device is in the disabled state, the first logic network module determines that the Bluetooth communication function is disabled.
[0310] When the communication function is enabled, the first logical network module can set a full-time scanning window, enabling the first electronic device to scan broadcasts continuously. In some embodiments, the first logical network module setting a full-time scanning window can be understood as: the first logical network module instructs the first communication module to set a full-time scanning window so that the first communication module can continuously scan broadcasts.
[0311] In some embodiments, the first logical network module may call the init() function to instruct the first communication module to set a full-time scanning window.
[0312] S807, the first logic network module sets the second device information in the first communication module.
[0313] The first logical network module sets the second device information in the first communication module, which can be understood as: the first logical network module sends the second device information to the first communication module, and the first communication module stores the second device information.
[0314] In some embodiments, the first logical network module may call the updatePeerBtInformation() function to set the second device information in the first communication module. For example, the first logical network module may set the second network ID and the second IRK in the first communication module.
[0315] S808, the first logic network module sets the on / off state of the first electronic device and the first network ID in the first communication module.
[0316] In some embodiments, the device state of the first electronic device may include: a screen-on / off state of the first electronic device. For example, the screen-on / off state may include a screen-on state and a screen-off state. In some embodiments, when the embodiments of this application are applied to a super terminal scenario, the device state of the first electronic device may further include: a super terminal's on / off state. For example, the super terminal's on / off state may include an on state and a off state. In this example, the first logical network module may also set the super terminal's on / off state in the first communication module.
[0317] The first logical network module sets the device state of the first electronic device in the first communication module. This can be understood as: the first logical network module sends the device state of the first electronic device to the first communication module, and the first communication module stores the device state of the first electronic device. In some embodiments, the device state of the first electronic device can be referred to as the first device state.
[0318] Referring to the descriptions of Broadcasts 1-5, the first electronic device can send different broadcasts depending on its state. For example, when the first electronic device is on, it can send Broadcast 1, Broadcast 2, Broadcast 3, and Broadcast 5. When the first electronic device is off, it can send Broadcast 4. The first electronic device sends broadcasts through the first communication module, and the purpose of the first logic network module setting the on / off state of the first electronic device in the first communication module is to allow the first communication module to detect whether the broadcast corresponds to the on / off state of the first electronic device. When the broadcast corresponds to the on / off state of the first electronic device, the first communication module can send the broadcast; when the broadcast corresponds to the state of the first electronic device, the first communication module can choose not to send the broadcast, thus avoiding broadcast transmission errors.
[0319] In some embodiments, the first logical network module may call the setScreenStatus() function to set the on / off state of the first electronic device in the first communication module.
[0320] In some embodiments, the first logical network module can call the `setMagicCode()` function to set the first network ID of the first electronic device in the first communication module. The purpose of setting the first network ID in the first communication module is that the first communication module can detect whether a broadcast corresponds to the first network ID. When the network ID carried in the broadcast is the first network ID, the first communication module can send the broadcast; when the network ID carried in the broadcast is not the first network ID, the first communication module can choose not to send the broadcast, thus avoiding broadcast transmission errors.
[0321] In this embodiment, the order of S806, S807, and S808 is not restricted.
[0322] S809, the first logic network module instructs the first communication module to start scanning.
[0323] In this embodiment, to improve the detection speed of electronic devices, the first logical network module can set the scanning window of the first electronic device to a full-time scanning window, meaning that after the first electronic device starts scanning, it will continuously scan broadcasts. In this way, the first electronic device does not need to match the sending window of the second electronic device; as long as the second electronic device sends a broadcast, the first electronic device can receive it, thus improving the speed at which the second electronic device detects the first electronic device.
[0324] Similarly, for the second electronic device, after logging into the first account, the second electronic device will also execute the corresponding operations in S802-S809. In this embodiment, the second logical network module in the second electronic device can be set to a full-time scanning window. After the second electronic device starts scanning, it will continuously scan for broadcasts. When the first electronic device sends a broadcast, the second electronic device can receive the broadcast, which can improve the speed at which the first electronic device discovers the second electronic device.
[0325] In some embodiments, the first logical network module may call the scan function (startScan() function) to instruct the first communication module to start scanning.
[0326] In some embodiments, the first logical network module may send a second message to the first communication module, the second message being used to instruct the first communication module to start scanning.
[0327] S810, the first communication module starts full-time scanning.
[0328] In some embodiments, after the first communication module successfully starts scanning, it can call a first scan callback function to notify the first logical network module that the scan has started successfully. For example, the first scan callback function can be the `onStartScanSuccess` function. Alternatively, if the first communication module fails to start scanning, it can call a second scan callback function to notify the first logical network module that the scan startup failed. For example, the second scan callback function can be the `onStartScanFailed` function.
[0329] In some embodiments, if the first communication module successfully initiates a scan, it can send a first response message to the logical network module, indicating that the first communication module has successfully initiated the scan. If the first communication module fails to initiate a scan, it can send a second response message to the logical network module, indicating that the scan initiation by the first communication module has failed.
[0330] It should be understood that Figure 8A The following example illustrates how the first communication module can successfully initiate a scan. It is understandable that if the first communication module fails to initiate a scan, S809 can be re-executed to ensure successful initiation of the scan.
[0331] S811, the first communication module notifies the first logical network module that the first communication module has successfully started scanning.
[0332] S812, the first logical network module detects whether there are offline electronic devices under the first account. If so, execute S813.
[0333] Electronic devices under the first account can be understood as electronic devices logged into the first account. For example, if both the first electronic device and the second electronic device are logged into the first account, then electronic devices under the first account can include both the first electronic device and the second electronic device. For the first electronic device, offline electronic devices under the first account can be understood as electronic devices logged into the first account that have not established a connection with the first electronic device.
[0334] In some embodiments, the first logical network module can detect whether there are offline electronic devices under the first account based on device information from the cloud. For example, the first electronic device may store connection information, which may include device information of electronic devices that have established a connection with the first electronic device. The first logical network module can detect whether there are offline electronic devices under the first account based on the connection information and the device information from the cloud.
[0335] S813, the first logic network module instructs the first communication module to send broadcast 1.
[0336] In this embodiment of the application, taking the example that the first electronic device has not established a connection with the second electronic device, the second electronic device can be an offline electronic device under the first account. When the first electronic device has not established a connection with the second electronic device, the first logical network module can instruct the first communication module to send broadcast 1.
[0337] For example, the first logical network module can call the `startAdvertise` function to instruct the first communication module to send broadcast 1. In this example, after the first communication module successfully starts broadcast 1, it can call the first broadcast callback function to notify the first logical network module that it is ready to send broadcast 1. Here, the first communication module successfully starting broadcast 1 can be understood as: the first communication module is ready to send broadcast 1. For example, the first broadcast callback function can be the `onStartAdvertiseSuccess` function.
[0338] Alternatively, if the first communication module fails to initiate broadcast 1, it can call the second broadcast callback function to notify the first logical network module that broadcast 1 has failed to start. For example, the second broadcast callback function could be the `onStartAdvertiseFailed` function.
[0339] For example, the first logical network module can send a third message to the first communication module, which instructs the first communication module to send broadcast 1. In this embodiment, if the first communication module successfully initiates broadcast 1, it can send a third response message to the logical network module, which instructs the first communication module to successfully initiate broadcast 1. If the first communication module fails to initiate broadcast 1, it can send a fourth response message to the logical network module, which instructs the first communication module to fail to initiate broadcast 1.
[0340] It should be understood that Figure 8A The following example illustrates how the first communication module can successfully initiate broadcast 1. It is understandable that if the first communication module fails to initiate broadcast 1, S812 can be re-executed to ensure the first communication module successfully initiates broadcast 1.
[0341] S814, the first communication module notifies the first logic network module that broadcast 1 has been successfully started.
[0342] In some embodiments, S814 is an optional step.
[0343] S815, the first communication module sends broadcast 1.
[0344] In some embodiments, broadcast 1 may include: a first account, a first network ID, a device type, a first random MAC address, a first connection status of the first electronic device, and attribute fields of broadcast 1, etc. The attribute fields of broadcast 1 can be referred to the description in the above embodiments. It should be understood that the first random MAC address is a random MAC address of the first electronic device generated by the first communication module.
[0345] The first connection status indicates the number of BLE connections established by the first electronic device, the number of available BLE connections, the number of established BR connections, and the number of available BR connections. The number of available BLE connections in the first electronic device can include the number of BLE connections available when the first electronic device is acting as a master, and the number of BLE connections available when the first electronic device is acting as a slave. Similarly, the number of available BR connections in the first electronic device can include the number of BR connections available when the first electronic device is acting as a client, and the number of BR connections available when the first electronic device is acting as a server.
[0346] It should be noted that the first connection state is the connection state of the first electronic device when it sends the data.
[0347] In some embodiments, the first communication module may transmit periodically. For example, the transmission period may be a third period. For instance, the third period may be 40ms.
[0348] S816, the second communication module determines that it is not in the first filtering rule.
[0349] When the second communication module in the second electronic device receives a broadcast 1 from the first communication module, the second communication module can perform filtering processing according to the first filtering rule. The purpose of the filtering processing by the first communication module is to determine whether to report to the second logical network module for processing. Specifically, if the second communication module determines that it will not report to the second logical network module for processing, it can intercept the broadcast, thereby reducing the amount of broadcast processing by the second logical network module and reducing the power consumption of the second electronic device.
[0350] The second communication module can filter broadcast 1 according to the first filtering rule and the information carried in broadcast 1. In this embodiment, when the second electronic device is not connected to the first electronic device, the second electronic device can process all broadcasts (broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5) from the first network ID. When the second electronic device is online with the first electronic device via BLE or BR connection, the second electronic device does not process all broadcasts from the first network ID, that is, the second electronic device does not support processing all broadcasts (broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5) from the first network ID. When the second electronic device is online with the first electronic device via BLE heartbeat, the second electronic device can process broadcasts from the first network ID other than broadcast 1 (broadcast 2, broadcast 3, broadcast 4, and broadcast 5).
[0351] Based on this processing rule, in some embodiments, the first filtering rule may include the network ID to be filtered, and the broadcast corresponding to the network ID. Here, "to be filtered" can be understood as: the second communication module does not report to the second logical network module. In this embodiment, the first electronic device has not established a connection with the second electronic device, and the first filtering rule does not include the first network ID. The second communication module, based on the first filtering rule, determines that broadcast 1 from the first network ID is not in the first filtering rule, and determines to report broadcast 1 to the second logical network module.
[0352] In some embodiments, the second electronic device may include a first selection rule, which may include network IDs that the second electronic device supports processing, as well as broadcasts corresponding to each network ID.
[0353] In this embodiment, the network IDs that the second electronic device supports processing are the network IDs of other electronic devices under the first account. Because the cloud can push device information of electronic devices under the first account to the second electronic device, the second electronic device can store the network IDs of other electronic devices under the first account. When the first network ID is included in the first selection rule, the second communication module can determine that the second electronic device supports processing broadcasts from that first network ID. Based on the second electronic device's support for processing broadcasts from the first network ID, the second communication module can also determine whether the second electronic device supports processing broadcasts from that first network ID based on the broadcasts corresponding to each network ID.
[0354] In this embodiment of the application, the second electronic device has not yet established a connection with the first electronic device. The broadcast corresponding to the first network ID in the first selection rule includes broadcast 1, broadcast 2, broadcast 3, broadcast 4 and broadcast 5. Broadcast 1 is included in the broadcast corresponding to the first network ID. The second communication module can determine that the second electronic device supports processing broadcast 1 from the first network ID.
[0355] In this embodiment of the application, when the second communication module determines that the second electronic device supports processing broadcast 1 from the first network ID, the second communication module determines to report broadcast 1 to the second logical network module. It is understood that when the second communication module determines that the second electronic device supports processing broadcast 1 from the first network ID, the second communication module determines not to report broadcast 1 to the second logical network module and discards broadcast 1.
[0356] S817, the second communication module reports broadcast 1 to the second logic network module.
[0357] In some embodiments, the second communication module may call the onDeviceFound() function to report broadcast 1 to the second logical network module.
[0358] S818, the second logic network module determines the response broadcast 5.
[0359] In response to broadcast 1, the second logical network module can determine whether to reply to broadcast 1. In some embodiments, the second logical network module can determine whether to reply to broadcast 1 based on the attributes of broadcast 1. Wherein, if the attribute of broadcast 1 is "reply required", the second logical network module can determine to reply to broadcast 1.
[0360] S819, the second logic network module instructs the second communication module to send broadcast 5.
[0361] In some embodiments, the second logical network module can call the `startAdvertise` function to instruct the second communication module to send broadcast 5. In this example, after the second communication module successfully starts broadcast 5, it can call the first broadcast callback function to notify the second logical network module that it is ready to send broadcast 5. Here, the successful initiation of broadcast 5 by the second communication module can be understood as the second communication module being ready to send broadcast 5. For example, the first broadcast callback function can be the `onStartAdvertiseSuccess` function.
[0362] Alternatively, if the second communication module fails to initiate broadcast 5, it can call the second broadcast callback function to notify the second logical network module that broadcast 5 has failed to start. For example, the second broadcast callback function could be the `onStartAdvertiseFailed` function.
[0363] In some embodiments, the second logical network module may send a fourth message to the second communication module, the fourth message instructing the second communication module to send broadcast 5. In this embodiment, if the second communication module successfully initiates broadcast 5, it may send a fifth response message to the logical network module, the fifth response message instructing the second communication module to successfully initiate broadcast 5. If the second communication module fails to initiate broadcast 5, it may send a sixth response message to the logical network module, the sixth response message instructing the second communication module to fail to initiate broadcast 5.
[0364] It should be understood that Figure 8A The following example illustrates how the second communication module can successfully initiate broadcast 5. It is understandable that if the second communication module fails to initiate broadcast 5, S819 can be re-executed to ensure the second communication module successfully initiates broadcast 5.
[0365] S820, the second communication module notifies the second logic network module that broadcast 5 has been successfully started.
[0366] In some embodiments, S820 is an optional step.
[0367] S821, the second communication module sends a broadcast 5 to the first communication module.
[0368] In some embodiments, the second communication module may send broadcast 5 to the first communication module based on the first random MAC address carried in broadcast 1.
[0369] In some embodiments, broadcast 5 may include: a first account, a second network ID, a device type of the second electronic device, a second random MAC address, a second connection status of the second electronic device, and attribute fields of broadcast 5, etc. It should be understood that the second random MAC address is a random MAC address of the second electronic device generated by the second communication module. The second connection status can be described with reference to the description of the first connection status.
[0370] S822, the first communication module determines that broadcast 5 is not in the second filtering rule.
[0371] The filtering process for broadcast 5 by the first communication module in S822 can be referenced to the description of broadcast 1 by the second communication module in S816.
[0372] In some embodiments, the first communication module can filter broadcast 5 according to a second filtering rule. The second filtering rule may include: the network ID to be filtered, and the broadcast corresponding to the network ID. In this embodiment, the first electronic device has not established a connection with the second electronic device, and the second network ID is not included in the first filtering rule. Based on the first filtering rule, the second communication module determines that broadcast 5 from the second network ID is not in the first filtering rule, and therefore determines to report broadcast 5 to the second logical network module.
[0373] In some embodiments, the first electronic device may include a second selection rule, which may include network IDs that the first electronic device supports processing, and broadcasts corresponding to each network ID. For example, the second selection rule may include a second network ID, and broadcasts 1, 2, 3, 4, and 5 corresponding to the second network ID.
[0374] S823, the first communication module reports broadcast 5 to the first logic network module.
[0375] S824, the first logic network module determines the connection method and connection direction.
[0376] In some embodiments, the connection method can be Bluetooth. The Bluetooth connection can include a connection based on a fixed MAC address or a connection based on a random MAC address. Wherein, based on the first logical network module determining that a connection based on a fixed MAC address is supported, the connection method can be a BR connection or a BLE connection. Wherein, a connection based on a random MAC address is a BLE short connection.
[0377] Connection direction can indicate the direction in which a connection is initiated, such as a first electronic device initiating a connection to a second electronic device, or a second electronic device initiating a connection to a first electronic device. In some embodiments, connection direction can also be used to indicate the initiator of the connection.
[0378] In some embodiments, the first logical network module can determine whether the connection method is a connection based on a fixed MAC address or a connection based on a random MAC address based on the second IRK in the second device information. Specifically, if the connection method is a connection based on a fixed MAC address, the first logical network module can determine whether the specific connection method can be a BR connection or a BLE connection based on the available BLE and BR connections in the first and second electronic devices. If the connection method is a connection based on a random MAC address, the first logical network module can determine that the specific connection method is a BLE short connection.
[0379] In some embodiments, the first logical network module can determine the connection direction based on the number of BLE connections and BR connections available in the first and second electronic devices, as well as the first device identifier (UDID) of the first electronic device and the second UDID of the second electronic device.
[0380] The detailed method for determining the connection method and direction in the first logical network module can be found in [reference needed]. Figure 7 The description in the text.
[0381] It should be understood that Figure 8A The document illustrates two example connection processes. Example 1 (S825-S845) demonstrates the process of establishing a long connection between a first electronic device and a second electronic device, using the first electronic device initiating the connection as an example. Example 2 (S846-S868) demonstrates the process of establishing a short connection between a first electronic device and a second electronic device, using the first electronic device initiating the connection as an example.
[0382] Understandable Figure 8A The text uses the terms "Example 1" and "Example 2" to illustrate two different connection processes between the first and second electronic devices. Figure 8B(1) details the process of establishing a long connection between the first and second electronic devices in Example 1. Figure 8C The process of establishing a short connection between the first electronic device and the second electronic device in Example 2 is described in detail.
[0383] Example 1: Connection based on a fixed MAC address (BR connection or BLE connection). See Figure 8B(1) for example 1:
[0384] S825, the first logic network module instructs the first communication module to establish a first type of connection with the second communication module.
[0385] The first type of connection is a connection based on a fixed MAC address, such as a BR connection or a BLE connection. Specifically, whether to establish a BR connection or a BLE connection depends on the determination result of the first logical network module in S824.
[0386] In some embodiments, the first logical network module may send a fifth message to the first communication module, the fifth message being used to instruct the first communication module to establish a first type of connection with the second communication module.
[0387] S826, the first communication module establishes a first type of connection with the second communication module based on the second MAC address of the second electronic device.
[0388] The second MAC address is the fixed address of the second electronic device. The first communication module can establish a long connection with the second communication module based on the second MAC address.
[0389] S827, the first communication module notifies the first logic network module that the connection is successful.
[0390] In some embodiments, the first communication module may call a connection success callback function to notify the first logical network module that the first communication module and the second communication module have successfully connected.
[0391] In some embodiments, the first communication module may send a sixth message to the first logical network module, the sixth message being used to indicate that the first communication module and the second communication module have successfully connected.
[0392] S828, the first logical network module initiates device authentication to the first device authentication module.
[0393] In some embodiments, the first logical network module may initiate a device authentication request to the first device authentication module to instruct the first device authentication module to perform device authentication with the second device authentication module, thereby improving the security of the connection.
[0394] S829, the first device authentication module and the second device authentication module perform device authentication.
[0395] The equipment certification process may include the following steps:
[0396] (1) The first device authentication module and the second device authentication module exchange their respective UDIDs, and the first device authentication module and the second device authentication module complete the handshake based on the UDIDs of both parties.
[0397] (2) After the first device authentication module and the second device authentication module complete the handshake, they can initiate a security authentication from one end to the other according to specific rules. After the security authentication is completed, the first device authentication module and the second device authentication module can negotiate and generate a session key.
[0398] (3) The first device authentication module and the second device authentication module can perform encrypted transmission based on the key. The transmitted data may include, but is not limited to, device information of both parties, and attribute values indicating whether or not to maintain a long connection. For example, the first device authentication module can send third device information to the second device authentication module, and the second device authentication module can send fourth device information to the first device authentication module.
[0399] The third device information may include: the third connection status of the first electronic device. The third connection status may include: the number of BLE connections established by the first electronic device, the number of available BLE connections, the number of established BR connections, and the number of available BR connections. Specifically, the number of available BLE connections in the first electronic device may include: the number of available BLE connections when the first electronic device is acting as a master, and the number of available BLE connections when the first electronic device is acting as a slave. Similarly, the number of available BR connections in the first electronic device may include: the number of available BR connections when the first electronic device is acting as a client, and the number of available BR connections when the first electronic device is acting as a server.
[0400] The fourth device information may include: the fourth connection state of the second electronic device. The fourth connection state can be described with reference to the third connection state. It should be noted that the third connection state refers to the connection state of the first electronic device when it is authenticating with the second electronic device. The fourth connection state refers to the connection state of the second electronic device when it is authenticating with the first electronic device.
[0401] In some embodiments, the fourth device information may also include a second network ID, a second IRK, a second MAC address, etc.
[0402] (4) In some embodiments, after the first device authentication module and the second device authentication module complete device authentication, the first device authentication module can determine whether the first electronic device can maintain the current BLE connection or BR connection, and the second device authentication module can also determine whether the second electronic device can maintain the current BLE connection or BR connection. The first device authentication module and the second device authentication module can exchange information once, such as close ACK. The close ACK may carry an identifier, which is used to indicate whether the current long connection can be maintained.
[0403] For example, the first device authentication module can send a first close ACK to the second device authentication module. This first close ACK may carry a first identifier, which indicates whether the first electronic device can maintain its current BLE or BR connection. Similarly, the second device authentication module can send a second close ACK to the first device authentication module. This second close ACK may carry a second identifier, and the first identifier indicates whether the second electronic device can maintain its current BLE or BR connection.
[0404] If the first and second electronic devices can maintain the current BLE or BR connection, S830-S845 can continue to be executed. If the first or second electronic device cannot maintain the current BLE or BR connection, both parties can disconnect the current BLE or BR connection while keeping the BLE heartbeat online.
[0405] Understandably, the purpose of the first device authentication module determining whether the first electronic device can maintain the current BLE connection or BR connection, and the second device authentication module determining whether the second electronic device can maintain the current BLE connection or BR connection, is as follows: After the first electronic device determines the connection method as BLE connection or BR connection in S824, there are multiple electronic devices in the actual scenario. During the device authentication process of the two, the first electronic device or the second electronic device may establish a connection (BLE connection or BR connection) with other electronic devices, occupying the available BLE connection or BR connection, causing the first electronic device and the second electronic device to be unable to maintain the BLE connection or BR connection with each other. Therefore, it is determined that the connection between the two can be maintained in a more suitable way.
[0406] This section uses the example of the first device authentication module determining whether the first electronic device can maintain its current BLE or BR connection to illustrate the point:
[0407] 1) When a BLE connection is established between the first electronic device and the second electronic device: if there is at least one available BLE connection when the first electronic device is the master and the second electronic device is the slave, or if there is at least one available BLE connection when the first electronic device is the slave and the second electronic device is the master, the first device authentication module determines that the first electronic device can maintain the current BLE connection.
[0408] In 1), since the first electronic device and the second electronic device have already established a BLE connection, occupying 1 BLE connection resource, it is sufficient to retain at least 1 available BLE connection without affecting the execution of other services.
[0409] 2) When a BR connection is established between the first electronic device and the second electronic device: if there is at least one available BR connection when the first electronic device is the master device (client) and the second electronic device is the slave device (server), or if there is at least one available BR connection when the first electronic device is the server and the second electronic device is the client, the first device authentication module determines that the first electronic device can maintain the current BR connection.
[0410] Similarly to 1), if the first electronic device and the second electronic device have already established a BR connection, the first electronic device and the second electronic device occupy 1 BR connection resource. Therefore, it is sufficient to retain at least 1 available BLE connection without affecting the execution of other services.
[0411] 3) The number of connections established by the first electronic device is less than or equal to a preset number, that is, the sum of the BLE connections and BR connections established by the first electronic device is less than or equal to a preset number. For example, the preset number is 5.
[0412] The second device authentication module determines whether the second electronic device can maintain the current BLE connection or BR connection, which can be referred to in the relevant description of the first electronic device.
[0413] In Example 1, the first electronic device can maintain its current BLE connection or BR connection, and the second electronic device can maintain its current BLE connection or BR connection, as shown below:
[0414] S830, the first communication module reports to the first logic network module that the second electronic device is online.
[0415] In some embodiments, when the first communication module reports to the first logical network module that the second electronic device is online, the interface of the first electronic device may display the identifier of the second electronic device, such as... Figure 8A As shown in the image.
[0416] When a long-term connection (such as a BLE connection or a BR connection) is established between the first electronic device and the second electronic device, the first electronic device and the second electronic device can maintain the connection online.
[0417] In some embodiments, the first logical network module may mark the second electronic device as connected online.
[0418] S831, the first logical network module updates the first stored information.
[0419] The first stored information includes device information of the electronic device that has established a connection with the first electronic device. In this embodiment, for example, after the first device authentication module and the second device authentication module perform device authentication, the second electronic device, as a newly established electronic device connected to the first electronic device, can have its fourth device information added to the first stored information by the first logical network module.
[0420] In some embodiments, the first logical network module may store the second network ID and second IRK of the second electronic device in the first storage information. For example, the first storage information may represent a list of devices that have established connections with the first electronic device.
[0421] S832, the first logic network module instructs the first communication module to update the second filtering rule.
[0422] In some embodiments, the first logical network module may call the updateScan() function to instruct the first communication module to update the second filtering rule.
[0423] S833, the first communication module updates the second filtering rule.
[0424] The second filtering rule includes the network ID to be filtered and the broadcast corresponding to each network ID. Because the first communication module can perform continuous scanning, it can receive broadcasts from the second electronic device whenever the second electronic device sends one. For example, when the second and third electronic devices establish a connection, the second electronic device can send broadcast 1, and in response to broadcast 1 from the third electronic device, the second electronic device can send broadcast 5. To avoid the first communication module processing a large number of broadcasts from the second electronic device, when the first and second electronic devices establish a connection, the first communication module can discard the broadcast received from the second electronic device without processing it. In other words, when the first and second electronic devices establish a connection, the first communication module blocks broadcasts from the second electronic device.
[0425] The first communication module can add a second network ID to the second filtering rules. Thus, in response to a broadcast from the second electronic device, the first communication module can determine, based on the updated second filtering rules, not to report the broadcast from the second electronic device.
[0426] In some embodiments, the first communication module can also modify the second selection rule. The second selection rule includes the network IDs that the first electronic device supports processing, and the broadcasts corresponding to each network ID. For example, before modification, the network IDs that the first electronic device supports processing in the second selection rule may include a second network ID and a third network ID. The third network ID is the network ID of the third electronic device. After modification, the network IDs that the first electronic device supports processing in the second selection rule may exclude the second network ID but include the third network ID. Thus, in response to a broadcast from the second electronic device, the first communication module can determine, based on the modified second selection rule, not to report the broadcast from the second electronic device.
[0427] S834, the first communication module notifies the first logical network module that the update was successful.
[0428] In some embodiments, after the first communication module successfully updates the second filtering rule, it can call back the first update callback function to notify the first logical network module that the second filtering rule has been updated successfully. For example, the first update callback function can be the `onUpdateScanSuccess()` function. If the first communication module fails to update the second filtering rule, it can call back the second update callback function to notify the first logical network module that the second filtering rule update has failed. For example, the second update callback function can be the `onUpdateScanFailed()` function.
[0429] It should be understood that Figure 8A The following example illustrates how the second communication module can successfully update the second filtering rule. It is understandable that if the second communication module fails to update the second filtering rule, S830 can be re-executed to ensure that the first communication module successfully updates the second filtering rule.
[0430] S835, the second communication module reports to the second logic network module that the first electronic device is online.
[0431] In some embodiments, when the second communication module reports to the second logical network module that the first electronic device is online, the interface of the second electronic device may display the identifier of the first electronic device, which can be referred to... Figure 8A As shown in the image.
[0432] In some embodiments, the second logical network module may mark the first electronic device as connected online.
[0433] S836, the second logical network module updates the second stored information.
[0434] The second storage information includes device information of the electronic device that has established a connection with the second electronic device. In this embodiment, for example, after the first device authentication module and the second device authentication module perform device authentication, the first electronic device, as the newly established electronic device connected to the second electronic device, can have its third device information added to the second storage information by the second logical network module.
[0435] In some embodiments, the first logical network module may store the first network ID and first IRK of the first electronic device in second storage information. For example, the second storage information may represent a list of devices that have established connections with the second electronic device.
[0436] S837, the second logic network module instructs the second communication module to update the first filtering rule.
[0437] S838, the second communication module updates the first filtering rule.
[0438] The updated first filtering rule may include the first network ID.
[0439] S839, the second communication module notifies the second logic network module that the update was successful.
[0440] S837-S839 can be referenced from the description of the execution steps of the first communication module in S832-S834.
[0441] S840, the first logical network module marks the connection attribute and adds the second electronic device to the long connection list.
[0442] The first logical network module can mark the attributes of the connection established between the first electronic device and the second electronic device. The connection attribute can indicate the connection method, such as a BLE connection or a BR connection.
[0443] The first logical network module adds the second electronic device to the long-connection list. For example, the first logical network module can add the identifier of the second electronic device, the second network ID, the second IRK, or other information used to uniquely identify the second electronic device to the long-connection list. In some embodiments, the long-connection list can be understood as the connection information of the first electronic device.
[0444] In some embodiments, when a connection is established between the first electronic device and the second electronic device, the first electronic device and the second electronic device can collaboratively perform services based on this connection. For example, after S840, the following S841-S842 or S843-S845 can also be executed:
[0445] S841, the first business module triggers the first business.
[0446] Data volume: This can be viewed as the amount of data to be transmitted when the first and second electronic devices collaborate to perform the first service. The data volume of the first service is less than or equal to a first threshold. BLE or BR connections can support the transmission of the data volume of the first service.
[0447] For example, a user triggering a first electronic device to send pictures, files, etc., to a second electronic device can be considered the first service.
[0448] S842, the first communication module sends the data of the first service to the second communication module through a long connection.
[0449] With a long-lived connection (BLE or BR) established between the first and second electronic devices, the BLE or BR connection can support the transmission of the first service's data volume. The first communication module can send the first service's data to the second communication module through the long-lived connection. In this example, because the first and second electronic devices discover each other and establish connections quickly, the smooth execution of the service is guaranteed.
[0450] Based on S841 and S842, the process of the first electronic device and the second electronic device performing the first service is described below with reference to Figure 8B(2):
[0451] Taking a mobile phone as the first electronic device and a tablet computer as the second electronic device, referring to Figure 8B(2)a, when the first electronic device and the second electronic device are connected online, the interface 801 of the mobile phone can display the identifier 81 of the tablet computer. Referring to Figure 8B(2)a, the interface 801 can also include the identifier 82 of the mobile phone. In some embodiments, the interface 801 can also include the identifier 82A of the first account. In Figure 8B(2)a, the identifier 82A of the first account is represented by the avatar of the first account (the text "avatar of the first account").
[0452] When a user operates the phone's identifier 82, it can trigger the phone to display a service menu 83. The service menu 83 can include identifiers of services supported by the phone and tablet. Referring to Figure 8B(2)b, for example, the service menu 83 can include identifiers for various services such as screen sharing service 831, network sharing service 832, camera service 833, and scanning service 834. Referring to Figure 8B(2)b, taking the user's operation of the network sharing service identifier 832 as an example, the first service is network sharing service, meaning the phone can send network information of the first electronic device to the tablet. For example, the network information could be WiFi hotspot information.
[0453] For example, referring to bc in Figure 8B(2), the user can long press the identifier of network sharing service 832 and drag the identifier to identifier 81 on the tablet to trigger the first service. Because the amount of network information is small, the long connection (BLE connection or BR connection) currently established by the first electronic device and the second electronic device can support the first service. Therefore, in response to the first service, the first communication module sends network information to the second communication module through the long connection.
[0454] In order to indicate that the mobile phone and tablet computer are performing the first service, referring to d in Figure 8B(2), after the user triggers the first service, the mobile phone can display the logo of the network sharing service 832 around the logo 81 of the tablet computer, and display the text information such as "using the 'network sharing service'" 84 on the interface 801 to indicate that the mobile phone and tablet computer are performing the network sharing service.
[0455] Similarly, the tablet computer's interface 802 can display the text message 85 "Connected to mobile phone" and the identifier of network sharing service 832 to prompt the user that the tablet computer and mobile phone are performing network sharing services. In some embodiments, referring to c in FIG8B(2), the tablet computer's interface 802 can also display an identifier 86 "Disconnected". The user can trigger the tablet computer and mobile phone to disconnect by operating the identifier 86.
[0456] S843, the first business module triggers the second business.
[0457] The data volume of the second service exceeds the first threshold. BLE or BR connections cannot support the transmission of the second service's data volume. For example, if a user triggers screen mirroring from a first electronic device to a second electronic device, and the first electronic device sends mirrored data to the second electronic device, and the amount of mirrored data exceeds the first threshold, the screen mirroring service can be considered the second service.
[0458] S844, the first communication module establishes a third type of connection with the second communication module through a long connection.
[0459] The third type of connection is used to support the transmission of data for the second service. For example, the third type of connection can be a point-to-point (P2P) connection. This application embodiment does not describe in detail the process of establishing the third type of connection between the first communication module and the second communication module.
[0460] In this example, the first and second electronic devices discover and establish connections quickly. When the connection established between the first and second electronic devices cannot support the second service, they can quickly establish a third type of connection through the existing connection to smoothly execute the second service. This eliminates the need for the first and second electronic devices to discover each other before establishing the third type of connection.
[0461] S845, the first communication module sends the data of the second service to the second communication module through the third type of connection.
[0462] Based on S843 and S845, the process of the first electronic device and the second electronic device performing the second service is described below with reference to Figure 8B(3):
[0463] Taking a mobile phone as the first electronic device and a tablet computer as the second electronic device, referring to Figure 8B(3)a, when the first and second electronic devices are connected online, the interface 801 of the mobile phone can display the tablet computer's identifier 81. Referring to Figure 8B(3)a, the interface 801 can also include the mobile phone's identifier 82. When the user operates the mobile phone's identifier 82, the mobile phone can trigger the display of the service menu 83. Referring to Figure 8B(3)b, for example, the service menu 83 can include identifiers for various services such as screen sharing service 831, network sharing service 832, shooting service 833, and scanning service 834.
[0464] Referring to b in Figure 8B(3), taking the identifier of the user-operated screen sharing service 831 as an example, the second service is screen sharing, that is, the mobile phone can project its screen onto the tablet computer, and the mobile phone can send projection data to the tablet computer. For example, referring to bc in Figure 8B(3), the user can long press the identifier of the screen sharing service 831 and drag the identifier to the identifier 81 on the tablet computer to trigger the second service. Because the amount of projection data is small, the long connection (BLE connection or BR connection) currently established by the first electronic device and the second electronic device cannot support the second service. Therefore, in response to the second service, the first communication module establishes a third type of connection with the second communication module through the long connection.
[0465] To indicate that the mobile phone and tablet are establishing a third type of connection, referring to d in 5B(3), the mobile phone can display a connection indicator 87 above the tablet's indicator 81 to prompt the user that the mobile phone and tablet are establishing a third type of connection. When the mobile phone and tablet are establishing a third type of connection, referring to e in 5B(3), the mobile phone can display a connection success indicator 88 above the tablet's indicator 81.
[0466] When a third type of connection is established between a mobile phone and a tablet, the mobile phone can send screen mirroring data to the tablet based on this third type of connection.
[0467] In order to indicate that the mobile phone and tablet computer are performing the second service, referring to f in Figure 8B(3), the mobile phone can display the logo of the screen sharing service 831 around the logo 81 of the tablet computer, and display the text information 84A such as "using the screen sharing service" on the interface 801 to indicate that the mobile phone and tablet computer are performing the screen sharing service.
[0468] Similarly, referring to f in Figure 8B(3), a small window 89 can be displayed on the tablet's interface 802, showing the screen mirroring interface of the mobile phone. In addition, the tablet's interface 802 can also display the text message 85 indicating "Mobile phone connected" and the logo of the screen sharing service 831 to prompt the user that the tablet and mobile phone are performing network sharing services.
[0469] In some embodiments, referring to f in FIG8B(3), a “disconnect” indicator 86 may also be displayed on the interface 802 of the tablet computer. The user can trigger the tablet computer and the mobile phone to disconnect by operating the indicator 86.
[0470] In this embodiment of the application, when the first electronic device and the second electronic device establish a BLE connection or a BR connection, according to the service initiated by the first electronic device, the first electronic device can transmit service data based on the established BLE connection or BR connection, or quickly establish a third type of connection based on the established BLE connection or BR connection to transmit service data, which can ensure the smooth execution of the service.
[0471] Example 2: BLE short connection. See Example 2 for reference. Figure 8C :
[0472] S846, the first logic network module instructs the first communication module to establish a second type of connection with the second communication module.
[0473] In some embodiments, the first logical network module may send a seventh message to the first communication module, the seventh message being used to instruct the first communication module to establish a second type of connection with the second communication module. The second type of connection may be a connection based on a random MAC address or a short connection.
[0474] S847, the first communication module establishes a second type of connection with the second communication module based on the second random MAC address of the second electronic device.
[0475] Broadcast 5 includes the second random MAC address of the second electronic device, and the first communication module can establish a second type of connection with the second communication module based on the second random MAC address of the second electronic device.
[0476] S848, the first communication module notifies the first logical network module that the connection is successful.
[0477] S849, the first logical network module initiates device authentication to the first device authentication module.
[0478] S850, the first device authentication module and the second device authentication module perform device authentication.
[0479] S848-S850 can be referenced from the descriptions in S826-S828.
[0480] Example 2 illustrates that the first electronic device cannot maintain a long-term connection, and / or the second electronic device cannot maintain a long-term connection.
[0481] S851, the first communication module reports to the first logic network module that the second electronic device is online.
[0482] S851 can be referred to in the description in S830.
[0483] S852, the second communication module reports to the second logic network module that the first electronic device is online.
[0484] S852 can be referred to in the description in S836.
[0485] S853, the first logic network module and the second logic network module disconnect the second type of connection.
[0486] S854, the first logic network module and the second logic network module keep the BLE heartbeat online.
[0487] In this embodiment, BLE heartbeat online status can be understood as follows: the first logical network module and the second logical network module disconnect the established second type of connection and notify each other of their online status or refresh the other party's online status through interactive broadcasting. For example, when the first electronic device's screen is on, the first electronic device can send broadcast 3 to refresh the online status of the second electronic device. For example, when the first electronic device's screen is off, the first electronic device can send broadcast 4 to refresh the online status of the second electronic device. For example, when the first electronic device's screen is on, the first electronic device can send broadcast 5 to notify the second electronic device of its own online status.
[0488] For example, the first logical network module can send heartbeat information to the second logical network module, which indicates that the first electronic device is online. When the second electronic device receives the heartbeat information from the first electronic device, it can refresh the online status of the first electronic device to online.
[0489] For example, the second logical network module can mark the first electronic device as having an online heartbeat, and the first logical network module can mark the second electronic device as having an online heartbeat.
[0490] S855, the first logical network module updates the first stored information.
[0491] S856, the first logic network module instructs the first communication module to update the second filtering rule.
[0492] S855-S856 can be referred to the descriptions in S831-S832.
[0493] S857, the first communication module updates the second filtering rule.
[0494] Unlike S833, since the first and second electronic devices do not establish a BR connection or a BLE connection, but instead maintain a BLE heartbeat online, the first and second electronic devices cannot exchange information through the connection. In order for the first and second electronic devices to receive each other's re-establishment notifications, offline notifications, or heartbeat detections, the first and second electronic devices can block each other's broadcast 1, but not the other's broadcast 2, broadcast 3, broadcast 4, and broadcast 5.
[0495] In some embodiments, the first communication module may add a second network ID and a broadcast 1 corresponding to the second network ID to the second filtering rule. In this way, in response to broadcast 1 from the second electronic device, the first communication module may, based on the updated second filtering rule, determine not to report broadcast 1 from the second electronic device, but to report broadcasts 2, 3, 4 and 5 from the second electronic device.
[0496] In some embodiments, the first communication module can modify the broadcast corresponding to the second network ID in the second selection rule. For example, before modification, the network IDs supported by the first electronic device in the second selection rule may include: a second network ID and a third network ID, where the second network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5, and the third network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5. After modification, the network IDs supported by the first electronic device in the second selection rule may include: a second network ID and a third network ID, where the second network ID corresponds to broadcast 2, broadcast 3, broadcast 4, and broadcast 5, and the third network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5. Thus, in response to broadcast 1 from the second electronic device, the first communication module can, based on the modified second selection rule, determine not to report broadcast 1 from the second electronic device, but to report broadcasts 2, broadcast 3, broadcast 4, and broadcast 5 from the second electronic device.
[0497] S858, the first communication module notifies the first logical network module that the update was successful.
[0498] S858 can be referred to in the description in S834.
[0499] S859, the second logical network module updates the second stored information.
[0500] S860, the second logic network module instructs the second communication module to update the first filtering rule.
[0501] S859-S860 can be referred to in the descriptions in S836-S837.
[0502] S861, the second communication module updates the first filtering rule.
[0503] In some embodiments, the first communication module may add a first network ID and the broadcast 1 corresponding to the first network ID to the second filtering rule. In this way, in response to the broadcast 1 from the first electronic device, the first communication module may determine, based on the updated second filtering rule, not to report the broadcast 1 from the first electronic device, but to report broadcasts 2, 3, 4 and 5 from the first electronic device.
[0504] In some embodiments, the first communication module can modify the broadcast corresponding to the first network ID in the second selection rule. For example, before modification, the network IDs that the second electronic device can process in the second selection rule may include: a first network ID and a third network ID, where the first network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5, and the third network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5. After modification, the network IDs that the second electronic device can process in the second selection rule may include: a first network ID and a third network ID, where the first network ID corresponds to broadcast 2, broadcast 3, broadcast 4, and broadcast 5, and the third network ID corresponds to broadcast 1, broadcast 2, broadcast 3, broadcast 4, and broadcast 5. Thus, in response to broadcast 1 from the first electronic device, the first communication module can, based on the modified second selection rule, determine not to report broadcast 1 from the first electronic device, but to report broadcast 2, broadcast 3, broadcast 4, and broadcast 5 from the first electronic device.
[0505] S862, the second communication module notifies the second logic network module that the update was successful.
[0506] S862 can be referred to the description in S839.
[0507] In some embodiments, when a connection is established between the first electronic device and the second electronic device, the first electronic device and the second electronic device can collaboratively perform services based on this connection. For example, after S862, the following S863-S865 or S866-S868 can also be executed:
[0508] S863, the first business module triggers the first business.
[0509] S864, the first communication module establishes a BR connection with the second electronic device via a heartbeat online connection.
[0510] Because online heartbeat is an online method and cannot transmit business data, when the first business module triggers the first business, the first communication module can establish a BR connection with the second electronic device through online heartbeat. For example, the first communication module can initiate a BR connection to the second electronic device via heartbeat packets. The BR connection can support the transmission of the data volume of the first business.
[0511] S864, the first communication module sends the data of the first service to the second communication module through the BR connection.
[0512] S865, the first business module triggers the second business.
[0513] S866, the first communication module establishes a third type of connection with the second communication module via an online heartbeat.
[0514] S866 can be referred to in the description in S864.
[0515] S867, the first communication module sends the data of the second service to the second communication module through the third type of connection.
[0516] The second and third types of connections can be referred to in Example 1.
[0517] In this embodiment of the application, when the first electronic device and the second electronic device establish a heartbeat connection, since the heartbeat connection does not support data transmission, when the first service module triggers the first service, the first communication module establishes a BR connection with the second electronic device through the heartbeat connection, and sends the data of the first service to the second communication module based on the BR connection. The process of the user triggering the first service can be referred to the description in ac of Figure 8B(2), and the process of the first electronic device and the second electronic device establishing a BR connection and transmitting the data of the first service through the BR connection can be referred to the description in df of Figure 8B(3).
[0518] Similarly, in the embodiments of this application, when the first electronic device and the second electronic device establish a heartbeat online connection, since the heartbeat online connection does not support data transmission, when the first service module triggers the second service, the first communication module establishes a third type of connection with the second electronic device through the heartbeat online connection, and sends the data of the second service to the second communication module based on the third type of connection, as described in Figure 8B(3).
[0519] In this embodiment of the application, when the first electronic device and the second electronic device establish a heartbeat online connection, the first electronic device can establish a BR connection based on the heartbeat online connection to transmit service data, or quickly establish a third type of connection based on the heartbeat online connection to transmit service data, which can ensure the smooth execution of the service.
[0520] After the first and second electronic devices maintain an online connection (BLE connection online, BR connection online, or BLE heartbeat online), i.e., after S840 or S862. See reference. Figure 8A You can also perform the following operations:
[0521] S869, the first logical network module detects whether there are any offline electronic devices under the first account. If yes, proceed to S870; otherwise, return to S813.
[0522] In some embodiments, the first electronic device may store first storage information and third storage information. The first storage information may include device information of an electronic device already connected to the first electronic device. The third storage information is device information of an electronic device under the first account in the cloud. The first logical network module can detect whether the first storage information is the same as the third storage information to detect whether there are offline electronic devices under the first account.
[0523] Wherein, if the first storage information is the same as the third storage information, it means that there is no offline electronic device under the first account. If the first storage information is different from the third storage information, it means that there is still an offline electronic device under the first account, and the first electronic device can initiate a connection with the offline electronic device, as described in S813-S868.
[0524] S870, the first logic network module instructs the first communication module to stop sending broadcast 1.
[0525] In some embodiments, the first logical network module may call the stopAdvertise() function to instruct the first communication module to stop sending broadcast 1.
[0526] In some embodiments, the first logical network module may send an eighth message to the first communication module, the eighth message being used to instruct the first communication module to stop sending broadcast 1.
[0527] S871, the first communication module notifies the first logic network module to stop sending broadcast 1.
[0528] In some embodiments, after the first communication module successfully stops sending broadcast 1, it can call a first broadcast stop callback function to notify the first logical network module to stop sending broadcast 1. For example, the first broadcast stop callback function can be the `onStopAdvertiseSuccess` function. If the first communication module fails to stop sending broadcast 1, it can call a second broadcast stop callback function to notify the first logical network module that it has not stopped sending broadcast 1. For example, the second broadcast stop callback function can be the `onStopAdvertiseFailed` function.
[0529] In this embodiment, the first logical network module can set the first communication module to scan continuously, and the second logical network module can set the second communication module to scan continuously. Thus, when the first communication module sends broadcast 1, because the second communication module is constantly scanning, it can directly receive broadcast 1 and send back broadcast 5 to the first communication module, triggering the establishment of a connection between the first and second electronic devices. In this embodiment, it is not necessary for the sending window of the first electronic device to correspond with the scanning window of the second electronic device to receive broadcast 1. The second electronic device receives broadcast 1 quickly, which improves the speed at which the first electronic device discovers the second electronic device, thereby increasing the speed at which the first and second electronic devices establish a connection.
[0530] In addition, since the first electronic device and the second electronic device can scan continuously, in order to reduce the broadcast processing load and power consumption of the first electronic device and the second electronic device, after the first electronic device and the second electronic device establish a connection, the first logical network module can update the second filtering rule, and the second logical network module can update the first filtering rule, so as to ensure that the first electronic device and the second electronic device can selectively process broadcasts.
[0531] It should be noted that the module names involved in the embodiments of this application can all be defined as other names, as long as they can achieve the function of each module, and no specific restrictions are placed on the module names.
[0532] It should be noted that the device information and data involved in the embodiments of this application (including but not limited to data used for analysis, data stored, data displayed, etc.) are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0533] The communication method of the embodiments of this application has been described above. The related apparatus for performing the above method provided in the embodiments of this application is described below. Those skilled in the art will understand that the methods and apparatus can be combined and referenced with each other, and the related apparatus provided in the embodiments of this application can perform the steps in the above communication method.
[0534] The communication method provided in this application can be applied to electronic devices with communication functions. For example, the electronic device can be the first electronic device, the second electronic device, and the third electronic device described above. The specific device configuration of the electronic device can be referred to the relevant descriptions above, and will not be repeated here.
[0535] This application provides an electronic device, which can be the first electronic device, the second electronic device, and the third electronic device described in the above embodiments. (Refer to...) Figure 9 The electronic device includes a processor 901 (e.g., a CPU) and a memory 902. The memory 902 may include high-speed random-access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device. The memory 902 may store various instructions for performing various processing functions and implementing the method steps of this application.
[0536] Optionally, the electronic device involved in this application may further include: a power supply 903, a communication bus 904, and a communication port 905. The communication port 905 is used to enable communication between the electronic device and other peripherals. In this embodiment, the memory 902 is used to store computer-executable program code, which includes instructions. When the processor 901 executes the instructions, the instructions cause the processor 901 of the electronic device to perform the actions described in the above method embodiment. The implementation principle and technical effects are similar and will not be repeated here.
[0537] Optionally, the electronic device involved in this application may further include: a display screen 906. The display screen 906 is used to display the interface of the electronic device.
[0538] This application provides a chip. The chip includes a processor, which is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to those in the related embodiments described above, and will not be repeated here.
[0539] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, it implements the methods described above. The methods described in the above embodiments can be implemented wholly or partially by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored as one or more instructions or code on or transmitted over the computer-readable medium. The computer-readable medium can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0540] In one possible implementation, a computer-readable medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage or other magnetic storage devices, or any other medium targeted to carry or to store the required program code in the form of instructions or data structures, and accessible by a computer. Furthermore, any connection is appropriately referred to as a computer-readable medium. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. As used herein, disks and optical discs include optical discs, laser discs, optical discs, Digital Versatile Discs (DVDs), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0541] This application provides a computer program product, which includes a computer program that, when run, causes the computer to perform the above-described method.
[0542] This application describes embodiments of methods, apparatus (systems), and computer program products according to embodiments of this application with reference to flowchart illustrations and / or block diagrams. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable device to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations. Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0543] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.
Claims
1. A communication method, characterized in that, Applied to a first electronic device, the method includes: While maintaining a heartbeat connection with the second electronic device, and while the first electronic device switches from screen on to screen off, a first broadcast is sent. The first broadcast is used to detect the online status of the second electronic device. The second electronic device, which is in a screen-off state, cannot process the first broadcast. If no second broadcast in response to the first broadcast is received from the second electronic device within a third preset time period, the second electronic device is marked as pre-offline; When the first electronic device switches to screen-on mode, it periodically sends a third broadcast. The third broadcast is used to detect the online status of the second electronic device. The second electronic device, whether in screen-off or screen-on mode, can handle the third broadcast. When the duration of the first moment and the second moment is less than or equal to the fifth preset duration, the second electronic device is marked as online. The first moment is the moment when the second electronic device is marked as pre-offline. The second moment is the moment when the second electronic device receives a second broadcast in response to the third broadcast. The second broadcast is used as a reply to the broadcast. If the time elapsed since the first moment exceeds the fifth preset time, and no response is received from the second electronic device in response to the third broadcast, the second electronic device is marked as offline.
2. The method according to claim 1, characterized in that, The method further includes: While maintaining a heartbeat connection with the second electronic device and with the screen on in the first electronic device, when a fourth broadcast is received from the second electronic device, the second electronic device is marked as pre-offline, the fourth broadcast being used to indicate that the second electronic device is offline; Periodically send third broadcasts; When the duration of the first moment and the second moment is less than or equal to the fifth preset duration, the second electronic device is marked as online. The first moment is the moment when the second electronic device is marked as pre-offline, and the second moment is the moment when the second electronic device receives the second broadcast in response to the third broadcast. If the time elapsed since the first moment exceeds the fifth preset time, and no response is received from the second electronic device in response to the third broadcast, the second electronic device is marked as offline.
3. The method according to claim 1 or 2, characterized in that, When the second electronic device is marked as offline, the method further includes: When a sixth broadcast is received from the second electronic device, a corresponding operation is performed according to the connection attribute of the sixth broadcast to enable the online / offline status of the second electronic device and the first electronic device to be symmetrical. The symmetry of the online / offline status of the second electronic device and the first electronic device is used to characterize that the online / offline status of the first electronic device marked by the second electronic device is the same as the online / offline status of the second electronic device marked by the first electronic device.
4. The method according to claim 3, characterized in that, The step of performing the corresponding operation based on the connection attribute of the sixth broadcast includes: When the connection attribute of the sixth broadcast is connectable, a connection request is sent to the second electronic device, wherein the connection request is used to trigger the second electronic device to mark the first electronic device as online.
5. The method according to claim 3, characterized in that, The step of performing the corresponding operation based on the connection attribute of the sixth broadcast includes: When the connection attribute of the sixth broadcast is not connectable, a second broadcast in response to the sixth broadcast is sent to the second electronic device. The second broadcast is used to trigger the second electronic device to mark the first electronic device as offline.
6. The method according to claim 4 or 5, characterized in that, The method further includes: A fifth broadcast is sent, the fifth broadcast being used to discover other electronic devices logged into the same account as the first electronic device; Receives a second broadcast from a second electronic device. Both the first and second electronic devices are logged into the first account, and the second electronic device is set to scan broadcasts around the clock. Establish a connection with the second electronic device; Stay online with the second electronic device; Broadcasts from the second electronic device are blocked online.
7. The method according to claim 1, characterized in that, The method further includes: While maintaining a connection with the second electronic device online and marking the second electronic device as offline, send handshake information to the second electronic device; Within a second preset time period, when a confirmation message is received from the second electronic device in response to the handshake information, the second electronic device is marked as online; Within the second preset time period, if the confirmation information is not received, the connection with the second electronic device is disconnected, wherein disconnecting the connection with the second electronic device is used to trigger the second electronic device to mark the first electronic device as offline.
8. The method according to claim 7, characterized in that, The method further includes: When a connection is established with the second electronic device, the second electronic device is marked as online; Send the handshake information to the second electronic device; If no confirmation message in response to the handshake is received from the second electronic device within a first preset time period, the second electronic device is marked as offline.
9. An electronic device, characterized in that, include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the electronic device to perform the method as described in any one of claims 1-8.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-8.
11. A chip system, characterized in that, It includes at least one processor and a communication interface, the communication interface and the at least one processor being interconnected via a line, the at least one processor being used to run a computer program or instructions to perform the method as described in any one of claims 1-8.
12. A computer program product, characterized in that, Includes a computer program that, when run, causes a computer to perform the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Bluetooth device state detection method and device, electronic device and medium
CN111866827A
State notification method and apparatus
WO2024109399A1
