Communication method and device

By managing the association of connection and link information for different services within electronic devices, and utilizing reference counting and bridging technologies, the problem of connection management between devices under hardware constraints is solved, resulting in more efficient communication performance and user experience.

CN121815454APending Publication Date: 2026-04-07HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

How to effectively manage established WiFi P2P connections to improve the communication performance of electronic devices, especially how to expand the connection methods between devices under hardware limitations and improve user experience.

Method used

By storing connection information corresponding to different services in electronic devices and associating it with link information, referencing is used to manage connections and bridging, avoiding the repeated establishment of physical links. Different connection schemes, such as bridging or multiplexing GO, are used to establish connections with the destination device, thus expanding the device's connection methods.

Benefits of technology

It improves the communication performance of electronic devices, expands the ways to connect devices, enhances the user experience, and saves communication resources and power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121815454A_ABST
    Figure CN121815454A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a communication method and device, relates to the field of communication, and can improve the communication performance of electronic equipment. The method is applied to a first electronic device, and comprises the following steps: the first electronic device establishes a first WiFi P2P connection with a second electronic device; storing the first connection information and the first link information; the first connection information comprises an identifier of the first electronic equipment and an identifier of the second electronic equipment; the first link information indicates a WiFi P2P physical link between the first electronic equipment and the second electronic equipment; the first connection information and the first link information have an association relationship; the first electronic equipment establishes bridge connection with the third electronic equipment based on the second electronic equipment; storing the second connection information; the second connection information comprises an identifier of the first electronic equipment, an identifier of the second electronic equipment and an identifier of the third electronic equipment; the second connection information is associated with the first connection information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and more particularly to a communication method and apparatus. Background Technology

[0002] To better serve users, various electronic devices can exchange data (information), enabling functions such as file sharing, multi-screen collaboration, and screen mirroring. For example, device A and device B can use WiFi peer-to-peer (P2P) technology for data transmission. WiFi P2P is also known as WiFi Direct. Compared to Bluetooth communication, WiFi P2P has a longer communication range and greater bandwidth, offering significant advantages.

[0003] Currently, an electronic device can establish WiFi P2P connections with multiple electronic devices. How to manage the established WiFi P2P connections is an urgent problem to be solved. Summary of the Invention

[0004] This application provides a communication method and apparatus, which enables electronic devices to manage established WiFi P2P connections and improve the communication performance of electronic devices.

[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0006] In a first aspect, a communication method is provided, applied to a first electronic device. The method includes: in response to a user initiating a first service, the first electronic device establishes a first WiFi P2P connection with a second electronic device; the first electronic device stores first connection information and first link information; the first connection information includes an identifier of the first electronic device and an identifier of the second electronic device; the first link information indicates a WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information and the first link information are associated; in response to a user initiating a second service, the first electronic device establishes a connection with a third electronic device based on the second electronic device; the second service is different from the first service; the first electronic device stores second connection information; the second connection information includes an identifier of the first electronic device, an identifier of the second electronic device, and an identifier of the third electronic device; the second connection information and the first connection information are associated. Based on the method provided in this application, connection information corresponding to different services on the first electronic device can be associated, and the connection information corresponding to the service is associated with the link information, enabling different services to reuse the same physical link without repeatedly establishing physical links for different services, thereby improving the communication performance of the first electronic device.

[0007] In one possible implementation, the first connection information further includes a first reference count, which indicates the number of services corresponding to the first WiFi P2P connection; the second connection information further includes a second reference count, which indicates the number of services corresponding to the connection (i.e., bridging) between the first electronic device and the third electronic device. Thus, by using the reference counts (the first and second reference counts), the number of services corresponding to each connection (WiFi P2P connection and bridging) can be managed, ensuring the normal connection and secure disconnection of WiFi P2P connections and bridging.

[0008] In one possible implementation, the method further includes: decrementing the first reference count in the first connection information by 1 in response to the termination of the first service; and maintaining the WiFi P2P physical link corresponding to the first WiFi P2P connection if the first reference count in the first connection information is 0 and the second reference count in the second connection information associated with the first connection information is not 0. Thus, when the first service terminates, the first reference count in the first connection information corresponding to the first service can be decremented by 1. If the first reference count is 0 but the second reference count is not 0, there is no need to disconnect the WiFi P2P physical link corresponding to the first WiFi P2P connection. This is because the first connection information and the second connection information are associated; that is, the bridging corresponding to the second connection information depends on the WiFi P2P physical link associated with the first connection information. Therefore, there is no need to disconnect the WiFi P2P physical link corresponding to the first WiFi P2P connection, ensuring the normal connection of the bridging and thus ensuring the normal operation of the service corresponding to the bridging.

[0009] In one possible implementation, in response to the end of the second service, the second reference count in the second connection information is decremented by 1; if the first reference count in the first connection information is 0, and the second reference count in the second connection information associated with the first connection information is 0, the WiFi P2P physical link corresponding to the first WiFi P2P connection is disconnected. Thus, when the second service ends, the second reference count in the second connection information corresponding to the second service can be decremented by 1. If both the first and second reference counts are 0, the WiFi P2P physical link corresponding to the first WiFi P2P connection can be disconnected. That is, the number of services corresponding to the first WiFi P2P connection associated with the first connection information is 0, and the number of services corresponding to the bridging associated with the second connection information is 0. In other words, no service needs to rely on the first WiFi P2P connection and bridging. Therefore, the WiFi P2P physical link reused by the first WiFi P2P connection and bridging (i.e., the WiFi P2P physical link associated with the first connection information) can be disconnected, saving communication resources and power consumption of the first electronic device.

[0010] In one possible implementation, the first connection information further includes the network card name corresponding to the first WiFi P2P connection, and at least one of the P2P roles played by the first electronic device in the first WiFi P2P connection; the second connection information further includes the network card name corresponding to the connection (i.e., bridging) between the first electronic device and the third electronic device, and at least one of the P2P roles played by the first electronic device in the bridging.

[0011] In one possible implementation, establishing a connection between the first electronic device and the third electronic device via the second electronic device includes: the first electronic device sending its device identifier and network interface card (NIC) information to the third electronic device; and the first electronic device receiving a connection success message from the third electronic device, indicating that a second WiFi P2P connection has been successfully established between the third electronic device and the second electronic device. In this way, the third electronic device can establish a WiFi P2P connection with the second electronic device based on its device ID and NIC information. Since the second electronic device has established WiFi P2P connections with both the first and third electronic devices, it can act as a bridge, connecting the first and third electronic devices and forwarding information between them. This expands the connection options for the first electronic device, enabling communication between it and more devices, better meeting user needs, and improving user experience.

[0012] In one possible implementation, the first electronic device acts as a managed GC in the first WiFi P2P connection and has no free network interface card (NIC), while the third electronic device has a free NIC. That is, when the first electronic device acts as a managed GC and has no free NIC, and the third electronic device has a free NIC, the first electronic device can establish a connection with the third electronic device through the second electronic device (i.e., the first electronic device and the third electronic device establish a bridge). This expands the connection methods of the first electronic device, enabling communication between the first electronic device and more devices (e.g., the third electronic device) using WiFi P2P technology, better meeting user needs and improving user experience.

[0013] In one possible implementation, the first electronic device includes a first application module and a first WiFi module. The first application module is located at the application layer, and the first WiFi module is located at the framework layer. The first electronic device storing first connection information and first link information includes: the first application module storing the first connection information; and the first WiFi module storing the first link information. The first electronic device storing second connection information includes: the first application module storing the second connection information.

[0014] It should be understood that the first application module has device networking capabilities and can sense the connection status of multiple devices, while the first WiFi module lacks networking capabilities and can only sense one-to-one physical connection status. Therefore, the first WiFi module is responsible for establishing and managing the WiFi P2P physical link between two devices, and is not aware of bridging. The first application module is responsible for bridging management of three or more devices, maintaining the association between bridging and WiFi P2P connections, as well as the association (or dependency) between WiFi P2P connections and WiFi P2P physical links, but is not responsible for establishing and managing the WiFi P2P physical link. This dependency allows modules with different capabilities to fully leverage their respective advantages, better manage connection and link information, and improve the communication performance of the first electronic device.

[0015] In one possible implementation, after the first electronic device receives the first operation, the method further includes: establishing a first communication channel between the first application module and the third electronic device; registering the first communication channel with the first WiFi module, the first communication channel being used to transmit information between the first WiFi module and the third electronic device. It should be noted that the first application module has capabilities such as device discovery, device authentication, and data encryption / decryption. The first application module can reuse its existing capabilities to establish the first communication channel for the first WiFi module and register the first communication channel with the first WiFi module, enabling the first WiFi module to perform secure information interaction with other devices based on the first communication channel. In this way, the WiFi link module does not need to add complex and redundant communication capabilities (device discovery, device authentication, data encryption / decryption, etc.), allowing modules with different capabilities to fully leverage their respective advantages and avoiding complex and redundant implementation processes.

[0016] In one possible implementation, the method further includes: a first WiFi module obtaining WiFi capability information of a first electronic device from a WiFi driver; the WiFi capability information of the first electronic device includes the P2P role and idle network card information of the first electronic device; the P2P role of the first electronic device is the P2P role that the first electronic device plays in the WiFi P2P connection already established by the first electronic device; the first WiFi module calls a first communication channel to send the WiFi capability information of the first electronic device; and the first application module sends the WiFi capability information of the first electronic device to a third electronic device through the first communication channel. In this way, the first WiFi module can call the first communication channel to send the WiFi capability information of the first electronic device to the first application module, and then the first application module can send the WiFi capability information of the first electronic device to the third electronic device through the first communication channel. This eliminates the need for the WiFi link module to add complex and redundant communication capabilities (device discovery, device authentication, data encryption / decryption, etc.), allowing modules with different capabilities to fully leverage their respective advantages and avoiding complex and redundant implementation processes.

[0017] In one possible implementation, the method further includes: a first WiFi module receiving a decision result from a third electronic device via a first communication channel, the decision result instructing the third electronic device to establish a connection with the first electronic device through a second electronic device; the first WiFi module notifying a first application module to initiate bridging; the first application module entering bridging state; and the first application module sending the device ID and network interface card (NIC) MAC address of the second electronic device to the third electronic device. Thus, the third electronic device can establish a WiFi P2P connection with the second electronic device based on the device ID and NIC information of the second electronic device. Since the second electronic device has established WiFi P2P connections with both the first and third electronic devices, it can act as a bridge to connect the first and third electronic devices, forwarding information between them. This expands the connection options for the first electronic device, enabling communication between it and more devices, better meeting user needs, and improving user experience.

[0018] In one possible implementation, the first electronic device further includes a first application. The first electronic device receiving the first operation includes: the first application receiving the first operation; after the first application module sends the device ID and network card MAC address of the second electronic device to the third electronic device, the method further includes: the first application module receiving a connection success message from the third electronic device; the first application module notifying the first application of a successful device connection; and the first application prompting the user that the target service has been successfully initiated. In this way, the user can perform data interaction for the target service through the first electronic device and the third electronic device, which can improve the user experience.

[0019] Secondly, a communication method is provided, applied to a second electronic device. The method includes: establishing a first WiFi P2P connection between the second electronic device and a first electronic device; storing first connection information and first link information; the first connection information includes the identifiers of the first and second electronic devices; the first link information indicates a WiFi P2P physical link between the first and second electronic devices; the first connection information and the first link information are associated; establishing a second WiFi P2P connection between the second electronic device and a third electronic device; storing second connection information, third connection information, and second link information; the second connection information includes the identifiers of the first, second, and third electronic devices; the third connection information includes the identifiers of the second and third electronic devices; the second link information indicates a WiFi P2P physical link between the second and third electronic devices; the second connection information is associated with the first and third connection information, and the third connection information is associated with the second link information. Based on the method provided in the embodiments of this application, different connection information corresponding to different connections (first WiFi P2P connection and bridging) can be associated, and the connection information is associated with the link information, so that different connections (first WiFi P2P connection and bridging) can reuse the same physical link without having to repeatedly establish physical links, which can improve the communication performance of the second electronic device.

[0020] Thirdly, a communication method is provided for a third electronic device. The method includes: the third electronic device receiving information from a first electronic device about a second electronic device, the second electronic device's information including a device identifier and network interface card (NIC) information; the third electronic device establishing a connection with the first electronic device based on the second electronic device; the third electronic device storing second connection information, third connection information, and second link information; the second connection information including the identifiers of the first, second, and third electronic devices; the third connection information including the identifiers of the second and third electronic devices; the second link information indicating a WiFi P2P physical link between the second and third electronic devices; the second connection information being associated with the third connection information, and the third connection information being associated with the second link information. Based on the method provided in this application, different connection information corresponding to different connections (first WiFi P2P connection and bridging) can be associated, and the connection information is associated with the link information, enabling different connections (first WiFi P2P connection and bridging) to reuse the same physical link without needing to repeatedly establish a physical link, thereby improving the communication performance of the second electronic device.

[0021] Fourthly, a communication method is provided, applied to a communication system including a first electronic device, a second electronic device, and a third electronic device. The method includes: in response to a user initiating a first service, the first electronic device establishes a first WiFi P2P connection with the second electronic device; the first electronic device stores first connection information and first link information; the second electronic device stores the first connection information and first link information; wherein the first connection information includes an identifier of the first electronic device and an identifier of the second electronic device; the first link information indicates a WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information and the first link information are associated; in response to a user initiating a second service, the first electronic device establishes a connection with the third electronic device based on the second electronic device; the second service is different from the first service; the first electronic device establishing a connection with the third electronic device based on the second electronic device includes: the second electronic device establishing a second WiFi connection with the third electronic device. P2P connection; the first electronic device also stores second connection information; the second electronic device also stores second connection information, third connection information, and second link information, and the third electronic device stores second connection information, third connection information, and second link information; wherein, the second connection information includes the identifier of the first electronic device, the identifier of the second electronic device, and the identifier of the third electronic device; the third connection information includes the identifier of the second electronic device and the identifier of the third electronic device; the second link information is used to indicate the WiFi P2P physical link between the second electronic device and the third electronic device; the second connection information is associated with the first connection information and the third connection information, and the third connection information is associated with the second link information.

[0022] Fifthly, a first electronic device is provided, the first electronic device comprising: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processors are coupled; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the first electronic device causes the first electronic device to perform the method as described in the first aspect and any possible design thereof.

[0023] In a sixth aspect, a second electronic device is provided, the second electronic device comprising: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processor are coupled; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the second electronic device causes the second electronic device to perform the method as described in the second aspect and any possible design thereof.

[0024] A seventh aspect provides a third electronic device, the third electronic device comprising: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processors are coupled; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the third electronic device causes the third electronic device to perform the method as described in the third aspect and any possible design thereof.

[0025] Eighthly, this application provides a chip system including one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via lines. The chip system described above can be applied to electronic devices including communication modules and memory. The interface circuits are used to receive signals from the memory of the electronic device and send the received signals to the processor, the signals including computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device can perform the methods described in the first, second, or third aspects and any possible design embodiments thereof.

