WiFi P2P connection method and device

By using the WiFi module to determine WiFi P2P connection configuration information between electronic devices and utilizing the communication channel transmission capability information between the application module and the WiFi module, the problem of communication quality degradation caused by unreasonable WiFi P2P connection negotiation is solved, and an efficient and simple connection process is achieved.

CN121815453APending 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

When establishing a WiFi P2P connection between electronic devices, improper negotiation can lead to a decrease in communication quality.

Method used

The WiFi module determines the WiFi P2P connection configuration information, and the communication channel between the application module and the WiFi module is used to transmit capability information to avoid duplicate capability requirements. The decision is made based on the real-time acquired device WiFi capability information.

Benefits of technology

It improves the quality of WiFi P2P communication, simplifies the connection process, saves communication overhead and storage space, and avoids redundant implementation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121815453A_ABST
    Figure CN121815453A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a WiFi (Wireless Fidelity) P2P (Peer-to-Peer) connection method and device, relates to the field of communication, and can improve the communication quality of WiFi P2P. The method is applied to a first electronic device, the first electronic device comprises a first application module and a first WiFi module, and the first application module receives WiFi capability information of a second electronic device from the second electronic device; the first application module sends WiFi capability information of the second electronic equipment to the first WiFi module; the first WiFi module obtains WiFi capability information of the first electronic equipment; the first WiFi module determines WiFi P2P connection configuration information according to the WiFi capability information of the second electronic equipment and the WiFi capability information of the first electronic equipment; and the first electronic equipment establishes WiFi P2P connection with the second electronic equipment based on the WiFi P2P connection configuration information.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of communication, and in particular to a WiFi P2P connection method and device. BACKGROUND

[0002] In order to better serve users, data transmission (information interaction) can be performed between various electronic devices to achieve file sharing, multi-screen collaboration, screen projection and the like. The electronic devices can use WiFi direct (WiFi direct, also referred to as peer-to-peer, P2P) technology to perform data transmission. Compared with Bluetooth communication, WiFi P2P has a longer communication distance and a larger bandwidth, and has obvious advantages.

[0003] However, when establishing a WiFi P2P communication connection between electronic devices, the channel for WiFi P2P connection and the device acting as a group owner (GO) need to be negotiated. If the negotiation is unreasonable, the communication quality of WiFi P2P will be reduced. SUMMARY

[0004] Embodiments of the present application provide a WiFi P2P connection method and device, which can improve the communication quality of WiFi P2P.

[0005] To achieve the above-mentioned purpose, embodiments of the present application use the following technical solutions:

[0006] In a first aspect, a WiFi P2P connection method is provided, applied to a first electronic device, the first electronic device comprising a first application module and a first WiFi module, the first application module being located at an application layer, and the first WiFi module being located at a framework layer. The method comprises: the first application module receiving WiFi capability information of a second electronic device from the second electronic device; the first application module sending the WiFi capability information of the second electronic device to the first WiFi module; the first WiFi module obtaining WiFi capability information of the first electronic device; the first WiFi module determining WiFi P2P connection configuration information according to the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device, the WiFi P2P connection configuration information comprising information of a channel for WiFi P2P connection and a device acting as a manager GO; and the first electronic device establishing a WiFi P2P connection with the second electronic device based on the WiFi P2P connection configuration information.

[0007] The scheme provided in the embodiments of the present application is that the first WiFi module (the WiFi link module of the first electronic device) decides the WiFi P2P connection configuration information. Since the first WiFi module has the ability to acquire the WiFi capability information of the local device (the first electronic device) in real time, the WiFi P2P connection configuration information can be decided based on the WiFi capability information of the local device and the WiFi capability information from the opposite end more conveniently and efficiently, and the communication quality of the WiFi P2P can be improved. Moreover, compared with the scheme in which the first application module decides the WiFi P2P connection configuration information, the scheme provided in the embodiments of the present application does not need the first application module to acquire the WiFi capability information of the local device from the first WiFi module and save the WiFi capability information of the local device, and thus the communication overhead and the storage space can be saved, and the process of the WiFi P2P connection method is more simple and efficient.

[0008] In a possible implementation, before the first application module receives the WiFi capability information of the second electronic device, the method further includes: the first application module establishes a physical link with the second electronic device; the first application module establishes a first communication channel with the second electronic device; the first communication channel is established on the physical link; 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 second electronic device; and the first application module receiving the WiFi capability information of the second electronic device includes: the first application module receiving the WiFi capability information of the second electronic device through the first communication channel. That is, the first communication channel (auxiliary channel) can be established on the basis of the physical link established between the first application module and the second electronic device, and the first WiFi module and the second electronic device do not need to establish an additional physical connection (communication link). That is, the already established communication link can be reused to establish the communication channel for the first WiFi module and the second electronic device, and the communication resources can be saved.

[0009] It should be noted that the first application module has the capabilities of device discovery, device authentication, data encryption and decryption, etc. The first application module can reuse the existing capabilities to establish the first communication channel for the first WiFi module, and register the first communication channel with the first WiFi module, so that the first WiFi module can perform information security interaction with other devices based on the first communication channel. In this way, the first WiFi module does not need to add complex and redundant communication capabilities (device discovery, device authentication, data encryption and decryption, etc.), so that the different modules can fully exert their respective advantages, and the complex and redundant implementation process is avoided.

[0010] In a possible implementation, the format of the data packet transmitted in the first communication channel is TLV format; wherein T in the TLV is used to indicate the type of the receiving module corresponding to the data packet; V in the TLV represents the actual numerical value carried in the data packet; and L in the TLV represents the length of the actual numerical value. When the data is transmitted by using the TLV protocol, no extra invalid load (for example, a key field) needs to be carried, and the transmission efficiency and expansibility are better.

[0011] In a possible implementation, the WiFi capability information of the first electronic device includes at least one of the following: an identifier, a model, available channels of at least one network card, and information of a WiFi connection established by the first electronic device. In this way, the WiFi P2P connection configuration information can be determined based on more detailed and specific WiFi capability information, and compared with a scheme in which the WiFi P2P connection configuration information is determined by simply judging the role and channel capability, the scheme provided in this application can ensure that the determination result of the WiFi P2P connection configuration information is more reasonable.

[0012] In a possible implementation, the first application module receives the WiFi capability information of the second electronic device through the first communication channel includes: the first application module receives a first data packet from the second electronic device through the first communication channel, the first data packet includes a first packet header and first data, the first packet header is used to indicate that the first data packet is from the first communication channel, and the first data includes the WiFi capability information of the second electronic device; and the first application module sends the WiFi capability information of the second electronic device to the first WiFi module includes: the first application module strips the first packet header from the first data packet, and sends the first data to the first WiFi module. In this way, the first application module can transmit data for the first WiFi module through the first communication channel, without the first WiFi module adding complex and redundant communication capabilities (device discovery, device authentication, data encryption and decryption capabilities), so that the different modules can fully exert their respective advantages, and the complex and redundant implementation process is avoided.

[0013] In a possible implementation, the first data further includes QoS information of a target service, the target service is a service for data exchange based on the WiFi P2P connection, and the QoS information of the target service includes one or more of the following: bandwidth requirement, time delay requirement, and jitter requirement of the target service. In this way, the connection mode (WiFi P2P connection or bridging) of 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, so that the service requirement can be better met, and problems such as freezing and frame dropping of the service (for example, a screen sharing service) can be avoided.

[0014] In a possible implementation, the first WiFi module determines the WiFi P2P connection configuration information according to the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device, including: in a case where the QoS information of the target service meets the first condition, and the first electronic device and the second electronic device support WiFi P2P connection of the first frequency band, the channel used for WiFi P2P connection in the WiFi P2P connection configuration information is the channel of the first frequency band; wherein the first condition includes: the expected bandwidth of the target service is greater than a first threshold. In this way, the connection mode between the local device and the peer device can be determined as WiFi P2P connection based on the QoS information of the service and the WiFi capability information of the device, which can better meet the service requirements and avoid problems such as stuttering and frame drop of the service (for example, screen sharing service).

[0015] In a possible implementation, the method further includes: in a case where the QoS information of the target service meets the first condition, and the first electronic device and the second electronic device do not support WiFi P2P connection of the first frequency band, the first electronic device sends indication information to the second electronic device; wherein the indication information is used to indicate that the first electronic device connects with the second electronic device through a third electronic device, the third electronic device is a device that has established a WiFi P2P connection with the second electronic device, and the P2P role of the third electronic device in the established WiFi P2P connection is a manager GO. In this way, the connection mode between the local device and the peer device can be determined as a bridging mode based on the QoS information of the service and the WiFi capability information of the device, which can better meet the service requirements and avoid problems such as stuttering and frame drop of the service (for example, screen sharing service).

[0016] In a possible implementation, the first electronic device connects with the second electronic device through the third electronic device, including: the first electronic device receives device identification (device ID) and network card information of the third electronic device from the second electronic device; the first electronic device establishes a second WiFi P2P connection with the third electronic device based on the device ID and the network card information of the third electronic device; and the first electronic device sends a connection success message to the second electronic device, the connection success message being used to indicate that the connection between the first electronic device and the third electronic device is successful. In this way, the first electronic device can establish a WiFi P2P connection with the third electronic device based on the device ID and the network card information of the third electronic device. Since the third electronic device establishes WiFi P2P connections with the first electronic device and the second electronic device respectively, the third electronic device can bridge the first electronic device and the second electronic device as a bridge, and perform information forwarding for the first electronic device and the second electronic device. In this way, the connection mode of the first electronic device is expanded, the first electronic device can support communication between the first electronic device and more devices, which can better meet user needs and improve user experience.

[0017] In a possible implementation, after the first WiFi module determines the WiFi P2P connection configuration information, the method further includes: the first WiFi module calling the first communication channel to send the WiFi P2P connection configuration information to the first application module; the first application module encapsulating a second data packet, the second data packet including a second packet header and second data, the second packet header being used to indicate that the second data packet is from the first communication channel, and the second data including the WiFi P2P connection configuration information; and the first application module sending the second data packet to the second electronic device based on the first communication channel. In this way, the first application module can transmit data (for example, the WiFi P2P connection configuration information) for the first WiFi module through the first communication channel, without the first WiFi module adding complex and redundant communication capabilities (device discovery, device authentication, data encryption and decryption, and the like), so that the different modules can fully exert their respective advantages, and the complex and redundant implementation process is avoided.

[0018] In a possible implementation, the first application module receives a third data packet from the second electronic device through the first communication channel, the third data packet including a third packet header and connection information of a device acting as a GO, the third packet header being used to indicate that the third data packet is from the first communication channel; the first application module stripping the third packet header from the third data packet and sending the connection information of the device acting as the GO to the first WiFi module; and the first WiFi module establishing a WiFi P2P connection with the second electronic device based on the connection information of the device acting as the GO. In this way, the first electronic device can establish a WiFi P2P connection with the second electronic device, and perform information interaction of a service through the WiFi P2P connection, thereby meeting the service requirement.

[0019] In a possible implementation, the method further includes: the first application module establishing a second communication channel with the second electronic device; the second communication channel being established on a physical link, and the second communication channel being used to transmit information between the first application module and the second electronic device; the first application module receiving a fourth data packet from the second electronic device through the second communication channel, the fourth data packet including an IP and a TCP port of the second electronic device; and the first application module establishing a TCP secure channel based on the WiFi P2P connection with the second electronic device based on the IP and the TCP port of the second electronic device. In this way, the communication can be performed based on the TCP secure channel, and the communication security can be further improved.

[0020] In a possible implementation, the data packet transmitted in the second communication channel is in a key-value pair format. The data packet in the key-value pair format is convenient to parse and has high parsing accuracy.

