Communication method, electronic device, and related apparatus
Patent Information
- Application Number
- CN202410946309.3
- 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
[0071]应当理解的是,本申请的第二方面至第七方面与本申请的第一方面的技术方案相对应,各方面及对应的可行实施方式所取得的有益效果相似,不再赘述。
Smart Images

Figure CN121397473B_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] A prerequisite for business collaboration is the interconnectivity of multiple electronic devices. Interoperability can be understood as the ability for multiple electronic devices to discover, connect to, and transmit data with each other. Currently, the slow discovery speed between electronic devices affects the connection speed between them, thus impacting business execution. Summary of the Invention
[0004] This application provides a communication method, an electronic device, and related apparatus that can improve the discovery speed between electronic devices, thereby increasing the connection speed between multiple electronic devices.
[0005] In a first aspect, 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 a first electronic device as an example. In this method, the first electronic device can send a first broadcast, which is used to discover electronic devices. The first broadcast is a first type of broadcast. For example, the first broadcast is broadcast 1. Upon receiving broadcast 1, the second electronic device can determine to send a second broadcast in response. For example, the second broadcast can be broadcast 5. Correspondingly, the first electronic device receives the second broadcast from the second electronic device. Both the first and second electronic devices are logged into a first account, and the second electronic device is set to scan broadcasts at all times.
[0006] In this application, the second electronic device can be configured to perform a full-time scanning broadcast. This means that whenever the first electronic device sends a first broadcast, the second electronic device can respond with a second broadcast, increasing the speed at which the first electronic device discovers the second electronic device. Similarly, in some embodiments, the first electronic device can also be configured to perform a full-time scanning broadcast. This allows the first electronic device to quickly receive broadcasts from other electronic devices when they need to establish a connection, further improving the speed of inter-device discovery.
[0007] A first electronic device can establish a connection with a second electronic device. When this connection is established, the first electronic device can remain online with the second electronic device, and this online connection can be either a first online mode or a second online mode. For example, when a long-term connection (such as a Bluetooth Low Energy (BLE) connection or a classic Bluetooth BR connection) is established between the first and second electronic devices, the connection remains online. When a short-term connection is established between the first and second electronic devices, the connection can be broken, but a heartbeat remains online.
[0008] Specifically, when the online mode is the first online mode, all broadcasts from the second electronic device are blocked. When the online mode is the second online mode, broadcasts of the first type from the second electronic device are blocked. For example, the first online mode is connection online, and the second online mode is heartbeat online.
[0009] In this application, 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 correspondingly, the second electronic device can also block all broadcasts from the first electronic device. The reason is that since the first and second electronic devices remain connected online, they can interact through this connection. Processing broadcasts from the other end increases the power consumption and broadcast processing load of the electronic devices, affecting their performance.
[0010] When the first and second electronic devices maintain a heartbeat connection, the first electronic device can block first-type broadcasts from the second electronic device, and similarly, the second electronic device can also block first-type broadcasts from the first electronic device. This is because the first and second electronic devices have already discovered each other and are maintaining a heartbeat connection, thus eliminating the need to process first-type broadcasts. However, for broadcasts 2, 3, 4, and 5, the online status of both devices can be refreshed to ensure consistency, facilitating the timely establishment of a stable long-term connection. Therefore, when the first and second electronic devices maintain a heartbeat connection, they do not need to block broadcasts 2, 3, 4, and 5 from each other.
[0011] In one possible implementation, the first broadcast has the properties of being unconnectable, requiring a reply, and being unwakeable, while the second broadcast has the properties of being connectable, not requiring a reply, and being unwakeable.
[0012] In one possible implementation, in response to broadcast 5, the first electronic device can determine the connection method and connection direction, the connection direction indicating the initiator of the connection, and the first electronic device can establish a connection with the second electronic device according to the connection method and connection direction. In one possible implementation, the connection method includes connections based on random Media Access Control (MAC) addresses and connections based on fixed MAC addresses.
[0013] In one possible scenario, when the first electronic device is logged into the first account, the first electronic device can report its first device information to the cloud. The cloud can then push device information of electronic devices under the first account to the first electronic device. This device information includes the second device information of the second electronic device. The second device information may include: a second network ID, a second identity resolution key (IRK), and a second connection status. The second connection status includes: the number of BLE connections established by the second electronic device, the number of available BLE connections, the number of established BR connections, and the number of available BR connections, etc.
[0014] In one possible scenario, if the first electronic device is logged into a first account but is not connected to the cloud, it cannot obtain information about the second electronic device from the cloud. In this scenario, the first electronic device can obtain information about the second device during device authentication.
[0015] In some embodiments, broadcast 5 may include a second connection state.
[0016] The following describes the method by which the first electronic device determines the connection method and direction:
[0017] Because connections based on fixed MAC addresses require a correct second IRK and a second MAC address (fixed MAC address), if the second device information does not contain the second electronic device's second identity resolution key IRK, the connection method is a connection based on a random MAC address; or,
[0018] If the second device information contains the second IRK of the second electronic device, and the second IRK is incorrect, the connection method is a connection based on a random MAC address; or,
[0019] If the second device information contains the second IRK of the second electronic device, and the second IRK is correct, the connection method is a connection based on a fixed MAC address.
[0020] In one possible implementation, when the connection method is based on a fixed MAC address:
[0021] 1) When the first electronic device acts as the master and the second electronic device acts as the slave, there must be at least two available BLE connections. Alternatively, when the first electronic device acts as the slave and the second electronic device acts as the master, there must be at least two available BLE connections, and the connection method must be a BLE connection. The purpose of this configuration is to reserve at least one available BLE connection for other services to ensure their smooth execution.
[0022] When the connection method is determined to be BLE connection, the number of available BLE connections when the first electronic device acts as the master is greater than the number of available BLE connections when the second electronic device acts as the master; or...
[0023] When the connection method is determined to be a BLE connection, and given that the number of available BLE connections when the first electronic device is the master and the number of available BLE connections when the second electronic device is the master are the same, the first electronic device is the connection initiator. The hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device. In other words, the connection initiator can be the electronic device with the larger hash value of its device identifier.
[0024] 2) When there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, or when there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: If there are at least two available BR connections when the first electronic device acts as the master (client) and the second electronic device acts as the slave (server), or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, the connection method is BR connection. The purpose of this setting is to reserve at least one available BR connection for other services to ensure their smooth execution.
[0025] When the connection method is determined to be BLE connection, the number of available BR connections when the first electronic device acts as a client is greater than the number of available BR connections when the second electronic device acts as a client; or...
[0026] When the connection method is determined to be BLE connection, and the number of available BR connections when the first electronic device is the client and the number of available BR connections when the second electronic device is the client are the same, the first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
[0027] 3) It is determined that there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and that there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master; and,
[0028] When it is determined that there are fewer than two available BR connections when the first electronic device acts as the client and the second electronic device acts as the server, and when there are fewer than two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, the connection method is short connection.
[0029] In section 3), the following methods may also be included:
[0030] 3-1) There is one available BLE connection when the first electronic device is the master and the second electronic device is the slave, and there is one available BLE connection when the first electronic device is the slave and the second electronic device is the master. The short connection can be a BLE connection.
[0031] 3-2) When the first electronic device is the master and the second electronic device is the slave, there are 0 available BLE connections. When the first electronic device is the slave and the second electronic device is the master, there are 1 available BR connection when the first electronic device is the client and the second electronic device is the server, or when the first electronic device is the server and the second electronic device is the client, there is 1 available BR connection. The short connection can be a BR connection.
[0032] The purpose of this setting is to prioritize BLE short connections over BR short connections in order to reduce the power consumption of electronic devices.
[0033] In the case of BLE short connection or BR short connection, the first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
[0034] In one possible implementation, when the connection method is based on a fixed MAC address:
[0035] 1) There is one available BLE connection when the first electronic device is the master and the second electronic device is the slave, or there is one available BLE connection when the first electronic device is the slave and the second electronic device is the master, and the connection method is a short BLE connection.
[0036] In this context, the first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
[0037] 2) When there are 0 available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are 0 available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master, the first logical network module determines that a short connection cannot be established. In this embodiment, the reason for not establishing a BR short connection in this case is that a BR short connection needs to be established based on a fixed MAC address. Although the first logical network module has determined the second random MAC address, it cannot resolve the second MAC address based on this second random MAC address, causing the BR short connection to fail. Therefore, the BR short connection is not established.
[0038] In one possible implementation, while 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. Specifically, while the first and second electronic devices remain connected online, the first electronic device can add the second network ID of the second electronic device to a second filtering rule. This second filtering rule is used to filter out broadcasts that do not require processing by the first electronic device.
[0039] Thus, when the first electronic device receives a broadcast from the second electronic device, the broadcast carries the second network ID. According to this second filtering rule, the first electronic device can filter out the broadcast, meaning it doesn't need to process it, thus reducing its power consumption.
[0040] In one possible implementation, while the first electronic device and the second electronic device remain connected online, the first electronic device can block broadcasts of the first type from the second electronic device. Specifically, while the first and second electronic devices remain connected online, the first electronic device can add the second network ID of the second electronic device and the corresponding first type of broadcast to a second filtering rule. This second filtering rule is used to filter out broadcasts that do not require processing by the first electronic device.
[0041] Thus, when the first electronic device receives a first type of broadcast from the second electronic device, the broadcast carries a second network ID. According to the second filtering rule, the first electronic device can filter out the broadcast, meaning it doesn't need to process it, thus reducing its power consumption.
[0042] In one possible implementation, when the connection method is a short connection, the first electronic device and the second electronic device establish a short connection. However, after device authentication is performed based on the short connection, the first electronic device and the second electronic device can disconnect the short connection with the second electronic device, and the first electronic device and the second electronic device keep their heartbeats online.
[0043] This application embodiment designs broadcast 3, broadcast 4, and broadcast 5, which can be used in situations where a heartbeat is online. Specifically, when the first electronic device and the second electronic device establish a BLE heartbeat online connection, the second electronic device can send broadcast 4 when switching from screen-on to screen-off mode to quickly refresh the online status of the first electronic device. The attributes of broadcast 4 can be configured as: connectable, requires a response, and cannot be woken up.
[0044] In the case where the first electronic device and the second electronic device establish a BLE heartbeat online connection, after the second electronic device switches to screen off, the second electronic device can periodically send broadcast 4 to refresh the online status of the first electronic device.
[0045] Specifically, when the first and second electronic devices establish a BLE heartbeat connection, the second electronic device can send a broadcast (Broadcast 3) to the first electronic device when the second electronic device switches from off-screen to on-screen to quickly refresh the first electronic device's online status. The attributes of Broadcast 3 can be configured as: connectable, requires a response, and wakeable.
[0046] Specifically, when the first and second electronic devices establish a BLE heartbeat connection, and the second electronic device is on, it can periodically send Broadcast 5 to the first electronic device to refresh its online status. The attributes of Broadcast 5 can be configured as: connectable, no reply required, and non-wakeable.
[0047] In this application, while the first electronic device and the second electronic device maintain a heartbeat connection, the first electronic device can receive a third broadcast from the second electronic device, the third broadcast including a fourth connection status of the second electronic device. The third broadcast can be broadcast 3, broadcast 4, or broadcast 5.
[0048] Based on the fourth connection state, the first electronic device establishes a BLE connection with the second electronic device when at least two available BLE connections exist (either the first electronic device is the master and the second electronic device is the slave), or when at least two available BLE connections exist (the first electronic device is the slave and the second electronic device is the master).
[0049] When there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: If there are at least two available BR connections when the first electronic device acts as the master client and the second electronic device acts as the slave server, or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, establish a BR connection with the second electronic device.
[0050] In one possible implementation, when the third broadcast is broadcast 3 and the first electronic device is on, the first electronic device determines whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
[0051] Specifically, when the first electronic device acts as the master and the second electronic device acts as the slave, at least two available BLE connections exist; or, when the first electronic device acts as the slave and the second electronic device acts as the master, at least two available BLE connections exist, a BLE connection is established with the second electronic device; or...
[0052] When there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: If there are at least two available BR connections when the first electronic device acts as the master client and the second electronic device acts as the slave server, or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, establish a BR connection with the second electronic device.
[0053] Specifically, when the third broadcast is broadcast 3, and the first electronic device is in a screen-off state, the first electronic device is woken up in response to the third broadcast. When the first electronic device is in a wake-up state, it is determined whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state. For details, please refer to the description of "when the first broadcast is broadcast 3 and the first electronic device is in a screen-on state".
[0054] In one possible implementation, when the third broadcast is broadcast 4 and the first electronic device is on, the first electronic device can determine whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
[0055] In one possible implementation, when the third broadcast is broadcast 5 and the first electronic device is on, the first electronic device can determine whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
[0056] In one possible implementation, while the first electronic device and the second electronic device maintain a heartbeat connection, if the second electronic device is powered off, its WiFi switch is turned off, or its network switch is turned off, the second electronic device can send a fourth broadcast to the first electronic device. This fourth broadcast is used to indicate that the second electronic device is offline, and its attributes are: unconnectable, no reply required, and unwakeable. This fourth broadcast is broadcast 2.
[0057] Specifically, when the first electronic device has its screen on, in response to broadcast 2, the first electronic device can disconnect the second electronic device. When the first electronic device has its screen off, in response to broadcast 2, the first electronic device may not need to perform any action.
[0058] Secondly, embodiments of this application provide a communication method. The executing entity of this method can be a second electronic device or a chip in the second electronic device, etc. The following description uses a second electronic device as an example. In this method, the second electronic device receives a first broadcast from a first electronic device. Both the first and second electronic devices are logged into a first account. The second electronic device is set to scan broadcasts at all times, and the first broadcast is a first type of broadcast.
[0059] In response to the first broadcast, the second electronic device sends a second broadcast to the first electronic device, and the second electronic device can establish a connection with the first electronic device. After establishing a connection with the first electronic device, the second electronic device remains online with the first electronic device, and the online mode includes a first online mode and a second online mode. When the online mode is the first online mode, the second electronic device blocks all broadcasts from the first electronic device; when the online mode is the second online mode, the second electronic device blocks broadcasts of the first type from the first electronic device.
[0060] In one possible implementation, the first broadcast has the attributes of being unconnectable and requiring a response. In response to the first broadcast, a second broadcast is sent to the first electronic device, including: sending the second broadcast to the first electronic device according to the attributes of the first broadcast.
[0061] In one possible implementation, the method further includes: when switching from a screen-off state to a screen-on state, sending a third broadcast to a first electronic device. The third broadcast is used to detect the online status of the first electronic device, and its attributes include connectable, requiring a response, and wakeable. For example, the third broadcast could be broadcast 3.
[0062] In one possible implementation, the method further includes: when switching from screen-on to screen-off, sending a third broadcast to the first electronic device. The third broadcast is used to detect the online status of the first electronic device, and the attributes of the third broadcast are connectable, require a response, and cannot be woken up. For example, the third broadcast can be broadcast 4.
[0063] In one possible implementation, the method further includes: when the screen is on, sending a third broadcast to the first electronic device, the third broadcast indicating that the second electronic device is online, and the attributes of the third broadcast being connectable, requiring no response, and not wakeable. For example, the third broadcast could be broadcast 5.
[0064] In one possible implementation, the method further includes: sending a fourth broadcast to the first electronic device when it is powered off, the WiFi switch is turned off, or the network switch is turned off. The fourth broadcast is used to instruct the second electronic device to go offline, and the attributes of the fourth broadcast are unconnectable, no reply required, and unwakeable. For example, the third broadcast can be broadcast 2.
[0065] 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.).
[0066] 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.
[0067] 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.
[0068] 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.
[0069] 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.
[0070] 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.).
[0071] 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
[0072] Figure 1A This is a schematic diagram of an interactive broadcast between electronic device 1 and electronic device 2.
[0073] Figure 1B A schematic diagram illustrating interactive broadcasting between electronic device 1 and electronic device 2 provided in an embodiment of this application;
[0074] Figure 1C Another schematic diagram illustrating the interactive broadcast between electronic device 1 and electronic device 2 provided in this application embodiment;
[0075] Figure 2 A schematic diagram of a system architecture applicable to the communication method provided in the embodiments of this application;
[0076] Figure 3A A schematic diagram illustrating the interaction between electronic devices via the cloud, as provided in an embodiment of this application.
[0077] Figure 3B A schematic diagram illustrating the interaction of device information between electronic devices during device authentication, provided as an embodiment of this application.
[0078] Figure 4 A schematic diagram of the structure of an electronic device is provided for an embodiment of this application;
[0079] Figure 5A(1) is a schematic diagram of an interface of the first electronic device provided in an embodiment of this application;
[0080] Figure 5A(2) is a flowchart illustrating one embodiment of the communication method provided in this application.
[0081] Figure 5B(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;
[0082] Figure 5B(2) is a schematic diagram of an interface of the first electronic device and the second electronic device performing the first service according to an embodiment of this application;
[0083] Figure 5B(3) is a schematic diagram of an interface for the first electronic device and the second electronic device to perform a second service according to an embodiment of this application.
[0084] Figure 5C A schematic diagram illustrating a process for establishing an online heartbeat connection between a first electronic device and a second electronic device provided in an embodiment of this application;
[0085] Figure 6 A flowchart illustrating another embodiment of the communication method provided in this application;
[0086] Figure 7 A flowchart illustrating another embodiment of the communication method provided in this application;
[0087] Figure 8 A flowchart illustrating another embodiment of the communication method provided in this application;
[0088] Figure 9This provides another structural schematic diagram of an electronic device for embodiments of this application. Detailed Implementation
[0089] 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:
[0090] 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, such as browsing web pages, watching videos, and playing games.
[0091] 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.
[0092] 3. Wake-up: In this embodiment, after the electronic device's screen is turned off, the electronic device 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.
[0093] 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.
[0094] 4. Long connection and short connection: Long connection and short connection are two connection modes. Their main difference lies in the connection lifecycle and applicable scenarios.
[0095] 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 data once, and the short connection is closed after the data transmission is complete.
[0096] 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.
[0097] 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.
[0098] 7. BLE Heartbeat Online: This 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.
[0099] In some embodiments, BLE Heartbeat Online can be simply referred to as Heartbeat Online.
[0100] 8. Electronic equipment:
[0101] 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 handheld devices, computing devices or other processing devices connected to a wireless modem, vehicle-mounted devices, wearable devices, terminal devices in 5G networks or terminal devices in future evolved public land mobile networks (PLMNs).
[0102] 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.
[0103] 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.
[0104] 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.
[0105] In this embodiment, the electronic device or cloud includes 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 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.
[0106] 9. Other terms:
[0107] 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.
[0108] 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.
[0109] 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.
[0110] 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:
[0111] 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.
[0112] 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.
[0113] 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 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.
[0114] After electronic device 1 discovers electronic device 2, electronic device 1 and electronic device 2 can establish a connection. In some embodiments, for example, electronic device 1 can initiate a connection request to electronic device 2. In response to the connection request, electronic device 1 and electronic device 2 can establish a connection. After the connection is established, electronic device 1 and electronic device 2 can exchange data through the connection to perform business operations.
[0115] In some embodiments, the connection established between electronic devices may include, but is not limited to, WiFi connection, Bluetooth connection, etc.
[0116] Taking the establishment of a Bluetooth connection between electronic devices as an example, the following will combine... Figure 1A This section details the process by which electronic device 1 discovers electronic device 2:
[0117] 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.
[0118] Reference Figure 1A Electronic 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 1AWithin 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.
[0119] 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.
[0120] To improve the speed of discovering electronic devices and thus the speed of establishing connections between them, in some embodiments, while keeping the duration of the scanning window of electronic device 2 constant, the scanning frequency of electronic device 2 can be increased. This means reducing the time interval between two adjacent scanning windows of electronic device 2, or in other words, reducing the scanning cycle of electronic device 2. This increases the number of times electronic device 2 scans broadcasts from electronic device 1, improving the speed at which electronic device 1 discovers electronic device 2.
[0121] For example, in the prior art, such as Figure 1A 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 1B 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. Where t3 is less than t2. (Refer to...) Figure 1B Within the scanning window at time T2, electronic device 2 can receive the broadcast from electronic device 1; time T2 is earlier than time T1. Compared to Figure 1A 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.
[0122] 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... Figure 1C Taking the example where electronic device 2 receives broadcasts continuously from time T0, in this example, because electronic device 2 is constantly receiving broadcasts, it can receive any broadcast sent by electronic device 1. (Refer to...) Figure 1C 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 1A and Figure 1BElectronic 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.
[0123] 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.
[0124] 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 following embodiments.
[0125] Figure 2 This is a schematic diagram of a system architecture applicable to the communication method provided in the embodiments of this application. (Refer to...) Figure 2 The system architecture can include multiple electronic devices, as well as the cloud.
[0126] It should be understood that Figure 2 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.
[0127] 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 2 The mobile phone can connect to a tablet or PC, allowing users to control the tablet or PC from their mobile phone.
[0128] 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.
[0129] For example, in a home setting, a home router can also connect to speakers, smart screens, smart appliances, and mobile phones.
[0130] This application does not exhaustively list the scenarios in which the communication method is applicable.
[0131] 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.
[0132] Figure 2 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.
[0133] 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:
[0134] 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.
[0135] 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.
[0136] 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.
[0137] 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.
[0138] The following is combined with Figure 3A The following example illustrates how the first electronic device reports its device information to the cloud:
[0139] In some embodiments, the first electronic device can generate a network ID and an identity resolving key (IRK) after powering on. In some embodiments, the device information of the first electronic device may include: the identifier of the first electronic device, the device type, the first media access control (MAC) address, the first network ID, and the first IRK.
[0140] The identifier of the first electronic device may include at least one of the following: the name of the first electronic device or its International Mobile Equipment Identity (IMEI). The device type of the first electronic device may be, for example, a mobile phone, a smart bracelet, a watch, a PC, or a tablet computer. In some embodiments, the device type of the first electronic device may further include its model number.
[0141] The MAC address of the first electronic device can be referred to as the fixed MAC address of the first electronic device.
[0142] The first network ID is used by other electronic devices to identify the first electronic device during the process of establishing a connection with other electronic devices.
[0143] In some embodiments, the first electronic device may employ a hash algorithm to generate a random number within a preset numerical range based on the MAC address of the first electronic device. This random number may be a first network ID. For example, the preset numerical range may be 0-31.
[0144] In some embodiments, after the first electronic device is powered on, it can determine whether to generate an online networking ID or an offline networking ID based on its ability to connect to the cloud. Specifically, if it determines it can connect to the cloud, the first electronic device can generate an online networking ID. If it determines it cannot connect to the cloud, the first electronic device can generate an offline networking ID.
[0145] For example, if the first electronic device does not have cellular network and Wi-Fi enabled, the first electronic device determines that it cannot access the cloud. If the first electronic device has cellular network or Wi-Fi enabled, the first electronic device determines that it can access the cloud.
[0146] In some embodiments, because the first network ID is a random number between 0 and 31, collisions may occur between network IDs generated by electronic devices as the number of electronic devices increases. A collision between network IDs generated by electronic devices can be understood as the electronic devices generating the same network ID. When electronic devices have the same network ID, other electronic devices will treat them as a single device, leading to communication failures. Therefore, to address the problem of network ID collisions, this application also provides a network ID backoff method, as shown below:
[0147] 1) In some embodiments, for example, 0-15 can be set as the numerical range of offline network ID and 16-31 as the numerical range of online network ID, which can avoid collisions between online network ID and offline network ID.
[0148] 2) Online network ID backoff method:
[0149] Reference Figure 3A After the first electronic device logs into the first account, it can report its device information to the cloud. The cloud can then push this device information to the second and third electronic devices. This device information includes the first network ID. The following example illustrates the backoff method for the online network ID using the second electronic device:
[0150] The second electronic device receives a first network ID from the cloud. It can then determine if this first network ID is the same as its own network ID (second network ID). If the first and second network IDs are identical, the second electronic device can generate a different network ID (such as a new second network ID) and re-report it to the cloud. The cloud can then push this new second network ID to other electronic devices under the first account.
[0151] In some embodiments, the device information of the first electronic device may further include a timestamp, which is the time when the first electronic device generates the first network ID. For example, the cloud can push device information of a second electronic device to the first electronic device, the device information of the second electronic device including a second network ID and a second timestamp. The cloud can also push device information of the first electronic device to the second electronic device, the device information of the first electronic device including a first network ID and a first timestamp. The second timestamp is later than the first timestamp.
[0152] In this example, the second electronic device can determine that the first network ID and the second network ID are the same, and the first electronic device can also determine that the first network ID and the second network ID are the same. However, both the second and first electronic devices can determine from the first and second timestamps that the second timestamp is later than the first timestamp. In this example, refer to... Figure 3A The second electronic device can regenerate a different network ID (such as a new second network ID) and re-report it to the cloud. The cloud can then push the new second network ID of the second electronic device to other electronic devices under the first account.
[0153] It should be understood that Figure 3A The example of the second electronic device determining whether the first network ID and the second network ID are the same is used to illustrate this. In actual scenarios, the first electronic device can also determine whether the first network ID and the second network ID are the same. If the first network ID and the second network ID are the same, a new network ID can also be generated by the party that generated the network ID later (such as the second electronic device).
[0154] 3) Offline network ID backoff method:
[0155] Taking the first electronic device as an example, when the first electronic device cannot connect to the cloud, it can generate an offline network ID. Because the first electronic device cannot connect to the cloud, it cannot report its device information to the cloud. Similarly, other electronic devices under the first account (such as the second and third electronic devices) cannot receive device information from the first electronic device in the cloud. In this example, refer to... Figure 3B During the device authentication process, the first and second electronic devices can exchange their respective device information, allowing them to determine whether the network IDs are identical. The device authentication process can be referenced in Examples 1 and 2 below.
[0156] In some embodiments, when a network ID collision occurs, either device can regenerate a different network ID.
[0157] In some embodiments, when network IDs collide, the party with the later timestamp can regenerate a different network ID and notify the other party of the new network ID. For example, Figure 3B Taking the second electronic device as the one with the later timestamp as an example, when the first and second electronic devices establish a long connection, the second electronic device can send a new network ID to the first electronic device through this long connection. When the first and second electronic devices establish a short connection, the second electronic device can send a new network ID to the first electronic device via broadcast. The method by which the first and second electronic devices establish a long or short connection can be referred to the relevant description in the following embodiments.
[0158] In some embodiments, the first electronic device can update the second filtering rule based on the new second network ID of the second electronic device. The second filtering rule is used to filter out broadcasts that the first electronic device does not need to process. For example, when the first electronic device receives a broadcast from the second electronic device, the broadcast may carry a network ID, and the first electronic device can determine whether to process the broadcast based on the second filtering rule and the network ID carried in the broadcast.
[0159] The second filtering rule can be specifically described in the following embodiments.
[0160] In some embodiments, when a first electronic device sends a broadcast, it may include a first network ID in the broadcast so that other electronic devices can identify that the broadcast originated from the first electronic device based on the first network ID. For example, the first electronic device may represent the first network ID in the broadcast using a fixed-length array of bits (bytes). For instance, the fixed length could be 4 bytes.
[0161] In some embodiments, the first electronic device may update the first network ID.
[0162] For example, when a first electronic device detects that its first network ID is the same as that of another electronic device, the first electronic device can update its first network ID. In this example, the first electronic device can notify other electronic devices under the first account of the updated network ID by uploading the updated network ID to the cloud.
[0163] For example, when the first electronic device establishes a connection with the second electronic device (such as a BR connection or a BLE connection), and the first electronic device updates the network ID, the first electronic device can directly notify the second electronic device of the updated network ID based on the connection between the first electronic device and the second electronic device.
[0164] For example, when the first electronic device and the second electronic device maintain BLE heartbeat online, the first electronic device can broadcast the updated network ID to the second electronic device.
[0165] The first IRK is used by other electronic devices to resolve the first MAC address of the first electronic device. This resolution process will not be elaborated upon in this embodiment. Other functions of the first IRK can be found in the descriptions of the following embodiments.
[0166] Before introducing the communication method provided in the embodiments of this application, the structure of the electronic device will be described first. Taking the first electronic device as an example, refer to... Figure 4 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 2 The structures of the second and third electronic devices shown can be described with reference to the structure of the first electronic device.
[0167] 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.
[0168] 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.
[0169] 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.
[0170] 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.
[0171] 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.
[0172] Having described the structure of the first electronic device above, to facilitate understanding of the communication method provided in this application embodiment, the broadcast designed in this application embodiment is described below:
[0173] 1. Broadcast 1
[0174] Broadcast 1 is used by a first electronic device to discover other electronic devices in order to establish a connection with them.
[0175] 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.
[0176] 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.
[0177] 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.
[0178] 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.
[0179] 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.
[0180] 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.
[0181] 2. Broadcast 2
[0182] Broadcast 2, used for notification of the first electronic device being taken offline.
[0183] The conditions for sending Broadcast 2 can be set as follows: when the first electronic device is powered off, or the first electronic device has its WiFi function turned off, or the first electronic device has its networking function turned off, the first electronic device does not need to establish a connection with other electronic devices, and the first electronic device can send Broadcast 2.
[0184] 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 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 does not need to perform any action.
[0185] 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.
[0186] 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.
[0187] In this scenario, when a connection is established between the first and second electronic devices (BLE or BR connection), or when both 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 being offline.
[0188] 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.
[0189] In some embodiments, broadcast 2 may be configured with attribute fields that indicate the attributes of broadcast 2, as described in broadcast 1.
[0190] 3. Broadcast 3
[0191] Broadcast 3 is used to rebuild long-lived connections and to quickly refresh the online status of the second electronic device when the first electronic device's screen is on.
[0192] The sending conditions for broadcast 3 can be set as follows:
[0193] 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.
[0194] 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.
[0195] 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.
[0196] 2) If the first electronic device and the second electronic device establish a BLE heartbeat online connection, and if the first electronic device and the second electronic device meet the conditions for a long connection, the first electronic device may send a broadcast 3 to notify the first electronic device and the second electronic device to rebuild the BR connection or BLE connection.
[0197] The condition that the first and second electronic devices meet the long-term connection requirement can be understood as: the first and second electronic devices meet the conditions for establishing a BLE connection or a BR connection. Specific conditions can be found in [reference needed]. Figure 7 The description in the text.
[0198] 3) The first electronic device is on, and a second electronic device is pre-offline. The first electronic device can send broadcast 3 to refresh the online status of the second electronic device. Pre-offline means that when the first electronic device and the second electronic device have established a BLE heartbeat online relationship, and the first electronic device sends broadcast 3 or broadcast 4, the second electronic device does not reply with broadcast 5, and the first electronic device can determine that the second electronic device is pre-offline.
[0199] 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.
[0200] In some embodiments, broadcast 3 may be configured with an attribute field that indicates the attributes of broadcast 3, as described in broadcast 1.
[0201] 4. Broadcast 4
[0202] Broadcast 4 is used to quickly refresh the online status of the second electronic device when the first electronic device is off.
[0203] The sending conditions for Broadcast 4 can be set as follows:
[0204] 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.
[0205] 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.
[0206] 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.
[0207] 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.
[0208] 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.
[0209] In some embodiments, broadcast 4 may be configured with an attribute field that indicates the attributes of broadcast 4, as described in broadcast 1.
[0210] 5. Broadcast 5
[0211] Broadcast 5 is used to respond to broadcasts and to provide feedback to the second electronic device that the first electronic device is online.
[0212] The sending conditions for broadcast 5 can be set as follows:
[0213] 1) In response to broadcast 1, broadcast 3 or broadcast 4 from the first electronic device, the second electronic device may feed back broadcast 5 to the first electronic device.
[0214] 2) When the first electronic device and the second electronic device establish a BLE heartbeat online connection, when the first electronic device is on, it can periodically send broadcast 5 to allow 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, it 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 might be 30 seconds, and the first period might be 300 seconds.
[0215] 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.
[0216] In some embodiments, broadcast 5 may be configured with an attribute field that indicates the attributes of broadcast 5, as described in broadcast 1.
[0217] 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.
[0218] 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.
[0219] 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.
[0220] In this example, refer to Figure 1A 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.
[0221] In some embodiments, refer to Figure 1B and Figure 1C 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.
[0222] 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.
[0223] For example, when the first electronic device and the second electronic device can maintain an online connection or heartbeat, referring to Figure 5A(1), the interface of the first electronic device can display the identifier 51 of the second electronic device. In Figure 5A(1), the first electronic device is a mobile phone and the second electronic device is a tablet computer as an example. Similarly, the interface of the second electronic device can display the identifier of the first electronic device.
[0224] When a user sees the identifier of the second electronic device on the interface of the first electronic device, they can determine that the first and second electronic devices can maintain a connection or heartbeat online. In some embodiments, where the first and second electronic devices can establish a persistent connection (such as a BLE connection or a BR connection), in response to a user triggering an operation to send data from the first electronic device to the second electronic device, the first electronic device can send data to the second electronic device based on this persistent connection.
[0225] In some embodiments, when the first electronic device and the second electronic device can maintain an online BLE heartbeat, in response to a user triggering an operation whereby the first electronic device sends data to the second electronic device, the first electronic device and the second electronic device can establish a persistent connection, and the first electronic device can send data to the second electronic device based on this persistent connection. The specific manner in which the first electronic device and the second electronic device perform services while maintaining an online connection or having an online BLE heartbeat can be referred to the description in the following embodiments.
[0226] Reference Figure 4 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. 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.
[0227] Scene 1:
[0228] 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, referring to FIG5A(2), the communication method provided in this application embodiment may include:
[0229] S501, the first logical network module logs in to the first account.
[0230] 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.
[0231] S502, 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.
[0232] S503, the first far-field module reports the first device information of the first electronic device to the cloud.
[0233] 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.
[0234] 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.
[0235] 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.
[0236] S504, the cloud sends the second device information of the second electronic device to the first far-field module.
[0237] 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.
[0238] 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.
[0239] S505, the first far-field module sends the second device information to the first logical network module.
[0240] S506, with the communication function enabled, the first logical network module sets a scanning window for all times.
[0241] 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.
[0242] 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.
[0243] 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.
[0244] S507, the first logical network module sets the second device information in the first communication module.
[0245] 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.
[0246] 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.
[0247] S508, 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.
[0248] 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.
[0249] 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.
[0250] 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.
[0251] 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.
[0252] 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.
[0253] In this embodiment, the order of S506, S507, and S508 is not restricted.
[0254] S509, the first logic network module instructs the first communication module to start scanning.
[0255] 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.
[0256] Similarly, for the second electronic device, after logging into the first account, the second electronic device will also execute the corresponding operations in S502-S509. 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.
[0257] In some embodiments, the first logical network module may call the scan function (startScan() function) to instruct the first communication module to start scanning.
[0258] 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.
[0259] S510, the first communication module starts full-time scanning.
[0260] 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.
[0261] 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.
[0262] It should be understood that Figure 5A(2) is illustrated using the example of the first communication module successfully starting the scan. It is understood that if the first communication module fails to start the scan, S509 can be re-executed to enable the first communication module to successfully start the scan.
[0263] S511, the first communication module notifies the first logical network module that the first communication module has successfully started scanning.
[0264] S512, the first logical network module detects whether there are offline electronic devices under the first account. If so, execute S513.
[0265] 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.
[0266] 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.
[0267] S513, the first logic network module instructs the first communication module to send broadcast 1.
[0268] In this embodiment, taking the example of the first electronic device not establishing 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 does not establish a connection with the second electronic device, the first logical network module can instruct the first communication module to send Broadcast 1. Broadcast 1 has the attributes of being unconnectable, requiring a reply, and being wakeable.
[0269] 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.
[0270] 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.
[0271] 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.
[0272] It should be understood that Figure 5A(2) is illustrated using the example of the first communication module successfully starting broadcast 1. It can be understood that if the first communication module fails to start broadcast 1, S512 can be re-executed to enable the first communication module to successfully start broadcast 1.
[0273] S514, the first communication module notifies the first logic network module that broadcast 1 has been successfully started.
[0274] In some embodiments, S514 is an optional step.
[0275] S515, the first communication module sends broadcast 1.
[0276] 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.
[0277] 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.
[0278] It should be noted that the first connection state is the connection state of the first electronic device when the first electronic device sends broadcast 1.
[0279] In some embodiments, the first communication module may periodically send Broadcast 1. For example, the transmission period of Broadcast 1 may be a third period. For instance, the third period may be 40ms.
[0280] S516, the second communication module determines that broadcast 1 is not in the first filtering rule.
[0281] When the second communication module in the second electronic device receives broadcast 1 from the first communication module, the second communication module can filter broadcast 1 according to the first filtering rule. The purpose of the first communication module filtering broadcast 1 is to determine whether to report broadcast 1 to the second logical network module for processing. Specifically, if the second communication module determines that broadcast 1 should not be reported to the second logical network module for processing, it can intercept broadcast 1, thereby reducing the amount of broadcast processing by the second logical network module and reducing the power consumption of the second electronic device.
[0282] 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).
[0283] 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.
[0284] 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.
[0285] 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.
[0286] 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.
[0287] 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.
[0288] S517, the second communication module reports broadcast 1 to the second logic network module.
[0289] In some embodiments, the second communication module may call the onDeviceFound() function to report broadcast 1 to the second logical network module.
[0290] S518, the second logic network module determines the response broadcast 5.
[0291] 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.
[0292] S519, the second logic network module instructs the second communication module to send broadcast 5.
[0293] 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.
[0294] 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.
[0295] 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.
[0296] It should be understood that Figure 5A(2) is illustrated using the successful initiation of broadcast 5 by the second communication module as an example. It is understood that if the second communication module fails to initiate broadcast 5, S519 can be re-executed to enable the second communication module to successfully initiate broadcast 5.
[0297] S520, the second communication module notifies the second logic network module that broadcast 5 has been successfully started.
[0298] In some embodiments, S520 is an optional step.
[0299] S521, the second communication module sends a broadcast 5 to the first communication module.
[0300] 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.
[0301] 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.
[0302] S522, the first communication module determines that broadcast 5 is not in the second filtering rule.
[0303] The filtering process for broadcast 5 by the first communication module in S522 can be referenced to the description of broadcast 1 by the second communication module in S516.
[0304] 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.
[0305] 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.
[0306] S523, the first communication module reports broadcast 5 to the first logic network module.
[0307] S524, the first logic network module determines the connection method and connection direction.
[0308] 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.
[0309] 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.
[0310] 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.
[0311] 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.
[0312] 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.
[0313] It should be understood that Figure 5A(2) shows the connection process for two examples. Example 1 consists of S525-S545, which demonstrates the process of establishing a long connection between the first electronic device and the second electronic device by taking the first electronic device initiating the connection as an example. Example 2 consists of S546-S568, which demonstrates the process of establishing a short connection between the first electronic device and the second electronic device by taking the first electronic device initiating the connection as an example.
[0314] It is understandable that Figure 5A(2) uses the words "Example 1" and "Example 2" to illustrate two different connection processes between the first electronic device and the second electronic device. Figure 5B(1) details the process of establishing a long connection between the first electronic device and the second electronic device in Example 1. Figure 5C The process of establishing a short connection between the first electronic device and the second electronic device in Example 2 is described in detail.
[0315] Example 1: Connection based on a fixed MAC address (BR connection or BLE connection). See Figure 5B(1) for example 1:
[0316] S525, the first logic network module instructs the first communication module to establish a first type of connection with the second communication module.
[0317] 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 S524.
[0318] 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.
[0319] S526, 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.
[0320] 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.
[0321] S527, the first communication module notifies the first logic network module that the connection is successful.
[0322] 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.
[0323] 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.
[0324] S528, the first logical network module initiates device authentication to the first device authentication module.
[0325] 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.
[0326] S529, the first device authentication module and the second device authentication module perform device authentication.
[0327] The equipment certification process may include the following steps:
[0328] (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.
[0329] (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.
[0330] (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 may send third device information to the second device authentication module, and the second device authentication module may send fourth device information to the first device authentication module.
[0331] 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.
[0332] 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.
[0333] In some embodiments, the fourth device information may also include a second network ID, a second IRK, a second MAC address, etc.
[0334] (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.
[0335] 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.
[0336] If the first and second electronic devices can maintain the current BLE or BR connection, S530-S545 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.
[0337] 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 that the connection method is BLE connection or BR connection in S524, 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.
[0338] 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:
[0339] 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.
[0340] 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.
[0341] 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.
[0342] 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.
[0343] 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.
[0344] 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.
[0345] 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:
[0346] S530, the first communication module reports to the first logic network module that the second electronic device is online.
[0347] 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, as shown in FIG5A(1).
[0348] 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.
[0349] In some embodiments, the first logical network module may mark the second electronic device as connected online.
[0350] S531, the first logical network module updates the first stored information.
[0351] 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.
[0352] 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.
[0353] S532, the first logic network module instructs the first communication module to update the second filtering rule.
[0354] 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.
[0355] S533, the first communication module updates the second filtering rule.
[0356] 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.
[0357] 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.
[0358] 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.
[0359] S534, the first communication module notifies the first logical network module that the update was successful.
[0360] 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.
[0361] It should be understood that Figure 5A(2) illustrates the case where the second communication module successfully updates the second filtering rule. It is understood that if the second communication module fails to update the second filtering rule, S530 can be re-executed to enable the first communication module to successfully update the second filtering rule.
[0362] S535, the second communication module reports to the second logic network module that the first electronic device is online.
[0363] In some embodiments, when the second communication module reports to the second logic 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, as shown in FIG5A(1).
[0364] In some embodiments, the second logical network module can mark the first electronic device as connected online.
[0365] S536, the second logical network module updates the second stored information.
[0366] 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.
[0367] 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.
[0368] S537, the second logic network module instructs the second communication module to update the first filtering rule.
[0369] S538, the second communication module updates the first filtering rule.
[0370] The updated first filtering rule may include the first network ID.
[0371] S539, the second communication module notifies the second logic network module that the update was successful.
[0372] S537-S539 can be referenced from the description of the execution steps of the first communication module in S532-S534.
[0373] S540, the first logical network module marks the connection attribute and adds the second electronic device to the long connection list.
[0374] 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.
[0375] 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.
[0376] 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 S540, the following S541-S542 or S543-S545 can also be executed:
[0377] S541, the first business module triggers the first business.
[0378] 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.
[0379] 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.
[0380] S542, the first communication module sends the data of the first service to the second communication module through a long connection.
[0381] 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.
[0382] Based on S541 and S542, the process of the first electronic device and the second electronic device performing the first service is described below with reference to Figure 5B(2):
[0383] Taking a mobile phone as the first electronic device and a tablet computer as the second electronic device, referring to Figure 5B(2)a, when the first electronic device and the second electronic device are connected online, the interface 501 of the mobile phone can display the identifier 51 of the tablet computer. Referring to Figure 5B(2)a, the interface 501 can also include the identifier 52 of the mobile phone. In some embodiments, the interface 501 can also include the identifier 52A of the first account. In Figure 5B(2)a, the identifier 52A of the first account is represented by the avatar of the first account (the text "avatar of the first account").
[0384] When a user operates the phone's identifier 52, it can trigger the phone to display a service menu 53. The service menu 53 can include identifiers of services supported by the phone and tablet. Referring to Figure 5B(2)b, for example, the service menu 53 can include identifiers for various services such as screen sharing service 531, network sharing service 532, camera service 533, and scanning service 534. Referring to Figure 5B(2)b, taking the user's operation of the network sharing service identifier 532 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.
[0385] For example, referring to bc in Figure 5B(2), the user can long press the identifier of network sharing service 532 and drag the identifier to identifier 51 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.
[0386] In order to indicate that the mobile phone and tablet computer are performing the first service, referring to d in Figure 5B(2), after the user triggers the first service, the mobile phone can display the logo of the network sharing service 532 around the logo 51 of the tablet computer, and display the text information such as "using the 'network sharing service'" 54 on the interface 501 to indicate that the mobile phone and tablet computer are performing the network sharing service.
[0387] Similarly, the tablet computer's interface 502 can display the text message 55 "Connected to mobile phone" and the identifier of network sharing service 532 to prompt the user that the tablet computer and mobile phone are performing network sharing services. In some embodiments, referring to d in FIG5B(2), the tablet computer's interface 502 can also display an identifier 56 "Disconnected". The user can trigger the tablet computer and mobile phone to disconnect by operating the identifier 56.
[0388] S543, the first business module triggers the second business.
[0389] 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.
[0390] S544, the first communication module establishes a third type of connection with the second communication module through a long connection.
[0391] 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.
[0392] 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.
[0393] S545, the first communication module sends the data of the second service to the second communication module through the third type of connection.
[0394] Based on S543 and S545, the process of the first electronic device and the second electronic device performing the second service is described below with reference to Figure 5B(3):
[0395] Taking a mobile phone as the first electronic device and a tablet computer as the second electronic device, referring to Figure 5B(3)a, when the first and second electronic devices are connected online, the interface 501 of the mobile phone can display the tablet computer's identifier 51. Referring to Figure 5B(3)a, the interface 501 can also include the mobile phone's identifier 52. When the user operates the mobile phone's identifier 52, the mobile phone can trigger the display of the service menu 53. Referring to Figure 5B(3)b, for example, the service menu 53 can include identifiers for various services such as screen sharing service 531, network sharing service 532, shooting service 533, and scanning service 534.
[0396] Referring to b in Figure 5B(3), taking the identifier of the user-operated screen sharing service 531 as an example, the second service is screen sharing, that is, the mobile phone can project its screen to the tablet computer, and the mobile phone can send projection data to the tablet computer. For example, referring to bc in Figure 5B(3), the user can long press the identifier of the screen sharing service 531 and drag the identifier to the identifier 51 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.
[0397] To indicate that the phone and tablet are establishing a third type of connection, referring to d in 5B(3), the phone can display a connection indicator 57 above the tablet's indicator 51 to prompt the user that the phone and tablet are establishing a third type of connection. When the phone and tablet are establishing a third type of connection, referring to e in 5B(3), the phone can display a connection success indicator 58 above the tablet's indicator 51.
[0398] 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.
[0399] In order to indicate that the mobile phone and tablet computer are performing the second service, referring to f in Figure 5B(3), the mobile phone can display the logo of the screen sharing service 531 around the logo 51 of the tablet computer, and display the text information such as "using the screen sharing service" 54A on the interface 501 to indicate that the mobile phone and tablet computer are performing the screen sharing service.
[0400] Similarly, referring to f in Figure 5B(3), a small window 59 can be displayed on the tablet's interface 502, showing the screen mirroring interface of the mobile phone. In addition, the tablet's interface 502 can also display the text message "Mobile phone connected" 55 and the screen sharing service 531 logo to prompt the user that the tablet and mobile phone are performing network sharing services.
[0401] In some embodiments, referring to f in FIG5B(3), a “disconnect” indicator 56 may also be displayed on the interface 502 of the tablet computer. The user can trigger the tablet computer and the mobile phone to disconnect by operating the indicator 56.
[0402] 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.
[0403] Example 2: BLE short connection. See Example 2 for reference. Figure 5C :
[0404] S546, the first logic network module instructs the first communication module to establish a second type of connection with the second communication module.
[0405] 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.
[0406] S547, 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.
[0407] 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.
[0408] S548, the first communication module notifies the first logical network module that the connection is successful.
[0409] S549, the first logical network module initiates device authentication to the first device authentication module.
[0410] S550, the first device authentication module and the second device authentication module perform device authentication.
[0411] S548-S550 can be referred to in the descriptions in S526-S528.
[0412] 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.
[0413] S551, the first communication module reports to the first logic network module that the second electronic device is online.
[0414] S551 can be referred to in the description in S530.
[0415] S552, the second communication module reports to the second logic network module that the first electronic device is online.
[0416] S552 can be referred to the description in S536.
[0417] S553, the first logic network module and the second logic network module disconnect the second type of connection.
[0418] S554, the first logic network module and the second logic network module keep the BLE heartbeat online.
[0419] 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.
[0420] 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.
[0421] 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.
[0422] S555, the first logical network module updates the first stored information.
[0423] S556, the first logic network module instructs the first communication module to update the second filtering rule.
[0424] S555-S556 can be referred to in the descriptions in S531-S532.
[0425] S557, the first communication module updates the second filtering rule.
[0426] Unlike S533, 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.
[0427] 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.
[0428] 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.
[0429] S558, the first communication module notifies the first logical network module that the update was successful.
[0430] S558 can be referred to the description in S534.
[0431] S559, the second logical network module updates the second stored information.
[0432] S560, the second logic network module instructs the second communication module to update the first filtering rule.
[0433] S559-S560 can be referred to in the descriptions in S536-S537.
[0434] S561, the second communication module updates the first filtering rule.
[0435] 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.
[0436] 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 broadcasts 2, broadcast 3, broadcast 4, and broadcast 5 from the first electronic device.
[0437] S562, the second communication module notifies the second logic network module that the update was successful.
[0438] S562 can be referred to the description in S539.
[0439] 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 S562, the following S563-S565 or S566-S568 can also be executed:
[0440] S563, the first business module triggers the first business.
[0441] S564, the first communication module establishes a BR connection with the second electronic device via an online heartbeat.
[0442] 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.
[0443] S564, the first communication module sends the data of the first service to the second communication module through the BR connection.
[0444] S565, the first business module triggers the second business.
[0445] S566, the first communication module establishes a third type of connection with the second communication module via an online heartbeat.
[0446] S566 can be found in the description in S564.
[0447] S567, the first communication module sends the data of the second service to the second communication module through the third type of connection.
[0448] The second and third types of connections can be referred to in Example 1.
[0449] In this embodiment, 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 5B(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 5B(3).
[0450] 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 5B(3).
[0451] 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.
[0452] After the first electronic device and the second electronic device establish a connection (BLE connection, or BR connection, or BLE heartbeat online), that is, after S540 or S562, referring to Figure 5A(2), the following operations can also be performed:
[0453] S569, the first logical network module detects whether there are any offline electronic devices under the first account. If yes, proceed to S570; otherwise, return to S513.
[0454] 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.
[0455] 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 S513-S568.
[0456] S570, the first logic network module instructs the first communication module to stop sending broadcast 1.
[0457] In some embodiments, the first logical network module may call the stopAdvertise() function to instruct the first communication module to stop sending broadcast 1.
[0458] 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.
[0459] S571, the first communication module notifies the first logic network module to stop sending broadcast 1.
[0460] 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.
[0461] 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.
[0462] 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.
[0463] Scene 2:
[0464] In one possible scenario: the first electronic device logs into the first account, the second electronic device logs into the first account, and when the first electronic device is not connected to the cloud, in response to the user triggering the first electronic device to establish a connection with other electronic devices, the first electronic device can also execute S506, S508-S511, S513-S568 in scenario one.
[0465] Understandably, unlike Scenario 1, because the first electronic device is not connected to the cloud, it cannot obtain device information of other electronic devices under the first account from the cloud. Therefore, when the first electronic device receives broadcast 5, it can first report and process broadcast 5. After the first and second electronic devices establish a BLE or BR connection, the first electronic device can update the second filtering rule. The second filtering rule includes the second network ID. Alternatively, after the first and second electronic devices establish a BLE heartbeat online connection, the first electronic device can update the second filtering rule. The second filtering rule can include the second network ID, and the second network ID corresponds to broadcast 1.
[0466] In scenario two, when the first electronic device is not connected to the cloud, the first logical network module can set the first electronic device to scan at all times, and the second logical network module can set the second electronic device to scan at all times. This can improve the speed at which the first electronic device discovers the second electronic device, thereby improving the speed at which the first electronic device and the second electronic device establish a connection.
[0467] 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 electronic device can update the second filtering rule, and the second electronic device can update the first filtering rule, so as to ensure that the first electronic device and the second electronic device can selectively process broadcasts.
[0468] In Example 2 above, the first electronic device and the second electronic device can establish a BLE heartbeat online connection.
[0469] In one possible scenario, when the first and second electronic devices have established a BLE heartbeat connection, when the first electronic device switches from off-screen to on-screen, it can send a broadcast (broadcast 3) to the second electronic device to refresh the second device's online status. The attributes of broadcast 3 are: connectable, requires a response, and can be woken up.
[0470] In one possible scenario, when the first and second electronic devices establish a BLE heartbeat connection, the first electronic device can periodically send Broadcast 5 when its screen is on. Broadcast 5 is used by the second electronic device to refresh the online status of the first electronic device. The attributes of Broadcast 5 are: connectable, no reply required, and non-wakeable.
[0471] In one possible scenario, when the first electronic device and the second electronic device establish a BLE heartbeat online connection, the first electronic device can send a broadcast 4 to refresh the online status of the second electronic device when the first electronic device switches from screen on to screen off.
[0472] In one possible scenario, when the first electronic device and the second electronic device establish a BLE heartbeat online connection, the first electronic device can periodically send broadcast 4 to refresh the online status of the second electronic device when the first electronic device is in a screen-off state.
[0473] Among them, the attributes of broadcast 4 are connectable, require a reply, and cannot be woken up.
[0474] In summary, 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 and the second electronic device can exchange broadcasts 3 and 5. When the first electronic device and the second electronic device establish a BLE heartbeat online connection and the first electronic device is off, the first electronic device and the second electronic device can exchange broadcasts 4.
[0475] Taking broadcast 3 sent by the first electronic device as an example, broadcast 3 can carry the latest connection status of the first electronic device. In practical application scenarios, the first electronic device may release some BR connections or BLE connections, and the second electronic device may also release some BR connections or BLE connections. In response to broadcast 3, if the second electronic device determines that there are available BR connections or BLE connections between the first and second electronic devices, based on the properties of broadcast 3, the second electronic device can directly establish a connection with the first electronic device.
[0476] The process of re-establishing a long-term connection (such as a BR connection or a BLE connection) between the first electronic device and the second electronic device is described below.
[0477] Reference Figure 6 In some embodiments, the communication method of this application may further include S601-S606. S601-S606 may be executed after S562:
[0478] S601, the first logic network module instructs the first communication module to send a third broadcast.
[0479] In some embodiments, the third broadcast can be broadcast 3, broadcast 4, or broadcast 5. Specifically, when the first electronic device is on, the first logic network module instructs the first communication module to send broadcast 3 or broadcast 5. When the first electronic device is off, the first logic network module instructs the first communication module to send broadcast 4.
[0480] Broadcast 3 has the attributes of being connectable, requiring a response, and being wakeable. Broadcast 4 has the attributes of being connectable, requiring a response, and not being wakeable. Broadcast 5 has the attributes of being connectable, not requiring a response, and not being wakeable.
[0481] The third broadcast may include: first account, first network ID, device type, third random MAC address, fifth connection status, and attribute fields of the third broadcast, etc.
[0482] S602, the first communication module notifies the first logic network module that the third broadcast has been successfully started.
[0483] S603, the first communication module sends a third broadcast.
[0484] S604, the second communication module determines that the third broadcast is not in the first filtering rule.
[0485] S605, the second communication module reports the third broadcast to the second logic network module.
[0486] S601-S605 can be referenced from the relevant descriptions of Broadcast 1 in S513-S517.
[0487] In response to broadcast 3, the second logical network module can determine whether a usable BR connection or BLE connection exists between the first electronic device and the second electronic device based on the fifth connection state and the sixth connection state of the second electronic device. If a usable BR connection or BLE connection exists between the first electronic device and the second electronic device, the following S606 can be executed.
[0488] S606, the second logic network module determines the connection method and connection direction.
[0489] The method for determining the connection method and direction in the second logical network module can refer to S524 or Figure 7 The description in the text.
[0490] It is understandable that the steps in Example 1 or Example 2 above can be performed after S606.
[0491] In this embodiment of the application, when the first electronic device and the second electronic device establish a BLE heartbeat online connection, and when there is an available BR connection or BLE connection in the first electronic device and the second electronic device, the first electronic device and the second electronic device can trigger the first electronic device and the second electronic device to re-establish the BR connection or BLE connection through a third broadcast (such as broadcast 3, broadcast 4 or broadcast 5), so as to enable the connection to be more stable.
[0492] The following is combined with Figure 7 This section describes the process by which the first and second logical network modules determine the connection method and direction in scenarios one and two.
[0493] The following section introduces the method used by the first logical network module in S524 to determine the connection method and direction:
[0494] The following describes the method for determining the connection method in the first logical network module, which includes the following steps 1 and 2:
[0495] Step 1: The first logical network module determines, based on the second IRK, whether the first electronic device supports establishing a connection based on a fixed MAC address or a connection based on a random MAC address.
[0496] As described in the above embodiments, when the first electronic device can access the cloud, the first logical network module can obtain second device information of the second electronic device through the cloud, which may include the second IRK. When the first electronic device is not connected to the cloud, the first electronic device can obtain fourth device information of the second electronic device during the device authentication process, which may include the second IRK.
[0497] Additionally, based on the description in the above embodiments, broadcast 5 may include a second random MAC address. Broadcast 5 is used to respond to broadcast 1, and the attributes of broadcast 5 are connectable, no reply required, and unwakeable.
[0498] In some embodiments, when the second IRK is missing in the second device information (or the fourth device information), for example, when the network is poor and packets are lost, and the second device information (or the fourth device information) does not contain the second IRK, the first logical network module can determine that the first electronic device supports establishing a connection based on a random MAC address.
[0499] In some embodiments, when the second device information (or fourth device information) includes a second IRK, the first logical network module can resolve the third MAC address of the second electronic device based on the second IRK and the second random MAC address. This is because the second device information pushed from the cloud to the first logical network module includes the second MAC address, which is a fixed MAC address. The first logical network module can determine whether the second MAC address and the third MAC address are the same. Specifically, when the second MAC address and the third MAC address are the same, the first logical network module can determine that the second IRK is correct. When the second MAC address and the third MAC address are different, the first logical network module can determine that the second IRK is incorrect.
[0500] When the second IRK is correct, the first logical network module determines that the first electronic device supports establishing a connection based on a fixed MAC address. The fact that the first electronic device supports establishing a connection based on a fixed MAC address indicates that the first electronic device can support BLE persistent connections.
[0501] When the second IRK fails, the first logical network module determines that the first electronic device does not support connections based on fixed MAC addresses; that is, the first electronic device supports connections based on random MAC addresses. The fact that the first electronic device supports establishing connections based on random MAC addresses indicates that the first electronic device can support BLE short connections.
[0502] Step 2:
[0503] Scenario 1: If the first electronic device supports connections based on a fixed MAC address, the first logical network module can determine the connection method according to the following rules:
[0504] In some embodiments, at least one available connection (such as a BR connection or a BLE connection) can be reserved in each connection direction to prevent interference with the normal connection initiation of other services. For example, at least one available BLE connection and at least one available BR connection can be reserved on the first electronic device side, and at least one available BLE connection and at least one available BR connection can be reserved on the second electronic device side. The following explanation uses one available connection as an example:
[0505] 1) When the first electronic device acts as the master and the second electronic device acts as the slave, there are at least two available BLE connections, or when the first electronic device acts as the slave and the second electronic device acts as the master, there are at least two available BLE connections, the first logical network module can determine that the connection method is a BLE connection.
[0506] For example, when the first electronic device acts as the master, it has 5 available BLE connections; when it acts as the slave, it has 3 available BLE connections; when the second electronic device acts as the master, it has 5 available BLE connections; and when it acts as the slave, it has 5 available BLE connections. In this example, when the first electronic device acts as the master and the second electronic device acts as the slave, there are 5 available BLE connections; when the first electronic device acts as the slave and the second electronic device acts as the master, there are at least two available BLE connections, resulting in 3 available BLE connections. This conforms to rule 1) above, and the first logical network module can determine that the connection method is a BLE connection.
[0507] In some embodiments, when the connection method is determined to be a BLE connection, the first logical network module can designate the target electronic device as the initiator of the BLE connection. The target electronic device is the master among those with a larger number of available BLE connections when acting as the master. The target electronic device can be either the first electronic device or the second electronic device.
[0508] For example, in the above example, when the first electronic device acts as the master and the second electronic device acts as the slave, there are 5 available BLE connections; when the first electronic device acts as the slave and the second electronic device acts as the master, there are 3 available BLE connections. Specifically, when the first electronic device acts as the master, there are 5 available BLE connections, and when the second electronic device acts as the master, there are 3 available BLE connections. The number of available BLE connections when the first electronic device acts as the master is greater than the number of available BLE connections when the second electronic device acts as the master. Therefore, the first electronic device can be used as the initiator of the BLE connection, i.e., the connection direction is from the first electronic device to the second electronic device.
[0509] In some embodiments, when the number of available BLE connections when the first electronic device acts as the master is equal to the number of available BLE connections when the second electronic device acts as the master, the first logical network module can determine the connection direction based on the UDIDs of both devices. For example, the first logical network module can designate the device with the larger hash value of its UDID as the initiator of the connection.
[0510] 2) When there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: If there are at least two available BR connections when the first electronic device acts as the client and the second electronic device acts as the server, or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, the first logical network module can determine that the connection method is a BR connection.
[0511] After the first logical network module determines that the connection method is a BR connection, it can designate the target electronic device as the initiator of the BR connection. The target electronic device is the client with the most available BR connections when acting as a client. The target electronic device can be either the first electronic device or the second electronic device.
[0512] In some embodiments, when the number of available BR connections when the first electronic device acts as a client is equal to the number of available BR connections when the second electronic device acts as a client, the first logical network module can determine the connection direction based on the UDIDs of both devices. For example, the first logical network module can designate the device with the larger hash value of its UDID as the initiator of the connection.
[0513] 3) The first logical network module determines that there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and that there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master; and,
[0514] If it is determined that there are fewer than two available BR connections when the first electronic device acts as a client and the second electronic device acts as a server, and if there are fewer than two available BR connections when the first electronic device acts as a server and the second electronic device acts as a client, the first logical network module can determine that the connection mode is a short connection.
[0515] In some embodiments, there is one available BLE connection when the first electronic device acts as the master and the second electronic device acts as the slave, and there is one available BLE connection when the first electronic device acts as the slave and the second electronic device acts as the master. This short connection can be a BLE connection.
[0516] In this example, if the first logical network module determines that the short connection can be a BLE short connection, it can choose the one with the larger hash value of UDID as the initiator of the connection.
[0517] In some embodiments, when the first electronic device acts as the master and the second electronic device acts as the slave, there are 0 available BLE connections. In the case where there are 0 available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master, there is 1 available BR connection when the first electronic device acts as the client and the second electronic device acts as the server, or there is 1 available BR connection when the first electronic device acts as the server and the second electronic device acts as the client. This short connection can be a BR connection.
[0518] In this example, if the first logical network module determines that the short connection can be a BR short connection, it will select the one with the larger hash value of UDID as the initiator of the connection.
[0519] Scenario 2: If the first electronic device supports connections based on random MAC addresses, the first logical network module can determine the connection method according to the following rules:
[0520] 1) When the first electronic device acts as the master and the second electronic device acts as the slave, there is one available BLE connection; or, when the first electronic device acts as the slave and the second electronic device acts as the master, there is one available BLE connection. The first logical network module determines that the short connection is a BLE short connection.
[0521] If the first logical network module determines that the short connection can be a BLE short connection, the first logical network module can take the one with the larger hash value of UDID as the initiator of the connection.
[0522] 2) When there are 0 available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are 0 available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master, the first logical network module determines that a short connection cannot be established. In this embodiment, the reason for not establishing a BR short connection in this case is that a BR short connection needs to be established based on a fixed MAC address. Although the first logical network module has determined the second random MAC address, it cannot resolve the second MAC address based on this second random MAC address, causing the BR short connection to fail. Therefore, the BR short connection is not established.
[0523] In summary, the first logical network module can determine the connection method and connection direction. Specifically, in S524, when the connection direction is for the second electronic device to initiate a connection to the first electronic device, the first logical network module can send a connection request to the second logical network module, allowing the second electronic device to initiate the connection. When the connection direction is for the first electronic device to initiate a connection to the second electronic device, the first electronic device can directly initiate a connection to the second electronic device.
[0524] The process of determining the connection method and connection direction in the first logical network module of this application embodiment has been described above. The purpose of determining the connection method is to enable the first electronic device and the second electronic device to use a more stable and faster connection method, ensuring the smooth execution of services. The purpose of determining the connection direction is to avoid the problem of both parties initiating the connection. After negotiation, one party initiates the connection, which can improve the connection speed.
[0525] It is understandable that in S606, the second logical network module determines the connection method and connection direction, which can be referred to the description of the first logical network module determining the connection method and connection direction.
[0526] Understandable Figure 7 The document illustrates the process of the first logical network module determining the connection method and direction when the first electronic device and the second electronic device interact with each other via broadcast 1 and broadcast 5, respectively, and the process of the second logical network module determining the connection method and direction when the first electronic device and the second electronic device interact with each other via broadcast 3.
[0527] Based on the above embodiments, the communication method provided by the embodiments of this application will be described below from the perspective of a first electronic device, a second electronic device, and cloud interaction. It should be understood that the following... Figure 8 The following example illustrates the concept of both the first and second electronic devices being able to access the cloud.
[0528] Reference Figure 8 The communication method provided in this application embodiment may include:
[0529] S801, the first electronic device logs into the first account.
[0530] S802, the first electronic device reports its information to the cloud.
[0531] S803, the second electronic device logs into the first account.
[0532] S804, the second electronic device reports the second device information to the cloud.
[0533] S805, the cloud pushes information about the second device to the first electronic device.
[0534] S806, the cloud pushes information about the first device to the second electronic device.
[0535] It should be understood that the embodiments of this application do not limit the order between S801-S802 and S803-S804, nor do they limit the order between S805 and S806.
[0536] S807, the first electronic device and the second electronic device discover each other and establish a connection based on broadcast.
[0537] The broadcast can be broadcast 1-broadcast 5 as shown in the above embodiments. The process of establishing a connection between the first electronic device and the second electronic device can be referred to the description in the above embodiments.
[0538] S808, the first electronic device and the second electronic device are certified.
[0539] S809, the first electronic device and the second electronic device maintain a BLE connection online, or a BR connection online, or a heartbeat online.
[0540] In some embodiments, when the first electronic device or the second electronic device goes offline, for example, when it is powered off or the user turns off the communication switch (such as the Bluetooth switch), the first electronic device and the second electronic device can broadcast to each other and disconnect.
[0541] It should be understood that the embodiments of this application have the same technical principles and effects as the embodiments described above, and can be referred to the descriptions in the embodiments above.
[0542] 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.
[0543] 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.
[0544] 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.
[0545] 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.
[0546] 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.
[0547] 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.
[0548] 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.
[0549] 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.
[0550] 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.
[0551] 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.
[0552] This application provides a computer program product, which includes a computer program that, when run, causes a computer to perform the above-described method.
[0553] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will 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, create means for implementing the functions specified in one or more flowchart illustrations and / or one or more block diagrams.
[0554] 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: Send a first broadcast, the first broadcast being used to discover electronic devices, the first broadcast being a first type of broadcast; After receiving a second broadcast from the second electronic device, a connection is established with the second electronic device. Both the first electronic device and the second electronic device are logged into the first account, and the second electronic device is set to scan broadcasts at all times. After establishing a connection with the second electronic device, the device remains online, and the online mode includes a first online mode and a second online mode; When the online mode is the first online mode, all broadcasts from the second electronic device are blocked; When the online mode is the second online mode, the first type of broadcast from the second electronic device is blocked; The first online mode is online connection, and the second online mode is online heartbeat.
2. The method according to claim 1, characterized in that, The establishment of a connection with the second electronic device includes: Determine the connection method and connection direction, wherein the connection direction is used to indicate the initiator of the connection; A connection is established with the second electronic device according to the connection method and the connection direction.
3. The method according to claim 2, characterized in that, The connection methods include connections based on random media access control (MAC) addresses and connections based on fixed MAC addresses.
4. The method according to claim 3, characterized in that, If the second device information of the second electronic device does not contain the second identity resolution key (IRK) of the second electronic device, the connection method is a connection based on a random MAC address; or, If the second device information contains the second IRK of the second electronic device, and the second IRK is incorrect, the connection method is a connection based on a random MAC address; or, If the second device information contains the second IRK of the second electronic device and the second IRK is correct, the connection method is a connection based on a fixed MAC address.
5. The method according to claim 4, characterized in that, In the case where the connection method is based on a fixed MAC address: When the first electronic device acts as the master and the second electronic device acts as the slave, there are at least two available BLE connections; or, when the first electronic device acts as the slave and the second electronic device acts as the master, there are at least two available BLE connections, the connection method is a BLE connection. Wherein, the first electronic device is the initiator of the connection, and the number of BLE connections available when the first electronic device is acting as the master is greater than the number of BLE connections available when the second electronic device is acting as the master; or... When the number of available BLE connections when the first electronic device acts as the master is the same as the number of available BLE connections when the second electronic device acts as the master, the first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
6. The method according to claim 4, characterized in that, In the case where the connection method is based on a fixed MAC address: When there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and when there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: if there are at least two available BR connections when the first electronic device acts as the master client and the second electronic device acts as the slave server, or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, the connection method is BR connection; Wherein, the first electronic device is the initiator of the connection, and the number of BR connections available when the first electronic device is acting as a client is greater than the number of BR connections available when the second electronic device is acting as a client; or... When the number of available BR connections when the first electronic device acts as a client is the same as the number of available BR connections when the second electronic device acts as a client, the first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
7. The method according to claim 4, characterized in that, In the case where the connection method is based on a fixed MAC address: When it is determined that there are fewer than two available BLE connections when the first electronic device is acting as the master and the second electronic device is acting as the slave, and when there are fewer than two available BLE connections when the first electronic device is acting as the slave and the second electronic device is acting as the master; and, The connection method is a short connection when it is determined that there are fewer than two available BR connections when the first electronic device acts as a client and the second electronic device acts as a server, and when there are fewer than two available BR connections when the first electronic device acts as a server and the second electronic device acts as a client.
8. The method according to claim 7, characterized in that, When the connection method is a short connection: There is one available BLE connection when the first electronic device acts as the master and the second electronic device acts as the slave, and there is one available BLE connection when the first electronic device acts as the slave and the second electronic device acts as the master. The short connection can be a BLE connection.
9. The method according to claim 7, characterized in that, When the connection method is a short connection: There are 0 available BLE connections when the first electronic device is the master and the second electronic device is the slave. In the case where there are 0 available BLE connections when the first electronic device is the slave and the second electronic device is the master: there is 1 available BR connection when the first electronic device is the client and the second electronic device is the server, or there is 1 available BR connection when the first electronic device is the server and the second electronic device is the client. The short connection can be a BR connection.
10. The method according to claim 4, characterized in that, In the case where the connection method is based on a random MAC address: There is one available BLE connection when the first electronic device acts as the master and the second electronic device acts as the slave, or there is one available BLE connection when the first electronic device acts as the slave and the second electronic device acts as the master, wherein the connection method is a BLE short connection.
11. The method according to any one of claims 7-10, characterized in that, The first electronic device is the initiator of the connection, and the hash value of the first device identifier of the first electronic device is greater than the hash value of the second device identifier of the second electronic device.
12. The method according to any one of claims 7-11, characterized in that, When the connection method is a short connection, establishing a connection with the second electronic device includes: Establish a short connection with the second electronic device; Device authentication is performed with the second electronic device via the short connection; After completing the device authentication, disconnect the short connection with the second electronic device; After disconnecting the short connection with the second electronic device, maintain a heartbeat connection with the second electronic device.
13. The method according to claim 1, characterized in that, Before blocking all broadcasts from the second electronic device, the method further includes: Add the second network ID of the second electronic device to the second filtering rule, which is used to filter out broadcasts that do not need to be processed by the first electronic device. The blocking of all broadcasts from the second electronic device specifically involves determining to block all broadcasts from the second electronic device according to the second filtering rule.
14. The method according to claim 1, characterized in that, Before blocking the first type of broadcast from the second electronic device, the method further includes: The second network ID of the second electronic device and the broadcast of the first type corresponding to the second network ID are added to the second filtering rule. The second filtering rule is used to filter out broadcasts that do not need to be processed by the first electronic device. The blocking of the first type of broadcast from the second electronic device specifically involves: determining to block the first type of broadcast from the second electronic device according to the second filtering rule.
15. The method according to any one of claims 1-14, wherein, while maintaining a heartbeat connection with the second electronic device, the method further comprises: Receive a third broadcast from the second electronic device, the third broadcast including a fourth connection state of the second electronic device, the fourth connection state including: the number of BLE connections available when the second electronic device is a master, the number of BLE connections available when the second electronic device is a slave, the number of BR connections available when the second electronic device is a client, and the number of BR connections available when the second electronic device is a server. Based on the fourth connection state, if at least two available BLE connections exist when the first electronic device acts as the master and the second electronic device acts as the slave, or if at least two available BLE connections exist when the first electronic device acts as the slave and the second electronic device acts as the master, a new BLE connection is established with the second electronic device; or... If there are fewer than two available BLE connections when the first electronic device acts as the master and the second electronic device acts as the slave, and if there are fewer than two available BLE connections when the first electronic device acts as the slave and the second electronic device acts as the master: if there are at least two available BR connections when the first electronic device acts as the client and the second electronic device acts as the server, or if there are at least two available BR connections when the first electronic device acts as the server and the second electronic device acts as the client, then re-establish a BR connection with the second electronic device.
16. The method according to claim 1, characterized in that, The first broadcast is characterized as not connectable and requiring a reply. The second broadcast is sent by the second electronic device to the first electronic device after receiving the first broadcast. The second broadcast is characterized as connectable and requiring no reply.
17. The method according to claim 15, wherein the third broadcast is sent when the second electronic device switches from screen off to screen on, the method further comprising: When the first electronic device is on, based on the fourth connection state, it is determined whether to establish a BLE connection or a BR connection with the second electronic device. or, When the first electronic device is in a screen-off state, it is woken up in response to the third broadcast. When the first electronic device is in a wake-up state, it determines whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
18. The method according to claim 15, wherein the third broadcast is sent when the second electronic device switches from screen-on to screen-off, the method further comprising: When the first electronic device is on, it determines whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
19. The method according to claim 15, wherein the third broadcast is sent when the second electronic device is on, and the method further comprises: When the first electronic device is on, it determines whether to establish a BLE connection or a BR connection with the second electronic device based on the fourth connection state.
20. The method according to any one of claims 1-14, wherein, while maintaining a heartbeat connection with the second electronic device, the method further comprises: Receive a fourth broadcast from the second electronic device; When the first electronic device is on, the second electronic device is taken offline.
21. A communication method, characterized in that, Applied to a second electronic device, the method includes: Receives a first broadcast from a first electronic device, both the first and second electronic devices are logged into a first account, the second electronic device is set to scan broadcasts all day, and the first broadcast is a first type of broadcast; In response to the first broadcast, a second broadcast is sent to the first electronic device; Establish a connection with the first electronic device; After establishing a connection with the first electronic device, the device remains online. The online mode includes a first online mode and a second online mode. The first online mode is a connection online mode, and the second online mode is a heartbeat online mode. When the online mode is the first online mode, all broadcasts from the first electronic device are blocked; When the online mode is the second online mode, the first type of broadcast from the first electronic device is blocked.
22. The method according to claim 21, characterized in that, The first broadcast is characterized as unconnectable and requiring a reply. The response to the first broadcast, sending a second broadcast to the first electronic device, includes: Based on the attributes of the first broadcast, a second broadcast is sent to the first electronic device.
23. The method according to claim 21 or 22, characterized in that, The method further includes: When switching from screen off to screen on, a third broadcast is sent to the first electronic device. The third broadcast is used to detect the online status of the first electronic device. The attributes of the third broadcast are connectable, require reply, and can be woken up.
24. The method according to claim 21 or 22, characterized in that, The method further includes: When switching from screen on to screen off, a third broadcast is sent to the first electronic device. The third broadcast is used to detect the online status of the first electronic device. The attributes of the third broadcast are connectable, require a reply, and cannot be woken up.
25. The method according to claim 21 or 22, characterized in that, The method further includes: When the screen is on, a third broadcast is sent to the first electronic device. The third broadcast is used to indicate that the second electronic device is online. The attributes of the third broadcast are connectable, no reply required, and cannot be woken up.
26. The method according to claim 21 or 22, characterized in that, The method further includes: When the device is powered off, the WiFi switch is turned off, or the network switch is turned off, a fourth broadcast is sent to the first electronic device. The fourth broadcast is used to instruct the second electronic device to go offline. The attributes of the fourth broadcast are: not connectable, no reply required, and not wake-up.
27. 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-26.
28. 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-26.
29. 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 configured to run a computer program or instructions to perform the method as described in any one of claims 1-26.
30. 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-26.
Citation Information
Patent Citations
Broadcast scheduling processing method and device, computer equipment and storage medium
CN117407185A
Communication Method, Electronic Device, and System
US20240007211A1