[0026] Ninthly, this application provides a computer-readable storage medium including computer instructions. When the computer instructions are executed on an electronic device (such as a tablet computer or a mobile phone), they cause the electronic device to perform the methods described in the first, second, or third aspects and any possible design embodiments thereof.

[0027] In a tenth aspect, this application provides a computer program product that, when run on a computer, causes the computer to perform the method described in the first, second, or third aspect and any possible design thereof.

[0028] It is understood that the beneficial effects achieved by the system described in the fourth aspect, the first electronic device described in the fifth aspect, the second electronic device described in the sixth aspect, the second electronic device described in the seventh aspect, the chip system described in the eighth aspect, the computer-readable storage medium described in the ninth aspect, and the computer program product described in the tenth aspect can be referred to the beneficial effects in the first or second aspect and any possible design mode thereof, which will not be repeated here. Attached Figure Description

[0029] Figure 1 This is a schematic diagram of a device connection in the prior art;

[0030] Figure 2A A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;

[0031] Figure 2BA schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;

[0032] Figure 3A A flowchart is provided for an embodiment of this application;

[0033] Figure 3B This application provides a schematic diagram of the connection between devices according to an embodiment of the present application;

[0034] Figure 3C A schematic diagram of a connection management architecture provided in an embodiment of this application;

[0035] Figure 3D This is another schematic diagram of the connection between devices provided in the embodiments of this application;

[0036] Figure 3E This is a schematic diagram of yet another connection management architecture provided in an embodiment of this application;

[0037] Figure 4A This application provides a schematic diagram illustrating the establishment of a WiFi P2P connection.

[0038] Figure 4B This is a schematic diagram illustrating another method for establishing a WiFi P2P connection, as provided in an embodiment of this application.

[0039] Figure 5A A schematic diagram provided for an embodiment of this application;

[0040] Figure 5B This is yet another display schematic diagram provided for an embodiment of this application;

[0041] Figure 5C A schematic diagram of a negotiation channel and an auxiliary channel provided for embodiments of this application;

[0042] Figure 6 This is a schematic diagram illustrating another method for establishing a WiFi P2P connection, as provided in an embodiment of this application.

[0043] Figure 7A A schematic diagram illustrating the establishment of a bridge according to an embodiment of this application;

[0044] Figure 7B This is a schematic diagram illustrating another method of establishing a bridge, as provided in an embodiment of this application.

[0045] Figure 8 A schematic diagram illustrating disconnecting a WiFi P2P connection and bridging, provided as an embodiment of this application;

[0046] Figure 9 This is a schematic diagram of a chip system provided in an embodiment of this application. Detailed Implementation

[0047] To ensure clarity and conciseness in the description of the following embodiments, a brief introduction to the relevant concepts or technologies is given first:

[0048] WiFi P2P is a peer-to-peer connection technology that allows direct TCP / IP connections between any two devices (e.g., STAs) without the need for an access point (AP). One device acts as an access point (AP) and can be called the group owner (GO), while the other device is called a group client (GC). GCs can connect to the GO. In a P2P group, there is one GO and one or more GCs. Each GC can connect to a GO, meaning a GO can provide services to one or more GCs.

[0049] In smart living scenarios (such as smart office, sports and health, smart home, smart travel, and audio-visual entertainment), various electronic devices (such as mobile phones, tablets, computers, TVs, cameras, and smart cars) bring users a lot of convenience and unprecedented experiences. These electronic devices can transmit data (interact) with each other to enable functions such as file sharing, multi-screen collaboration, and screen mirroring, thereby better serving users.

[0050] Currently, electronic devices can use WiFi P2P technology for data transmission. For example, ... Figure 1 As shown, device A and device B can use WiFi P2P technology for data transmission. However, even if device A and device B have already established a WiFi P2P connection, due to hardware limitations (e.g., the number of network cards), device A may not be able to establish a WiFi P2P connection with other devices (e.g., device C), affecting the user experience.

[0051] In some embodiments, when the electronic device has hardware limitations (e.g., insufficient number of network cards), it can negotiate with the peer device based on the WiFi capability information of both devices (e.g., number of available network cards, P2P roles, etc.), and adopt different connection schemes according to different negotiation results. For example, when the network card resources of the local device (e.g., tablet B) are insufficient (e.g., no available network cards), a connection can be established with the destination device (e.g., mobile phone C) through bridging, or a WiFi P2P connection can be established with the destination device through multiplexing GO. This expands the connection methods between the local device and the destination device, enabling communication between the local device and more devices using WiFi P2P technology, better meeting user needs and improving user experience. However, how the electronic device specifically manages the established WiFi P2P connections and bridging remains an issue that needs to be addressed.

[0052] This application provides a communication method in which an electronic device (a first electronic device, a second electronic device, or a third electronic device) can respectively store the connection information corresponding to the established WiFi P2P connection and the bridge. The connection information corresponding to different services can be associated with each other, and the connection information corresponding to the services can be associated with the link information, so that different services can reuse the same physical link without having to repeatedly establish physical links for different services, thereby improving the communication performance of the first electronic device.

[0053] The method provided in this application can be applied to a first electronic device, a second electronic device, and a third electronic device. The first, second, or third electronic device can be, for example, a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device, and / or smart city device. This application does not impose any special limitations on the specific type of electronic device.

[0054] The following description uses the first electronic device, the second electronic device, and the third electronic device as examples to illustrate the hardware structure of electronic device 100. Figure 2A A schematic diagram of the hardware structure of the electronic device 100 is shown.

[0055] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, Universal Serial Bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, camera 193, display screen 194, and Subscriber Identification Module (SIM) card interface 195, etc.

[0056] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0057] The processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

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

[0059] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0060] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0061] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image and video playback, etc.). The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.).

[0062] In some embodiments, the processor 110 may include one or more interfaces. The USB interface 130 is an interface compliant with the USB standard specification, specifically a Mini USB interface, a Micro USB interface, a USB Type-C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used for data transfer between the electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices 100, such as AR devices.

[0063] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.

[0064] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0065] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low-noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1.

[0066] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including Wireless Local Area Networks (WLAN) (such as Wi-Fi), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), NFC, and Infrared (IR). The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0067] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.

[0068] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.

[0069] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), an Active-Matrix Organic Light-Emitting Diode (AMOLED), a Flexible Light-Emitting Diode (FLED), Mini LED, Micro LED, Micro-OLED, Quantum Dot Light-Emitting Diodes (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0070] In this embodiment of the application, the display screen can be a touch screen, which can receive user operations (e.g., first operation, second operation, etc.) to realize human-computer interaction.

[0071] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU performs mathematical and geometric calculations and is used for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0072] Electronic device 100 can acquire images through ISP, camera 193, video codec, GPU, display screen 194, and application processor.

[0073] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture of the Android system as an example to illustrate the software structure of electronic device 100. The layered architecture divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through interfaces.

[0074] In some embodiments, the technical architecture of the electronic device 100 includes: an application layer (application layer), a framework layer (application framework layer), a kernel layer, and a hardware layer. It should be understood that the embodiments in this application only describe some layers and components related to the solution in this application. In actual applications, the electronic device 100 may also include other layers and components, and this application does not impose specific limitations.

[0075] like Figure 2B As shown, the application layer can include smart interconnection applications and MagicLink application modules.

[0076] Among them, the smart interconnection application can be used to receive user operations (such as screen sharing initiated by the user) and call the MagicLink application module based on the user operations.

[0077] The MagicLink application module is responsible for managing business scenarios and networking between multiple devices, as well as managing the bridging and WiFi P2P connections corresponding to the business.

[0078] As an example, the MagicLink application module in the application layer may include a P2P connection control module, a P2P direct connection module, a P2P bridging module, a P2P dynamic networking module, a security authentication module, a P2P connection counting module, and a P2P connection information management module.

[0079] The P2P connection control module receives a connection call from the smart interconnection application (which is triggered by a screen sharing operation initiated by the user on the local machine (e.g., tablet B) to the destination device (e.g., mobile phone C). It can determine the connection method between the local machine and the destination device based on the local machine's capability information (e.g., the local machine's P2P role and idle network card information) and the destination device's capability information (e.g., the destination device's idle network card information).

[0080] In some embodiments, when the P2P role of the local device (e.g., tablet B) is GO and the local device has no idle network card, and the destination device (e.g., mobile phone C) has an idle network card, the P2P connection control module can call the P2P direct connection module, and the P2P direct connection module can reuse the GO to establish a WiFi P2P connection with the mobile phone C.

[0081] In other embodiments, when the local device (e.g., tablet B) has the P2P role of GC and both the local device and the destination device (e.g., mobile phone C) have idle network cards, the P2P connection control module can call the P2P direct connection module. The P2P direct connection module can establish a WiFi P2P connection with the destination device (e.g., mobile phone C) based on the local device's idle network card (e.g., WiFi network card 2).

[0082] In some other embodiments, when the local device (e.g., tablet B) has a P2P role of GC and the local device does not have a free network card, while the destination device (e.g., mobile phone C) has a free network card, the P2P connection control module can call the P2P bridging module, the P2P bridging module can call the P2P direct connection module, and the P2P direct connection module can establish a WiFi P2P connection on which the P2P bridging module depends.

[0083] In some other embodiments, the local device (e.g., tablet B) has the P2P role of GC, and neither the local device nor the destination device (e.g., mobile phone C) has a free network card. The P2P connection control module can call the P2P dynamic networking module, which can call the P2P direct connection module or the P2P bridging module to perform dynamic networking preemption (i.e., first disconnect the existing WiFi P2P connection established by the local device to release the occupied network card, and then establish a WiFi P2P connection with the destination device based on the released network card).

[0084] The security authentication module can be used for device security authentication and key exchange.

[0085] The P2P connection information management module is used to store and manage the connection information of the bridging and / or WiFi P2P connections corresponding to the service. This connection information may include the identifiers of members in the WiFi P2P group corresponding to the bridging and / or WiFi P2P connection, the network card name, and the P2P role of the device (phone A stores the P2P role of phone A, and tablet B stores the P2P role of tablet B), etc.

[0086] The P2P connection counting module is used to store and manage the reference counts (e.g., ref) of the bridging and / or WiFi P2P connections corresponding to the service. For example, ref = 1 indicates that the service reference count is 1, that is, there is a service (e.g., screen sharing service) referencing WiFi P2P connection 1, which means that the service (e.g., screen sharing service) interacts with the peer device (e.g., tablet B) based on WiFi P2P connection 1.

[0087] The framework layer can include a WiFi link module and an Android WiFi management module.

[0088] The Android WiFi management module is a native Android module used to manage the establishment and disconnection of WiFi P2P connections between the primary network interface card (NIC) of an electronic device (e.g., WiFi NIC 1) and the peer device. The process of establishing a WiFi P2P connection includes activating (raising / lowering) WiFi NIC 1, setting its frequency, service set identifier (SSID), and password, and then establishing a WiFi P2P connection with the peer device using the SSID and password. Subsequently, the MagicLink application module can establish an encrypted TCP channel using IP and TCP ports based on the established WiFi P2P connection.

[0089] The WiFi link module can manage the WiFi P2P physical link established between two devices.

[0090] The WiFi link module can also be used to manage extended network cards (e.g., WiFi network card 2) of electronic devices. These extended WiFi network cards may include more network cards, such as WiFi network card 3, WiFi network card 4, etc., and this application does not limit the scope of such extensions.

[0091] The WiFi link module can also be used to collect WiFi capability information (including the number of WiFi network cards, available WiFi channels, etc.) from WiFi drivers (e.g., the drivers for WiFi network card 1 and WiFi network card 2). The WiFi link module is compatible with the WiFi capabilities of different hardware platforms (e.g., WiFi chips or WiFi network cards).

[0092] The WiFi link module may include a WiFi service module. This WiFi service module can obtain WiFi capability information from the WiFi driver and, based on this information, determine WiFi P2P connection configuration information. Furthermore, according to instructions from the P2P direct connection module, the WiFi service module can invoke the WiFi protocol stack to establish a WiFi P2P physical link with the peer device.

[0093] In some implementations, the WiFi protocol stack can be integrated into the WiFi network card. The WiFi protocol stack can be a purely software module or a module combining software and hardware; this application does not specifically limit this.

[0094] The kernel layer is the layer between hardware and software. The kernel layer can contain WiFi drivers. WiFi drivers are the driver layer for WiFi network cards (e.g., WiFi card 1 and WiFi card 2), and are primarily responsible for interacting with the hardware. For example, a WiFi driver can include drivers for WiFi card 1 and WiFi card 2. The driver for WiFi card 1 is used to interact with WiFi card 1, and the driver for WiFi card 2 is used to interact with WiFi card 2.

[0095] In addition, the kernel layer may also include display drivers, camera drivers, audio drivers, sensor drivers, etc. (not shown in the figure).

[0096] The hardware layer may include a first network interface card (e.g., WiFi network interface card 1) and an extended network interface card (e.g., WiFi network interface card 2).

[0097] In this embodiment, WiFi P2P connections can be managed on a per-WiFi network card basis. Compared to managing WiFi P2P connections on a per-device basis, managing WiFi P2P connections on a per-WiFi network card basis can be compatible with more WiFi network cards on devices, and the management of WiFi P2P connections is more flexible and efficient.

[0098] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. In the description of this application, unless otherwise stated, "at least one" refers to one or more, and "more than one" refers to two or more. Furthermore, to facilitate a clear description of the technical solutions of the embodiments of this application, the terms "first," "second," etc., are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., do not necessarily imply differences.

[0099] For ease of understanding, the WiFi P2P connection method provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0100] like Figure 3A As shown, this application provides a WiFi P2P connection method, using mobile phone A (second electronic device), tablet computer B (first electronic device), and mobile phone C (third electronic device) as examples, including:

[0101] 301. In response to the operation of initiating the first service, tablet B and mobile phone A establish a WiFi P2P connection 1.

[0102] In some embodiments, in response to a user's screen sharing (first service) operation initiated by a tablet B to a mobile phone A, the tablet B can establish a WiFi P2P connection 1 (first WiFi P2P connection) with the mobile phone A to conduct information interaction based on the WiFi P2P connection 1.

[0103] For example, the first service could be a screen sharing service, which involves sharing the screen data of tablet B to mobile phone A. The first service may also include other types of services, such as network sharing, voice sharing, multi-screen collaboration, file sharing, etc., which are not limited in this application.