[0021] In a second aspect, a WiFi P2P connection method is provided and applied to a second electronic device. The second electronic device is in a same network as a first electronic device. The second electronic device includes a second application module and a second WiFi module. The second WiFi module has the capability of obtaining WiFi capability information. The method includes: obtaining, by the second WiFi module, the WiFi capability information of the second electronic device; sending, by the second WiFi module, the WiFi capability information of the second electronic device to the second application module; sending, by the second application module, the WiFi capability information of the second electronic device to the first electronic device; receiving, by the second application module, WiFi P2P connection configuration information from the first electronic device. The WiFi P2P connection configuration information includes information indicating a channel for WiFi P2P connection and a device acting as a manager GO; sending, by the second application module, the WiFi P2P connection configuration information to the second WiFi module; and establishing, by the second electronic device, a WiFi P2P connection with the first electronic device based on the WiFi P2P connection configuration information.

[0022] The second WiFi module can obtain the WiFi capability information of the second electronic device and send the WiFi capability information of the second electronic device to the first electronic device through the second application module, so that the first electronic device decides the WiFi P2P connection configuration information according to the WiFi capability information of the second electronic device. The second WiFi module can also receive the WiFi P2P connection configuration information from the first electronic device through the second application module and establish the WiFi P2P connection with the first electronic device based on the WiFi P2P connection configuration information.

[0023] In a possible implementation, before the second application module sends the WiFi capability information of the second electronic device to the first electronic device, the method further includes: establishing, by the second application module, a physical link with the first electronic device; establishing, by the second application module, a first communication channel with the first electronic device; the first communication channel is established on the physical link; registering, by the second application module, the first communication channel with the second WiFi module; the first communication channel is used to transmit information between the second WiFi module and the first electronic device; sending, by the second WiFi module, the WiFi capability information of the second electronic device to the second application module includes: calling, by the second WiFi module, the first communication channel to send the WiFi capability information of the second electronic device to the second application module; and sending, by the second application module, the WiFi capability information of the second electronic device to the first electronic device includes: sending, by the second application module, the WiFi capability information of the second electronic device to the first electronic device through the first communication channel.

[0024] In a possible implementation, the format of a data packet transmitted in the first communication channel is TLV format.

[0025] In a possible implementation, the second electronic device includes at least one of the following: an identifier, a model, available channels of the at least one network card, and information about WiFi connections established by the second electronic device.

[0026] In a possible implementation, the first electronic device further includes a first application, and before the second WiFi module sends the WiFi capability information of the second electronic device to the second application module, the method further includes: the first application receives a first operation, the first operation being used to initiate a screen sharing service; the first application initiates a connection call to the second application module, and sends quality of service (QoS) information of the screen sharing service to the second application module; the second application module sends the QoS information to the second WiFi module; and the second WiFi module sending the WiFi capability information of the second electronic device to the second application module includes: the second WiFi module sending the WiFi capability information of the second electronic device and the QoS information to the second application module.

[0027] In a possible implementation, the second application module sending the WiFi capability information of the second electronic device to the first electronic device includes: the second application module encapsulating a first data packet, the first data packet including a first packet header and first data, the first packet header being used to indicate that the first data packet comes from a first communication channel, and the first data including the WiFi capability information of the second electronic device and the QoS information; and the second application module sending the first data packet to the first electronic device based on the first communication channel.

[0028] In a possible implementation, the second application module receiving the WiFi P2P connection configuration information from the first electronic device includes: the second application module receiving a second data packet from the first electronic device through the first communication channel, the second data packet including a second packet header and second data, the second packet header being used to indicate that the second data packet comes from the first communication channel, and the second data including the WiFi P2P connection configuration information; and the second application module sending the WiFi P2P connection configuration information to the second WiFi module includes: the second application module stripping the second packet header from the second data packet, and sending the second data to the second WiFi module.

[0029] In a possible implementation, in a case where the QoS information of the target service meets a first condition, and the first electronic device and the second electronic device support WiFi P2P connection in a first frequency band, the channel used for the WiFi P2P connection in the WiFi P2P connection configuration information is a channel in the first frequency band; and the first condition includes that an expected bandwidth of the target service is greater than a first threshold.

[0030] In a possible implementation, the method further includes: in a case where the QoS information of the target service meets the first condition, and the first electronic device and the second electronic device do not support the WiFi P2P connection of the first frequency band, the second electronic device receives indication information from the first electronic device, the indication information being used to indicate that the first electronic device connects with the second electronic device through a third electronic device, the third electronic device being a device that has established a WiFi P2P connection with the second electronic device, and a P2P role of the third electronic device in the established WiFi P2P connection being a manager GO.

[0031] In a possible implementation, the first electronic device connecting with the second electronic device through the third electronic device includes: the second electronic device sending device identification and network card information of the third electronic device to the first electronic device; and the second electronic device receiving a connection success message from the first electronic device, the connection success message being used to indicate that the connection between the first electronic device and the third electronic device is successful.

[0032] In a possible implementation, the method further includes: the second WiFi module determining connection information of the device acting as the GO according to the WiFi P2P connection configuration information; the second WiFi module sending the connection information of the device acting as the GO to the second application module; the second application module encapsulating a third data packet, the third data packet including a third packet header and the connection information of the device acting as the GO, the third packet header being used to indicate that the third data packet comes from the first communication channel; the second application module sending the third data packet to the first electronic device through the first communication channel; and the second WiFi module establishing a WiFi P2P connection with the first electronic device based on the connection information of the device acting as the GO.

[0033] In a possible implementation, the method further includes: the second application module establishing a second communication channel with the first electronic device; the second application module sending a fourth data packet to the first electronic device through the second communication channel, the fourth data packet including an IP and a TCP port of the second electronic device; and the second application module establishing a TCP secure channel based on the WiFi P2P connection with the first electronic device based on the IP and the TCP port of the second electronic device.

[0034] In a possible implementation, the fourth data packet transmitted in the second communication channel is in a key-value pair format.

[0035] The method provided in the second aspect can refer to the beneficial effects in the first aspect and any possible implementation manner thereof, which will not be described herein again.

[0036] In a third aspect, a WiFi P2P connection method is provided, applied to a communication system including a first electronic device and a second electronic device, the first electronic device including a first application module and a first WiFi module, the first WiFi module having the capability of obtaining WiFi capability information, the second electronic device including a second application module and a second WiFi module, the second WiFi module having the capability of obtaining WiFi capability information, the method including: the second WiFi module obtaining WiFi capability information of the second electronic device; the second WiFi module sending the WiFi capability information of the second electronic device to the second application module; the second application module sending the WiFi capability information of the second electronic device to the first application module; the first application module receiving the WiFi capability information of the second electronic device; the first application module sending the WiFi capability information of the second electronic device to the first WiFi module; the first WiFi module obtaining WiFi capability information of the first electronic device; the first WiFi module determining WiFi P2P connection configuration information according to the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device, the WiFi P2P connection configuration information being used to indicate a channel for WiFi P2P connection and a device acting as a manager GO; the first WiFi module sending the WiFi P2P connection configuration information to the first application module; the first application module sending the WiFi P2P connection configuration information to the second application module; the second application module receiving the WiFi P2P connection configuration information, the WiFi P2P connection configuration information being used to indicate a channel for WiFi P2P connection and a device acting as a manager GO; the second application module sending the WiFi P2P connection configuration information to the second WiFi module; and the second electronic device establishing a WiFi P2P connection with the first electronic device based on the WiFi P2P connection configuration information.

[0037] In a fourth aspect, a communication system is provided, which includes a first electronic device and a second electronic device, the first electronic device includes a first application module and a first WiFi module, the first WiFi module has the capability of obtaining WiFi capability information, the second electronic device includes a second application module and a second WiFi module, the second WiFi module has the capability of obtaining WiFi capability information, wherein: the second WiFi module obtains the WiFi capability information of the second electronic device; the second WiFi module sends the WiFi capability information of the second electronic device to the second application module; the second application module sends the WiFi capability information of the second electronic device to the first application module; the first application module receives the WiFi capability information of the second electronic device; the first application module sends the WiFi capability information of the second electronic device to the first WiFi module; the first WiFi module obtains the WiFi capability information of the first electronic device; the first WiFi module determines WiFi P2P connection configuration information according to the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device, the WiFi P2P connection configuration information is used to indicate a channel for WiFi P2P connection and a device as a manager GO; the first WiFi module sends the WiFi P2P connection configuration information to the first application module; the first application module sends the WiFi P2P connection configuration information to the second application module; the second application module receives the WiFi P2P connection configuration information, the WiFi P2P connection configuration information is used to indicate a channel for WiFi P2P connection and a device as a manager GO; the second application module sends the WiFi P2P connection configuration information to the second WiFi module; and the second electronic device establishes a WiFi P2P connection with the first electronic device based on the WiFi P2P connection configuration information.

[0038] In a fifth aspect, a first electronic device is provided, which includes: 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 configured to store computer program codes, the computer program codes include computer instructions; when the computer instructions are executed by the processors, the first electronic device performs the method of the first aspect and any possible design of the first aspect.

[0039] In a sixth aspect, a second electronic device is provided, which includes: 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 configured to store computer program codes, the computer program codes include computer instructions; when the computer instructions are executed by the processors, the second electronic device performs the method of the second aspect and any possible design of the second aspect.

[0040] In a seventh aspect, the present application provides a chip system, which comprises one or more interface circuits and one or more processors. The interface circuits and the processors are interconnected by wires. The chip system can be applied to an electronic device comprising a communication module and a memory. The interface circuit is configured to receive a signal from the memory of the electronic device and send the received signal to the processor, the signal comprising computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device can perform the method of the first aspect or the second aspect or any possible design of the first aspect or the second aspect.

[0041] In an eighth aspect, the present application provides a computer readable storage medium comprising computer instructions. When the computer instructions are executed on an electronic device (such as a tablet computer or a mobile phone), the electronic device is caused to perform the method of the first aspect or the second aspect or any possible design of the first aspect or the second aspect.

[0042] In a ninth aspect, the present application provides a computer program product, which, when executed on a computer, causes the computer to perform the method of the first aspect or the second aspect or any possible design of the first aspect or the second aspect.

[0043] It can be understood that the system of the fourth aspect, the first electronic device of the fifth aspect, the second electronic device of the sixth aspect, the chip system of the seventh aspect, the computer readable storage medium of the eighth aspect and the computer program product of the ninth aspect provided above can achieve the beneficial effects as described in the first aspect or the second aspect or any possible design of the first aspect or the second aspect, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS

[0044] Figure 1A A connection diagram between devices provided by an embodiment of the present application;

[0045] Figure 1B A signal interaction diagram provided by an embodiment of the present application;

[0046] Figure 2 A hardware structure diagram of an electronic device provided by an embodiment of the present application;

[0047] Figure 3A A software and hardware architecture diagram of an electronic device provided by an embodiment of the present application;

[0048] Figure 3B Another software and hardware architecture diagram of an electronic device provided by an embodiment of the present application;

[0049] Figure 4A A diagram of establishing a WiFi P2P connection provided by an embodiment of the present application;

[0050] Figure 4B Another diagram for establishing a WiFi P2P connection provided by an embodiment of the present application is shown in FIG. 6.

[0051] Figure 5A A diagram provided by an embodiment of the present application is shown in FIG. 7.

[0052] Figure 5B Another diagram provided by an embodiment of the present application is shown in FIG. 8.

[0053] Figure 5C A diagram for negotiating a tunnel and an auxiliary tunnel provided by an embodiment of the present application is shown in FIG. 9.

[0054] Figure 6 Another diagram for establishing a WiFi P2P connection provided by an embodiment of the present application is shown in FIG. 10.

[0055] Figure 7A A diagram for establishing a bridge provided by an embodiment of the present application is shown in FIG. 11.

[0056] Figure 7B Another diagram for establishing a bridge provided by an embodiment of the present application is shown in FIG. 12.

[0057] Figure 8 A diagram of a chip system provided by an embodiment of the present application is shown in FIG. 13. DETAILED DESCRIPTION

[0058] For the sake of clear and concise description of the following embodiments, first, a brief introduction of related concepts or technologies is given:

[0059] WiFi P2P: a point-to-point connection technology, which can establish a tcp / ip connection between each two devices (e.g., STA) directly, without the participation of an AP. One of the devices can play a role similar to an access point (Access Point, AP), which can be called a group owner / manager (group owner, GO), and the other device is called a group client / managed (group client, GC), which can be connected to the GO. In a P2P group, there is a GO and one or more GCs. The one or more GCs can be connected to a GO, i.e., the GO can provide services for one or more GCs.

[0060] In the smart life scenario (e.g., smart office, sports health, smart home, smart travel, and audio-visual entertainment life scenarios), various electronic devices (such as mobile phones, tablets, computers, televisions, cameras, smart cars, etc.) bring a lot of convenience and unprecedented experience to users' life. Various electronic devices in the smart life scenario can perform data transmission (information interaction) to realize file sharing, multi-screen collaboration, screen projection, etc., so as to better serve users.

[0061] At present, the electronic devices can adopt WiFi P2P technology to perform data transmission. However, when the electronic devices establish a WiFi P2P connection, the channel for the WiFi P2P connection and the device acting as a group owner (GO) need to be negotiated. If the negotiation is unreasonable, the communication quality of the WiFi P2P connection will be reduced.

[0062] As shown in Figure 1A As shown in Figure 1B As shown in

[0063] To solve the above problems, the embodiment of the present application provides a WiFi P2P connection method, which can be responsible for deciding the WiFi P2P connection configuration information by the WiFi link module. Since the WiFi link module can obtain the WiFi capability information in real time, the WiFi P2P connection configuration information can be decided based on the WiFi capability information more conveniently and efficiently, so that the process of the WiFi P2P connection method is more simple and efficient.

[0064] The method provided by the embodiments of the present application can be applied to a first electronic device and a second electronic device. The first electronic device or the second electronic device may, for example, be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device, and / or a smart city device, and the embodiments of the present application do not specially limit the specific type of the electronic device.

[0065] The first electronic device or the second electronic device is taken as the hardware structure of the electronic device 100 as an example for description below. Figure 2 A hardware structure schematic diagram of the electronic device 100 is shown.

[0066] The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, and the like.

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

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

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

[0070] The memory in the processor 110 can also be configured to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. This avoids repeated access and reduces the waiting time of the processor 110, thereby improving the efficiency of the system.

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

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

[0073] In some embodiments, the processor 110 can include one or more interfaces. The USB interface 130 is an interface conforming to the USB standard specification, and can be 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 to transmit data between the electronic device 100 and a peripheral device. It can also be used to connect a headset to play audio through the headset. The interface can also be used to connect other electronic devices 100, such as AR devices, etc.

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

[0075] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas.

[0076] The mobile communication module 150 can provide a solution including 2G / 3G / 4G / 5G wireless communication applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transmit the processed signals to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves radiated through the antenna 1.

[0077] The wireless communication module 160 can provide a solution including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), global navigation satellite systems (GNSS), frequency modulation (FM), NFC, infrared technology (IR), etc. wireless communication applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrated with at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive signals to be transmitted from the processor 110, perform frequency modulation and amplification on the signals, and convert them into electromagnetic waves radiated through the antenna 2.

[0078] In some embodiments, the antenna 1 and the mobile communication module 150 of the electronic device 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology.

[0079] The electronic device 100 can implement an audio function through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, and an application processor, etc. For example, music playing, recording, etc.

[0080] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can adopt 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), a Mini LED, a Micro LED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 can include one or N display screens 194, and N is a positive integer greater than 1.

[0081] In the embodiments of the present application, the display screen can be a touch screen, and the touch screen can receive user operations (for example, a first operation, a second operation, etc.) to realize human-computer interaction.

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

[0083] The electronic device 100 can implement an image acquisition function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor, etc.

[0084] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiments of the present application take an Android system with a layered architecture as an example to exemplarily illustrate the software structure of the electronic device 100.

[0085] The software system of the electronic device 100 can employ a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. Embodiments of the present application take an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100. The layered architecture divides the software into several layers, each of which has a clear role and division of labor. The layers communicate with each other through interfaces.

[0086] In some embodiments, the technical architecture of the electronic device 100 includes an application layer (application program layer), a framework layer (application framework layer), a kernel layer, and a hardware layer. It should be understood that the present application only illustrates the relevant part of the layer and the part of the component, and the electronic device 100 can also include other layers and components in actual application, which are not limited in the present application.

[0087] As shown in FIG. 1, the application layer can include a smart interconnection application (first application) and a MagicLink application module (first application module or second application module). Figure 3A The smart interconnection application can be used to receive a user operation (for example, a user-initiated screen sharing operation) and call the MagicLink application module based on the user operation.

[0088] The MagicLink application module is responsible for the management of business scenarios and the networking between multiple devices.

[0089] The framework layer can include a WiFi link module (first WiFi module or second WiFi module) and an Android WiFi management module.

[0090] The Android WiFi management module is an Android native module and can be used to manage the first network card (for example, WiFi card 1) of the electronic device to establish or disconnect a WiFi P2P connection with a peer device. The process of establishing a WiFi P2P connection can include starting (pulling up) the WiFi card 1, setting the frequency, service set identifier (SSID), and password for the WiFi card 1, establishing a WiFi P2P connection with the peer device through the SSID and password. Then, the MagicLink application module can establish a TCP encrypted channel through IP and TCP port based on the established WiFi P2P connection.

[0091] The WiFi link module can be used to manage the extended network card (for example, WiFi card 2) of the electronic device. The extended WiFi card can also include more network cards, such as WiFi card 3, WiFi card 4, etc., which are not limited in the present application.

[0092] The WiFi link module can be used to manage the extended network card (for example, WiFi card 2) of the electronic device. The extended WiFi card can also include more network cards, such as WiFi card 3, WiFi card 4, etc., which are not limited in the present application.

[0093] 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).

[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 some embodiments, such as Figure 3A As shown, the MagicLink application module can obtain WiFi capability information from the WiFi link module, save the obtained WiFi capability information, and then decide on WiFi P2P connection configuration information based on the saved WiFi capability information. The WiFi P2P connection configuration information includes the network card used for WiFi P2P communication. For example, if the MagicLink application module decides to use the first WiFi network card (e.g., WiFi network card 1) for WiFi P2P connection, it can call the Android WiFi management module. The Android WiFi management module can configure WiFi network card 1 through its driver to enable WiFi P2P connection with the peer device. If the MagicLink application module decides to use the second WiFi network card (e.g., WiFi network card 2) for WiFi P2P connection, it can call the WiFi link module. The WiFi link module can configure WiFi network card 2 through its driver to enable WiFi P2P connection with the peer device.

[0098] In other embodiments, such as Figure 3BAs shown, the WiFi link module is responsible for deciding the WiFi P2P connection configuration information, which can be decided based on the WiFi capability information of the device. The WiFi P2P connection configuration information includes a network card used for WiFi P2P communication. If the WiFi link module decides to use the first WiFi network card (e.g., WiFi network card 1) for WiFi P2P connection, it can call the Android WiFi management module, which can configure the WiFi network card 1 through the driver of the WiFi network card 1 to connect to the peer device through WiFi P2P; if the WiFi link module decides to use the second WiFi network card (e.g., WiFi network card 2) for WiFi P2P connection, it can call the WiFi link module, which can configure the WiFi network card 2 through the driver of the WiFi network card 2 to connect to the peer device through WiFi P2P.

[0099] Compared with Figure 3A In the embodiment shown, Figure 3B In the embodiment shown, the WiFi link module is responsible for deciding the WiFi P2P connection configuration information, rather than the MagicLink application module, so the MagicLink application module does not need to obtain the WiFi capability information from the WiFi link module. The WiFi link module can obtain the WiFi capability information in real time and decide the WiFi P2P connection configuration information based on the WiFi capability information more conveniently and efficiently, making the process of the WiFi P2P connection method more concise and efficient. Moreover, Figure 3B In the embodiment shown, the MagicLink application module does not need to save the WiFi capability information, which can save storage space.

[0100] Moreover, compared with Figure 3A In the embodiment shown, the MagicLink application module is responsible for both business scenario management and decision of the WiFi P2P connection configuration information. Figure 3BIn the illustrated embodiment, the WiFi link module is responsible for deciding the WiFi P2P connection configuration information, which realizes the functional decoupling of the MagicLink application module and the WiFi link module, so that the MagicLink application module and the WiFi link module can exert their respective advantages (the advantage of the MagicLink application module is business scenario management and multi-device networking, and the MagicLink application module cannot directly obtain WiFi capability information and cannot timely perceive WiFi state changes; the advantage of the WiFi link module is channel management and hardware capability adaptation, and the WiFi link module can directly obtain WiFi chip capability and can perceive WiFi state changes at any time). Moreover, the functional decoupling of the MagicLink application module and the WiFi link module facilitates subsequent evolution (for example, the WiFi link module can flexibly adjust the number of WiFi P2P connection links based on hardware capability).

[0101] In the embodiment, the WiFi P2P connection can be managed in units of WiFi cards, and compared with managing the WiFi P2P connection in units of devices, the way of managing the WiFi P2P connection in units of WiFi cards can be compatible with more WiFi cards of devices and can be more flexible and efficient in managing the WiFi P2P connection.

[0102] In some embodiments, one module (component) in the above-mentioned embodiments (for example, the illustrated embodiment) can be split into two or more modules, or two or more modules at the same level can be combined into the same module. Figure 3B

[0103] As an example, the MagicLink application module at the application layer can include a P2P direct connection module and a security authentication module. The P2P direct connection module can be used for networking and information interaction with a peer device, and the security authentication module can be used for device security authentication and key exchange.

[0104] The WiFi link module can include a WiFi service module. The WiFi service module can be used to obtain WiFi capability information from a WiFi driver and decide WiFi P2P connection configuration information based on the WiFi capability information.

[0105] The electronic device can further include a WiFi protocol stack, and the Android WiFi management module or the WiFi service module can call the WiFi protocol stack to establish a WiFi P2P connection (WiFi P2P physical link) with a peer device.

[0106] ​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.

[0107] 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.

[0108] 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.

[0109] like Figure 4A As shown, this application provides a WiFi P2P connection method, taking a tablet computer B as the first electronic device and a mobile phone A as the second electronic device, which includes:

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

[0111] 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.

[0112] 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.

[0113] 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.

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

[0115] After the Bluetooth switch of the mobile phone A is turned on, the mobile phone A can send a Bluetooth broadcast; similarly, after the Bluetooth switch of the tablet computer B is turned on, the tablet computer B can send a Bluetooth broadcast. The MagicLink application module of the mobile phone A can discover the tablet computer B based on the Bluetooth broadcast sent by the tablet computer B. The MagicLink application module of the tablet computer B can discover the mobile phone A based on the Bluetooth broadcast sent by the mobile phone A. That is, the mobile phone A and the tablet computer B can discover the opposite device based on the Bluetooth broadcast sent by the opposite device.

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

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

[0118] The Bluetooth communication protocol can be a traditional Bluetooth protocol, can also be a Bluetooth low energy (BLE) protocol, and of course, can also be other new Bluetooth protocol types to be launched in the future, which are not limited by the application.

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

[0120] The mobile phone A and the tablet computer B can perform device security authentication based on the Bluetooth connection, and confirm that the opposite device is a trusted device. Then, the mobile phone A and the tablet computer B can exchange keys and perform secure communication based on the keys.

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

[0122] The WiFi basic parameters can include a version number of the WiFi link module, and the version number of the WiFi link module is used to indicate the number of supported WiFi network cards, the number of supported WiFi P2P links, and the supported service scenarios (for example, trust ring, honor sharing) and the like.

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

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

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

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

[0127] 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.

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

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

[0130] 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.

[0131] Steps 405a-408 above are optional steps.

[0132] 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.

[0133] 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.

[0134] 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.

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

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

[0137] 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".

[0138] 411a, the smart interconnection application of the mobile phone A receives a user initiated operation of screen sharing.

[0139] The screen sharing refers to projecting the screen of the local device (e.g., the mobile phone A) onto the screen of the peer device (e.g., the tablet B). The embodiments of the present application take the target service as the screen sharing service for example. The target service is a service based on the WiFi P2P connection for data exchange. The target service can also include other types of services, such as multi-screen collaboration, file sharing, etc., which are not limited in the present application.

[0140] For example, as shown in (a) of FIG. 4, in response to the user sliding down the notification panel from the status bar of the mobile phone A, the mobile phone A displays the notification panel, which can include the "Trust Ring Multi-Device Interconnection Center" option 41. In response to the user triggering operation (e.g., clicking operation) on the "Trust Ring Multi-Device Interconnection Center" option 41, the mobile phone A can display the control interface 42 as shown in (b) of FIG. 4. Figure 5B Figure 5B

[0141] In some embodiments, the user can drag the identification 44 of the tablet B to the direction of the identification 43 of the local device by a drag operation. When the position of the drag operation ends near the identification 43 of the local device, the local device (i.e., the mobile phone A) and the tablet B can implement screen sharing (i.e., the screen of the mobile phone A can be projected onto the screen of the tablet B). In other embodiments, the user can drag the identification 43 of the local device to the direction of the identification 44 of the tablet B by a drag operation. When the position of the drag operation ends near the identification 44 of the tablet B, the local device (i.e., the mobile phone A) and the tablet B can implement screen sharing.

[0142] 411b, the smart interconnection application of the mobile phone A identifies the quality of service (QoS) information of the screen sharing service.

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

[0144] ​​412、The smart interconnection application of the mobile phone A initiates a connection call to the MagicLink application module of the mobile phone A.

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

[0146] 413a、The MagicLink application module of the mobile phone A creates a negotiation channel (channel 1) with the MagicLink application module of the tablet B.

[0147] When the MagicLink application module of the mobile phone A receives the connection call of the smart interconnection application, it can save the QoS information of the screen sharing service. Moreover, the MagicLink application module of the mobile phone A can create a negotiation channel (channel 1) to the opposite device (tablet B). For example, as shown in Figure 5C , the channel 1 is used for information interaction between the MagicLink application modules of different devices (the MagicLink application module of the mobile phone A and the MagicLink application module of the tablet B).

[0148] The MagicLink application module of the mobile phone A can create the channel 1 based on the discovery and networking type between the mobile phone A and the tablet B. For example, if the discovery and networking type between the mobile phone A and the tablet B is a WiFi local area network, the channel 1 can be created based on the WiFi connection; if the discovery and networking type between the mobile phone A and the tablet B is a Bluetooth network, the channel 1 can be created based on the Bluetooth connection.

[0149] Further, after the channel 1 is successfully created, the MagicLink application module of the mobile phone A and the MagicLink application module of the tablet B can perform device security authentication and secret key interaction based on the channel 1, so as to complete the creation of an encrypted negotiation channel (i.e., an encrypted channel 1).

[0150] It should be understood that the Bluetooth connection or the WiFi connection refers to a physical channel (also referred to as a physical link) for transmitting data between the two parties of communication (for example, the mobile phone A and the tablet B). Based on the same physical channel, multiple virtual channels (also referred to as data links) can be created. The virtual channel has the function of information interaction between specific modules in a predefined data processing protocol. For example, the channel 1 is a virtual channel, and the channel 1 can be used for information interaction between the MagicLink application modules of different devices.

[0151] Exemplarily, the data processing protocol of the negotiation channel (i.e. channel 1) can be a first data processing protocol, and the first data processing protocol can be used to process (encapsulate or parse) a data packet in a key+value format. That is, the data packet corresponding to the first data processing protocol is in a key+value format. The data packet in the key+value format occupies extra bandwidth when sending data because it carries extra load (key). However, the data packet in the key+value format is convenient to parse and has high accuracy.

[0152] Exemplarily, the format of the data packet of the negotiation channel (i.e. channel 1) can be as shown in Table 1:

[0153] Table 1

[0154] key IP TCP port value XX XX

[0155] Wherein, the IP and TCP port refer to the IP and TCP port of the local device (mobile phone A) used to establish the WiFi P2P connection.

[0156] 413b, the MagicLink application module of the mobile phone A creates an auxiliary channel (channel 2) with the MagicLink application module of the tablet computer B.

[0157] The MagicLink application module of the mobile phone A can also create an auxiliary channel (channel 2) with the opposite device (tablet computer B). The channel 2 is a virtual channel. Exemplarily, as shown in Figure 5C The channel 2 can be used for communication (information interaction) between the WiFi link modules of different devices (the WiFi link module of the mobile phone A and the WiFi link module of the tablet computer B). When the WiFi link modules of different devices perform information interaction based on the channel 2, the MagicLink application modules of different devices can be used for forwarding.

[0158] The MagicLink application module of the mobile phone A can create the channel 2 based on the discovery and networking type between the current mobile phone A and the tablet computer B, and on the basis of different types of network connections. For example, if the discovery and networking type between the mobile phone A and the tablet computer B is a WiFi local area network, the channel 2 can be created on the basis of the WiFi connection; if the discovery and networking type between the mobile phone A and the tablet computer B is a Bluetooth network, the channel 2 can be created on the basis of the Bluetooth connection.

[0159] Further, after the channel 2 is successfully created, the MagicLink application module of the mobile phone A and the MagicLink application module of the tablet computer B can perform a device security authentication and secret key interaction based on the channel 2. Thus, an encrypted auxiliary channel (i.e. encrypted channel 2) is created.

[0160] Exemplarily, the data processing protocol of the auxiliary channel (i.e., channel 2) can be a second data processing protocol, and the second data processing protocol can be used to process (package or parse) a data packet in TLV format. That is, the format of the data packet corresponding to the second data processing protocol is TLV format. Among them, T in TLV is dataType (abbreviation Type), which is used to indicate the type of the receiving module corresponding to the data; V represents the actual value carried in the data packet; L represents the length of the actual value. Among them, the lengths of T and L can be fixed, for example, they can be 2 bytes or 4 bytes, and the length of V is determined based on L.

[0161] It should be noted that when the WiFi link modules of different devices interact information based on the channel 2, they can be forwarded via the MagicLink application modules of the respective devices. Since the data packet corresponding to the data processing protocol of the channel 2 is in TLV format, the MagicLink application module does not need to parse the data of the WiFi link module (for example, it does not need to parse the data of the WiFi link module into a key+value structure) when forwarding the data of the WiFi link module, and can directly transmit the data of the WiFi link module, which can improve the transmission efficiency. And compared with the json protocol, when sending data using the TLV protocol, there is no need to carry excess invalid load (for example, the key field), and the transmission efficiency and scalability are better.

[0162] Exemplarily, the format of the data packet of the auxiliary channel (i.e., channel 2) can be as shown in Table 2:

[0163] Table 2

[0164] dataType length value 0 XX XXXXX

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

[0166] Optionally, the data packet of the auxiliary channel (i.e., channel 2) can also include an encryption and decryption field (e.g., AuthDataHead), which is used to indicate the encryption and decryption type of the data packet of the auxiliary channel (i.e., channel 2).

[0167] In one possible implementation, the auxiliary channel (i.e., channel 2) can provide negotiation capabilities for the MagicLink application modules and WiFi link modules of different devices at the same time, that is, it can be used for data interaction of the Magiclink application modules and WiFi link modules between different devices at the same time. In this way, based on one transmission based on the auxiliary channel (i.e., channel 2), the data interaction needs of the Magiclink application modules and WiFi link modules can be met at the same time. For example, the format of the data packet of the auxiliary channel (i.e., channel 2) can be as shown in Table 3:

[0168] Table 3

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

[0170] Wherein, the dataType 1 field is 1, which can indicate that the receiving module corresponding to the data (value 1) is the Magiclink application module of the opposite end, and the Length 1 indicates the length of the value 1; the dataType 2 field is 0, which can indicate that the receiving module corresponding to the data (value 2) is the WiFi link module of the opposite end, and the Length 2 indicates the length of the value 2.

[0171] 414a, the MagicLink application module of the mobile phone A saves the channel 1 and the channel 2.

[0172] Wherein, the channel 2 can be the first communication channel, and the channel 1 can be the second communication channel.

[0173] 414b, the MagicLink application module of the tablet B saves the channel 1 and the channel 2.

[0174] 415a, the MagicLink application module of the mobile phone A registers the channel 2 to the WiFi link module of the mobile phone A.

[0175] The MagicLink application module of the mobile phone A can send a registration request to the WiFi link module, and the registration request can carry the configuration information (such as the channel name and the data processing protocol of the channel) of the channel 2. The WiFi link module of the mobile phone A can save the configuration information of the channel 2 for subsequent calling.

[0176] 415b, the MagicLink application module of the tablet B registers the channel 2 to the WiFi link module of the tablet B.

[0177] The MagicLink application module of the tablet B can send a registration request to the WiFi link module, and the registration request can carry the configuration information (such as the channel name and the data processing protocol of the channel) of the channel 2. The WiFi link module of the tablet B can save the configuration information of the channel 2 for subsequent calling.

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

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

[0180] 417a, the WiFi link module of the mobile phone A judges whether the dual-end device can meet the service requirement based on the WiFi basic parameters of the dual-end device.

[0181] In the case that the WiFi capability (mainly the capability indicated by the static capability information) of the dual-end device cannot meet the service requirement (the QoS information of the service), the negotiation channel does not need to be established, and the negotiation process does not need to be initiated, thereby avoiding unnecessary negotiation and saving negotiation resources. Moreover, the WiFi link layer module can notify the intelligent interconnection application of the screen sharing failure through the MagicLink application module, and the intelligent interconnection application can prompt the user of the screen sharing failure.

[0182] In the case that the WiFi basic parameters of the dual-end device can meet the service requirement, step 417b can be performed. That is, the latest WiFi capability information of the mobile phone A (mainly the latest dynamic capability information is collected, and the static capability information is usually fixed and does not need to be repeatedly collected) is collected, and data packet 1 is generated based on the collected WiFi capability information and the QoS information of the screen sharing service.

[0183] Step 417a is an optional step. In the case that steps 405a-408 are performed, step 417a can be performed, otherwise, step 417a can not be performed.

[0184] 417b, the WiFi link module of the mobile phone A generates data packet 1.

[0185] In some embodiments, the WiFi link module of the mobile phone A can receive the information transmitted by the MagicLink application module of the mobile phone A, and can perform the following processing: 1. collect the latest WiFi capability information of the mobile phone A (for example, the WiFi link module of the 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 capability (the number and model of the WiFi card) and the resource occupation (the occupation of the WiFi card)); 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 mobile phone A and the QoS information of the screen sharing service. Data packet 1 is used to negotiate the WiFi P2P connection configuration information with the opposite end.

[0186] The WiFi capability information can include static capability information (information that is basically fixed and unchanged), and the static capability information includes the number of WiFi cards supported by the device, the WiFi card identifier, the WiFi card model, and the available WiFi channel.

[0187] Further, the WiFi capability information can further include dynamic capability information (dynamic changing information, also referred to as WiFi occupation state information), and the dynamic capability information can include information of WiFi connections established by the device (or the network card) (for example, the number of established WiFi connections and the state of the established WiFi connections (for example, P2P roles of the two-end devices of the WiFi connection, network card information, etc.)) and the like.

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

[0189] If the bandwidth requirement of the service (for example, the screen sharing service) is high bandwidth, the type of the physical connection can be a WiFi P2P connection of the 5G frequency band, and one of the two-end devices does not support the WiFi P2P connection of the 5G frequency band, that is, the capability of one of the two-end devices cannot meet the requirement of the service. In this case, the negotiation channel does not need to be established, and the negotiation process does not need to be initiated, thereby avoiding unnecessary negotiation and saving negotiation resources. In addition, the WiFi link layer module can notify the smart interconnection application of the screen sharing failure through the MagicLink application module, and the smart interconnection application can prompt the user that the screen sharing fails.

[0190] 418a, the WiFi link module of the mobile phone A calls the channel 2, and transmits the data packet 1.

[0191] Since the data packet 1 (carrying the WiFi capability information of the mobile phone A) generated by the WiFi link module of the mobile phone A needs to be sent to the WiFi link module of the opposite device, the data packet 1 can be transmitted through the auxiliary channel (channel 2) established by the MagicLink application module.

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

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

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

[0195] The MagicLink packet header can include a datatype and a length.

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

[0197] Table 4

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

[0199] The datatype field is 0, which can indicate that the receiving module corresponding to the value is the WiFi link module of the opposite end, the length indicates the length of the value (for example, 5 bytes), and the value indicates the data packet 1 generated by the WiFi link module of the mobile phone A (for example, 01 02 03 04 05).

[0200] 418c, the MagicLink application module of the mobile phone A sends the data packet 2 through the channel 2.

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

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

[0203] 420, the MagicLink application module of the tablet B sends the data packet 1 to the WiFi link module of the tablet B through the channel 2.

[0204] 421a, the WiFi link module of the tablet B parses the data packet 1 to obtain the WiFi capability information of the initiating end device (that is, the mobile phone A) and the QoS information of the service.

[0205] In addition, the WiFi link module of the tablet B can obtain the WiFi capability information of the local device (that is, the tablet B).

[0206] As shown in Figure 4B , the method further includes:

[0207] 421b, the WiFi link module of the tablet B makes a decision according to the information carried by the data packet 1 and the WiFi capability information of the tablet B, and generates the data packet 3 according to a result of the decision.

[0208] That is, the WiFi link module of the tablet B can make a decision according to the WiFi capability information of the dual-end device and the QoS information of the service (for example, the screen sharing service), and generate the data packet 3 according to a result of the decision.

[0209] In some embodiments, when the QoS information of the service satisfies the first condition, if the tablet B and the mobile phone A support the WiFi P2P connection of the 5G frequency band, the tablet B and the mobile phone A can establish the WiFi P2P connection of the 5G frequency band. The tablet B can make a decision to generate corresponding WiFi P2P connection configuration information. The data packet 3 includes the WiFi P2P connection configuration information. The WiFi P2P connection configuration information can include information such as a role (GO and GC) of P2P communication, a network card used by the P2P communication, a channel (for example, a 5G channel), and an antenna.

[0210] Optionally, whether the tablet B supports the WiFi P2P connection of the 5G frequency band can be determined based on the WiFi capability information of the tablet B. For example, if the tablet B includes an idle network card and the idle network card supports the 5G frequency band, it is considered that the tablet B supports the WiFi P2P connection of the 5G frequency band. Similarly, whether the mobile phone A supports the WiFi P2P connection of the 5G frequency band can be determined based on the WiFi capability information of the mobile phone A. For example, if the mobile phone A includes an idle network card and the idle network card supports the 5G frequency band, it is considered that the mobile phone A supports the WiFi P2P connection of the 5G frequency band.

[0211] In some embodiments, in a case that the P2P role of the tablet B is GO (that is, the P2P role of the tablet B in the established WiFi P2P connection (for example, the tablet B and the mobile phone C have established a WiFi P2P connection) is GO) and the network card used by the tablet B to establish the WiFi P2P connection supports the 5G frequency band, and the mobile phone A has an idle network card, the tablet B can reuse the GO to establish the WiFi P2P connection with the mobile phone A. That is, the tablet B continues to be the GO and connects the mobile phone A as the GC. That is, the tablet B as the GO can not only connect the mobile phone C as the GC, but also connect the mobile phone A as the GC. In this way, the tablet B reuses the GO to establish the WiFi P2P connection with the mobile phone A, which can expand the connection device of the tablet B and save the network card resource.

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

[0213] In some embodiments, when the QoS information of the service satisfies the first condition, if the tablet B or the mobile phone A does not support the WiFi P2P connection of the 5G frequency band, the tablet B can return a decision result to the mobile phone A, the decision result being used to indicate to establish the bridge.

[0214] In some embodiments, when the QoS information of the service satisfies the second condition, if the tablet B and the mobile phone A support the WiFi P2P connection of the 5G frequency band, the tablet B and the mobile phone A can establish the WiFi P2P connection of the 5G frequency band. If the tablet B and the mobile phone A do not support the WiFi P2P connection of the 5G frequency band but support the WiFi P2P connection of the 2.4G frequency band, the tablet B and the mobile phone A can establish the WiFi P2P connection of the 2.4G frequency band. The tablet B can generate corresponding WiFi P2P connection configuration information, which can include information such as a role (GO and GC) of the P2P communication, a network card used by the P2P communication, a channel (5G channel / 2.4G channel), and an antenna.

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

[0216] In the case that the QoS information of the service satisfies the first condition and the tablet B and the mobile phone A support establishing the WiFi P2P connection of the 5G frequency band, after step 421a, steps 422a-437 can be performed to establish the WiFi P2P connection (the WiFi P2P connection of the 5G frequency band) between the tablet B and the mobile phone A.

[0217] In the case that the QoS information of the service satisfies the first condition and the tablet B and the mobile phone A do not support establishing the WiFi P2P connection of the 5G frequency band, referring to steps 702-726 below, the bridge (e.g., the bridge of the 5G frequency band) can be established between the tablet B and the mobile phone A.

[0218] In the case that the QoS information of the service meets the second condition, and the tablet B and the mobile phone A support establishing the WiFi P2P connection of the 2.4G or 5G frequency band, referring to steps 422a-437, the WiFi P2P connection (the WiFi P2P connection of the 2.4G or 5G frequency band) can be established between the tablet B and the mobile phone A.

[0219] In the case that the QoS information of the service meets the second condition, and the tablet B and the mobile phone A do not support establishing the WiFi P2P connection of the 2.4G and 5G frequency band, referring to steps 702-726, the tablet B and the mobile phone A can establish the connection in the bridging manner (the connection of the 2.4G or 5G frequency band).

[0220] In the embodiments of the present application, the connection manner (the WiFi P2P connection or the bridging) of the local device and the opposite device can be determined based on the QoS information of the service and the WiFi capability information of the device, so that the service requirement can be better met, and the problems such as the lag and the frame drop of the service (for example, the screen sharing service) can be avoided.

[0221] In some embodiments, the WiFi link module can determine the manner of the P2P network card (the network card used for the P2P communication) in the WiFi P2P connection configuration information in the following manner: selecting the available idle network card of the device (for example, the tablet B) to establish the WiFi P2P connection. For example, the WiFi link module can sequentially detect whether the first WiFi network card (for example, the WiFi network card 1) and the second WiFi network card (for example, the WiFi network card 2) are available, if the first WiFi network card is available, directly using the first WiFi network card to establish the WiFi P2P connection, if the first WiFi network card is not available, checking whether the second WiFi network card is available, and if the second WiFi network card is available, using the second WiFi network card to establish the WiFi P2P connection. Of course, if the device (for example, the tablet B) further includes more WiFi network cards (for example, the third WiFi network card), the detection can be continued until the available WiFi network card is detected.

[0222] In some embodiments, the WiFi link module decides the way of P2P channel and antenna (antenna used for P2P communication) in the WiFi P2P connection configuration information as follows: 1. In the case of high bandwidth traffic (e.g., the expected bandwidth of the traffic is greater than a preset bandwidth (e.g., 40 MB / s)), a 5G frequency channel is selected to establish a WiFi P2P connection, and an exclusive antenna (i.e., one WiFi P2P connection exclusively uses one or more antennas for data transmission); 2. In the case of low-to-medium bandwidth traffic (e.g., the expected bandwidth of the traffic is less than the preset bandwidth), a 2.4G frequency channel is selected to establish a WiFi P2P connection, or a 5G frequency channel is selected to establish a WiFi P2P connection, and the antennas can be shared (e.g., two WiFi P2P connections can share one or more antennas for data transmission).

[0223] In some embodiments, the WiFi link module decides the way of P2P role in the WiFi P2P connection configuration information as follows: a device with strong WiFi chip capability (e.g., a WiFi chip that can integrate WiFi network cards, the more WiFi network cards integrated, the newer the WiFi network card model, the stronger the WiFi chip capability) and sufficient power (e.g., a device connected to a power source (e.g., a television) has more sufficient power than a device connected to a charger (e.g., a mobile phone, a tablet computer)) acts as a GO.

[0224] 422a, the WiFi link module of the tablet computer B calls channel 2, and transmits data packet 3.

[0225] Since the data packet 3 (carrying the WiFi P2P connection configuration information) generated by the WiFi link module of the tablet computer B needs to be sent to the WiFi link module of the opposite device, the data packet 3 can be transmitted through the auxiliary channel (channel 2) established by the MagicLink application module.

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

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

[0228] The MagicLink application module of the tablet computer B adds a MagicLink packet header (second packet header) to the data packet 3 (second data) to obtain the data packet 4 (second data packet).

[0229] 422c, the MagicLink application module of the tablet computer B sends the data packet 4 through channel 2.

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

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

[0232] 423b, the MagicLink application module of the mobile phone A sends the data packet 3 to the WiFi link module of the mobile phone A through the channel 2.

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

[0234] The data packet 3 includes the WiFi P2P connection configuration information decided by the opposite device (the tablet B). For example, the WiFi P2P connection configuration information can be that the mobile phone A is the GO, the tablet B is the GC, the P2P channel is established on the 5G channel (for example, the channel with the frequency of 5805MHz and the channel number of 161), and the WiFi card 2 of the tablet B is the P2P card. The mobile phone A can create the GO based on the WiFi P2P connection configuration information.

[0235] Further, after the mobile phone A creates the GO, the mobile phone A can also perform the following steps:

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

[0237] The IP and the card name of the local (GO device) refer to the IP and the card used to create the WiFi P2P connection.

[0238] 425b, after the MagicLink application module of the mobile phone A receives the IP and the card name, the MagicLink application module of the mobile phone A starts to listen to the TCP port, and encapsulates the IP and the TCP port of the local into a data packet 5 according to the communication protocol of the channel 1.

[0239] That is, the MagicLink application module of the mobile phone A can listen to the IP and the TCP port used to establish the WiFi P2P connection, and encapsulate the IP and the TCP port of the local into a data packet 5 (the fourth data packet).

[0240] The data packet 5 is used to establish the transmission channel on the WiFi P2P connection.

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

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

[0243] Since the data packet 5 (carrying the IP and TCP port) generated by the MagicLink application module of the mobile phone A is required to be sent to the MagicLink application module of the opposite device, the data packet 5 can be transmitted through the negotiation channel (channel 1) established by the MagicLink application module.

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

[0245] 426b. The MagicLink application module of the tablet B saves the IP and TCP port of the opposite device (the mobile phone A).

[0246] The IP and TCP port of the opposite device (the mobile phone A) are used for subsequent establishment of the negotiation channel on the P2P.

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

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

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

[0250] Since the data packet 6 (carrying the connection information of the device as GO) generated by the WiFi link module of the mobile phone A is required to be sent to the WiFi link module of the opposite device, the data packet 6 can be transmitted through the auxiliary channel (channel 2) established by the MagicLink application module.

[0251] The MagicLink application module of the mobile phone A adds a MagicLink packet header (third packet header) to the data packet 6 (carrying the connection information of the device as GO) to obtain a data packet 7 (third data packet).

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

[0253] Steps 425a-425c can be executed in parallel with steps 427a-427c.

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

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

[0256] Steps 427a-427b can be executed in parallel with steps 428a-428b.

[0257] That is, the MagicLink application module of the tablet B can receive different data packets through different channels and process the different data packets differently.

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

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

[0260] The WiFi link module of the tablet B connects the mobile phone A as GO based on the GO connection information of the opposite end (the mobile phone A).

[0261] That is, the tablet B as GC connects the mobile phone A as GO.

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

[0263] The WiFi notification message includes the related information of the WiFi P2P connection, such as the IP and the network card name (for example, the network card 1 of the mobile phone A and the network card 2 of the tablet B) of the local device (the tablet B) and the opposite end (the mobile phone A) for establishing the WiFi P2P connection, the P2P role (for example, the mobile phone A as GO and the tablet B as GC), the ID (serviceid) of the WiFi P2P connection, and the like.

[0264] 431b. The MagicLink application module of the tablet B saves the WiFi P2P connection.

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

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

[0267] 432b. The MagicLink application module of the mobile phone A saves the WiFi P2P connection.

[0268] Steps 431a-431b and steps 432a-432b can be executed in parallel. That is, after the WiFi connection is successful, the WiFi modules of the two-end devices A and B respectively notify the MagicLink application modules of the two-end devices A and B that the P2P connection is successful. The MagicLink application modules of the two-end devices A and B can save the WiFi P2P connection, so as to perform communication based on the WiFi P2P connection subsequently.

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

[0270] The MagicLink application module of the tablet B can perform logical judgment according to the P2P role of the local device, so as to determine what kind of processing is performed. For example, in the case that the P2P role of the tablet B is GC, the MagicLink application module of the tablet B can read the IP and port of the opposite device (the mobile phone A) saved in step 427b, and create a TCP encrypted channel based on the WiFi P2P connection to the opposite device (the mobile phone A) based on the IP and port of the opposite device (the mobile phone A).

[0271] The TCP encrypted channel based on the WiFi P2P connection can provide a more secure, stable, high-bandwidth, and low-latency negotiation channel than the Bluetooth channel for the business (for example, the screen sharing business) of the smart interconnection application, and provide a negotiation channel for the subsequent link management negotiation of the MagicLink application module. That is, the MagicLink application modules of the two-end devices (for example, the mobile phone A and the tablet B) can interact the data (for example, screen display information) of the business (for example, the screen sharing business) based on the TCP encrypted channel based on the WiFi P2P connection.

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

[0273] 434、The MagicLink application module of the mobile phone A replies to the MagicLink application module of the tablet B that the TCP encrypted channel based on WiFi P2P connection is created.

[0274] 435a、The MagicLink application module of the mobile phone A saves the TCP encrypted channel based on WiFi P2P connection.

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

[0276] 435b、The MagicLink application module of the tablet B saves the TCP encrypted channel based on WiFi P2P connection.

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

[0278] The step 435a and the step 435b can be executed in parallel.

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

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

[0281] 437、The smart interconnection application of the mobile phone A initiates the screen sharing service, and prompts the user that the screen sharing service is established successfully.

[0282] The smart interconnection application of the mobile phone A can initiate the screen sharing service based on the TCP encrypted channel based on WiFi P2P connection. That is, the screen sharing data (for example, the information related to the screen of the mobile phone A) is sent to the opposite device (the tablet B) through the WiFi P2P connection.

[0283] The steps 436-437 can be executed after the step 432a or the step 432b or the step 434.

[0284] The tablet B can be the first electronic device, the MagicLink application module of the tablet B can be the first application module, and the WiFi link module of the tablet B can be the first WiFi module; the mobile phone A can be the second electronic device, the MagicLink application module of the mobile phone A can be the second application module, and the WiFi link module of the mobile phone A can be the second WiFi module.

[0285] The scheme provided by the embodiment of the application is that the WiFi link module (i.e., the first WiFi module) of the tablet B decides the WiFi P2P connection configuration information according to the WiFi capability information of the mobile phone A and the WiFi capability information of the tablet B. Since the first WiFi link module has the capability to acquire the WiFi capability information of the local machine (tablet B) in real time, the WiFi P2P connection configuration information can be decided more conveniently and efficiently based on the WiFi capability information of the local machine and the WiFi capability information from the opposite end, and the communication quality of the WiFi P2P can be improved. In this way, the MagicLink application module does not need to acquire the WiFi capability information of the local machine from the WiFi link module, and the WiFi capability information of the local machine does not need to be saved, the communication overhead and the storage space can be saved, and the flow of the WiFi P2P connection method is more simple and efficient.

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

[0287] As shown in FIG. 5, taking the channel one of the 5G frequency band as an example for the channel of the WiFi P2P connection (the first WiFi P2P connection) established by the mobile phone A and the tablet B, the method can further include the following steps: Figure 6

[0288] 440, the mobile phone A receives the operation of the user connecting the WiFi of the mobile phone A to the router.

[0289] For example, the WiFi of the mobile phone A can be connected to the channel two of the 5G frequency band of the router.

[0290] ​It should be noted that before the operation of receiving the user connecting the WiFi of the mobile phone A to the router, the WiFi of the mobile phone A and the tablet computer B has not been connected to the router, the WiFi P2P connection (the first WiFi P2P connection) established between the mobile phone A and the tablet computer B can be established on the optimal channel (for example, the channel one of the 5G frequency band), and the working state of the mobile phone A and the tablet computer B can be single band single concurrent (SBSC) or dual band dual concurrent (DBDC), that is, the mobile phone A and the tablet computer B only work on the channel of a single frequency band, and the WiFi transmission performance is relatively optimal. After the operation of receiving the user connecting the WiFi of the mobile phone A to the router, the WiFi link module of the mobile phone A needs to work on two channels at the same time, that is, the WiFi P2P connection of the mobile phone A and the tablet computer B works on the channel one of the 5G frequency band, and the WiFi of the mobile phone A is connected to the channel two of the 5G frequency band of the router. The working state of the mobile phone A is dual band adaptive concurrent (DBAC) or dual band single concurrent (DBSC), that is, the mobile phone A and the tablet computer B support working on two channels, but can only stably work on one channel (that is, single concurrent) for a period of time, resulting in a decline in WiFi transmission performance.

[0291] 441、In response to the operation of receiving the user connecting the WiFi of the mobile phone A to the router, the WiFi link module perceives the change of the WiFi connection state, and initiates the WiFi P2P channel switching negotiation.

[0292] In response to the operation of receiving the user connecting the WiFi of the mobile phone A to the router, the WiFi link module perceives the change of the WiFi connection state, and the change of the WiFi connection state causes the WiFi interference to be intensified, thereby affecting the transmission rate. In this case, the WiFi link module can initiate the WiFi P2P channel switching negotiation.

[0293] 442、The WiFi link module of the mobile phone A acquires the current channel state information and the WiFi capability information of the local machine, and generates a data packet 10.

[0294] The current channel state information of the local machine includes the supported channel of the local machine (the mobile phone A), the occupied channel of the WiFi P2P connection and the STA connection established by the local machine, and the like.

[0295] 443a、The WiFi link module of the mobile phone A calls the channel 2, and inputs the data packet 10.

[0296] Since the data packet 10 (carrying the current channel state information and WiFi capability information of the local device) generated by the WiFi link module of the mobile phone A is needed to be sent to the WiFi link module of the opposite device, the data packet 10 can be transmitted through the auxiliary channel (channel 2) established by the MagicLink application module.

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

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

[0299] The MagicLink application module of the mobile phone A adds a MagicLink packet header to the data packet 10 to obtain the data packet 11.

[0300] 443c, the MagicLink application module of the mobile phone A sends the data packet 11 through the channel 2.

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

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

[0303] 445, the MagicLink application module of the tablet B sends the data packet 10 to the WiFi link module of the tablet B through the channel 2.

[0304] 446, the WiFi link module of the tablet B parses the data packet 10 to obtain the channel state information and WiFi capability information of the opposite device (the mobile phone A).

[0305] 447, the WiFi link module of the tablet B combines the WiFi capability information and channel state information of the local device to make a channel switching decision, selects an optimal channel, and encapsulates the channel switching decision result into a data packet 12.

[0306] 448a, the WiFi link module of the tablet B calls the channel 2 and inputs the data packet 12.

[0307] Since the data packet 12 (carrying the channel switching decision result) generated by the WiFi link module of the tablet B is needed to be sent to the WiFi link module of the opposite device, the data packet 12 can be transmitted through the auxiliary channel (channel 2) established by the MagicLink application module.

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

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

[0310] The MagicLink application module of the tablet B adds a MagicLink packet header to the data packet 12 to obtain the data packet 13.

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

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

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

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

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

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

[0317] For example, the WiFi P2P channel between the mobile phone A and the tablet B can be switched to the same channel (channel two in the 5G frequency band) of the WiFi router connected by the mobile phone A. In this way, the co-frequency and different channel interference can be reduced.

[0318] In some embodiments, when the QoS information of the service meets the first condition, and the tablet B and the mobile phone A do not support the 5G frequency band WiFi P2P connection, the tablet B and the mobile phone A can establish a connection in a bridging manner (for example, the tablet B (the first electronic device) establishes a connection with the mobile phone A (the second electronic device) through the mobile phone C (the third electronic device)). Figure 7A

[0319] ​It should be noted that before step 702, step 701 can also be included.

[0320] 701, the mobile phone A establishes a WiFi P2P connection with the mobile phone C.

[0321] That is, before the bridge is established between the mobile phone A and the tablet B, the mobile phone A has already established a WiFi P2P connection with the mobile phone C. For example, the network card 0 of the mobile phone A can establish a WiFi P2P connection with the network card 0 of the mobile phone C, and the mobile phone C can act as a GO, and the mobile phone A can act as a GC.

[0322] The process of establishing the WiFi P2P connection between the mobile phone A and the mobile phone C can refer to the embodiment shown in Figure 4A-4B The process of establishing the WiFi P2P connection between the mobile phone A and the tablet B will not be described here.

[0323] 702, the smart interconnection application of the mobile phone A receives a screen sharing operation initiated by a user.

[0324] 703, the smart interconnection application of the mobile phone A identifies the QoS information of the network sharing service.

[0325] 704, the smart interconnection application of the mobile phone A initiates a connection call to the MagicLink application module of the mobile phone A.

[0326] 705a, the MagicLink application module of the mobile phone A creates a negotiation channel (channel 1) with the MagicLink application module of the tablet B.

[0327] 705b, the MagicLink application module of the mobile phone A creates an auxiliary channel (channel 2) with the MagicLink application module of the tablet B.

[0328] 706a, the MagicLink application module of the mobile phone A saves the channel 1 and the channel 2.

[0329] 706b, the MagicLink application module of the tablet B saves the channel 1 and the channel 2.

[0330] 707a, the MagicLink application module of the mobile phone A registers the channel 2 with the WiFi link module of the mobile phone A.

[0331] 707b, the MagicLink application module of the tablet B registers the channel 2 with the WiFi link module of the tablet B.

[0332] 708a, the MagicLink application module of the mobile phone A judges that the opposite end is a new version device.

[0333] Steps 703-708a can refer to the related description of steps 411b-415a, and will not be repeated here.

[0334] In the case that the peer device is a new version device (i.e., the version of the MagicLink protocol of the peer device is a new version), the MagicLink application module of the mobile phone A can perform steps 708b and 709.

[0335] The MagicLink protocol is a P2P data processing protocol, i.e., a communication protocol for discovering and pairing through Bluetooth (e.g., BLE) broadcast, and then performing data interaction through WiFi P2P. In the case that the version of the MagicLink protocol is a new version, the device can support establishing multi-WiFi P2P card management. Moreover, the functions of the MagicLink application module and the WiFi link module of the device are decoupled, the MagicLink application module is responsible for business scenario management and device networking, and the WiFi link module is responsible for deciding WiFi P2P connection configuration information and establishing a WiFi P2P connection.

[0336] In the embodiments of the present application, the local device (e.g., the mobile phone A) and the peer device can both be new version devices.

[0337] 708b, the MagicLink application module of the mobile phone A initiates a connection call to the WiFi link module of the mobile phone A.

[0338] 709, the WiFi link module of the mobile phone A sends its WiFi capability information to the WiFi link module of the tablet B.

[0339] The specific process can refer to steps 417-421a, and will not be repeated here.

[0340] In the embodiments of the present application, the WiFi capability information of the mobile phone A can also include P2P role (e.g., the mobile phone A can act as a GC) information of the mobile phone A in the established WiFi P2P connection (the WiFi P2P connection established by the mobile phone A and the mobile phone C).

[0341] 710a, the WiFi link module of the tablet B decides whether the tablet B can establish a WiFi P2P connection with the mobile phone A according to the WiFi capability information of the mobile phone A and the WiFi capability information of the tablet B.

[0342] In the embodiment of the present application, the mobile phone A has established a WiFi P2P connection with the mobile phone C, the P2P role of the mobile phone A is GC, and the tablet computer B has no idle network card. The P2P role of the tablet computer B can be a default role (the P2P role of the tablet computer B can be the default role when the tablet computer B has not established a WiFi P2P connection), and the tablet computer B has an idle network card.

[0343] In the case that the P2P role of the mobile phone A is GC and the tablet computer has no idle network card, the tablet computer B cannot directly establish a WiFi P2P connection with the mobile phone A.

[0344] 710b. In the case that the tablet computer B cannot establish a WiFi P2P connection with the mobile phone A, the WiFi link module of the tablet computer B decides whether the tablet computer B can establish a bridge with the GO device connected by the mobile phone A according to the WiFi capability information of the mobile phone A and the WiFi capability information of the tablet computer B.

[0345] In the case that the P2P role of the mobile phone A is GC and the tablet computer B has an idle network card, the tablet computer B decides to establish a bridge with the mobile phone A based on the GO device connected by the mobile phone A (for example, the mobile phone C) (that is, the bridge is established among the tablet computer B, the mobile phone A and the GO device connected by the mobile phone A).

[0346] 710c. The WiFi link module of the tablet computer B sends the decision result (indicating to establish a bridge) to the WiFi link module of the mobile phone A.

[0347] For example, the decision result can indicate that the tablet computer B establishes a bridge with the mobile phone A based on the GO device connected by the mobile phone A (that is, the bridge is established among the tablet computer B, the mobile phone A and the GO device connected by the mobile phone A).

[0348] The specific process can be referred to the related description of steps 422a-424.

[0349] In some embodiments, the WiFi link module of the tablet computer B can carry the WiFi capability information of the tablet computer B when sending the decision result to the WiFi link module of the mobile phone A.

[0350] 710d. The WiFi link module of the tablet computer B informs the MagicLink application module of the tablet computer B to enter the bridge state.

[0351] 710e. The MagicLink application module of the tablet computer B enters the bridge state.

[0352] The MagicLink application module of the tablet computer B can wait for the mobile phone A to initiate the bridge process.

[0353] 711a, the WiFi link module of the phone A informs the MagicLink application module of the phone A to initiate a bridge process.

[0354] 711b, the MagicLink application module of the phone A judges that the local can bridge with the idle network card of the tablet B.

[0355] Based on step 701, the phone A has established a WiFi P2P connection with the phone C through the network card 0 of the local, in which the P2P role of the phone A is GC. Moreover, the phone A has no idle network card. In this case, the local (for example, the phone A) can establish a bridge with the tablet B through the network card 0 of the local. The network card 0 is the network card of the phone A for establishing the WiFi P2P connection with the phone C, and the phone A can connect to the phone C through the network card 0, and then connect the tablet B based on the phone C. That is, the tablet B can establish a WiFi P2P connection with the GO device (for example, the phone C) of the first WiFi P2P connection saved by the local, so that the local (the phone A) can indirectly connect based on the GO device (for example, the phone C) and the opposite device (for example, the tablet B), that is, bridge (also can be called P2P bridge). Further, the phone C can forward information between the phone A and the tablet B.

[0356] 712, the MagicLink application module of the phone A enters a bridge state.

[0357] As shown in Figure 7B , the method further comprises:

[0358] 713, the MagicLink application module of the phone A sends the device ID and the network card MAC of the GO device to the MagicLink application module of the tablet B.

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

[0360] The network card of the GO device (for example, the phone C) can be the network card (for example, the network card 0 of the phone C) of the GO device for establishing the WiFi P2P connection with the phone A.

[0361] 714, the MagicLink application module of the tablet B sends the device ID and the network card MAC of the GO device to the WiFi link module of the tablet B.

[0362] The tablet B and the phone C establish the channel 1 and the channel 2. The specific process can refer to the related description of steps 413a-415b, which will not be repeated here.

[0363] 715. The WiFi link module of the tablet B generates a WiFi negotiation packet 1, which is used to indicate that the tablet B connects the GO device (the phone C) as the GC of the network card (e.g., the network card 0).

[0364] The WiFi negotiation packet 1 can include the P2P role (e.g., GC) of the tablet B and the network card MAC (e.g., the MAC of the network card 0 of the phone C) of the phone C.

[0365] 716a. The WiFi link module of the tablet B invokes the channel 2 and passes in the WiFi negotiation packet 1.

[0366] 716b. The MagicLink application module of the tablet B adds a bridge field to the WiFi negotiation packet 1, obtaining a WiFi negotiation packet 2.

[0367] The bridge field is used to indicate that the WiFi negotiation packet 1 is a bridge request packet, which is used to establish a bridge.

[0368] 716c. The MagicLink application module of the tablet B sends the WiFi negotiation packet 2 to the phone C.

[0369] The MagicLink application module of the tablet B can send the WiFi negotiation packet 2 through the channel 2 between the tablet B and the phone C.

[0370] 717. The MagicLink application module of the phone C receives the WiFi negotiation packet 2 through the channel 2, and strips the bridge field to obtain the WiFi negotiation packet 1.

[0371] 718. The MagicLink application module of the phone C enters a bridge state.

[0372] After recognizing the bridge field of the WiFi negotiation packet 2, the MagicLink application module of the phone C can enter the bridge state, i.e., prepare to establish a bridge with the opposite device (e.g., the tablet B).

[0373] 719. The MagicLink application module of the phone C sends the WiFi negotiation packet 1 to the WiFi link module of the phone C.

[0374] 720. The WiFi link module of the phone C parses the WiFi negotiation packet 1 and determines that the tablet B connects the network card of the phone C as the GC.

[0375] 721. The WiFi link module of the tablet B and the WiFi link module of the phone C establish a WiFi P2P connection.

[0376] The detailed procedure can refer to the description of the WiFi P2P connection between the mobile phone A and the tablet B (i.e., steps 425a-430), and the mobile phone A in steps 425a-430 is replaced by the mobile phone C (i.e., the mobile phone C is the GO device, and the tablet B is the GC device), which will not be repeated here.

[0377] 722a. The WiFi link module of the mobile phone C sends a WiFi notification message to the MagicLink application module of the mobile phone C, and the WiFi notification message is used to notify the WiFi P2P connection success.

[0378] The MagicLink application module of the mobile phone C saves the WiFi P2P connection. A TCP encrypted channel based on the WiFi P2P connection can also be created between the mobile phone C and the tablet B. The detailed procedure can refer to the description of the TCP encrypted channel based on the WiFi P2P connection between the mobile phone C and the mobile phone A (i.e., steps 433-435b), and the mobile phone A in steps 433-435b is replaced by the tablet B, which will not be repeated here.

[0379] 722b. The WiFi link module of the tablet B sends a WiFi notification message to the MagicLink application module of the tablet B, and the WiFi notification message is used to notify the WiFi P2P connection success.

[0380] For example, the network card 0 of the mobile phone C can establish a WiFi P2P connection with the network card 0 of the tablet B. In the WiFi P2P connection, the mobile phone C can be the GO device (GO end), and the tablet B can be the GC (GC end).

[0381] It should be noted that the purpose of the WiFi P2P connection between the mobile phone C and the tablet B is to bridge the mobile phone A and the tablet B through the mobile phone C. It can be considered that the mobile phone C, the mobile phone A and the tablet B form a P2P bridging connection (referred to as a bridging connection), and the P2P roles of the devices in the P2P bridging connection are as follows: the mobile phone C-GO (i.e., the mobile phone C as the GO device); the mobile phone A-GC (i.e., the mobile phone A as the GC device); and the tablet B-GC (i.e., the tablet B as the GC device).

[0382] The mobile phone C and the tablet B can save the P2P bridging information (for example, the mobile phone C-G0; the mobile phone A-GC; and the tablet B-GC) respectively.

[0383] 723. The MagicLink application module of the tablet B notifies the MagicLink application module of the mobile phone A of the bridging success.

[0384] That is, the MagicLink application module of the tablet B can send a connection success message to the MagicLink application module of the mobile phone A, and the connection success message is used to indicate that the tablet B is connected with the mobile phone C (the third electronic device) successfully.

[0385] The mobile phone A can save the role information of the P2P bridging connection (for example, mobile phone C-G0; mobile phone A-GC; tablet B-GC).

[0386] 724、The MagicLink application module of the mobile phone A notifies the smart interconnection application of the mobile phone A of the device connection success.

[0387] That is, after the TCP encrypted channel based on the WiFi P2P connection is established successfully, the MagicLink application module of the mobile phone A notifies the smart interconnection application of the mobile phone A of the device connection success.

[0388] 725、The smart interconnection application of the mobile phone A prompts the user that the screen sharing service is established successfully.

[0389] In addition, the smart interconnection application of the mobile phone A can initiate the screen sharing service based on the TCP encrypted channel of the WiFi P2P connection. That is, the screen sharing data (for example, the information related to the screen of the mobile phone C) is sent to the opposite end device (the mobile phone A) through the WiFi P2P connection.

[0390] 726、The smart interconnection application of the mobile phone A and the smart interconnection application of the tablet B perform information interaction of screen sharing.

[0391] The smart interconnection application of the mobile phone A can perform information interaction of screen sharing with the smart interconnection application of the tablet B through the MagicLink application module of the mobile phone C. That is, the mobile phone C can be used as a transfer device to forward the information that needs to be interacted between the mobile phone A and the tablet B.

[0392] In the embodiments of the present application, the tablet B can establish a bridge with the mobile phone A through the mobile phone C based on the QoS information of the service and the WiFi capability information of the device, so that the service (for example, the screen sharing service) demand can be better met, and the problems such as lag and frame drop of the service can be avoided.

[0393] An embodiment of the present application provides a chip system, such as Figure 8As shown, the chip system includes at least one processor 801 and at least one interface circuit 802. The processor 801 and the interface circuit 802 can be interconnected by a line. For example, the interface circuit 802 can be used to receive a signal from another device (e.g., a memory of a first electronic device (e.g., tablet B) or a memory of a second electronic device (e.g., mobile phone A)). For another example, the interface circuit 802 can be used to send a signal to another device (e.g., the processor 801).

[0394] For example, the interface circuit 802 can read an instruction stored in a memory of the device and send the instruction to the processor 801. When the instruction is executed by the processor 801, it can cause the first electronic device or the second electronic device (e.g., the electronic device 100 as shown) to perform various steps in the above embodiments. Figure 2 For example, the interface circuit 802 can read an instruction stored in a memory of the device and send the instruction to the processor 801. When the instruction is executed by the processor 801, it can cause the first electronic device or the second electronic device (e.g., the electronic device 100 as shown) to perform various steps in the above embodiments.

[0395] Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0396] Some other embodiments of the present application provide a first electronic device (e.g., the electronic device 100 as shown), which can include a communication module, a memory and one or more processors. The communication module, the memory and the processor are coupled. The memory is configured to store computer program code, which includes computer instructions. Figure 2 Some other embodiments of the present application provide a second electronic device (e.g., the electronic device 100 as shown), which can include a communication module, a memory and one or more processors. The communication module, the memory and the processor are coupled. The memory is configured to store computer program code, which includes computer instructions.