[0104] For example, such as Figure 3B As shown, tablet B can establish WiFi P2P connection 1 with mobile phone A (for example, tablet B can establish WiFi P2P connection 1 with mobile phone A's WiFi network card 1 through WiFi network card 1). In WiFi P2P connection 1, mobile phone A's P2P role is GO, and tablet B's P2P role is GC. Mobile phone C has no connection.

[0105] In this embodiment, mobile phone A and tablet computer B can respectively save the connection information (first connection information) corresponding to WiFi P2P connection 1. The connection information may include the identifiers of members in the WiFi P2P group corresponding to WiFi P2P connection 1, service reference counts (e.g., ref), network card names, and the P2P roles of the devices (mobile phone A saves the P2P role of mobile phone A, and tablet computer B saves the P2P role of tablet computer B), etc.

[0106] For example, the connection information saved by mobile phone A can be: WiFi P2P connection 1 (AB, ref=1, p2p0, GO). Here, AB indicates that the members of the WiFi P2P group corresponding to WiFi P2P connection 1 include mobile phone A and tablet B; ref=1 indicates that the service reference count is 1, meaning that a service (e.g., screen sharing service) references WiFi P2P connection 1, that is, this service (e.g., screen sharing service) interacts with the peer device (e.g., tablet B) based on WiFi P2P connection 1; p2p0 refers to the network card name corresponding to WiFi P2P connection 1 (i.e., the identifier of the network card used by mobile phone A to establish WiFi P2P connection 1); and GO indicates that the P2P role of mobile phone A is GO.

[0107] The connection information stored by tablet B can be: WiFi P2P Connection 1 (AB, ref=1, p2p0, GC). Here, AB indicates that the members of the WiFi P2P group corresponding to WiFi P2P Connection 1 include mobile phone A and tablet B; ref=1 indicates that the service reference count (first reference count) is 1, meaning that a service (e.g., screen sharing service) references WiFi P2P Connection 1, and that this service (e.g., screen sharing service) interacts with the peer device (e.g., mobile phone A) based on WiFi P2P Connection 1; p2p0 refers to the network card name corresponding to WiFi P2P Connection 1, and GC indicates that mobile phone A's P2P role is GO.

[0108] Mobile phone A and tablet B can also save the first link information, which is used to indicate the WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information is related to the first link information.

[0109] like Figure 3CFigure (a) shows a schematic diagram of a connection management architecture for mobile phone A. The MagicLink application module of mobile phone A can provide WiFi P2P interface 1 to upper-layer applications (e.g., smart interconnection applications). WiFi P2P interface 1 depends on WiFi P2P connection 1, and the connection information corresponding to WiFi P2P connection 1 can be, for example, WiFi P2P connection 1 (AB, ref = 1, p2p0, GO). WiFi P2P connection 1 depends on WiFi P2P physical link 1 between mobile phone A and tablet B; the two ends of WiFi P2P physical link 1 are mobile phone A and tablet B, respectively, and the P2P role of the local device (e.g., mobile phone A) in this WiFi P2P physical link is GO. In other words, WiFi P2P connection 1 stored in the MagicLink application module of mobile phone A is associated with WiFi P2P physical link 1 stored in the WiFi link module of mobile phone A. That is, WiFi P2P connection 1 corresponds to WiFi P2P physical link 1 (WiFi P2P connection 1 depends on WiFi P2P physical link 1).

[0110] like Figure 3C Figure (b) shows a schematic diagram of a connection management architecture for tablet B. The MagicLink application module of tablet B can provide WiFi P2P interface 1 to upper-layer applications (e.g., smart interconnection applications). WiFi P2P interface 1 depends on WiFi P2P connection 1, and the connection information corresponding to WiFi P2P connection 1 can be, for example, WiFi P2P connection 1 (AB, ref = 1, p2p0, GO). WiFi P2P connection 1 depends on WiFi P2P physical link 1 between mobile phone A and tablet B; the two ends of WiFi P2P physical link 1 are mobile phone A and tablet B, respectively, and the P2P role of the local device (e.g., tablet B) in this WiFi P2P physical link is GC. In other words, WiFi P2P connection 1 stored in the MagicLink application module of tablet B is associated with WiFi P2P physical link 1 stored in the WiFi link module of tablet B. That is, WiFi P2P connection 1 corresponds to WiFi P2P physical link 1 (WiFi P2P connection 1 depends on WiFi P2P physical link 1).

[0111] 302. In response to the user's initiation of a second service, tablet B and mobile phone C establish a bridging connection.

[0112] For example, in response to a user's network sharing (second service) operation initiated on its own device (e.g., tablet B) to a destination device (e.g., mobile phone C), if tablet B's P2P role is GC (tablet B's P2P role in WiFi P2P connection 1 is GC), tablet B has no free network cards (i.e., all of tablet B's WiFi network cards are occupied), and the destination device (e.g., mobile phone C) has a free network card, tablet B can establish a bridge with mobile phone C through mobile phone A. That is, mobile phone A can act as a bridge between tablet B and mobile phone C. Tablet B and mobile phone C can share data traffic based on the bridged connection.

[0113] For example, the second service could be a network sharing service, which involves sharing the data traffic of tablet B to mobile phone C. The second service may also include other types of services, such as screen sharing, voice sharing, multi-screen collaboration, file sharing, etc., which are not limited in this application.

[0114] In some embodiments, tablet B can send information from mobile phone A (e.g., mobile phone A's device ID and network card MAC address) to mobile phone C, and mobile phone C can establish a WiFi P2P connection with mobile phone A based on the information from mobile phone A. That is, mobile phone A establishes WiFi P2P connections with both tablet B and mobile phone C. Therefore, mobile phone A can act as a bridge to connect tablet B and mobile phone C, forwarding information between tablet B and mobile phone C.

[0115] For example, such as Figure 3D As shown, tablet B establishes WiFi P2P connection 1 with mobile phone A (for example, tablet B can establish WiFi P2P connection 1 with mobile phone A's WiFi network card 1 through WiFi network card 1). Mobile phone C establishes WiFi P2P connection 2 with mobile phone A (a second WiFi P2P connection). For example, mobile phone C can establish WiFi P2P connection 2 with mobile phone A's WiFi network card 1 through WiFi network card 1. That is, mobile phone A can act as a bridge to connect tablet B and mobile phone C, and mobile phone A can forward information between tablet B and mobile phone C.

[0116] Mobile phone A, tablet B, and mobile phone C can each save the bridging connection information (second connection information). Among them, the connection information saved by mobile phone A may include: WiFi P2P connection 1 (AB,ref=1,p2p0,GO), WiFi P2P connection 2 (AC,ref=0,p2p0,GO), and P2P bridging (CAB,ref=1,p2p0,GO).

[0117] In WiFi P2P connection 1 (AB, ref=1, p2p0, GO), AB indicates that the members of the WiFi P2P group corresponding to WiFi P2P connection 1 include mobile phone A and tablet B; ref=1 indicates that the service reference count (second reference count) is 1, that is, there is a service (e.g., screen sharing service) referencing WiFi P2P connection 1, that is, the service (e.g., screen sharing service) interacts with the peer device (e.g., tablet B) based on WiFi P2P connection 1; p2p0 refers to the network card name corresponding to WiFi P2P connection 1, and GO indicates that mobile phone A's P2P role in WiFi P2P connection 1 is GO.

[0118] In WiFi P2P Connection 2 (AC, ref = 0, p2p0, GO), AC indicates that the members of the WiFi P2P group corresponding to WiFi P2P Connection 2 include mobile phone A and mobile phone C; ref = 1 indicates that the service reference count is 1, that is, there is a service (e.g., screen sharing service) referencing WiFi P2P Connection 2, that is, the service (e.g., screen sharing service) interacts with the peer device (e.g., mobile phone C) based on WiFi P2P Connection 2; p2p0 refers to the network card name corresponding to WiFi P2P Connection 2, and GO indicates that mobile phone A's P2P role in WiFi P2P Connection 2 is GO.

[0119] In P2P bridging (CAB, ref = 1, p2p0, GO), CAB (which can also be represented as ABC or CBA, etc., this application does not limit) indicates that the members of the WiFi P2P group corresponding to the P2P bridging include mobile phone A, tablet B, and mobile phone C; ref = 1 indicates that the service reference count is 1, that is, there is a service (e.g., network sharing service) referencing the P2P bridging, that is, the service (e.g., network sharing service) interacts with the peer device (e.g., tablet B) based on the P2P bridging; p2p0 refers to the network card name corresponding to the P2P bridging, and GO indicates that the P2P role of mobile phone A in the P2P bridging is GO.

[0120] The connection information stored by tablet B may include: WiFi P2P connection 1 (AB,ref=1,p2p0,GO) and P2P bridging (CAB,ref=1,p2p0,GO).

[0121] The connection information stored in mobile phone C may include: WiFi P2P connection 2 (AC,ref=0,p2p0,GO) and P2P bridging (CAB,ref=1,p2p0,GO).

[0122] For details regarding the connection information saved by tablet B and mobile phone C, please refer to the explanation of the connection information saved by mobile phone A; further details will not be provided here.

[0123] like Figure 3E As shown in (a), this is a schematic diagram of a connection management architecture for mobile phone A. The MagicLink application module of mobile phone A can provide WiFi P2P interface 1 to upper-layer applications (e.g., smart interconnection applications), and can also manage WiFi P2P connection 1, P2P bridging, and WiFi P2P connection 2. The WiFi link module of mobile phone A can manage WiFi P2P physical link 1 and WiFi P2P physical link 2.

[0124] Among them, WiFi P2P interface 1 can be an interface provided to service 1 (e.g., a screen sharing service initiated by tablet B to mobile phone A). WiFi P2P interface 1 depends on WiFi P2P connection 1, and the connection information corresponding to WiFi P2P connection 1 can be, for example, WiFi P2P connection 1 (AB,ref=1,p2p0,GO). WiFi P2P connection 1 depends on WiFi P2P physical link 1. The two ends of WiFi P2P physical link 1 are mobile phone A and tablet B, respectively, and the P2P role of the local device (e.g., mobile phone A) in WiFi P2P physical link 1 is GO. The connection information corresponding to P2P bridging can be, for example, P2P bridging (CAB,ref=1,p2p0,GO). P2P bridging depends on WiFi P2P connection 1 and WiFi P2P connection 2. The connection information corresponding to WiFi P2P connection 2 can be, for example, WiFi P2P connection 2 (AC,ref=0,p2p0,GO). WiFi P2P connection 2 depends on WiFi P2P physical link 2. The two ends of WiFi P2P physical link 2 are mobile phone A and mobile phone C, and the P2P role of the local device (e.g., mobile phone A) in WiFi P2P physical link 2 is GO.

[0125] In other words, the P2P bridges stored in the MagicLink application module of phone A correspond to WiFi P2P connection 1 and WiFi P2P connection 2 (i.e., the P2P bridges stored in phone A are related to WiFi P2P connection 1 and WiFi P2P connection 2 stored in phone A). Different WiFi P2P connections stored in the MagicLink application module of phone A correspond to different WiFi P2P physical links in phone A's WiFi link module. For example, WiFi P2P connection 1 corresponds to WiFi P2P physical link 1 (WiFi P2P connection 1 depends on WiFi P2P physical link 1); WiFi P2P connection 2 corresponds to WiFi P2P physical link 2 (i.e., WiFi P2P connection 2 depends on WiFi P2P physical link 2).

[0126] like Figure 3E As shown in (b), this is a schematic diagram of a connection management architecture for tablet B. The MagicLink application module of tablet B can provide WiFi P2P interface 1 and WiFi P2P interface 2 to upper-layer applications (e.g., smart interconnection applications), and can also manage WiFi P2P connection 1 and P2P bridging. The WiFi link module of tablet B can manage WiFi P2P physical link 1.

[0127] In this configuration, WiFi P2P interface 1 can be an interface provided to service 1 (e.g., a screen sharing service initiated by tablet B to tablet B), and WiFi P2P interface 2 is an interface provided to service 2 (e.g., a network sharing service initiated by tablet B to mobile phone C). WiFi P2P interface 1 depends on WiFi P2P connection 1, and the connection information corresponding to WiFi P2P connection 1 can be, for example, WiFi P2P connection 1 (AB,ref=1,p2p0,GO). WiFi P2P connection 1 depends on WiFi P2P physical link 1. The two ends of WiFi P2P physical link 1 are mobile phone A and tablet B, respectively, and the P2P role of the local device (e.g., tablet B) in WiFi P2P physical link 1 is GC. WiFi P2P interface 2 depends on P2P bridging, and the connection information corresponding to P2P bridging can be, for example, P2P bridging (CAB,ref=1,p2p0,GO). P2P bridging depends on WiFi P2P connection 1.

[0128] In other words, the P2P bridge stored in the MagicLink application module of tablet B corresponds to WiFi P2P connection 1 (i.e., the P2P bridge stored in tablet B is related to WiFi P2P connection 1 stored in tablet B). Among them, WiFi P2P connection 1 corresponds to WiFi P2P physical link 1 (WiFi P2P connection 1 depends on WiFi P2P physical link 1).

[0129] like Figure 3E As shown in (c), this is a schematic diagram of a connection management architecture for mobile phone C. The MagicLink application module of mobile phone C can provide a WiFi P2P interface 2 to upper-layer applications (e.g., smart interconnection applications), and can also manage P2P bridging and WiFi P2P connections 2. The WiFi link module of mobile phone C can manage the WiFi P2P physical link 2.

[0130] WiFi P2P interface 2 is the interface provided to service 2 (e.g., a network sharing service initiated by tablet B to mobile phone C). WiFi P2P interface 2 relies on P2P bridging, and the connection information corresponding to P2P bridging could be, for example, P2P bridging (CAB,ref=1,p2p0,GO). P2P bridging relies on WiFi P2P connection 2. The connection information corresponding to WiFi P2P connection 2 could be, for example, WiFi P2P connection 2 (AC,ref=0,p2p0,GO). WiFi P2P connection 2 relies on WiFi P2P physical link 2. The two ends of WiFi P2P physical link 2 are mobile phone C and mobile phone C, and the P2P role of the local device (e.g., mobile phone C) in WiFi P2P physical link 2 is GO.

[0131] In other words, the P2P bridge saved in the MagicLink application module of phone C corresponds to WiFi P2P connection 2 (i.e., the P2P bridge saved in phone C is related to WiFi P2P connection 2 saved in phone C). WiFi P2P connection 2 saved in the MagicLink application module of phone C corresponds to WiFi P2P physical link 2 (i.e., WiFi P2P connection 2 depends on WiFi P2P physical link 2).

[0132] Based on the communication method provided in the embodiments of this application, electronic devices (first electronic devices, second electronic devices, or third electronic devices) can respectively save the established WiFi P2P connection and the connection information corresponding to the bridge. The connection information corresponding to different services can be associated with each other, and the connection information corresponding to the services is associated with the link information, so that different services can reuse the same physical link without having to repeatedly establish physical links for different services, which can improve the communication performance of the first electronic device.

[0133] like Figure 4A As shown, this application embodiment provides a WiFi P2P connection method, taking the establishment of a WiFi P2P connection (first WiFi P2P connection) between mobile phone A (second electronic device) and tablet computer B (first electronic device) as an example, including:

[0134] 401. Turn on WiFi and Bluetooth on mobile phone A and tablet B.

[0135] Taking mobile phone A as an example, in response to the user from Figure 5A By swiping down from the top of interface 501, phone A can display interface 502. Interface 502 includes a WLAN switch 5021 and a Bluetooth switch 5022. Phone A can receive user input to switches 5021 and 5022 (e.g., tapping) to enable WiFi and Bluetooth.

[0136] For example, in response to user requests Figure 5A When the user clicks the application icon 5013 in the settings interface 501, phone A can display interface 503, which includes WLAN settings 5031 and Bluetooth settings 5032. Phone A can receive user actions on settings 5031 and 5032 to enable WiFi and Bluetooth.

[0137] The process of enabling WiFi and Bluetooth on tablet B can be referred to the above description, and will not be repeated in this application.

[0138] 402. The MagicLink application module of mobile phone A and the MagicLink application module of tablet B discover the other device via Bluetooth broadcast.

[0139] After Bluetooth is turned on on phone A, phone A can send Bluetooth broadcasts; similarly, after Bluetooth is turned on on tablet B, tablet B can send Bluetooth broadcasts. Phone A's MagicLink application module can discover tablet B based on the Bluetooth broadcasts sent by tablet B. Tablet B's MagicLink application module can discover phone A based on the Bluetooth broadcasts sent by phone A. In other words, phone A and tablet B can discover each other based on Bluetooth broadcasts sent by the other device.

[0140] 403. The MagicLink application module of mobile phone A and the MagicLink application module of tablet computer B establish a Bluetooth connection.

[0141] The MagicLink application module of mobile phone A and the MagicLink application module of tablet B can establish a Bluetooth connection and communicate via the Bluetooth communication protocol.

[0142] The Bluetooth communication protocol can be the traditional Bluetooth protocol, or the Bluetooth Low Energy (BLE) protocol; of course, it can also be other new Bluetooth protocol types that will be launched in the future, which is not limited in this application.

[0143] 404. The MagicLink application module of mobile phone A and the MagicLink application module of tablet B perform device security authentication and exchange keys based on Bluetooth connection.

[0144] Mobile phone A and tablet B can perform device security authentication via Bluetooth to confirm that the other end is a trusted device. Then, mobile phone A and tablet B can exchange keys for secure communication.

[0145] 405a. The MagicLink application module of mobile phone A requests the WiFi link module of mobile phone A to obtain the basic WiFi parameters.

[0146] The basic WiFi parameters may include the version number of the WiFi link module, which indicates the number of WiFi network cards supported by the device, the number of supported WiFi P2P links, and the supported service scenarios (e.g., Trust Ring, Honor Share).

[0147] 406a. The WiFi link module of mobile phone A obtains the basic WiFi parameters of mobile phone A.

[0148] 407a. The WiFi link module of mobile phone A returns the basic WiFi parameters of mobile phone A to the MagicLink application module of mobile phone A.

[0149] 405b. The MagicLink application module of tablet B requests the WiFi basic parameters of tablet B from the WiFi link module of tablet B.

[0150] 406b. The WiFi link module of tablet B obtains the basic WiFi parameters of tablet B.

[0151] The basic WiFi parameters of tablet B can be found in the description of the basic WiFi parameters of phone A, and will not be repeated here.

[0152] 407b. The WiFi link module of tablet B returns the basic WiFi parameters of tablet B to the MagicLink application module of tablet B.

[0153] Steps 405a-407a and steps 405b-407b can be executed simultaneously.

[0154] 408. The MagicLink application module of mobile phone A and the MagicLink application module of tablet B exchange the basic WiFi parameters of the other end.

[0155] Optionally, after mobile phone A and tablet B establish a Bluetooth connection, the MagicLink application module of mobile phone A and the MagicLink application module of tablet B can exchange the basic WiFi parameters of the other end. This allows mobile phone A or tablet B to make a preliminary judgment based on its own and the other end's basic WiFi parameters after receiving a user-initiated service (e.g., screen sharing service). For details, please refer to the relevant description in step 417.

[0156] 409a. The MagicLink application module of mobile phone A reports the online status of the peer device (i.e. tablet B) to the smart interconnection application of mobile phone A.

[0157] That is, the MagicLink application module of mobile phone A reports the online status of tablet B to the smart interconnection application of mobile phone A.

[0158] 409b. The MagicLink application module of tablet B reports the online status of device (phone A) to the smart interconnection application of tablet B.

[0159] 410. The smart interconnection application of mobile phone A notifies the user that device (tablet B) is online.

[0160] For example, such as Figure 5B As shown in (b), the interface of mobile phone A can display the icon 44 of tablet B (hereinafter referred to as tablet B), prompting the user that "tablet B is online".

[0161] 411a. The smart interconnection application of mobile phone A receives the screen sharing operation initiated by the user.

[0162] Screen sharing refers to projecting the screen of a device (e.g., mobile phone A) onto the screen of a peer device (e.g., tablet B). This application uses WiFi P2P communication as an example for screen sharing, but WiFi P2P communication can also include other types of services, such as multi-screen collaboration and file sharing, which are not limited in this application.

[0163] For example, such as Figure 5B As shown in (a), in response to a user swiping down from the status bar of phone A to display the notification panel, phone A displays the notification panel, which may include the "Trust Ring Multi-Device Interconnection Center" option 41. In response to a user triggering an action on the "Trust Ring Multi-Device Interconnection Center" option 41 (e.g., a click), phone A may display as shown in (a). Figure 5BThe control interface 42 shown in (b) is shown in the figure. The control interface 42 includes the device identifier 43 of the local device (i.e., mobile phone A) and the device identifier 44 of the tablet computer B (hereinafter referred to as tablet B) (that is, the local device (i.e., mobile phone A) and tablet computer B are both joined to the same trust ring).

[0164] In some implementations, the user can drag the device identifier 44 of tablet B towards the device identifier 43 of the device itself. When the drag operation ends near the device identifier 43 of the device itself, screen sharing can be achieved between the device (i.e., mobile phone A) and tablet B (i.e., the screen of mobile phone A can be projected onto the screen of tablet B). In other implementations, the user can drag the device identifier 43 of the device itself towards the identifier 44 of tablet B. When the drag operation ends near the identifier 44 of tablet B, screen sharing can be achieved between the device (i.e., mobile phone A) and tablet B.

[0165] 411b. The Smart Interconnection Application of Mobile Phone A identifies the Quality of Service (QoS) information of the screen sharing service.

[0166] The QoS information for a service (e.g., screen sharing) may include one or more of the following: expected bandwidth, latency, jitter, priority, etc. For example, a screen sharing service can be a high-bandwidth service. For instance, the expected bandwidth of a screen sharing service may be greater than a preset bandwidth (e.g., 40MB / s). Alternatively, a screen sharing service can be a low-latency service. For instance, the latency requirement for a screen sharing service is less than 20ms.

[0167] 412. The Smart Interconnection application of mobile phone A initiates a connection call to the MagicLink application module of mobile phone A.

[0168] The smart interconnection application on mobile phone A can call the device connection interface of the MagicLink application module to pass in the QoS information of the screen sharing service.

[0169] 413a. The MagicLink application module of mobile phone A and the MagicLink application module of tablet computer B establish a negotiation channel (channel 1).

[0170] When the MagicLink application module of mobile phone A receives a connection call from the smart interconnection application, it can save the QoS information of the screen sharing service. Furthermore, the MagicLink application module of mobile phone A can create a negotiation channel (channel 1) with the peer device (tablet B). For example, as shown... Figure 5CAs shown, channel 1 is used for information exchange between MagicLink application modules of different devices (MagicLink application module of mobile phone A and MagicLink application module of tablet computer B).

[0171] The MagicLink application module on phone A can create Channel 1 based on the discovery and network type between phone A and tablet B, regardless of the network connection type. For example, if the discovery and network type between phone A and tablet B is a WiFi LAN, Channel 1 can be created based on the WiFi connection; if the discovery and network type between phone A and tablet B is a Bluetooth network, Channel 1 can be created based on the Bluetooth connection.

[0172] Furthermore, after Channel 1 is successfully created, the MagicLink application module of mobile phone A and the MagicLink application module of tablet B can perform device security authentication and key exchange based on Channel 1, thereby completing the creation of the encrypted negotiation channel (i.e., encrypted Channel 1).

[0173] It should be understood that a Bluetooth connection or a WiFi connection refers to a physical channel (also called a physical link) used for data transmission between two communicating parties (e.g., mobile phone A and tablet B). Multiple virtual channels (also called data links) can be created based on the same physical channel. Virtual channels have the function of exchanging information between specific modules using predefined data processing protocols. For example, channel 1 is a virtual channel that can be used for information exchange between MagicLink application modules on different devices.

[0174] For example, the data processing protocol of the negotiation channel (i.e., channel 1) can be a first data processing protocol, which can be used to process (encapsulate or parse) data packets in key+value format. That is, the data packets corresponding to the first data processing protocol are in key+value format. Key+value format data packets are easy to parse, but they carry redundant payload (key) when sending data, consuming additional bandwidth. Furthermore, key+value format data packets require complete parsing during forwarding (e.g., data needs to be parsed into key+value format), making data transmission inefficient.

[0175] For example, the format of the data packets for the negotiation channel (i.e., channel 1) can be as shown in Table 1:

[0176] Table 1

[0177] key IP TCP port value XX XX

[0178] Among them, IP and TCP ports refer to the IP and TCP ports used by the local device (phone A) to establish a WiFi P2P connection.

[0179] 413b. The MagicLink application module of mobile phone A and the MagicLink application module of tablet computer B create an auxiliary channel (channel 2).

[0180] The MagicLink application module on phone A can also create an auxiliary channel (channel 2) to the other device (tablet B). Channel 2 is a virtual channel. For example, ... Figure 5C As shown, channel 2 can be used for communication (information exchange) between WiFi link modules of different devices (WiFi link module of mobile phone A and WiFi link module of tablet B). When WiFi link modules of different devices exchange information based on channel 2, the information can be forwarded through the respective MagicLink application modules of each device.

[0181] The MagicLink application module on phone A can create Channel 2 based on the discovery and network type between phone A and tablet B, regardless of the network connection type. For example, if the discovery and network type between phone A and tablet B is a WiFi LAN, Channel 2 can be created based on the WiFi connection; if the discovery and network type between phone A and tablet B is a Bluetooth network, Channel 2 can be created based on the Bluetooth connection.

[0182] Furthermore, after Channel 2 is successfully created, the MagicLink application modules of mobile phone A and tablet B can perform device security authentication and key exchange based on Channel 2. Thus, the encrypted auxiliary channel (i.e., encrypted Channel 2) is created.

[0183] For example, the data processing protocol for the auxiliary channel (i.e., channel 2) can be a second data processing protocol, which can be used to process (encapsulate or parse) TLV format data packets. That is, the data packets corresponding to the second data processing protocol are in TLV format. In TLV, T stands for dataType (or simply Type), indicating the type of the receiving module corresponding to the data; V represents the actual value carried in the data packet; and L represents the length of the actual value. The lengths of T and L can be fixed, for example, 2 bytes or 4 bytes, and the length of V is determined based on L.

[0184] It should be noted that when WiFi link modules of different devices exchange information via Channel 2, the data can be forwarded through the respective MagicLink application modules of each device. Since the data packets corresponding to the data processing protocol of Channel 2 are in TLV format, the MagicLink application module does not need to parse the WiFi link module's data (e.g., it does not need to parse the WiFi link module's data into a key+value structure) when forwarding it; it can directly transmit the WiFi link module's data, thus improving transmission efficiency. Furthermore, compared to the JSON protocol, using the TLV protocol to send data does not require carrying redundant and invalid payloads (e.g., key fields), resulting in better transmission efficiency and scalability.

[0185] For example, the format of data packets for the auxiliary channel (i.e., channel 2) can be as shown in Table 2:

[0186] Table 2

[0187] dataType length value 0 XX XXXXX

[0188] For example, a dataType field of 0 can indicate that the receiving module corresponding to the data (i.e., the value) is the WiFi link module of the other end.

[0189] Optionally, the data packets of the secondary channel (i.e., channel 2) may also include encryption / decryption fields (e.g., AuthDataHead) to indicate the encryption / decryption type of the data packets of the secondary channel (i.e., channel 2).

[0190] In one possible implementation, the auxiliary channel (i.e., channel 2) can simultaneously provide negotiation capabilities for the MagicLink application module and the WiFi link module of different devices, meaning it can be used simultaneously for data interaction between the MagicLink application module and the WiFi link module of different devices. Thus, a single transmission based on the auxiliary channel (i.e., channel 2) can simultaneously meet the data interaction needs of the MagicLink application module and the WiFi link module. For example, the data packet format of the auxiliary channel (i.e., channel 2) can be as shown in Table 3:

[0191] Table 3

[0192] dataType 1 Length 1 value 1 dataType 2 Length 2 value 2 1 XX XX 0 XX XX

[0193] In this context, the dataType 1 field being 1 indicates that the receiving module corresponding to the data (value 1) is the Magiclink application module of the other end, and Length 1 indicates the length of value 1; the dataType 2 field being 0 indicates that the receiving module corresponding to the data (i.e., value 2) is the WiFi link module of the other end, and Length 2 indicates the length of value 2.

[0194] 414a. The MagicLink application module of mobile phone A saves channel 1 and channel 2.

[0195] 414b. The MagicLink application module of tablet B saves channel 1 and channel 2.

[0196] 415a. The MagicLink application module of mobile phone A registers channel 2 with the WiFi link module of mobile phone A.

[0197] The MagicLink application module of mobile phone A can send a registration request to the WiFi link module. The registration request can carry the configuration information of channel 2 (e.g., channel name, channel data processing protocol). The WiFi link module of mobile phone A can save the configuration information of channel 2 for later use.

[0198] 415b. The MagicLink application module of tablet B registers channel 2 with the WiFi link module of tablet B.

[0199] The MagicLink application module of tablet B can send a registration request to the WiFi link module. The registration request can carry the configuration information of channel 2 (e.g., channel name, channel data processing protocol). The WiFi link module of tablet B can save the configuration information of channel 2 for later use.

[0200] 416. The MagicLink application module of mobile phone A initiates a connection call to the WiFi link module of mobile phone A.

[0201] That is, the MagicLink application module of mobile phone A can transmit the following information to the WiFi link module of mobile phone A: QoS information of screen sharing service and WiFi basic parameters of the peer device (tablet B).

[0202] 417. The WiFi link module of mobile phone A generates data packet 1.

[0203] In some embodiments, the WiFi link module of mobile phone A can receive information from the MagicLink application module of mobile phone A and perform the following processing: 1. Collect the latest WiFi capability information of the local device (for example, the WiFi link module of mobile phone A can call the query interface of the WiFi driver to query the WiFi capability information, and the WiFi driver can return the WiFi capability information based on the current hardware capabilities (number, model, etc. of WiFi network cards) and resource usage (usage status of WiFi network cards); 2. Generate data packet 1 based on the collected WiFi capability information and the QoS information of the screen sharing service. That is, data packet 1 includes the latest WiFi capability information of the local device and the QoS information of the screen sharing service. Data packet 1 is used to negotiate WiFi P2P connection configuration information with the peer.

[0204] The WiFi capability information can include static capability information (basically fixed information), which includes the number of WiFi network cards supported by the device, WiFi network card identifier, WiFi network card model, available WiFi channels, and other information.

[0205] Furthermore, WiFi capability information can also include dynamic capability information (dynamically changing information, also known as WiFi occupancy status information). Dynamic capability information can include information about WiFi connections that the device (or network card) has established (e.g., the number of established WiFi connections and the status of established WiFi connections (e.g., the P2P role of the two-end devices in the WiFi connection, network card information, etc.)).

[0206] In other embodiments, the WiFi link layer module can make a preliminary judgment based on the currently acquired information (the WiFi basic parameters of both devices and the QoS information of the service). If it is determined that the WiFi capabilities of the two devices (mainly the capabilities indicated by static capability information) cannot meet the service requirements, there is no need to establish a negotiation channel or initiate a negotiation process, avoiding unnecessary negotiation and saving negotiation resources. Furthermore, the WiFi link layer module can notify the smart interconnection application of screen sharing failure through the MagicLink application module, and the smart interconnection application can prompt the user that screen sharing has failed. If it is determined that the WiFi basic parameters of both devices can meet the service requirements, the latest WiFi capability information of the local device can be collected (mainly the latest dynamic capability information; static capability information is usually fixed and does not need to be collected repeatedly), and data packet 1 can be generated based on the collected WiFi capability information and the QoS information of the screen sharing service.

[0207] For example, after receiving a connection call initiated by the MagicLink application module, the WiFi link layer module can parse the bandwidth requirement of the service (e.g., screen sharing service) and determine the type of physical connection corresponding to the service based on the bandwidth requirement. For instance, if the bandwidth requirement of the service (e.g., screen sharing service) is high bandwidth (e.g., expected bandwidth greater than 40MB / s), the physical connection type can be a 5GHz WiFi P2P connection. If the bandwidth requirement of the service is medium bandwidth (e.g., expected bandwidth greater than 10MB / s and less than 40MB / s), the physical connection type can be a 2.4GHz WiFi P2P connection. If the bandwidth requirement of the service is low bandwidth (e.g., expected bandwidth less than 10MB / s), the physical connection type can be a Bluetooth connection.

[0208] If a service (e.g., screen sharing) requires high bandwidth, and the physical connection type can be a 5GHz WiFi P2P connection, but one end device does not support 5GHz WiFi P2P connections (meaning one end device's capabilities cannot meet the service requirements), then there is no need to establish a negotiation channel or initiate a negotiation process, avoiding unnecessary negotiation and saving negotiation resources. Furthermore, the WiFi link layer module can notify the smart interconnection application of screen sharing failure through the MagicLink application module, and the smart interconnection application can then notify the user of the screen sharing failure.

[0209] 418a. The WiFi link module of mobile phone A calls channel 2 and sends data packet 1.

[0210] That is, the WiFi link module of mobile phone A calls channel 2 registered by the MagicLink application module and sends data packet 1 to the MagicLink application module of mobile phone A.

[0211] 418b. The MagicLink application module of mobile phone A encapsulates data packet 1 into data packet 2 according to the communication protocol of channel 2.

[0212] The MagicLink application module of mobile phone A can add a MagicLink header to data packet 1 to obtain data packet 2.

[0213] The MagicLink header can include the data type and the data length.

[0214] For example, the format of data packet 2 can be as shown in Table 4:

[0215] Table 4

[0216] dataType length value 0 5 01 02 03 04 05

[0217] The dataType field is 0, which indicates that the receiving module corresponding to the data (value) is the WiFi link module of the other end. Length indicates the length of the value (e.g., 5 bytes). The value indicates the data packet 1 generated by the WiFi link module of mobile phone A (e.g., 01 02 03 04 05).

[0218] 418c. The MagicLink application module of mobile phone A sends data packet 2 through channel 2.

[0219] 419. The MagicLink application module of tablet B receives data packet 2 from channel 2 and parses data packet 2 to obtain data packet 1 according to the communication protocol of channel 2.

[0220] The MagicLink application module of tablet B can strip the MagicLink header from data packet 2 to obtain data packet 1.

[0221] 420. The MagicLink application module of tablet B sends data packet 1 to the WiFi link module of tablet B.

[0222] 421a. The WiFi link module of tablet B parses data packet 1 to obtain the WiFi capability information and QoS information of the initiating device (i.e., mobile phone A).

[0223] Furthermore, the WiFi link module of tablet B can obtain the WiFi capability information of the local device (i.e., tablet B).

[0224] like Figure 4B As shown, the method also includes:

[0225] 421b. The WiFi link module of tablet B makes a decision based on the information carried in data packet 1 and the WiFi capability information of tablet B, and generates data packet 3 based on the decision result.

[0226] That is, the WiFi link module of tablet B can make decisions based on the WiFi capability information of both devices and the QoS information of services (e.g., screen sharing services), and then generate data packets 3 based on the decision results.

[0227] In some embodiments, when the QoS information of the service meets the first condition, if tablet B and mobile phone A support WiFi P2P connection on the 5G band, then tablet B and mobile phone A can establish a WiFi P2P connection on the 5G band. Tablet B can then generate corresponding WiFi P2P connection configuration information. Data packet 3 includes WiFi P2P connection configuration information. This WiFi P2P connection configuration information may include the roles (GO and GC) of P2P communication, the network card used for P2P communication, the channel (e.g., a 5G channel), antenna information, etc.

[0228] Optionally, it can be determined whether tablet B supports 5G band WiFi P2P connections based on the tablet B's WiFi capability information. For example, if tablet B includes an idle network card that supports the 5G band, then tablet B is considered to support 5G band WiFi P2P connections. Similarly, it can be determined whether mobile phone A supports 5G band WiFi P2P connections based on the mobile phone A's WiFi capability information. For example, if mobile phone A includes an idle network card that supports the 5G band, then mobile phone A is considered to support 5G band WiFi P2P connections.

[0229] In some embodiments, when tablet B's P2P role is GO (i.e., tablet B's P2P role is GO in an established WiFi P2P connection (e.g., tablet B and mobile phone C establish a WiFi P2P connection), and the network card used by tablet B to establish the WiFi P2P connection supports the 5G band; and mobile phone A has an idle network card, tablet B can reuse the GO to establish a WiFi P2P connection with mobile phone A. That is, tablet B continues to act as GO, connecting to mobile phone A, which acts as GC. In other words, as GO, tablet B can connect not only to mobile phone C, which acts as GC, but also to mobile phone A, which also acts as GC. In this way, tablet B's reuse of the GO to establish a WiFi P2P connection with mobile phone A expands the connected devices of tablet B and saves network card resources.

[0230] For example, the first condition may include: the QoS information of the service indicates that the expected bandwidth of the service is greater than a first threshold (e.g., 40 MB / s). Optionally, the first condition may also include: the expected latency of the service is less than a second threshold (e.g., 20 ms) and / or the jitter of the service is less than a third threshold (e.g., 5 ms).

[0231] In some embodiments, when the QoS information of the service meets the first condition, if tablet B or mobile phone A does not support WiFi P2P connection on the 5G band, tablet B can return a decision result to mobile phone A. The decision result is used to instruct the establishment of a bridge.

[0232] In some embodiments, when the QoS information of the service meets the second condition, if tablet B and mobile phone A support WiFi P2P connection on the 5G band, then tablet B and mobile phone A can establish a WiFi P2P connection on the 5G band. If tablet B and mobile phone A do not support WiFi P2P connection on the 5G band, but support WiFi P2P connection on the 2.4G band, then tablet B and mobile phone A can establish a WiFi P2P connection on the 2.4G band. Tablet B can generate corresponding WiFi P2P connection configuration information, which may include the P2P communication role (GO and GC), the network card used for P2P communication, the channel (5G channel / 2.4G channel), antenna, and other information.

[0233] For example, the second condition may include: the QoS information of the service indicates that the expected bandwidth of the service is less than or equal to a first threshold (e.g., 40 MB / s). Optionally, the first condition may also include: the expected latency of the service is greater than or equal to a second threshold (e.g., 20 ms) and / or the jitter of the service is greater than or equal to a third threshold (e.g., 5 ms).

[0234] In this embodiment, the connection method (WiFi P2P connection or bridging) between the local device and the peer device can be determined based on the QoS information of the service and the WiFi capability information of the device. This can better meet the service requirements and avoid problems such as stuttering and frame drops in the service (e.g., screen sharing service).

[0235] In some embodiments, the WiFi link module determines the P2P network card (the network card used for P2P communication) in the WiFi P2P connection configuration information by selecting an available, idle network card of the device (e.g., tablet B) to establish a WiFi P2P connection. For example, the WiFi link module can sequentially detect whether the first WiFi network card (e.g., WiFi network card 1) and the second WiFi network card (e.g., WiFi network card 2) are available. If the first WiFi network card is available, it directly uses the first WiFi network card to establish a WiFi P2P connection; if the first WiFi network card is unavailable, it then checks whether the second WiFi network card is available. If the second WiFi network card is available, it uses the second WiFi network card to establish a WiFi P2P connection. Of course, if the device (e.g., tablet B) also includes more WiFi network cards (e.g., a third WiFi network card), it can continue to detect until an available WiFi network card is found.

[0236] In some embodiments, the WiFi link module may decide on the P2P channel and antenna (the antenna used for P2P communication) in the WiFi P2P connection configuration information in the following ways: 1. When the service is high bandwidth (e.g., the expected bandwidth of the service is greater than the preset bandwidth (e.g., 40MB / s)), a 5G band channel is selected to establish a WiFi P2P connection, and the antenna is exclusively used (i.e., one WiFi P2P connection exclusively uses one or more antennas for data transmission); 2. When the service is medium to low bandwidth (e.g., the expected bandwidth of the service is less than the preset bandwidth), a 2.4G band channel is selected to establish a WiFi P2P connection, or a 5G band channel is selected to establish a WiFi P2P connection, and the antenna can be shared (e.g., two WiFi P2P connections can share one or more antennas for data transmission).

[0237] In some embodiments, the WiFi link module may determine the P2P role in the WiFi P2P connection configuration information by designating the device as the GO as having strong WiFi chip capabilities (e.g., WiFi chips can integrate WiFi network cards, and the more WiFi network cards integrated and the newer the WiFi network card model, the stronger the WiFi chip capabilities) and sufficient power (e.g., the device connected to a power source (e.g., a TV) has more power than the device being charged (e.g., a mobile phone or tablet)).

[0238] 422a. The WiFi link module of tablet B calls channel 2 and sends data packet 3.

[0239] The WiFi link module of tablet B can call channel 2 registered by the MagicLink application module of tablet B to send data packet 3 to the MagicLink application module of tablet B.

[0240] 422b. The MagicLink application module of tablet computer B encapsulates data packet 3 into data packet 4 according to the communication protocol of channel 2.

[0241] The MagicLink application module of tablet B adds a MagicLink header to data packet 3, resulting in data packet 4.

[0242] 422c. The MagicLink application module of tablet B sends data packet 4 through channel 2.

[0243] 423a. The MagicLink application module of mobile phone A receives data packet 4 through channel 2 and parses data packet 4 according to the communication protocol of channel 2 to obtain data packet 3.

[0244] The MagicLink application module of mobile phone A can strip the MagicLink header from data packet 4 to obtain data packet 3.

[0245] 423b. The MagicLink application module of mobile phone A sends data packet 3 to the WiFi link module of mobile phone A.

[0246] 424. The WiFi link module of mobile phone A parses data packet 3 to obtain the WiFi P2P connection configuration information decided by the peer device (tablet B), and creates GO based on the WiFi P2P connection configuration information.

[0247] Data packet 3 includes WiFi P2P connection configuration information decided by the peer device (tablet B). For example, the WiFi P2P connection configuration information could be: mobile phone A acts as the GO (Go), tablet B acts as the GC (GC), the P2P channel is established on a 5G channel (e.g., channel 161 at a frequency of 5805MHz), and tablet B's WiFi network card 2 acts as the P2P network card. Mobile phone A can create a GO based on the WiFi P2P connection configuration information.

[0248] Furthermore, after phone A creates the GO, phone A can also perform the following steps:

[0249] 425a. The WiFi link module of mobile phone A sends the IP address and network card name of the local device (GO device) to the MagicLink application module of mobile phone A.

[0250] The IP address and network interface name of the local device (GO device) refer to the IP address and network interface used to create the WiFi P2P connection.

[0251] 425b. After receiving the IP address and network card name, the MagicLink application module of mobile phone A starts listening on the TCP port and encapsulates the local IP address and TCP port into a data packet 5 according to the communication protocol of channel 1.

[0252] That is, the MagicLink application module of mobile phone A can listen to the IP and TCP ports used to establish WiFi P2P connections, and encapsulate the listened local IP and TCP ports into data packets.

[0253] Among them, data packet 5 is used as the transmission channel for establishing a subsequent WiFi P2P connection.

[0254] For example, the format of data packet 5 can be as shown in Table 1 above (step 413a).

[0255] 425c. The MagicLink application module of mobile phone A sends data packet 5 to the MagicLink application module of tablet computer B through channel 1.

[0256] 426a. After receiving data packet 5, the MagicLink application module of tablet computer B parses data packet 5 through the communication protocol of channel 1.

[0257] 426b. The MagicLink application module of tablet B stores the IP and TCP port of the peer (phone A).

[0258] The IP and TCP ports of the peer (phone A) are used to establish a negotiation channel on the P2P platform later.

[0259] 427a. The WiFi link module of mobile phone A encapsulates the connection information of the local device (GO device) into a data packet 6, calls channel 2, and passes in the data packet 6.

[0260] The connection information for the GO device (i.e., the connection information of the device acting as the GO) includes the frequency created by the GO, SSID, password, etc. Data packet 6 is used for the GC and GO to establish a WiFi P2P connection.

[0261] 427b. The MagicLink application module of mobile phone A encapsulates data packet 6 into data packet 7 according to the communication protocol of channel 2.

[0262] The MagicLink application module of mobile phone A adds a MagicLink header to data packet 6, resulting in data packet 7.

[0263] 427c. The MagicLink application module of mobile phone A sends data packet 7 to the MagicLink application module of tablet computer B through channel 2.

[0264] Steps 425a-425c and steps 427a-427c can be executed in parallel.

[0265] 428a. After receiving data packet 7, the MagicLink application module of tablet computer B parses data packet 7 through the communication protocol of channel 2 to obtain data packet 6.

[0266] 428b. The MagicLink application module of tablet B sends data packet 6 to the WiFi link module of tablet B.

[0267] Steps 427a-427b and steps 428a-428b can be executed in parallel.

[0268] In other words, the MagicLink application module of tablet B can receive different data packets through different channels and process them differently.

[0269] 429. The WiFi link module of tablet B parses data packet 6 to obtain the GO connection information of the other end (phone A).

[0270] 430. The WiFi link module of tablet B establishes a WiFi P2P link layer connection with the WiFi link module of mobile phone A based on the GO connection information of the peer (mobile phone A).

[0271] The WiFi link module of tablet B connects to mobile phone A, which acts as GO, based on the GO connection information of the peer (mobile phone A).

[0272] That is, tablet B acts as GC and connects to mobile phone A as GO.

[0273] 431a. The WiFi link module of tablet B sends a WiFi notification message to the MagicLink application module of tablet B. The WiFi notification message is used to notify that the WiFi P2P connection is successful.

[0274] The WiFi notification message includes information related to the WiFi P2P connection, such as the IP address of the local device (tablet B) and the peer device (phone A) used to establish the WiFi P2P connection, the network card name (e.g., phone A corresponds to network card 1, and tablet B corresponds to network card 2), the P2P role (e.g., phone A is GO, and tablet B is GC), and the ID (serviceid) of this WiFi P2P connection.

[0275] 431b. The MagicLink application module of tablet B stores WiFi P2P connections.

[0276] The MagicLink application module of tablet B receives the WiFi notification message sent by the WiFi link module of tablet B, obtains the relevant information of WiFi P2P connection from the WiFi notification message, and saves the relevant information (i.e., saves the WiFi P2P connection).

[0277] 432a. The WiFi link module of mobile phone A sends a WiFi notification message to the MagicLink application module of mobile phone A. The WiFi notification message is used to notify that the WiFi P2P connection is successful.

[0278] 432b. The MagicLink application module of mobile phone A saves WiFi P2P connections.

[0279] Steps 431a-431b and 432a-432b can be executed in parallel. That is, after a successful WiFi connection, the WiFi modules of both devices A and B notify their respective MagicLink application modules that the P2P connection is successful. The MagicLink application modules of each device can save the WiFi P2P connection for subsequent communication based on that connection.

[0280] 433. The MagicLink application module of tablet B creates a TCP encrypted channel based on WiFi P2P connection to the MagicLink application module of mobile phone A.

[0281] The MagicLink application module of tablet B can make logical judgments based on its local P2P role to determine what kind of processing to perform. For example, when the P2P role of tablet B is GC, the MagicLink application module of tablet B can read the IP and port of the peer device (phone A) saved in step 427b, and create a TCP encrypted channel based on WiFi P2P connection to the peer device (phone A) based on the peer device (phone A)'s IP and port.

[0282] Among them, the TCP encrypted channel based on WiFi P2P connection can provide a more secure, stable, high-bandwidth, and low-latency negotiation channel for smart interconnection applications (such as screen sharing services) than the Bluetooth channel, providing a negotiation channel for subsequent link management negotiation of MagicLink application modules. That is, the MagicLink application modules of the two-end devices (e.g., mobile phone A and tablet B) can exchange service (e.g., screen sharing service) data (e.g., screen display information) based on the TCP encrypted channel of WiFi P2P connection.

[0283] Optionally, after the TCP encrypted channel based on the WiFi P2P connection is created, the devices (phone A and tablet B) can delete the previously created channel 1 and / or channel 2 to save storage space.

[0284] 434. The MagicLink application module of mobile phone A replies to the MagicLink application module of tablet computer B that the TCP encrypted channel based on WiFi P2P connection has been created.

[0285] 435a. The MagicLink application module of mobile phone A stores a TCP encrypted channel based on WiFi P2P connection.

[0286] That is, mobile phone A can save the TCP encrypted channel for subsequent interaction with the other end device (tablet B).

[0287] 435b. The MagicLink application module of tablet B stores a TCP encrypted channel based on WiFi P2P connection.

[0288] This means that tablet B can save the TCP encrypted channel for subsequent interaction with the peer device (phone A).

[0289] Steps 435a and 435b can be executed in parallel.

[0290] 436. The MagicLink application module of mobile phone A notifies the smart interconnection application of mobile phone A that the device connection is successful.

[0291] Once the encrypted TCP channel based on WiFi P2P connection is successfully established, the MagicLink application module of mobile phone A notifies the smart interconnection application of mobile phone A that the device connection is successful.

[0292] 437. The Smart Interconnection application on mobile phone A initiates a screen sharing service and notifies the user that the screen sharing service has been successfully established.

[0293] The smart connectivity application on mobile phone A can initiate screen sharing services over a TCP encrypted channel connected via WiFi P2P. This means sending screen sharing data (e.g., information related to mobile phone A's screen) to the other device (tablet B) via WiFi P2P connection.

[0294] Steps 436-437 can be performed after step 432a, step 432b, or step 434.

[0295] The solution provided in this application embodiment allows the WiFi link module to determine the WiFi P2P connection configuration information. Since the WiFi module is capable of obtaining its own WiFi capability information in real time, it can more conveniently and efficiently determine the WiFi P2P connection configuration information based on its own WiFi capability information and the WiFi capability information from the peer, thereby improving the communication quality of WiFi P2P. This eliminates the need for the MagicLink application module to obtain and store its own WiFi capability information from the WiFi link module, saving communication overhead and storage space, and making the WiFi P2P connection process simpler and more efficient.

[0296] In some embodiments, after mobile phone A and tablet B establish a WiFi P2P connection, the transmission performance of the WiFi P2P connection may change, affecting the transmission rate.

[0297] like Figure 6As shown, taking the WiFi P2P connection established between mobile phone A and tablet B (the first WiFi P2P connection) as an example with channel one of the 5G frequency band, the method may also include the following steps:

[0298] 440. Mobile phone A receives a user's command to connect mobile phone A's WiFi to the router.

[0299] For example, mobile phone A's WiFi can connect to channel 2 of the router's 5G frequency band.

[0300] It's important to note that before receiving the user's command to connect phone A's WiFi to the router, phone A and tablet B's WiFi are not yet connected to the router. The WiFi P2P connection established between phone A and tablet B (the first WiFi P2P connection) can be established on the optimal channel (e.g., channel one of the 5GHz band), and phone A and tablet B can operate in single-band single concurrent (SBSC) or dual-band dual concurrent (DBDC) mode, meaning phone A and tablet B operate only on a single frequency band channel, resulting in superior WiFi transmission performance. However, after receiving the user's command to connect phone A's WiFi to the router, phone A's WiFi link module needs to operate on two channels simultaneously. That is, the WiFi P2P connection between phone A and tablet B operates on channel one of the 5GHz band, and phone A's WiFi connects to the router's 5GHz band channel two. Phone A operates in either dual-band adaptive concurrent (DBAC) or dual-band single concurrent (DBSC) mode. This means that although phone A and tablet B support operating on two channels, they can only stably operate on one channel (i.e., single-transmission) for a period of time, resulting in a decrease in WiFi transmission performance.

[0301] 441. In response to the user's operation of connecting mobile phone A's WiFi to the router, the WiFi link module senses the change in WiFi connection status and initiates WiFi P2P channel switching negotiation.

[0302] In response to the user connecting phone A to the router's WiFi, the WiFi link module detects a change in the WiFi connection status. This change in connection status leads to increased WiFi interference, affecting transmission speed. In this situation, the WiFi link module can initiate WiFi P2P channel switching negotiation.

[0303] 442. The WiFi link module of mobile phone A obtains the current channel status information and WiFi capability information of the local machine and generates data packet 10.

[0304] The current channel status information of the device includes the channels supported by the device (phone A), the channels occupied by the established WiFi P2P connection and STA connection, etc.

[0305] 443a. The WiFi link module of mobile phone A calls channel 2 and sends in data packet 10.

[0306] That is, the WiFi link module of mobile phone A calls channel 2 registered by the MagicLink application module to send data packet 10 to the MagicLink application module of mobile phone A.

[0307] 443b. The MagicLink application module of mobile phone A encapsulates data packet 10 into data packet 11 according to the communication protocol of channel 2.

[0308] The MagicLink application module of mobile phone A adds a MagicLink header to data packet 10, resulting in data packet 11.

[0309] 443c. The MagicLink application module of mobile phone A sends data packet 11 through channel 2.

[0310] 444. The MagicLink application module of tablet B receives data packet 11 from channel 2 and parses data packet 11 according to the communication protocol of channel 2 to obtain data packet 10.

[0311] The MagicLink application module of tablet B can strip the MagicLink header from data packet 11 to obtain data packet 10.

[0312] 445. The MagicLink application module of tablet B sends data packet 10 to the WiFi link module of tablet B.

[0313] 446. The WiFi link module of tablet B parses data packet 10 to obtain the channel status information and WiFi capability information of the peer device (mobile phone A).

[0314] 447. The WiFi link module of tablet B combines the WiFi capability information and channel status information of the local end to make a channel switching decision, select the optimal channel, and encapsulate the channel switching decision result into a data packet 12.

[0315] 448a. The WiFi link module of tablet B calls channel 2 and sends in data packet 12.

[0316] The WiFi link module of tablet B calls channel 2 registered by the MagicLink application module of tablet B and sends data packet 12 to the MagicLink application module of tablet B.

[0317] 448b. The MagicLink application module of tablet computer B encapsulates data packet 12 into data packet 13 according to the communication protocol of channel 2.

[0318] The MagicLink application module of tablet B adds a MagicLink header to data packet 12, resulting in data packet 13.

[0319] 448c. The MagicLink application module of tablet B sends data packet 13 through channel 2.

[0320] 449a. The MagicLink application module of mobile phone A receives data packet 13 through channel 2 and parses data packet 13 to obtain data packet 12 according to the communication protocol of channel 2.

[0321] The MagicLink application module of tablet B can strip the MagicLink header from data packet 13 to obtain data packet 12.

[0322] 449b. The MagicLink application module of mobile phone A sends data packet 12 to the WiFi link module of mobile phone A.

[0323] 450. The WiFi link module of mobile phone A parses data packet 12 to obtain the channel switching decision result, and initiates the switching of WiFi P2P channel based on the channel switching decision result.

[0324] 451. The WiFi link module of mobile phone A and the WiFi link module of tablet B switch WiFi P2P channels.

[0325] For example, the WiFi P2P channel between mobile phone A and tablet B can be switched to the same channel (channel two of the 5G band) of the WiFi router connected to mobile phone A. This can reduce interference between devices on the same frequency but different channels.

[0326] like Figure 7A As shown, this application provides a communication method. Taking mobile phone A (second electronic device), tablet computer B (first electronic device), and mobile phone C (third electronic device) as examples, the process of bridging tablet computer B and mobile phone C is described when mobile phone A and tablet computer B have already established a WiFi P2P connection. The method includes:

[0327] 701. Mobile phone A and tablet B establish a WiFi P2P connection.

[0328] The process of establishing a WiFi P2P connection between mobile phone A and tablet B can be found in steps 401-437, and will not be repeated here.

[0329] For example, network card 0 of mobile phone A can establish a WiFi P2P connection with network card 0 of tablet computer B, and mobile phone A can act as GO and tablet computer B can act as GC.

[0330] 702. The smart interconnection application (first application) of tablet B receives network sharing operations initiated by the user.

[0331] A user-initiated network sharing operation could be to share network data with mobile phone C, that is, to share the data traffic of tablet B with mobile phone C.

[0332] The first operation is the user's operation of a target service initiated on tablet B. This embodiment of the application uses the example of the user initiating a network sharing service on tablet B as the first operation. The target service may also include other types of services, such as screen sharing, multi-screen collaboration, and file sharing, and this application does not limit this.

[0333] 703. The smart interconnection application of tablet B identifies QoS information of network sharing services.

[0334] 704. The Smart Connect application of tablet B initiates a connection call to the MagicLink application module of tablet B.

[0335] 705a. The MagicLink application module of tablet B and the MagicLink application module of mobile phone C establish a negotiation channel (channel 1).

[0336] Among them, the MagicLink application module of tablet B can be the first application module; the MagicLink application module of mobile phone C can be the second application module.

[0337] 705b. The MagicLink application module of tablet B and the MagicLink application module of mobile phone C create an auxiliary channel (channel 2).

[0338] Among them, the auxiliary channel (channel 2) can be the first communication channel.

[0339] 706a. The MagicLink application module of tablet B saves channel 1 and channel 2.

[0340] 706b, The MagicLink application module of mobile phone C saves channel 1 and channel 2.

[0341] 707a. The MagicLink application module of tablet B registers channel 2 with the WiFi link module of tablet B.

[0342] Among them, the WiFi link module of tablet B can be the first WiFi module.

[0343] 707b. The MagicLink application module of mobile phone C registers channel 2 with the WiFi link module of mobile phone C.

[0344] Among them, the WiFi link module of mobile phone C can be a second WiFi module.

[0345] 708a. The MagicLink application module of tablet B determines that the other end is a new version device.

[0346] If the peer device is a new version device (i.e., the version of the MagicLink protocol on the peer device is a new version), the MagicLink application module of tablet B can execute steps 708b and 709.

[0347] 708b. The MagicLink application module of tablet B initiates a connection call to the WiFi link module of tablet B.

[0348] Steps 703-708b can be referenced from the descriptions in steps 411b-417. Simply replace mobile phone A with tablet B and tablet B with mobile phone C in steps 411b-417. Further details will not be provided here.

[0349] 709. The WiFi link module of tablet B sends its own WiFi capability information to the WiFi link module of mobile phone C.

[0350] For the specific process, please refer to the description in steps 417-421a regarding mobile phone A sending WiFi capability information to tablet B. Simply replace mobile phone A with tablet B and tablet B with mobile phone C in steps 417-421a. The details will not be elaborated here.

[0351] Optionally, the WiFi link module of tablet B can also send QoS information of network sharing services to the WiFi link module of mobile phone C.

[0352] In this embodiment of the application, the WiFi capability information of tablet B may also include the P2P role of tablet B in the established WiFi P2P connection (the WiFi P2P connection established between mobile phone A and tablet B) (for example, tablet B may act as GC).

[0353] 710a. The WiFi link module of mobile phone C determines whether mobile phone C can establish a WiFi P2P connection with tablet computer B based on the WiFi capability information of tablet computer B and mobile phone C.

[0354] In this embodiment, tablet B has already established a WiFi P2P connection with mobile phone A. Tablet B's P2P role is GC, and the tablet has no available network card. Mobile phone C's P2P role can be the default role (if mobile phone C has not established a WiFi P2P connection, its P2P role can be the default role), and mobile phone C has an available network card.

[0355] If the P2P role of tablet B is GC and the tablet has no available network card, mobile phone C cannot directly establish a WiFi P2P connection with tablet B.

[0356] 710b. If mobile phone C cannot establish a WiFi P2P connection with tablet B, the WiFi link module of mobile phone C decides whether mobile phone C can establish a bridge with the GO device already connected to tablet B based on the WiFi capability information of tablet B and mobile phone C.

[0357] When the P2P role of tablet B is GC and mobile phone C has an idle network card, the decision is made to establish a bridge between mobile phone C and tablet B based on the GO devices already connected to tablet B (i.e., to establish a bridge between mobile phone C, tablet B, and the GO devices already connected to tablet B).

[0358] 710c, The WiFi link module of mobile phone C sends the decision result (to instruct the establishment of a bridge) to the WiFi link module of tablet computer B.

[0359] For example, the decision result (instruction information) can instruct mobile phone C to establish a bridge with tablet B based on the GO device that tablet B is connected to (i.e., establish a bridge between mobile phone C, tablet B, and the GO device that tablet B is connected to).

[0360] For the specific process, please refer to the relevant descriptions in steps 422a-424. Simply replace tablet B with mobile phone C, mobile phone A with tablet B, and data packet 3 with the decision result in steps 422a-424. Further details will not be elaborated here.

[0361] In some embodiments, when the WiFi link module of mobile phone C sends the decision result to the WiFi link module of tablet computer B, it may also carry the WiFi capability information of mobile phone C.

[0362] 710d, the WiFi link module of mobile phone C notifies the MagicLink application module of mobile phone C that it has entered the bridging state.

[0363] The MagicLink application module of 710e and mobile phone C enters the bridging state.

[0364] The MagicLink application module on mobile phone C can wait for tablet B to initiate the bridging process.

[0365] 711a. The WiFi link module of tablet B notifies the MagicLink application module of tablet B to initiate the bridging process.

[0366] 711b. The MagicLink application module of tablet computer B determines that the local machine can bridge with the idle network card of mobile phone C.

[0367] As we know from step 701, tablet B has established a WiFi P2P connection with mobile phone A through its own network card 0. In this WiFi P2P connection, tablet B's P2P role is GC. Furthermore, the device does not have a spare network card. In this case, the device (e.g., tablet B) can establish a bridge with mobile phone C through its own network card 0. That is, mobile phone C can establish a WiFi P2P connection with the GO device (e.g., mobile phone A) of the first WiFi P2P connection stored on the device. Thus, the device (tablet B) can indirectly connect to the peer device (e.g., mobile phone C) based on the GO device (e.g., mobile phone A), i.e., bridging (also called P2P bridging). Furthermore, mobile phone A can forward information between tablet B and mobile phone C.

[0368] 712. The MagicLink application module of tablet B enters the bridging state.

[0369] like Figure 7B As shown, the method also includes:

[0370] 713. The MagicLink application module of tablet B sends the device ID and network card MAC of the GO device to the MagicLink application module of mobile phone C.

[0371] The MagicLink application module of tablet B can send the device ID and network card MAC of the GO device to the MagicLink application module of mobile phone C through channel 1.

[0372] In this context, the network card of the GO device (e.g., mobile phone A) can be the network card that establishes a WiFi P2P connection between the GO device and tablet B (e.g., network card 0 of mobile phone A).

[0373] 714. The MagicLink application module of mobile phone C sends the device ID and network card MAC of the GO device to the WiFi link module of mobile phone C.

[0374] Establish channels 1 and 2 between mobile phone C and mobile phone A. For details, please refer to the descriptions in steps 413a-415b, simply replacing mobile phone A with mobile phone C and tablet B with mobile phone A. Further details will not be elaborated here.

[0375] 715. The WiFi link module of mobile phone C generates WiFi negotiation packet 1, which is used to instruct mobile phone C to act as the network card (e.g., network card 0) of GC to connect to GO device (mobile phone A).

[0376] WiFi negotiation packet 1 may include the P2P role of mobile phone C (e.g., GC) and the MAC address of mobile phone A's network card (e.g., the MAC address of mobile phone A's network card 0).

[0377] 716a. The WiFi link module of mobile phone C calls channel 2 and passes in WiFi negotiation packet 1.

[0378] 716b. The MagicLink application module of mobile phone C adds a bridging field to WiFi negotiation packet 1 to obtain WiFi negotiation packet 2.

[0379] The bridging field indicates that WiFi negotiation packet 1 is a bridging request packet used to establish a bridge.

[0380] 716c, the MagicLink application module of mobile phone C sends WiFi negotiation packet 2 to mobile phone A.

[0381] The MagicLink application module of mobile phone C can send WiFi negotiation packet 2 through channel 2 between mobile phone C and mobile phone A.

[0382] 717. The MagicLink application module of mobile phone A receives WiFi negotiation packet 2 through channel 2 and obtains WiFi negotiation packet 1 by stripping the bridging field.

[0383] 718. The MagicLink application module of mobile phone A enters the bridging state.

[0384] After the MagicLink application module of mobile phone A recognizes the bridging field of WiFi negotiation packet 2, it can enter the bridging state, that is, prepare to establish a bridge with the other end device (e.g., mobile phone C).

[0385] 719. The MagicLink application module of mobile phone A sends WiFi negotiation packet 1 to the WiFi link module of mobile phone A.

[0386] 720. The WiFi link module of mobile phone A parses WiFi negotiation packet 1 and determines that mobile phone C is the network card of GC connecting to mobile phone A.

[0387] 721. The WiFi link module of mobile phone C and the WiFi link module of mobile phone A establish a WiFi P2P connection.

[0388] For the specific process, please refer to the description of establishing a WiFi P2P connection between mobile phone A and tablet B (i.e., steps 425a-430). Simply replace tablet B in steps 425a-430 with mobile phone C (i.e., mobile phone A is the GO device and mobile phone C is the GC device). It will not be elaborated here.

[0389] 722a. The WiFi link module of mobile phone A sends a WiFi notification message to the MagicLink application module of mobile phone A. The WiFi notification message is used to notify that the WiFi P2P connection is successful.

[0390] The MagicLink application module of mobile phone A stores the WiFi P2P connection. Mobile phone A and mobile phone C can also create an encrypted TCP channel based on the WiFi P2P connection. For details, please refer to the description of creating an encrypted TCP channel based on the WiFi P2P connection between mobile phone A and tablet B (i.e., steps 433-435b). Simply replace tablet B with mobile phone C in steps 433-435b; details will not be elaborated here.

[0391] In this embodiment of the application, the MagicLink application module of mobile phone A can save the relevant connection information of mobile phone A. The relevant connection information of mobile phone A may include: WiFi P2P connection 1 (AB,ref=1,p2p0,GO), WiFi P2P connection 2 (AC,ref=0,p2p0,GO), and P2P bridging (CAB,ref=1,p2p0,GO).

[0392] Among them, WiFi P2P connection 1, WiFi P2P connection 2 and P2P bridging can all be established based on the network card 0 (network card name p2p0) of mobile phone A, and the P2P role of mobile phone A in WiFi P2P connection 1, WiFi P2P connection 2 and P2P bridging can all be GO.

[0393] The WiFi link module of mobile phone A can store relevant physical link information for mobile phone A. This information may include WiFi P2P physical link 1 (AB) and WiFi P2P physical link 2 (AC). For a more detailed description, please refer to the section above. Figure 3C and Figure 3D The description of that will not be repeated here.

[0394] 722b. The WiFi link module of mobile phone C sends a WiFi notification message to the MagicLink application module of mobile phone C. The WiFi notification message is used to notify that the WiFi P2P connection is successful.

[0395] For example, network card 0 of mobile phone A can establish a WiFi P2P connection with network card 0 of mobile phone C. In this WiFi P2P connection, mobile phone A can act as a GO device (GO end), and mobile phone C can act as a GC (GC end).

[0396] It should be noted that the purpose of establishing a WiFi P2P connection between phone A and phone C is to bridge tablet B and phone C through phone A. Phone A, tablet B, and phone C can be considered as forming a P2P bridging connection (or simply a bridging connection). The P2P roles of each device in this P2P bridging connection are as follows: phone A - GO (i.e., phone A acts as the GO device); tablet B - GC (i.e., tablet B acts as the GC device); and phone C - GC (i.e., phone C acts as the GC device).

[0397] Mobile phone A and mobile phone C can each store the role information of the P2P bridging connection (e.g., mobile phone A-G0; tablet B-GC; mobile phone C-GC).

[0398] In this embodiment, the MagicLink application module of mobile phone C can store relevant connection information of mobile phone C. This connection information may include: WiFi P2P connection 2 (AC,ref=0,p2p0,GC) and P2P bridge (CAB,ref=1,p2p0,GC). Both WiFi P2P connection 2 and P2P bridge can be established based on network card 0 (network card name p2p0) of mobile phone C, and the P2P role of mobile phone C in both WiFi P2P connection 2 and P2P bridge can be GC.

[0399] The WiFi link module of phone C can store relevant physical link information of phone C, which may include WiFi P2P physical link 2 (AC). For a related description, please refer to the above section. Figure 3C and Figure 3D The description of that will not be repeated here.

[0400] 723. The MagicLink application module of mobile phone C notifies the MagicLink application module of tablet computer B that the bridging is successful.

[0401] That is, the MagicLink application module of mobile phone C sends a connection success message to the MagicLink application module of tablet computer B. The connection success message is used to indicate that the second WiFi P2P connection between the third electronic device and the second electronic device has been successfully established.

[0402] In this embodiment, the MagicLink application module of tablet B can store relevant connection information of tablet B. This connection information may include: WiFi P2P connection 1 (AB, ref = 1, p2p0, GC) and P2P bridge (CAB, ref = 1, p2p0, GC). WiFi P2P connection 1 and P2P bridge can be established based on the network interface card 0 (NIC 0, named p2p0) of tablet B, and the P2P role of tablet B in both WiFi P2P connection 1 and P2P bridge can be GC.

[0403] The WiFi link module of tablet B can store relevant physical link information of tablet B, which may include WiFi P2P physical link 1 (AB). For a related description, please refer to the above section. Figure 3C and Figure 3D The description of that will not be repeated here.

[0404] 724. The MagicLink application module of tablet B notifies the Smart Connect application of tablet B that the device connection is successful.

[0405] Once the encrypted TCP channel based on the WiFi P2P connection is successfully established, the MagicLink application module of tablet B notifies the smart interconnection application of tablet B that the device connection is successful.

[0406] 725. The Smart Interconnection application of Tablet B prompts the user that the screen sharing service has been successfully established.

[0407] Furthermore, the smart connectivity application of tablet B can initiate screen sharing services over a TCP encrypted channel connected via WiFi P2P. This means sending screen sharing data (e.g., information related to the screen of mobile phone A) to the peer device (tablet B) via WiFi P2P connection.

[0408] 726. Screen sharing information interaction between the smart interconnection application of tablet B and the smart interconnection application of mobile phone C.

[0409] Tablet B can exchange information via screen sharing between mobile phone A and mobile phone C. In other words, mobile phone A can act as a relay device, forwarding the information that needs to be exchanged between tablet B and mobile phone C.

[0410] Based on the communication method provided in this application, negotiation can be conducted based on the WiFi capability information of both devices (e.g., the number of idle network cards, P2P roles, etc.). For example, when the network card resources of the local device (e.g., tablet B) are insufficient (e.g., no idle network card), a connection can be established with the destination device (e.g., mobile phone C) through bridging, expanding the connection methods between the local device and the destination device. This enables communication between the local device and more devices using WiFi P2P technology, better meeting user needs and improving user experience. It supports communication between the local device and more devices using WiFi P2P technology, better meeting user needs and improving user experience.

[0411] Among them, the electronic devices (first electronic device, second electronic device or third electronic device) can respectively store the established WiFi P2P connection and the connection information corresponding to the bridging. The connection information corresponding to different services can be associated with each other, and the connection information corresponding to the services is associated with the link information, so that different services can reuse the same physical link without having to repeatedly establish physical links for different services, which can improve the communication performance of the first electronic device.

[0412] The following explains the process of disconnecting the WiFi P2P connection between mobile phone A and tablet B, and the process of disconnecting the bridge connection between mobile phone A, tablet B, and mobile phone C. Figure 8 As shown, the method includes:

[0413] 730. Mobile phone A and tablet B disconnect from WiFi P2P connection 1.

[0414] When service 1 (the first service, for example, screen sharing service) between mobile phone A and tablet B ends, the reference count (ref) of the connection information corresponding to service 1 (for example, WiFi P2P connection 1 (AB,ref=1,p2p0,GO)) is refreshed, and mobile phone A and tablet B disconnect the WiFi P2P connection 1 saved by the MagicLink application module in the application layer.

[0415] For example, before mobile phone A disconnects from tablet B via WiFi P2P connection 1, the relevant connection information stored in mobile phone A's MagicLink application module may include: WiFi P2P connection 1 (AB,ref=1,p2p0,GO), WiFi P2P connection 2 (AC,ref=0,p2p0,GO), and P2P bridging (CAB,ref=1,p2p0,GO). The relevant physical link information stored in mobile phone A's WiFi link module may include WiFi P2P physical link 1 (AB) and WiFi P2P physical link 2 (AC). The relevant connection information stored in tablet B's MagicLink application module may include: WiFi P2P connection 1 (AB,ref=1,p2p0,GC) and P2P bridging (CAB,ref=1,p2p0,GC). The relevant physical link information stored in tablet B's WiFi link module may include WiFi P2P physical link 1 (AB). The connection information stored in the MagicLink application module of phone C may include: WiFi P2P connection 2 (AC,ref=0,p2p0,GC) and P2P bridging (CAB,ref=1,p2p0,GC). The physical link information stored in the WiFi link module of phone C may include WiFi P2P physical link 2 (AC).

[0416] In this embodiment of the application, when the WiFi P2P connection corresponding to the service is disconnected, the MagicLink application module can decrement the reference count (ref) of the WiFi P2P connection or P2P bridge corresponding to the service by 1.

[0417] For example, if WiFi P2P connection 1 corresponding to service 1 is disconnected, the MagicLink application module of mobile phone A can decrement the ref in WiFi P2P connection 1 (AB,ref=1,p2p0,GO) corresponding to service 1 by 1; the MagicLink application module of tablet B can decrement the ref in WiFi P2P connection 1 (AB,ref=1,p2p0,GC) corresponding to service 1 by 1.

[0418] When the ref of a WiFi P2P connection stored in the MagicLink application module of device (phone A or tablet B) is 0, and the ref of the P2P bridge associated with that WiFi P2P connection is also 0, the device's WiFi link module can disconnect the WiFi P2P physical link corresponding to that WiFi P2P connection. Otherwise, the device's WiFi link module will not disconnect (maintain) the WiFi P2P physical link corresponding to that WiFi P2P connection.

[0419] For example, when the reference count (ref) of WiFi P2P connection 1 is 0, and the reference count (ref) of the P2P bridge associated with WiFi P2P connection 1 is also 0, the devices (phone A and tablet B) can disconnect WiFi P2P physical link 1 corresponding to WiFi P2P connection 1; otherwise, the WiFi P2P physical link 1 is maintained.

[0420] In this embodiment of the application, when the WiFi P2P connection 1 corresponding to service 1 is disconnected, the reference count (ref) of WiFi P2P connection 1 is 0. However, the reference count (ref) of the P2P bridge associated with WiFi P2P connection 1 is not 0. Therefore, there is no need to disconnect the WiFi P2P physical link 1 corresponding to WiFi P2P connection 1.

[0421] 731. Mobile phone A, tablet B and mobile phone C disconnect from P2P bridging.

[0422] When Service 2 (second service, e.g., network sharing service) between mobile phone A and mobile phone C ends, refresh the reference count (ref) of the connection information corresponding to Service 2 (e.g., P2P bridge (CAB,ref=1,p2p0,GC)), and disconnect the P2P bridge saved by the MagicLink application module of the application layer between mobile phone A and tablet computer B.

[0423] After the P2P bridge between mobile phone A, tablet B and mobile phone C is disconnected, the ref in the P2P bridge (CAB,ref=1,p2p0,GO) saved by the MagicLink application module of mobile phone A is reduced by 1; the ref in the P2P bridge (CAB,ref=1,p2p0,GC) saved by the MagicLink application modules of tablet B and mobile phone C is reduced by 1, that is, the ref is 0.

[0424] If the ref of the P2P bridge stored in the MagicLink application module of a device (phone A, tablet B, or phone C) is 0, and the ref of the WiFi P2P connection (WiFi P2P connection 1 and / or WiFi P2P connection 2) associated with the P2P bridge is also 0, the MagicLink application module can clear the P2P bridge and the WiFi P2P connection associated with it. Furthermore, the MagicLink application module can send a request to the WiFi link module to disconnect the WiFi P2P physical link corresponding to the respective WiFi P2P connection. Based on the request sent by the MagicLink application module, the WiFi link module can disconnect the corresponding WiFi P2P physical link.

[0425] like Figure 8As shown, for mobile phone A, after mobile phone A, tablet B, and mobile phone C disconnect from the P2P bridge, the ref in the P2P bridge (CAB,ref=1,p2p0,GO) saved by the MagicLink application module of mobile phone A is 0, and the ref in WiFi P2P connection 1 (AB,ref=0,p2p0,GO) and WiFi P2P connection 2 (AC,ref=0,p2p0,GO) associated with the P2P bridge is also 0. In this case, the MagicLink application module of mobile phone A can send a request to the WiFi link module to disconnect WiFi P2P physical link 1 corresponding to WiFi P2P connection 1, and a request to disconnect WiFi P2P physical link 2 corresponding to WiFi P2P connection 2. The WiFi link module can disconnect WiFi P2P physical link 1 and WiFi P2P physical link 2.

[0426] For tablet B, after the P2P bridging between phone A, tablet B, and phone C is disconnected, the ref in the P2P bridging (CAB,ref=1,p2p0,GO) stored in tablet B's MagicLink application module is 0, and the ref in the WiFi P2P connection 1 associated with the P2P bridging (AB,ref=0,p2p0,GO) is also 0. In this case, tablet B's MagicLink application module can send a request to the WiFi link module to disconnect the WiFi P2P physical link 1 corresponding to WiFi P2P connection 1. The WiFi link module can then disconnect the WiFi P2P physical link 1.

[0427] For phone C, after phone A, tablet B, and phone C disconnect from the P2P bridge, the ref value in the P2P bridge (CAB,ref=1,p2p0,GO) stored in phone C's MagicLink application module is 0, and the ref value in the WiFi P2P connection 2 (AC,ref=0,p2p0,GO) associated with the P2P bridge is also 0. In this case, phone C's MagicLink application module can send a request to the WiFi link module to disconnect the WiFi P2P physical link 2 corresponding to WiFi P2P connection 2. The WiFi link module can then disconnect the WiFi P2P physical link 2.

[0428] Based on the method provided in this application, the number of services corresponding to each connection (WiFi P2P connection and bridging) can be managed based on reference counting, ensuring normal connection and secure disconnection of WiFi P2P connections and bridging. For example, when the first service ends, the first reference count in the first connection information corresponding to the first service can be decremented by 1. If the first reference count is 0, but the second reference count is not 0, then there is no need to disconnect the WiFi P2P physical link corresponding to the first WiFi P2P connection. This is because the first connection information and the second connection information are related; that is, the bridging corresponding to the second connection information depends on the WiFi P2P physical link associated with the first connection information. Therefore, there is no need to disconnect the WiFi P2P physical link corresponding to the first WiFi P2P connection, ensuring the normal connection of the bridging and thus ensuring the normal operation of the service corresponding to the bridging. Furthermore, when the second service ends, the second reference count in the second connection information corresponding to the second service can be decremented by 1. If both the first and second reference counts are 0, then the WiFi P2P physical link corresponding to the first WiFi P2P connection can be disconnected. That is, the number of services corresponding to the first WiFi P2P connection corresponding to the first connection information is 0, and the number of services corresponding to the bridge corresponding to the second connection information is 0. In other words, no service needs to rely on the first WiFi P2P connection and the bridge. Therefore, the WiFi P2P physical link reused by the first WiFi P2P connection and the bridge (i.e. the WiFi P2P physical link associated with the first connection information) can be disconnected, which can save the communication resources and power consumption of the first electronic device.

[0429] One embodiment of this application provides a chip system, such as... Figure 9 As shown, the chip system includes at least one processor 901 and at least one interface circuit 902. The processor 901 and the interface circuit 902 are interconnected via lines. For example, the interface circuit 902 can be used to receive signals from other devices (e.g., the memory of a first electronic device (e.g., tablet B) or the memory of a second electronic device (e.g., mobile phone A)). As another example, the interface circuit 902 can be used to send signals to other devices (e.g., the processor 901).

[0430] For example, interface circuit 902 can read instructions stored in the memory of the device and send the instructions to processor 901. When the instructions are executed by processor 901, a first electronic device (e.g., tablet B), a second electronic device (e.g., mobile phone A), or a third electronic device (e.g., mobile phone C) can perform the steps in the above embodiments.

[0431] Of course, the chip system may also include other discrete components, and this application embodiment does not specifically limit this.

[0432] Some embodiments of this application provide a first electronic device, which may include a communication module, a memory, and one or more processors. The communication module and the memory are coupled to the processors. The memory is used to store computer program code, which includes computer instructions.

[0433] Some embodiments of this application provide a second electronic device, which may include a communication module, a memory, and one or more processors. The communication module and the memory are coupled to the processors. The memory is used to store computer program code, which includes computer instructions.

[0434] Some embodiments of this application provide a third electronic device, which may include a communication module, a memory, and one or more processors. The communication module and the memory are coupled to the processors. The memory is used to store computer program code, which includes computer instructions.

[0435] This application also provides a computer-readable storage medium, which includes computer instructions, and the computer instructions are used in a first electronic device (such as...) Figure 2A When the computer instructions are executed on the second electronic device (e.g., tablet computer B), the electronic device 100 performs the various functions or steps performed by the first electronic device (e.g., tablet computer B) in the above method embodiment. Figure 2A When the computer instructions are executed on the electronic device 100 shown, the electronic device 100 performs the various functions or steps performed by the second electronic device (e.g., mobile phone A) in the above method embodiment. When the computer instructions are executed on the third electronic device (e.g., Figure 2A When the electronic device 100 shown is run, it causes the electronic device 100 to perform the various functions or steps performed by the third electronic device (e.g., mobile phone C) in the above method embodiment.

[0436] This application also provides a computer program product that, when run on a computer, causes the computer to perform various functions or steps performed by the first electronic device (e.g., tablet B), the second electronic device (e.g., mobile phone A), or the third electronic device (e.g., mobile phone C) in the above method embodiments.

[0437] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0438] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0439] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0440] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0441] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0442] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A communication method, characterized in that, Applied to a first electronic device, the method includes: In response to the user's initiation of the first service, the first electronic device establishes a first WiFi P2P connection with the second electronic device; The first electronic device stores first connection information and first link information; the first connection information includes the identifier of the first electronic device and the identifier of the second electronic device; the first link information is used to indicate the WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information and the first link information are associated. In response to a user initiating a second service, the first electronic device establishes a connection with the third electronic device based on the second electronic device; the second service is different from the first service. The first electronic device stores second connection information; the second connection information includes the identifier of the first electronic device, the identifier of the second electronic device, and the identifier of the third electronic device; the second connection information is associated with the first connection information.

2. The method according to claim 1, characterized in that, The first connection information also includes a first reference count, which is used to indicate the number of services corresponding to the first WiFiP2P connection; The second connection information also includes a second reference count, which indicates the number of services corresponding to the connection between the first electronic device and the third electronic device.

3. The method according to claim 2, characterized in that, The method further includes: In response to the termination of the first service, the first reference count in the first connection information is decremented by 1; If the first reference count in the first connection information is 0, and the second reference count in the second connection information associated with the first connection information is not 0, the WiFi P2P physical link corresponding to the first WiFi P2P connection is maintained.

4. The method according to claim 3, characterized in that, In response to the termination of the second service, the second reference count in the second connection information is decremented by 1; If the first reference count in the first connection information is 0, and the second reference count in the second connection information associated with the first connection information is 0, disconnect the WiFi P2P physical link corresponding to the first WiFi P2P connection.

5. The method according to any one of claims 1-4, characterized in that, The first connection information also includes the network card name corresponding to the first WiFi P2P connection, and at least one of the P2P roles played by the first electronic device in the first WiFi P2P connection; The second connection information also includes the network card name corresponding to the connection between the first electronic device and the third electronic device, and at least one of the P2P roles played by the first electronic device in the connection between the first electronic device and the third electronic device.

6. The method according to claim 1, characterized in that, The first electronic device establishes a connection with the third electronic device through the second electronic device, including: The first electronic device sends the device identifier and network card information of the second electronic device to the third electronic device; The first electronic device receives a connection success message from the third electronic device, the connection success message indicating that a second WiFi P2P connection has been successfully established between the third electronic device and the second electronic device.