[0397] Figure 2 Some other embodiments of the present application provide a computer readable storage medium, which includes computer instructions. When the computer instructions are run on a first electronic device (e.g., the electronic device 100 as shown), the electronic device 200 performs various functions or steps performed by the first electronic device (e.g., tablet B) in the above method embodiments. When the computer instructions are run on a second electronic device (e.g., the electronic device 100 as shown), the electronic device 200 performs various functions or steps performed by the second electronic device (e.g., mobile phone A) in the above method embodiments.

[0398] Some other embodiments of the present application provide a computer readable storage medium, which includes computer instructions. When the computer instructions are run on a first electronic device (e.g., the electronic device 100 as shown), the electronic device 200 performs various functions or steps performed by the first electronic device (e.g., tablet B) in the above method embodiments. When the computer instructions are run on a second electronic device (e.g., the electronic device 100 as shown), the electronic device 200 performs various functions or steps performed by the second electronic device (e.g., mobile phone A) in the above method embodiments. Figure 2 Figure 2

[0399] ​​​The embodiment of the present application further provides a computer program product, which, when running on a computer, enables the computer to perform each function or step of the first electronic device (for example, the tablet computer B) or the second electronic device (for example, the mobile phone A) in the above method embodiment.

[0400] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional modules is taken as an example, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

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