7. The method according to claim 6, characterized in that, The first electronic device has a managed GC role in the first WiFi P2P connection and no free network card, while the third electronic device has a free network card.

8. The method according to any one of claims 1-7, characterized in that, The first electronic device includes a first application module and a first WiFi module. The first application module is located in the application layer, and the first WiFi module is located in the framework layer. The first electronic device stores first connection information and first link information, including: The first application module saves the first connection information; The first WiFi module stores the first link information; The first electronic device stores the second connection information, including: The first application module stores the second connection information.

9. The method according to claim 8, characterized in that, After the first electronic device receives the first operation, the method further includes: The first application module establishes a first communication channel with the third electronic device; The first application module registers the first communication channel with the first WiFi module, and the first communication channel is used to transmit information between the first WiFi module and the third electronic device.

10. The method according to claim 9, characterized in that, The method further includes: The first WiFi module obtains the WiFi capability information of the first electronic device from the WiFi driver; the WiFi capability information of the first electronic device includes the P2P role and idle network card information of the first electronic device; the P2P role of the first electronic device is the P2P role that the first electronic device plays in the WiFi P2P connection that the first electronic device has established. The first WiFi module calls the first communication channel to send the WiFi capability information of the first electronic device; The first application module sends the WiFi capability information of the first electronic device to the third electronic device through the first communication channel.