[0402] The units described as separate components can or can not be physically separated, and the components shown as units can be one physical unit or multiple physical units, that is, can be located in one place or can be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0403] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0404] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The software product is stored in a storage medium, includes a plurality of instructions to make a device (which can be a single-chip microcomputer, a chip, etc.) or a processor execute all or part of the steps of the method described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0405] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any change or replacement within the technical scope disclosed in the present application should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A WiFi P2P connection method, characterized in that, Applied to a first electronic device, the first electronic device including a first application module and a first WiFi module, the first application module being located at the application layer and the first WiFi module being located at the framework layer, the method includes: The first application module receives the WiFi capability information of the second electronic device from the second electronic device; The first application module sends the WiFi capability information of the second electronic device to the first WiFi module; The first WiFi module obtains the WiFi capability information of the first electronic device; The first WiFi module determines WiFi P2P connection configuration information based on the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device. The WiFi P2P connection configuration information includes the channel used for WiFi P2P connection and the information of the device acting as the manager GO. The first electronic device establishes a WiFi P2P connection with the second electronic device based on the WiFi P2P connection configuration information.

2. The method according to claim 1, characterized in that, Before the first application module receives the WiFi capability information of the second electronic device, the method further includes: The first application module establishes a physical link with the second electronic device; The first application module establishes a first communication channel with the second electronic device; the first communication channel is established on the physical link; 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 second electronic device; The first application module receives the WiFi capability information of the second electronic device, including: The first application module receives the WiFi capability information of the second electronic device through the first communication channel.