11. The method according to claim 10, characterized in that, The method further includes: The first WiFi module receives a decision result from the third electronic device through the first communication channel. The decision result is used to instruct the third electronic device to establish a connection with the first electronic device through the second electronic device. The first WiFi module notifies the first application module to initiate bridging; The first application module enters the bridging state; The first application module sends the device ID and network card MAC of the second electronic device to the third electronic device.

12. The method according to claim 11, characterized in that, The first electronic device further includes a first application, and the first electronic device receiving a first operation includes: The first application receives the first operation; After the first application module sends the device ID and network card MAC of the second electronic device to the third electronic device, the method further includes: The first application module receives a connection success message from the third electronic device; the first application module notifies the first application that the device connection is successful; the first application prompts the user that the target service has been successfully initiated.

13. A communication method, characterized in that, Applied to a second electronic device, the method includes: The second electronic device establishes a first WiFi P2P connection with the first electronic device; The second electronic device stores first connection information and first link information; the first connection information includes the identifier of the first electronic device and the identifier of the second electronic device; the first link information is used to indicate the WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information and the first link information are associated. The second electronic device establishes a second WiFi P2P connection with the third electronic device; The second electronic device stores second connection information, third connection information, and second link information; the second connection information includes the identifier of the first electronic device, the identifier of the second electronic device, and the identifier of the third electronic device; the third connection information includes the identifier of the second electronic device and the identifier of the third electronic device; the second link information is used to indicate the WiFi P2P physical link between the second electronic device and the third electronic device; the second connection information is associated with the first connection information and the third connection information, and the third connection information is associated with the second link information.

14. A communication method, characterized in that, Applied to a third electronic device, the method includes: The third electronic device receives information from the first electronic device from the second electronic device, the information of the second electronic device including device identifier and network card information; The third electronic device establishes a connection with the first electronic device based on the second electronic device; The third electronic device stores second connection information, third connection information, and second link information; the second connection information includes the identifier of the first electronic device, the identifier of the second electronic device, and the identifier of the third electronic device; the third connection information includes the identifier of the second electronic device and the identifier of the third electronic device; the second link information is used to indicate the WiFi P2P physical link between the second electronic device and the third electronic device; the second connection information is associated with the three connection information, and the third connection information is associated with the second link information.

15. A communication method, characterized in that, The method, applied to a communication system including a first electronic device, a second electronic device, and a third electronic device, comprises: In response to the user's initiation of the first service, the first electronic device establishes a first WiFi P2P connection with the second electronic device; The first electronic device stores first connection information and first link information; the second electronic device stores the first connection information and the first link information; wherein, the first connection information includes the identifier of the first electronic device and the identifier of the second electronic device; the first link information is used to indicate the WiFi P2P physical link between the first electronic device and the second electronic device; the first connection information and the first link information are associated. In response to a user initiating a second service, the first electronic device establishes a connection with the third electronic device based on the second electronic device; the second service is different from the first service. The first electronic device establishes a connection with the third electronic device based on the second electronic device, including: The second electronic device establishes a second WiFi P2P connection with the third electronic device; The first electronic device also stores second connection information; the second electronic device also stores the second connection information, the third connection information, and the second link information; the third electronic device stores the second connection information, the third connection information, and the second link information; wherein, the second connection information includes the identifier of the first electronic device, the identifier of the second electronic device, and the identifier of the third electronic device; the third connection information includes the identifier of the second electronic device and the identifier of the third electronic device; the second link information is used to indicate the WiFi P2P physical link between the second electronic device and the third electronic device; the second connection information is associated with the first connection information and the third connection information, and the third connection information is associated with the second link information.

16. A communication system, characterized in that, The device includes a first electronic device, a second electronic device, and a third electronic device, wherein the first electronic device performs the method as described in any one of claims 1-12, the second electronic device performs the method as described in claim 13, and the third electronic device performs the method as described in claim 14.

17. An electronic device, characterized in that, The electronic device includes: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processor are coupled together. The memory is used to store computer program code, which includes computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-12, 13, or 14.

18. A computer-readable storage medium, characterized in that, Includes computer instructions; When the computer instructions are executed on a first electronic device, the first electronic device performs the method as described in any one of claims 1-12; or when the computer instructions are executed on a second electronic device, the second electronic device performs the method as described in claim 13; or when the computer instructions are executed on a third electronic device, the third electronic device performs the method as described in claim 14.