3. The method according to claim 2, characterized in that, The data packets transmitted in the first communication channel are in TLV format; wherein, T in TLV indicates the type of receiving module corresponding to the data packet; V in TLV represents the actual value carried in the data packet; and L in TLV represents the length of the actual value.

4. The method according to any one of claims 1-3, characterized in that, The WiFi capability information of the first electronic device includes at least one of the following: the identifier, model, available channel, and information on the WiFi connections already established by the first electronic device.

5. The method according to claim 2 or 3, characterized in that, The first application module receives the WiFi capability information of the second electronic device through the first communication channel, including: The first application module receives a first data packet from the second electronic device through the first communication channel. The first data packet includes a first header and first data. The first header is used to indicate that the first data packet comes from the first communication channel, and the first data includes WiFi capability information of the second electronic device. The first application module sends the WiFi capability information of the second electronic device to the first WiFi module, including: The first application module strips the first packet header from the first data packet and sends the first data to the first WiFi module.

6. The method according to claim 5, characterized in that, The first data also includes QoS information of the target service, which is a service that exchanges data based on WiFi P2P connection. The QoS information of the target service includes one or more of the bandwidth requirements, latency requirements, and jitter requirements of the target service.

7. The method according to claim 6, characterized in that, The first WiFi module determines the WiFi P2P connection configuration information based on the WiFi capability information of the second electronic device and the WiFi capability information of the first electronic device, including: When the QoS information of the target service meets the first condition, and the first electronic device and the second electronic device support WiFi P2P connection in the first frequency band, the channel used for WiFi P2P connection in the WiFi P2P connection configuration information is the channel of the first frequency band; wherein, the first condition includes: the expected bandwidth of the target service is greater than a first threshold.

8. The method according to claim 6 or 7, characterized in that, The method further includes: If the QoS information of the target service meets the first condition, and if the first electronic device and the second electronic device do not support WiFi P2P connection of the first frequency band, the first electronic device sends indication information to the second electronic device. The indication information is used to indicate that the first electronic device connects to the second electronic device through a third electronic device, wherein the third electronic device is a device that has established a WiFi P2P connection with the second electronic device, and the P2P role of the third electronic device in the established WiFi P2P connection is administrator GO.

9. The method according to claim 8, characterized in that, The first electronic device is connected to the second electronic device via a third electronic device, including: The first electronic device receives the device identifier and network card information of the third electronic device from the second electronic device; The first electronic device establishes a second WiFi P2P connection with the third electronic device based on the device identifier and network card information of the third electronic device; The first electronic device sends a connection success message to the second electronic device, the connection success message indicating that the connection between the first electronic device and the third electronic device is successful.

10. The method according to claim 7, characterized in that, After the first WiFi module determines the WiFi P2P connection configuration information, the method further includes: The first WiFi module calls the first communication channel to send the WiFi P2P connection configuration information to the first application module; The first application module encapsulates a second data packet, the second data packet including a second header and second data, the second header being used to indicate that the second data packet comes from the first communication channel, and the second data including the WiFiP2P connection configuration information; The first application module sends the second data packet to the second electronic device based on the first communication channel.

11. The method according to claim 10, characterized in that, The first application module receives a third data packet from the second electronic device through the first communication channel. The third data packet includes a third packet header and connection information of the device as a GO. The third packet header is used to indicate that the third data packet comes from the first communication channel. The first application module strips the third packet header from the third data packet and sends the connection information of the device acting as GO to the first WiFi module; The first WiFi module establishes a WiFi P2P connection with the second electronic device based on the connection information of the device acting as GO.

12. The method according to claim 11, characterized in that, The method further includes: The first application module establishes a second communication channel with the second electronic device; the second communication channel is established on the physical link and is used to transmit information between the first application module and the second electronic device. The first application module receives a fourth data packet from the second electronic device through the second communication channel. The fourth data packet includes the IP and TCP port of the second electronic device. The first application module establishes a secure TCP channel with the second electronic device based on the IP and TCP ports of the second electronic device, using the WiFi P2P connection.

13. The method according to claim 12, characterized in that, The data packets transmitted in the second communication channel are in key-value pair format.

14. A WiFi P2P connection method, characterized in that, Applied to a second electronic device, the second electronic device including a second application module and a second WiFi module, the method includes: The second WiFi module obtains the WiFi capability information of the second electronic device; The second WiFi module sends the WiFi capability information of the second electronic device to the second application module; The second application module sends the WiFi capability information of the second electronic device to the first electronic device; The second application module receives WiFi P2P connection configuration information from the first electronic device. The WiFi P2P connection configuration information includes information on the channel for indicating WiFi P2P connection and the device acting as the manager GO. The second application module sends the WiFi P2P connection configuration information to the second WiFi module; The second electronic device establishes a WiFi P2P connection with the first electronic device based on the WiFi P2P connection configuration information.

15. The method according to claim 14, characterized in that, Before the second application module sends the WiFi capability information of the second electronic device to the first electronic device, the method further includes: The second application module establishes a physical link with the first electronic device; The second application module establishes a first communication channel with the first electronic device; the first communication channel is established on the physical link; The second application module registers the first communication channel with the second WiFi module, and the first communication channel is used to transmit information between the second WiFi module and the first electronic device; The second WiFi module sends the WiFi capability information of the second electronic device to the second application module, including: The second WiFi module calls the first communication channel to send the WiFi capability information of the second electronic device to the second application module; The second application module sends the WiFi capability information of the second electronic device to the first electronic device, including: The second application module sends the WiFi capability information of the second electronic device to the first electronic device through the first communication channel.

16. The method according to claim 15, characterized in that, The data packets transmitted in the first communication channel are in TLV format.

17. The method according to any one of claims 14-16, characterized in that, The second electronic device includes at least one of the following: the identifier, model, available channel, and information on the WiFi connection already established by the second electronic device.

18. The method according to claim 15 or 16, characterized in that, The first electronic device further includes a first application. Before the second WiFi module sends the WiFi capability information of the second electronic device to the second application module, the method further includes: The first application receives a first operation, which is used to initiate a target service; The first application initiates a connection call to the second application module and sends the Quality of Service (QoS) information of the target service to the second application module; The second application module sends the QoS information to the second WiFi module; The second WiFi module sends the WiFi capability information of the second electronic device to the second application module, including: The second WiFi module sends the WiFi capability information and QoS information of the second electronic device to the second application module.

19. The method according to claim 18, characterized in that, The second application module sends the WiFi capability information of the second electronic device to the first electronic device, including: The second application module encapsulates a first data packet, which includes a first header and first data. The first header indicates that the first data packet comes from the first communication channel, and the first data includes the WiFi capability information and QoS information of the second electronic device. The second application module sends the first data packet to the first electronic device based on the first communication channel.

20. The method according to claim 19, characterized in that, The second application module receives WiFi P2P connection configuration information from the first electronic device, including: The second application module receives a second data packet from the first electronic device through the first communication channel. The second data packet includes a second header and second data. The second header is used to indicate that the second data packet comes from the first communication channel, and the second data includes the WiFi P2P connection configuration information. The second application module sends the WiFi P2P connection configuration information to the second WiFi module, including: The second application module strips the second packet header from the second data packet and sends the second data to the second WiFi module.

21. The method according to claim 20, characterized in that, When the QoS information satisfies the first condition, and the first electronic device and the second electronic device support WiFi P2P connection in the first frequency band, the channel used for WiFi P2P connection in the WiFi P2P connection configuration information is the channel of the first frequency band; wherein, the first condition includes: the expected bandwidth of the target service is greater than a first threshold.

22. The method according to claim 20 or 21, characterized in that, The method further includes: If the QoS information of the target service meets the first condition, and the first electronic device and the second electronic device do not support WiFi P2P connection of the first frequency band, the second electronic device receives indication information from the first electronic device. The indication information is used to instruct the first electronic device to connect to the second electronic device through a third electronic device. The third electronic device is a device that has established a WiFi P2P connection with the second electronic device, and the P2P role of the third electronic device in the established WiFi P2P connection is manager GO.

23. The method according to claim 22, characterized in that, The first electronic device is connected to the second electronic device via a third electronic device, including: The second electronic device sends the device identifier and network card information of the third electronic device to the first electronic device; The second electronic device receives a connection success message from the first electronic device, the connection success message indicating that the connection between the first electronic device and the third electronic device is successful.

24. The method according to claim 20, characterized in that, The method further includes: The second WiFi module determines the connection information of the device acting as GO based on the WiFi P2P connection configuration information; The second WiFi module sends the connection information of the device acting as GO to the second application module; The second application module encapsulates a third data packet, which includes a third header and connection information of the device acting as the GO. The third header is used to indicate that the third data packet comes from the first communication channel. The second application module sends the third data packet to the first electronic device through the first communication channel; The second WiFi module establishes a WiFi P2P connection with the first electronic device based on the connection information of the device acting as GO.

25. The method according to claim 24, characterized in that, The method further includes: The second application module establishes a second communication channel with the first electronic device; The second application module sends a fourth data packet to the first electronic device through the second communication channel. The fourth data packet includes the IP address and TCP port of the second electronic device. The second application module establishes a secure TCP channel with the first electronic device based on the IP and TCP ports of the second electronic device, using the WiFi P2P connection.

26. The method according to claim 25, characterized in that, The fourth data packet transmitted in the second communication channel is in key-value pair format.

27. A first electronic device, characterized in that, The first electronic device includes: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processors 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 first electronic device performs the method as described in any one of claims 1-13.

28. A second electronic device, characterized in that, The second electronic device includes: a wireless communication module, a memory, and one or more processors; the wireless communication module, the memory, and the processors 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 second electronic device performs the method as described in any one of claims 14-26.

29. A computer-readable storage medium, characterized in that, Includes computer instructions; When the computer instructions are executed on the first electronic device, the first electronic device performs the method as described in any one of claims 1-13; or When the computer instructions are executed on the second electronic device, the second electronic device causes the second electronic device to perform the method as described in any one of claims 14-26.

30. A computer program product, characterized in that, The computer program product is used to run on a computer to implement the method as described in any one of claims 1-13 or 14-26.