Communication method, electronic equipment and storage medium

By exchanging device information and negotiating roles on the basis of existing WI-FI P2P connections, and using original services and ports, WI-FI connections between devices are realized, which solves the problem that devices in the existing technology can no longer establish WI-FI P2P connections. problems, expanding equipment application and business execution capabilities.

CN118555682APending Publication Date: 2024-08-27HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310209565.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Once the existing WI-FI P2P connection is established, the device can no longer establish WI-FI P2P connections with other devices, which limits the execution and application expansion of services between devices.

Method used

On the basis of the established WI-FI P2P connection, by exchanging device information and negotiating roles, the original services and ports are used to realize the WI-FI connection between devices without resorting to AP or LAN for direct point-to-point communication.

Benefits of technology

It expands the application capabilities of the device, realizes collaborative business execution between devices, and enhances the flexibility and efficiency of WI-FI connections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118555682A
    Figure CN118555682A
Patent Text Reader

Abstract

The embodiment of the invention provides a communication method, electronic equipment and a storage medium, under the condition that a first electronic equipment and a second electronic equipment have established a WI-FI P2P connection, responding to an operation of triggering the first electronic equipment and a third electronic equipment to establish a WI-FI connection. The first electronic device can send device information of the first electronic device to a third electronic device and receive device information from the third electronic device, and the WI-FI connection is WI-FI connection between devices; and establishing WI-FI connection with the third electronic equipment according to the equipment information of the first electronic equipment and the equipment information of the third electronic equipment. In the application, the first electronic device which has established the WI-FI P2P connection can also establish the WI-FI connection with other electronic devices, and the first electronic device and the third electronic device can directly communicate, so that the first electronic device can cooperatively execute services with other electronic devices.
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 technology, and in particular, to a communication method, an electronic device, and a storage medium. Background Art

[0002] Wi-Fi direct, also known as Wi-Fi peer-to-peer (WI-FI P2P), is a Wi-Fi technology launched by the Wi-Fi Alliance that can achieve direct connection between devices. Devices can communicate one-to-one or one-to-many without the need for a local area network or access point (AP).

[0003] Currently, for a device that has established a WI-FI P2P connection, the device can no longer establish a WI-FI P2P connection with other devices, which limits the execution of services between devices. Summary of the invention

[0004] An embodiment of the present application provides a communication method, an electronic device, and a storage medium. On the basis that a WI-FI P2P connection has been established in the electronic device, the electronic device can establish a WI-FI connection with other electronic devices, and the WI-FI connection can realize point-to-point communication between the electronic device and the other electronic devices.

[0005] In the first aspect, an embodiment of the present application provides a communication method, and the execution subject of the communication method may be a first electronic device or a chip, a processor, etc. in the first electronic device. The following description is made by taking the first electronic device as an example. In this method, when the first electronic device has established a WI-FI P2P connection with the second electronic device, in response to an operation that triggers the first electronic device and the third electronic device to establish a WI-FI connection, the first electronic device may exchange device information with the third electronic device. Among them, the first electronic device may send the device information of the first electronic device to the third electronic device, and receive the device information from the third electronic device.

[0006] The first electronic device can establish a WI-FI connection with the third electronic device based on the device information of the first electronic device and the device information of the third electronic device. The WI-FI connection in the embodiment of the present application is a point-to-point connection, which can be established without the permission of the AP. After the first electronic device and the third electronic device establish a WI-FI connection, they can communicate directly without the help of an access point AP or a local area network. It is understandable that the WI-FI P2P connection is included in the WI-FI connection.

[0007] The WI-FI connection involved in the embodiments of the present application can be understood as at least one end of the WI-FI connection being "GO or GC". For example, taking the establishment of a WI-FI connection between a first electronic device and a third electronic device as an example, when the first electronic device is a GO, the third electronic device can be a GC or STA device, and when the first electronic device is a GC, the third electronic device can be a GO or softAP. Correspondingly, when the third electronic device is a GO, the first electronic device can be a GC or STA device, and when the third electronic device is a GC, the first electronic device can be a GO or softAP.

[0008] In an embodiment of the present application, when the first electronic device and the second electronic device have established a WI-FI P2P connection, the first electronic device can also establish a WI-FI connection with the third electronic device. The WI-FI connection has the same communication effect as the WI-FI P2P connection. The first electronic device and the third electronic device can communicate directly without communicating through a local area network or with the help of an AP. In this way, the first electronic device and the third electronic device can collaborate in executing services, thereby expanding the application of the first electronic device.

[0009] In a possible implementation, the communication method provided in the embodiment of the present application can be applied in the following two scenarios:

[0010] Scenario 1: In the WI-FI P2P connection established between the first electronic device and the second electronic device, the role of the first electronic device is a group member GC. In this scenario 1, the third electronic device may not have established a WI-FI P2P connection, or the third electronic device may have established a WI-FI P2P connection.

[0011] Scenario 2: In the WI-FI P2P connection established between the first electronic device and the second electronic device, the role of the first electronic device is the group manager GO, and the third electronic device and the fourth electronic device have established a WI-FI P2P connection.

[0012] It should be noted that in the WI-FI P2P connection established between the first electronic device and the second electronic device, the role of the first electronic device is the group manager GO. If the third electronic device has not established a WI-FI P2P connection, according to the current WI-FI P2P connection protocol, the third electronic device can be used as a GC to directly establish a WI-FI P2P connection with the first electronic device as the GO.

[0013] In this implementation, it can be realized that the first electronic device as a GC can also establish a WI-FI connection with other electronic devices, and it can also be realized that the first electronic device as a GO can also establish a WI-FI connection with other electronic devices that have established a WI-FI P2P connection, which can expand the application of the first electronic device. It should be understood that the first electronic device as a GC refers to: the role of the first electronic device in the WI-FI P2P connection established by the first electronic device is GC, and the first electronic device as a GO refers to: the role of the first electronic device in the WI-FI P2P connection established by the first electronic device is GO.

[0014] In the above scenario 1 and scenario 2, the first electronic device and the third electronic device may establish a WI-FI connection in the same manner, which may be as follows:

[0015] In an embodiment of the present application, the first electronic device can use the service in the first electronic device to establish a WI-FI connection with the third electronic device, where the service is a first service or a second service, where the first service is a service for the first electronic device to access an AP to access the network, and the second service is a service for the first electronic device to establish a WI-FI P2P connection.

[0016] It should be understood that the first service is a service used for the first electronic device to access the access point to access the network, which can be understood as: the first service can be used for the first electronic device to query the AP, exchange information with the AP, and access the AP, thereby achieving network access. In one example, the first service can be regarded as providing a network access function and a connection function, wherein the network access function can be used for the first electronic device to query the AP and exchange information with the AP, and the connection function is used for the first electronic device to establish a connection with the AP. Exemplarily, when the first electronic device includes a roaming function, the network access function includes a roaming function. When the first electronic device includes a roaming function and a function of detecting Internet access capability, the network access function includes a roaming function and a function of detecting Internet access capability.

[0017] In one embodiment, the first service is a WI-FI service, and the second service is a WI-FI P2P service.

[0018] In this implementation, there is no need to set additional processing logic in the first electronic device. Instead, the first electronic device that has established a WI-FI P2P connection can establish a WI-FI connection with other electronic devices by using existing services in the first electronic device.

[0019] The following describes a method for establishing a WI-FI connection between the first electronic device and the third electronic device:

[0020] First, when the first service is idle, the first electronic device can shield the network access function provided by the first service, retain the connection function provided by the first service, and use the connection function provided by the first service to establish a WI-FI connection with the third electronic device. The reason why the first electronic device shields the network access function provided by the first service is that the first electronic device uses the network access function provided by the first service to query the AP and interact with the AP, and then access the AP. In the embodiment of the present application, shielding the network access function provided by the first service can enable the first electronic device to use the connection function provided by the first service to establish a WI-FI connection with the third electronic device.

[0021] In a possible implementation, the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. The first electronic device includes a first port and a second port, the first electronic device includes a first WI-FI service and the second service, the first WI-FI service corresponds to the first port, and the second service corresponds to the second port. In this implementation, the first service is the first WI-FI service.

[0022] In a possible implementation, the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. The first electronic device includes a first port, a second port, and a third port, the first electronic device includes a first WI-FI service, a second WI-FI service, and the second service, the first WI-FI service corresponds to the first port, the second WI-FI service corresponds to the third port, and the second service corresponds to the second port. In this implementation, the first service is the first WI-FI service or the second WI-FI service.

[0023] In this implementation, the first electronic device can use the idle first service to establish a WI-FI connection with the third electronic device. The WI-FI connection can achieve the same communication effect as the WI-FI P2P connection, so that the first electronic device and the third electronic device can communicate directly to collaboratively perform business.

[0024] Secondly, the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. When the first service is not idle and the first electronic device has not used the first service to establish a WI-FI connection, if the first priority of the service collaboratively performed by the first electronic device and the second electronic device is lower than the second priority of the service collaboratively performed by the first electronic device and the third electronic device, the WI-FI P2P connection established with the second electronic device is disconnected, and the second service is used to establish a WI-FI P2P connection with the third electronic device.

[0025] Among them, the first service is not idle, and the first electronic device does not use the first service to establish a WI-FI connection, which can indicate that the first electronic device uses the first service to access the AP. In this example, the first electronic device can determine whether to preempt the second service to establish a WI-FI P2P connection with the third electronic device by comparing the first priority and the second priority. Among them, when the first priority is lower than the second priority, the first electronic device can determine to preempt the second service, and disconnect the WI-FI P2P connection established with the second electronic device, and use the second service to establish a WI-FI P2P connection with the third electronic device. Among them, when the first priority is higher than the second priority, the first electronic device can determine not to preempt the second service, that is, determine not to establish a WI-FI P2P connection with the third electronic device.

[0026] In this implementation, the first electronic device can establish a WI-FI P2P connection with the third electronic device by preempting the second service used to establish the WI-FI P2P connection, so that the first electronic device and the third electronic device can communicate directly to collaboratively perform services.

[0027] Third, the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. When the first service is not idle and the first electronic device uses the first service to establish a WI-FI connection with a fifth electronic device, the first electronic device can establish a WI-FI connection with the third electronic device based on the first priority, the second priority, and the third priority of the service collaboratively performed by the first electronic device and the fifth electronic device.

[0028] Among them, if the first priority and the third priority are both lower than the second priority, the first electronic device disconnects the WI-FI P2P connection established with the second electronic device, and uses the second service to establish a WI-FI P2P connection with the third electronic device, or disconnects the WI-FI connection established with the fifth electronic device, and uses the first service to establish a WI-FI connection with the third electronic device.

[0029] Among them, if the first priority and the third priority are both lower than the second priority, the first electronic device disconnects the WI-FI connection with the lowest priority and uses the service corresponding to the disconnected WI-FI connection to establish a WI-FI connection with the third electronic device.

[0030] Among them, if the first priority is higher than the second priority and the third priority is lower than the second priority, the first electronic device disconnects the WI-FI connection established with the fifth electronic device and uses the first service to establish a WI-FI connection with the third electronic device.

[0031] Among them, if the third priority is higher than the second priority and the first priority is lower than the second priority, the first electronic device disconnects the WI-FI P2P connection established with the second electronic device and uses the second service to establish a WI-FI P2P connection with the third electronic device.

[0032] If the first priority and the third priority are both higher than the second priority, the first electronic device determines not to establish a WI-FI connection with the third electronic device.

[0033] In this implementation, the first electronic device can establish a WI-FI connection with the third electronic device by preempting the second service used to establish a WI-FI P2P connection or the first service used to establish a point-to-point WI-FI connection. Similarly, the first electronic device and the third electronic device can communicate directly to collaboratively execute services.

[0034] In a possible implementation, the first electronic device may establish a Bluetooth channel with the third electronic device, and send device information of the first electronic device to the third electronic device and receive device information from the third electronic device through the Bluetooth channel.

[0035] The device information of the first electronic device is used to indicate the role of the first electronic device in the WI-FI P2P connection established with the second electronic device, and the device information of the third electronic device is used to indicate whether the third electronic device has established a WI-FI connection. In the case where the third electronic device has established a WI-FI connection, the device information of the third electronic device is also used to indicate the role of the third electronic device in the established WI-FI P2P connection.

[0036] The first electronic device may negotiate the role of the first electronic device and the role of the third electronic device in the WI-FI connection established with the third electronic device based on the device information of the first electronic device and the device information of the third electronic device. And the first electronic device may establish a WI-FI connection with the third electronic device based on the negotiated role of the first electronic device and the role of the third electronic device.

[0037] In this implementation, the first electronic device that has established a WI-FI P2P connection can also negotiate the role in the WI-FI connection with the third electronic device, and establish a WI-FI connection according to the negotiated role. The role of the first electronic device in the WI-FI connection can be the same as or different from the role of the first electronic device in the WI-FI P2P connection established by the second electronic device. Similarly, the role of the third electronic device in the WI-FI connection can be the same as or different from the role of the third electronic device in the established WI-FI P2P connection.

[0038] In a second aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory. The memory is used to store computer executable program code, and the program code includes instructions; when the processor executes the instructions, the instructions cause the electronic device to execute the method in the first aspect.

[0039] In a third aspect, an embodiment of the present application provides an electronic device, which may be the terminal device described in the first aspect. The electronic device may include a unit, a module or a circuit for executing the method provided in the first aspect above.

[0040] In a fourth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method in the first aspect.

[0041] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the method in the first aspect above.

[0042] The beneficial effects of the possible implementation methods of the second to fifth aspects mentioned above can be referred to the beneficial effects brought about by the first aspect mentioned above, and will not be elaborated here.

[0043] In the communication method provided by the embodiment of the present application, when the first electronic device and the second electronic device have established a WI-FI P2P connection, the first electronic device establishes a WI-FI connection with the third electronic device based on the device information of the first electronic device and the device information of the third electronic device. The WI-FI connection has the same communication effect as the WI-FI P2P connection. The first electronic device and the third electronic device can communicate directly without communicating through a local area network or with the help of an AP. In this way, the first electronic device and the third electronic device can collaborate in executing services, thereby expanding the application of the first electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A schematic diagram of a current WI-FI P2P connection of electronic devices;

[0045] Figure 2A Schematic diagram showing that GO can connect to at least one GC;

[0046] Figure 2B A schematic diagram showing that GC cannot connect to other devices;

[0047] Figure 2C Another schematic diagram showing that GC cannot connect to other devices;

[0048] Figure 3 A schematic diagram of a software architecture for an electronic device;

[0049] Figure 4A A connection diagram of an electronic device;

[0050] Figure 4B Another connection diagram of an electronic device;

[0051] Figure 5 A software structure block diagram of an electronic device provided in an embodiment of the present application;

[0052] Figure 6 A flow chart of an embodiment of a communication method provided in an embodiment of the present application;

[0053] Fig. 7A A connection diagram of an electronic device provided in an embodiment of the present application;

[0054] Figure 7B Another connection diagram of an electronic device provided in an embodiment of the present application;

[0055] Figure 7C Another connection diagram of an electronic device provided in an embodiment of the present application;

[0056] Fig.7D Another connection diagram of an electronic device provided in an embodiment of the present application;

[0057] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0058] Definitions of terms used in the embodiments of this application:

[0059] WI-FI direct: also known as WI-FI peer-to-peer (WI-FI P2P), electronic devices can communicate one-to-one or one-to-many without the help of a local area network or access point (AP).

[0060] Group owner (GO) or P2P GO: is a role in Wi-Fi P2P connection technology. The role of GO is similar to the access point (AP) in the infrastructure basic service set (infrastructure BSS).

[0061] Group owner (GC) or P2P GC: It is another role in Wi-Fi P2P connection technology. The role of GC is similar to that of station (STA) in Infrastructure BSS.

[0062] AP: refers to a device in a wireless local area network (WLAN) system. Electronic devices (such as STA devices) can access the network after connecting to an AP. An AP can be a router, for example.

[0063] STA: In a WLAN system, a STA device can access an AP to access (or visit) the network.

[0064] Dynamic Host Configuration Protocol (DHCP): Also known as Dynamic Host Configuration Protocol, it is a network protocol for IP networks, located in the application layer of the OSI model, and uses the UDP protocol. The Dynamic Host Configuration Protocol has two main uses: one is for the automatic allocation of IP addresses by intranets or network service providers, and the other is for intranet administrators to centrally manage all computers.

[0065] Address Resolution Protocol (ARP): is a protocol for obtaining physical addresses based on IP addresses. When a host sends information, it broadcasts an ARP request containing the target IP address to all hosts on the local area network and receives a return message to determine the target's physical address. After receiving the return message, the host can store the IP address and physical address in the local ARP cache and keep it for a certain period of time. The next time it requests, it will directly query the ARP cache to save resources.

[0066] The address resolution protocol is based on mutual trust among hosts in the network. Hosts on the local area network can send ARP reply messages autonomously. When other hosts receive the reply messages, they will not detect the authenticity of the messages and will record them in the local ARP cache. In this way, an attacker can send a fake ARP reply message to a host, so that the information it sends cannot reach the expected host or reaches the wrong host, which constitutes an ARP spoof. The ARP command can be used to query the correspondence between IP addresses and MAC addresses in the local ARP cache, add or delete static correspondence, etc.

[0067] Protocols similar to APR include reverse address resolution protocol (RARP), proxy ARP, and neighbor discovery protocol (NDP). In an example, NDP can be used to replace the address resolution protocol in IPv6.

[0068] The electronic device in the embodiments of the present application may be referred to as a user equipment (UE), a terminal, or other device with a WI-FI P2P connection function. For example, the electronic device may be a mobile phone, a portable android device (PAD), a personal digital assistant (PDA), a handheld device with a wireless communication function, a computing device, a vehicle-mounted device or a wearable device, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in a smart home, etc. The form of the electronic device is not specifically limited in the embodiments of the present application.

[0069] In one embodiment, the electronic devices may be interconnected via other communication networks, such as a Bluetooth network, a Zigbee network, or a near field communication (NFC) network.

[0070] Here combined Figure 1 , briefly describes the process of WI-FI P2P connection between current electronic devices. It should be understood that Figure 1 Taking the WI-FI P2P connection between device 1 (mobile phone) and device 2 (smart screen) as an example, the process of WI-FI P2P connection between device 1 (mobile phone) and device 2 (smart screen) may include:

[0071] Step 1: Device 1 and device 2 are connected via Bluetooth to establish a Bluetooth channel. The Bluetooth channel can be used as a signaling channel to transmit signaling for interaction between device 1 and device 2.

[0072] Step 2: Device 1 and device 2 exchange signals through the Bluetooth channel to determine whether the other end can establish a WI-FI P2P connection. If the other end can establish a WI-FI P2P connection, device 1 and device 2 can negotiate their respective roles in the WI-FI P2P connection. For example, device 1 can be a GO and device 2 can be a GC.

[0073] Step 3, device 1 and device 2 can also exchange signals through the Bluetooth channel to determine whether the two devices are in the same network. Among them, when device 1 and device 2 are in the same network, device 1 and device 2 can perform WI-FI P2P connection to establish a WI-FI P2P connection channel, and device 1 and device 2 can perform services in collaboration through the WI-FI P2P connection channel. Among them, when the two devices are not in the same network, device 1 can prompt device 2 that the local end is busy, or device 2 can prompt device 1 that the local end is busy, and device 1 and device 2 do not perform WI-FI P2P connection.

[0074] Exemplarily, after device 1 and device 2 establish a WI-FI P2P connection, device 1 can project the screen to device 2, wherein device 1 can transmit the data to be projected to device 2 through the WI-FI P2P connection channel. In one example, when device 1 and device 2 establish a WI-FI P2P connection, in addition to collaboratively performing the screen projection service, device 1 and device 2 can also reuse the WI-FI P2P connection channel to perform other services, such as device 1 can also share files with device 2 through the WI-FI P2P connection channel.

[0075] When device 1 and device 2 have been connected via Wi-Fi P2P, the GO role of device 1 and the GC role of device 2 cannot be modified. A GO can connect to multiple GCs, but a GC can only connect to one GO. Figure 2A In one example, device 1 as GO can also add device 3 to the GC list of device 1 to establish a WI-FI P2P connection with device 3 (such as a laptop), such that device 1 can share files with device 3.

[0076] However, device 2, which is the GC, can no longer establish a WI-FI P2P connection with other devices. Figure 2B , if device 2 initiates a WI-FI P2P connection with device 3, device 2 and device 3 can exchange signals through the Bluetooth channel. Device 2, as a GC, can no longer establish a WI-FI P2P connection with device 3, so device 2 cannot share files with device 3. Similarly, refer to Figure 2C If device 3 initiates a WI-FI P2P connection with device 2, device 2 and device 3 can exchange signaling through the Bluetooth channel. Device 2, as a GC, can no longer establish a WI-FI P2P connection with device 3.

[0077] Similarly, device 1, as a GO, is also unable to establish a WI-FI P2P connection with another GC. For example, device 4 and device 5 also establish a WI-FI P2P connection, such as device 4 as a GC and device 5 as a GO. In this example, referring to the relevant description of device 2, device 4, as a GC, is unable to establish a WI-FI P2P connection with device 1 (GO), and is unable to establish a WI-FI P2P connection with device 2 (GC). In addition, device 1, as a GO, is also unable to establish a WI-FI P2P connection with another GO. For example, device 1, as a GO, is unable to establish a WI-FI P2P connection with device 5. In other words, the device currently serving as a GO cannot establish a WI-FI P2P connection with electronic devices (such as GC or GO) in other WI-FI P2P connections.

[0078] In summary, device 2, as a GC, can no longer establish a WI-FI P2P connection with other devices, and device 2 can no longer collaborate with other devices to perform services, which limits the application of device 2. Similarly, device 1, as a GO, can no longer establish a WI-FI P2P connection with the GC and GO in other WI-FI P2P connections, and device 1 can no longer collaborate with the GC and GO in other WI-FI P2P connections to perform services, which limits the application of device 1. Accordingly, the communication method provided in the embodiment of the present application is intended to: when device 1 and device 2 are connected by WI-FI P2P, device 2, as a GC, can also establish a WI-FI P2P connection with other devices, and device 1, as a GO, can also establish a WI-FI P2P connection with the GC and GO in other WI-FI P2P connections, so as to expand the application of the devices.

[0079] Figure 3 A software architecture diagram for electronic devices. Figure 3 The software system of electronic equipment can adopt a layered architecture, which can divide the terminal's software system into several layers. Each layer has a clear role and division of labor, and the layers communicate through software ports.

[0080] In some embodiments, the electronic device may include an application layer, an application framework layer, a hardware abstract layer (HAL), a kernel layer, and a firmware layer. The embodiments of the present application do not limit the layering of the software structure of the electronic device. The modules included in each layer in the following embodiments are the modules involved in the embodiments of the present application, and the modules included in each layer below do not constitute a limitation on the structure of the terminal, and the level of module deployment (example description) does not constitute a limitation on the structure of the terminal.

[0081] The application layer may include a series of application packages, and the application layer runs the application by calling the application programming interface (API) provided by the application framework layer. Figure 3 The application layer including the application is taken as an example for explanation.

[0082] The application framework layer provides API and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Exemplarily, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.

[0083] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to applications. The data can include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of an icon or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window, such as a text message prompt in the status bar, a prompt sound, vibration of the electronic device 100, flashing of an indicator light, etc.

[0084] In one example, referring to Figure 3 , the application framework layer may also include: WI-FI services (WI-FIservices), P2P services 1 (P2P services 1), and P2P services 2 (P2P services 2). Among them, WI-FIservices is used to assist electronic devices to access AP to enable electronic devices to access the Internet. Electronic devices accessing the Internet can also be understood as electronic devices accessing the network, electronic devices accessing the network or electronic devices connecting to the network, and electronic devices accessing AP can be understood as electronic devices connecting to AP. P2Pservices 1 is used to assist electronic devices in establishing a WI-FI P2P connection.

[0085] It should be noted that in one embodiment, when device 1 and device 2 are connected to each other through WI-FI P2P, in order to enable device 1 or device 2 to also connect to other devices through WI-FI P2P, a P2P services 2 may be set up in the application framework layer. The P2P services 2 are used to assist the electronic device in establishing another WI-FI P2P connection. In this embodiment, when device 1 and device 2 establish a WI-FI P2P connection with other devices in a WI-FI P2P connection, it is not only necessary to satisfy that P2P services 2 has been set up in device 1 and device 2, but also that P2P services 2 has been set up in other devices in a WI-FI P2P connection.

[0086] The hardware abstraction layer may include multiple library modules, such as a camera library module, a motor library module, etc. The hardware of the electronic device may load the corresponding library module, thereby enabling the application framework layer to access the device hardware. The device hardware may include, for example, a motor, a camera, etc. in the electronic device.

[0087] The kernel layer is a layer between hardware and software. The kernel layer is used to drive the hardware to make the hardware work. The kernel layer at least includes display driver, camera driver, audio driver, sensor driver, motor driver, etc., which are not limited in the embodiments of the present application.

[0088] The firmware layer may include firmware that drives the hardware to work.

[0089] Reference Figure 3 In this embodiment, a P2P services 2 can be set up in the application framework layer, and the services 2 can assist the electronic device to establish a WI-FI P2P connection with other devices when a WI-FI P2P connection has been established. However, this embodiment requires the R&D personnel to establish a complete set of P2P services logic so that the electronic device can establish two WI-FI P2P connections, which is labor-intensive and costly.

[0090] In order to reduce the workload and to enable the electronic device to establish a WI-FI connection with other devices when a WI-FI P2P connection has been established, an embodiment of the present application provides a communication method. On the basis of not changing the original structure of the electronic device, the electronic device can also establish a WI-FI connection with other devices when a WI-FI P2P connection has been established. The WI-FI connection has the same communication effect as the WI-FI P2P connection, can realize point-to-point communication between devices, and thereby expand the application of the device.

[0091] It is understandable that multiple communication ports may be pre-set in the electronic device, and the connection capability supported by each communication port is pre-defined before the electronic device leaves the factory. In the following embodiments, the communication ports in the electronic device are referred to as ports for illustration.

[0092] In this embodiment, an electronic device with 2 ports and an electronic device with 3 ports are used as examples for explanation:

[0093] For example, if the electronic device has two ports, the connection capabilities supported by the two ports are as follows:

[0094] define WIFI_HAL_INTERFACE_COMBINATIONS{{{STA},1},{{AP},1}},\

[0095] {{{STA},1},{{P2P},1}}

[0096] Among them, refer to Figure 4A , the electronic device can connect to the AP as a STA device through port 1 "{{STA},1},{{AP},1}}". In addition, the electronic device can establish a WI-FIP2P connection with other electronic devices through port 2 "{{STA},1},{{P2P},1}}". Among them, in the prior art, in an established WI-FI P2P connection, an electronic device acting as a GO can connect to at least one GC through port 2, and the electronic device can perform at least one service through the established WI-FI P2P connection channel. In an established WI-FI P2P connection, an electronic device acting as a GC can connect to a GO through port 2.

[0097] In this example, if there is a need for the electronic device acting as a GC to establish a WI-FI P2P connection with other devices, or if there is a need for the electronic device acting as a GO to establish a WI-FI P2P connection with devices in other WI-FI P2P connections, the electronic devices can no longer establish a WI-FI P2P connection. Figure 4A and Figure 4B In the example, the device that establishes a Wi-Fi P2P connection with the electronic device is a mobile phone, and the AP is a router. It should be understood that the electronic device as a GC refers to: the role of the electronic device in the Wi-Fi P2P connection established by the electronic device is a GC, and the electronic device as a GO refers to: the role of the electronic device in the Wi-Fi P2P connection established by the electronic device is a GO.

[0098] For example, if the electronic device has three ports, the connection capabilities supported by the three ports are as follows:

[0099] define WIFI_HAL_INTERFACE_COMBINATIONS{{{STA},1},{{AP},1}},\

[0100] {{{STA},1},{{P2P},1}},\

[0101] {{{STA},2}}

[0102] Among them, refer to Figure 4B , the electronic device can connect to the AP as a STA device through port 1 "{{STA},1},{{AP},1}}". In addition, the electronic device can establish a WI-FI P2P connection with other electronic devices through port 2 "{{STA},1},{{P2P},1}}".

[0103] Similarly, in this example, if there is a need for the electronic device acting as a GC to establish a WI-FI P2P connection with other devices, or there is a need for the electronic device acting as a GO to establish a WI-FI P2P connection with other devices in a WI-FI P2P connection, there is also a problem that the electronic devices can no longer establish a WI-FI P2P connection.

[0104] In one embodiment, port 1 can be used as the first port, port 2 can be used as the second port, and port 3 can be used as the third port. In one embodiment, the first port and the third port can be used as ports for assisting electronic devices to access the network, and the second port is a port for assisting electronic devices to establish a WI-FI P2P connection.

[0105] At present, in one embodiment, whether it is an electronic device with two ports or an electronic device with three ports, the structure of the electronic device can be as follows: Figure 5 shown. Figure 5 A software structure block diagram of an electronic device provided in an embodiment of the present application. In one example, Figure 5 In the hardware abstraction layer and kernel layer, the hardware abstraction layer can be regarded as a layer of hardware abstraction layer. Figure 5 , the electronic device may include: an application layer, an application framework layer, a hardware abstraction layer, and a firmware layer. The functions of the application layer, the application framework layer, the hardware abstraction layer, and the firmware layer can refer to Figure 3 Related description in .

[0106] Reference Figure 5, the application framework layer of the electronic device may include two WI-FI FWKs, namely WI-FI FWK1 and WI-FI FWK2, and the HAL layer includes two WI-FI HALs, namely WI-FI HAL1 and WI-FI HAL2. The two WI-FI FWKs and two WI-FI HALs are used to assist the electronic device in communicating with other devices, which will not be described in detail in the embodiments of the present application.

[0107] Reference Figure 5 , the application framework layer may also include: WI-FI1 services, WI-FI P2P services, and WI-FI2 services. WI-FI1 services, WI-FI P2P services, and WI-FI2 services may all be referred to as services in electronic devices. In one embodiment, WI-FI1 services may also be used as the first WI-FI service, and WI-FI2 services may be used as the second WI-FI service. In one embodiment, WI-FI1 services and WI-FI2 services may also be referred to as station STA services.

[0108] Among them, WI-FI1 services and WI-FI2 services are used to assist electronic devices to access the network, such as assisting electronic devices to access AP to connect to the network. WI-FI P2P services are used to assist electronic devices to establish a WI-FIP2P connection. In the embodiment of the present application, WI-FI1 services and WI-FI2 services can also be used to assist electronic devices to establish a WI-FI connection, which has the same communication effect as the WI-FI P2P connection and can realize point-to-point communication between electronic devices.

[0109] In one embodiment, WI-FI1 services and WI-FI2 services may be collectively referred to as first services or WI-FI services, and WI-FI P2P services may be referred to as second services. In other words, the application framework layer may also include first services and second services, the first service may include WI-FI1 services and WI-FI2 services, and the second service may be WI-FI P2P services.

[0110] The first service is a service for electronic devices to access the AP to access the network, and the second service is a service for electronic devices to establish a WI-FI P2P connection. In other words, the first service can provide the function of electronic devices to access the AP to access the network, and the second service can provide the function of electronic devices to establish a WI-FI P2P connection.

[0111] Among them, the first port can correspond to WI-FI FWK1, WI-FI1 services and WI-FI HAL1 respectively, the second port can correspond to WI-FI FWK1, WI-FI P2P services and WI-FI HAL1 respectively, and the third port can correspond to WI-FI FWK2, WI-FI2 services and WI-FI HAL2 respectively. For example, if an electronic device can use WI-FI P2Pservices, WI-FI FWK1, and WI-FI HAL1 to establish a WI-FI P2P connection with other electronic devices, refer to the relevant description in the prior art. In addition, an electronic device can use WI-FI1 services, WI-FI FWK1 and WI-FI HAL1) to access an AP so that the electronic device can access the network.

[0112] In one embodiment, the application framework layer may further include: a service scheduling module. The service scheduling module is used to schedule the first WI-FI service, the second WI-FI service, and the WI-FI P2P service in the application framework layer. It should be understood that Figure 6 The steps performed by the electronic device shown in can be regarded as steps performed by the service scheduling module in the electronic device.

[0113] Reference Figure 5 The firmware layer may include firmware for driving three ports to work. The three ports may refer to the related descriptions of port 1 to port 3 mentioned above.

[0114] It should be understood that, for an electronic device with two ports, the firmware layer may include firmware for driving the two ports. In this embodiment, when the electronic device has two ports, the structure of the electronic device may be as follows: Figure 5 As shown, the electronic device may not run WI-FI2 services, WI-FI FWK2, and WI-FI HAL2.

[0115] Alternatively, in one embodiment, the electronic device with two ports may not include WI-FI2 services, WI-FI FWK2, and WI-FI HAL2. Accordingly, the electronic device with two ports includes: a first port and a second port, the first port may correspond to WI-FI FWK1, WI-FI1 services, and WI-FI HAL1 respectively, and the second port may correspond to WI-FI FWK1, WI-FI P2P services, and WI-FI HAL1 respectively.

[0116] In the prior art, an electronic device can use WI-FI P2P services to establish a WI-FI P2P connection with other electronic devices. Because the WI-FI P2P services are occupied, the electronic device as a GC cannot establish a WI-FI P2P connection with other devices, and the electronic device as a GO cannot establish a WI-FI P2P connection with other electronic devices in the WI-FI P2P connection. In the embodiment of the present application, when the electronic device has used WI-FI P2P services to establish a WI-FI P2P connection, the electronic device can also use the first service (such as WI-FI1 services or WI-FI2 services) to establish another WI-FI connection with other devices. The WI-FI connection can achieve the same effect as the WI-FI P2P connection and can ensure point-to-point communication between devices. In addition, in the embodiment of the present application, when the electronic device has used WI-FI P2P services to establish a WI-FI P2P connection, the electronic device can also establish another WI-FI P2P connection by preempting WI-FI P2P services, and can also achieve point-to-point communication between devices.

[0117] The communication method provided by the embodiments of the present application is described below in conjunction with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0118] Figure 6 A flow chart of an embodiment of a communication method provided in an embodiment of the present application. Figure 6 , the communication method provided in the embodiment of the present application may include:

[0119] S601: A first electronic device establishes a WI-FI P2P connection with a second electronic device.

[0120] The structure of the first electronic device can be as follows Figure 5As shown, the structure of the second electronic device may be the same as or different from that of the first electronic device, and the embodiment of the present application does not limit the structure of the second electronic device.

[0121] The first electronic device and the second electronic device both have a WI-FI P2P connection function, that is, the first electronic device and the second electronic device can both perform a WI-FI P2P connection. The process of the first electronic device and the second electronic device performing a WI-FI P2P connection can refer to Figure 1 For the description of steps 1 to 3, you can also refer to the description of the standard protocol for WI-FI P2P connection between devices.

[0122] In one embodiment, referring to Figure 5 In the structure of the first electronic device shown, the first electronic device can establish a WI-FI P2P connection with the second electronic device through the second service. Specifically, the first electronic device can establish a WI-FI P2P connection with the second electronic device through WI-FI FWK1, WI-FI P2Pservices, and WI-FI FWK1. After the first electronic device and the second electronic device establish a WI-FI P2P connection, they can collaboratively execute services. The embodiments of the present application do not limit the services that the first electronic device and the second electronic device can collaboratively execute, such as the service can be a screen projection service, a file sharing service, etc.

[0123] In the embodiment of the present application, in order to illustrate that the electronic device as GC can also establish a WI-FI P2P connection with other devices, and the electronic device as GO can also establish a WI-FI connection with other electronic devices in the WI-FI P2P connection, the role of the first electronic device is GC and GO respectively as an example for explanation in the embodiment of the present application. It should be understood that when the role of the first electronic device is GC, the role of the second electronic device is GO, and when the role of the first electronic device is GO, the role of the second electronic device is GC.

[0124] It should be understood that when the second electronic device acts as a GC or GO, the second electronic device can also establish a WI-FI connection with other electronic devices, and the relevant description of the steps performed by the first electronic device in the following embodiment can be referred to. Among them, the role of the first electronic device and the role of the second electronic device are negotiated by the first electronic device and the second electronic device, and the negotiation process can refer to the description in the standard protocol for WI-FI P2P connection between current devices.

[0125] S602: In response to an operation of triggering the first electronic device and the third electronic device to establish a WI-FI connection, the first electronic device and the third electronic device exchange device information.

[0126] The operation of triggering the first electronic device and the third electronic device to establish a WI-FI connection may include, but is not limited to: triggering the first electronic device to actively initiate a WI-FI P2P connection request with the third electronic device, such as triggering the first electronic device to share a file with the third electronic device, or triggering the third electronic device to actively initiate a WI-FI P2P connection request with the first electronic device, such as triggering the third electronic device to share a file with the first electronic device. In one example, the operation of establishing a WI-FI connection between the first electronic device and the third electronic device may be performed by a user. The embodiment of the present application does not limit the manner in which the user triggers the first electronic device to establish a WI-FI connection with the third electronic device, and may refer to the manner in which the user triggers the first electronic device to establish a WI-F direct connection with the third electronic device.

[0127] In other words, in response to the first electronic device initiating a request for a WI-FI connection to the third electronic device, or in response to receiving a request for a WI-FI connection from the third electronic device, the first electronic device and the third electronic device exchange device information. The exchange of device information between the first electronic device and the third electronic device can be understood as: the first electronic device sends the device information of the first electronic device to the third electronic device, and the third electronic device sends the device information of the third electronic device to the first electronic device. Accordingly, the first electronic device can receive device information from the third electronic device.

[0128] In one embodiment, the first electronic device and the third electronic device can exchange device information via a Bluetooth channel. Figure 1 In the process of establishing a WI-FI P2P connection shown in the figure, the first electronic device and the third electronic device can perform a Bluetooth connection to establish a Bluetooth channel, and exchange device information through the Bluetooth channel. In one embodiment, the first electronic device and the third electronic device can also exchange device information through other methods, such as through a short-range communication method such as NFC.

[0129] In one embodiment, the device information of the third electronic device can be used to indicate whether the third electronic device has established a WI-FI P2P connection, and when the third electronic device has established a WI-FI P2P connection, the device information of the third electronic device can also be used to indicate the role of the third electronic device in the established WI-FI P2P connection. Exemplarily, the device information of the third electronic device may include: role GO. The role GO may indicate that the third electronic device has established a WI-FI P2P connection, and the role is GO. The form of the device information in the embodiment of the present application is not limited. Similarly, because the first electronic device has established a WI-FI P2P connection with the second electronic device, the device information of the first electronic device is used to indicate the role of the first electronic device in the established WI-FI P2P connection.

[0130] In one embodiment, the device information of the third electronic device may further include any of the following items: whether the third electronic device can perform a WI-FI P2P connection, whether the WI-FI P2P connection supports multiplexing, and the identifier of the network to which the third electronic device belongs. Wherein, whether the WI-FI P2P connection supports multiplexing can be understood as: when the first electronic device and the third electronic device establish a WI-FI P2P connection, whether the first electronic device and the third electronic device can use the established WI-FI P2P connection channel to perform multiple services. Wherein, in the scenario where the WI-FI P2P connection supports multiplexing, the first electronic device and the third electronic device can use the established WI-FI P2P connection channel to perform multiple services. In the scenario where the WI-FI P2P connection does not support multiplexing, the first electronic device and the third electronic device can only perform one service using the established WI-FI P2P connection channel. The identifier of the network to which the third electronic device belongs is used to indicate the network to which the third electronic device is connected. The identifier of the network may be, for example, the name of the network or the IP address of the network. In one example, when the third electronic device is not connected to the network, the identifier of the network to which the third electronic device belongs may be empty, or the device information of the third electronic device may not carry the identifier of the network to which the third electronic device belongs.

[0131] Accordingly, in one embodiment, the device information of the first electronic device may include any of the following: whether the first electronic device can perform a WI-FI P2P connection, whether the WI-FI P2P connection supports multiplexing, and the identifier of the network to which the first electronic device belongs. Among them, "whether a WI-FI P2P connection can be performed, whether the WI-FI P2P connection supports multiplexing, and the identifier of the network to which the first electronic device belongs" can refer to the relevant description of the device information of the third electronic device.

[0132] In one embodiment, it may also be assumed that all electronic devices can perform WI-FI P2P connection, so the device information of the third electronic device may not include: whether the third electronic device can perform WI-FI P2P connection, and the device information of the first electronic device may not include: whether the first electronic device can perform WI-FI P2P connection.

[0133] S603: Establish a WI-FI connection with a third electronic device according to the device information of the first electronic device and the device information of the third electronic device.

[0134] In the prior art, when a first electronic device needs to establish a WI-FI P2P connection with a third electronic device, because the first electronic device has established a WI-FI P2P connection with the second electronic device, if the role of the first electronic device is GC, the first electronic device will not establish a WI-FI P2P connection with the third electronic device, or, if the role of the first electronic device is GO and the third electronic device has established a WI-FI P2P connection, the first electronic device will not establish a WI-FI P2P connection with the third electronic device.

[0135] In order to facilitate that the first electronic device as a GC can also establish a WI-FI connection with the third electronic device, and the first electronic device as a GO can also establish a WI-FI connection with the third electronic device that has established a WI-FI P2P connection, in an embodiment of the present application, the first electronic device can establish a WI-FI connection with the third electronic device based on the device information of the first electronic device and the device information of the third electronic device.

[0136] Here, the meaning of the WI-FI connection in the embodiment of the present application is explained by taking the WI-FI connection established between the first electronic device and the third electronic device as an example: in the WI-FI connection established between the first electronic device and the third electronic device, at least one end of the WI-FI connection is "GC or GO". In other words, in the WI-FI connection, at least one of the first electronic device and the third electronic device has a role (GO or GC) in the WI-FI P2P connection. Among them, the WI-FI connection in the embodiment of the present application includes a WI-FI P2P connection.

[0137] Exemplarily, in the WI-FI connection established between the first electronic device and the third electronic device, when the first electronic device is a GO, the third electronic device can act as a GC or STA device (simulating GC). In the WI-FI connection established between the first electronic device and the third electronic device, when the first electronic device is a GC, the third electronic device can be a GO or softAP (simulating GO). Correspondingly, in the WI-FI connection established between the first electronic device and the third electronic device, when the third electronic device is a GO, the first electronic device can act as a GC or STA device (simulating GC). In the WI-FI connection established between the first electronic device and the third electronic device, when the third electronic device is a GC, the first electronic device can be a GO or softAP (simulating GO). Among them, the simulated GC can establish a WI-FI connection with the GO, and the simulated GO can establish a WI-FI connection with the GC.

[0138] Similarly, in the following embodiments, it is mentioned that the third electronic device and the fifth electronic device establish a WI-FI connection, in which at least one of the third electronic device and the fifth electronic device has a role (GO or GC) in the WI-FI P2P connection.

[0139] The method provided in the embodiment of the present application can be applied to the following two scenarios:

[0140] Scenario 1: The role of the first electronic device in the WI-FI P2P connection established with the second electronic device is GC, the third electronic device may not have established a WI-FI P2P connection, or may have established a WI-FI P2P connection, and the role of the third electronic device in the established WI-FI P2P connection may be GC or GO. In one example, the device that has established a WI-FI P2P connection with the third electronic device may be a fourth electronic device.

[0141] Scenario 2: The role of the first electronic device in the WI-FI P2P connection established with the second electronic device is GO, the third electronic device has established a WI-FI P2P connection, and the role of the third electronic device in the established WI-FI P2P connection can be GC or GO.

[0142] In one embodiment, when the first electronic device establishes a WI-FI connection with the third electronic device, the first electronic device can use a service in the first electronic device to establish a WI-FI connection with the third electronic device, wherein the service can be the first service or the second service originally in the first electronic device.

[0143] For example, if the first electronic device establishes a WI-FI P2P connection with the second electronic device through the second service, and the second service is occupied, when the first service is not occupied, the first electronic device can use the first service to establish a WI-FI connection with the third electronic device. For the first electronic device with three ports, the first service can be the first WI-FI service or the second WI-FI service. For the first electronic device with two ports, the first service can be the first WI-FI service.

[0144] For example, if the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device, the second service is occupied, but when the business jointly performed by the first electronic device and the second electronic device is a preset business, the first electronic device can temporarily disconnect the WI-FI P2P connection established between the first electronic device and the second electronic device, and use the second service to establish a WI-FI P2P connection with the third electronic device. After the business jointly performed by the first electronic device and the third electronic device is completed, the first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. Among them, the preset business can be a business with low real-time requirements, such as file sharing.

[0145] In an embodiment of the present application, the first electronic device can negotiate the respective roles of the first electronic device and the third electronic device in the WI-FI connection established by the first electronic device and the third electronic device based on the device information of the first electronic device and the device information of the third electronic device, and then establish a WI-FI connection with the third electronic device based on the negotiated roles.

[0146] In one embodiment, the first electronic device and the third electronic device may negotiate roles according to their respective device capabilities, and reference may be made to the description in the standard protocol of the WI-FI P2P connection.

[0147] In one embodiment, in scenario one, if the third electronic device has not established a WI-FI P2P connection, the first electronic device can use the first service as a STA device, the STA device can simulate a GC, and the third electronic device can act as a GO, so that the first electronic device can establish a WI-FI connection with the third electronic device as a GO using the GC simulated by the STA device. In scenario one, if the third electronic device has established a WI-FI P2P connection, and in scenario two, the first electronic device and the third electronic device can negotiate roles based on their respective device capabilities, and can refer to the description in the standard protocol of the WI-FI P2P connection, or refer to the relevant description in the following embodiments.

[0148] In one embodiment, in scenario one, if the third electronic device has not established a WI-FI P2P connection, the first electronic device can act as a STA device, the STA device can act as a simulated GC, and the third electronic device can directly act as a GO. In scenario one, if the third electronic device has established a WI-FI P2P connection, and in scenario two, the first electronic device can negotiate roles based on the occupancy of the first service and the occupancy of the first service in the third electronic device, and the relevant description of scenario 2 in scenario one can be referred to below.

[0149] In an embodiment of the present application, when a first electronic device establishes a WI-FI P2P connection with a second electronic device, and the first electronic device acts as a GC or a GO, there is no need to add services in the first electronic device. Instead, the original services in the first electronic device are used to establish a WI-FI connection with a third electronic device. This not only reduces the cost and workload of R&D personnel, but also achieves the purpose of the first electronic device and the third electronic device collaboratively executing services, thereby expanding the application of the first electronic device.

[0150] The following takes scenario 1 as an example to illustrate a method for establishing a WI-FI connection between a first electronic device and a third electronic device:

[0151] Case 1: The role of the first electronic device in the WI-FI P2P connection established with the second electronic device is GC, and the third electronic device does not establish a WI-FI P2P connection.

[0152] In situation 1, the first electronic device can establish a WI-FI connection with the third electronic device in the following three ways.

[0153] Method 1:

[0154] The first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. In one possible scenario, the first service is idle. In this scenario, the first electronic device can shield the network access function provided by the first service and use the first service to establish a WI-FI connection with the third electronic device.

[0155] The first service being idle can be understood as: the first electronic device does not use the first service to connect to any device, such as the first electronic device does not use the first service to access the AP, and the first electronic device does not use the first service to establish a WI-FI connection with other electronic devices.

[0156] The first service is a service for the first electronic device to access the AP to access the network. In other words, the first electronic device can use the first service to access the AP to access the network. Specifically, the first service can provide network access and connection functions, such as roaming functions, and functions for detecting Internet access capabilities. Among them, the first electronic device can use the network access function to query the AP and interact with the AP, and the first electronic device can also use the connection function to establish a connection with the AP.

[0157] In an embodiment of the present application, in order to enable the first electronic device to establish a WI-FI connection with the third electronic device using the first service, it is necessary to shield the network access function provided by the first service, wherein the reason why the first electronic device shields the network access function provided by the first service is that: if the network access function provided by the first service is not shielded, when the first electronic device uses the first service, it will query the AP based on the roaming function, the detection of Internet access capabilities and other functions, and then roam to the AP, causing the first electronic device to be unable to establish a connection with the third electronic device. Therefore, in an embodiment of the present application, the first electronic device shields the network access function provided by the first service, so that the first electronic device will not access the AP, so that the first electronic device can use the connection function in the first service to establish a WI-FI connection with the third electronic device that interacts with the first electronic device.

[0158] The network access function may be pre-set. In one embodiment, if the first electronic device only includes a roaming function, the first electronic device may shield the roaming function of the first electronic device. If the first electronic device includes a roaming function and a function for detecting Internet access capability, the first electronic device may shield the roaming function and the function for detecting Internet access capability of the first electronic device.

[0159] In the first method, when the first electronic device establishes a WI-FI connection with the third electronic device, the first electronic device uses the first service and can be used as a STA device, and the first electronic device shields the network access function provided by the first service, so the STA device can simulate a GC and the third electronic device can be used as a GO. The simulated GC and the GO can establish a WI-FI connection.

[0160] Alternatively, when the first electronic device establishes a WI-FI connection with the third electronic device, the third electronic device can act as a GC, and the first electronic device uses the first service and can act as a softAP, wherein the softAP can be regarded as a simulated GO, and the simulated GO can establish a WI-FI connection with the GC.

[0161] In the embodiment of the present application, when the first electronic device has three ports, the first service may be a first WI-FI service or a second WI-FI service.

[0162] Reference Figure 4A In one possible scenario, the first electronic device uses the first WI-FI service and connects to the AP as a STA device through port 1 "{{STA},1},{{AP},1}}", and the first electronic device uses the WI-FI P2P service and establishes a WI-FI P2P connection with the second electronic device through port 2 "{{STA},1},{{P2P},1}}".

[0163] In this scenario, if the second WI-FI service is idle, the first electronic device can shield the network access function provided by the second WI-FI service, use the idle second WI-FI service, and establish a WI-FI connection with the third electronic device through port 3 "{{STA},2}}". Specifically, the first electronic device can use WI-FI FWK 2, WI-FI2 services, and WI-FIHAL 2, and establish a WI-FI connection with the third electronic device through port 3. Among them, the first electronic device can use the second WI-FI service as a STA device, the STA device acts as a simulated GC, and the third electronic device can act as a GO, so that the simulated GC (first electronic device) can establish a WI-FI connection with the GO (third electronic device).

[0164] Reference Fig. 7A , exemplarily, the first electronic device uses the first WI-FI service and connects to the AP through the first port, and the first electronic device uses the WI-FI P2P service and establishes a WI-FI P2P connection with the second electronic device through the second port, and the second WI-FI service is idle. In this example, if the user triggers the first electronic device to project the screen to the third electronic device, the first electronic device can shield the network access function provided by the second WI-FI service, use the second WI-FI service, and establish a WI-FI connection with the third electronic device through the third port, so that the first electronic device can project the screen to the third electronic device. It should be understood that Figure 7A-7D In the description, the second electronic device is a mobile phone and the third electronic device is a smart screen.

[0165] Similarly, when the first electronic device has three ports, in one possible scenario, the first electronic device can use the second WI-FI service and connect to the AP as a STA device through port 3 "{{STA},2}}", and the first electronic device can use the WI-FI P2P service and establish a WI-FIP2P connection with the second electronic device through port 2 "{{STA},1},{{P2P},1}}". In this scenario, the first WI-FI service is idle, then the first electronic device can shield the network access function provided by the first WI-FI service, use the idle first WI-FI service, and establish a WI-FI connection with the third electronic device through port 1 "{{STA},1},{{AP},1}}". Specifically, the first electronic device can use WI-FI FWK 1, WI-FI1 services, and WI-FI HAL 1, and establish a WI-FI connection with the third electronic device through port 1.

[0166] Similarly, when the first electronic device has three ports, in one possible scenario, the first electronic device is not connected to the AP, and the first electronic device can use the WI-FI P2P service and establish a WI-FI P2P connection with the second electronic device through port 2 "{{STA},1},{{P2P},1}}". In this scenario, both the first WI-FI service and the second WI-FI service are idle, and the first electronic device can shield the network access function provided by the first WI-FI service, use the idle first WI-FI service, and establish a WI-FI connection with the third electronic device through port 1 "{{STA},1},{{AP},1}}". Alternatively, the first electronic device can shield the network access function provided by the second WI-FI service, use the idle second WI-FI service, and establish a WI-FI connection with the third electronic device through port 3 "{{STA},2}}".

[0167] In one example, when the first WI-FI service and the second WI-FI service are both idle, the priorities of the first WI-FI service and the second WI-FI service can also be preset in the first electronic device, and the first electronic device can use the WI-FI service with a higher priority to establish a WI-FI connection with the third electronic device.

[0168] Reference Figure 7B In a, the first WI-FI service and the second WI-FI service are idle, the first electronic device uses the WI-FIP2P service, and establishes a WI-FI P2P connection with the second electronic device through the second port. In this case, if the user triggers the first electronic device to project the screen to the third electronic device, the first electronic device can shield the network access function provided by the second WI-FI service, use the second WI-FI service, and establish a WI-FI connection with the third electronic device through the third port. Alternatively, the first electronic device can shield the network access function provided by the first WI-FI service, use the first WI-FI service, and establish a WI-FI connection with the third electronic device through the first port. It should be understood that Figure 7B In a, the example of the first electronic device using the first WI-FI service to establish a WI-FI connection with the third electronic device is taken.

[0169] In the embodiment of the present application, when the first electronic device has two ports, the first service may be a first WI-FI service.

[0170] Reference Figure 4B, the first electronic device can use the WI-FI P2P service and establish a WI-FI P2P connection with the second electronic device through port 2 "{{STA},1},{{P2P},1}}". When the first WI-FI service is idle, the first electronic device can shield the network access function provided by the first WI-FI service, use the first WI-FI service, and establish a WI-FI connection with the third electronic device through port 1 "{{STA},1},{{AP},1}}".

[0171] Reference Figure 7B In b, the first WI-FI service is idle, the first electronic device uses the WI-FI P2P service, and establishes a WI-FI P2P connection with the second electronic device through the second port. In this case, if the user triggers the first electronic device to project the screen to the third electronic device, the first electronic device can shield the network access function provided by the first WI-FI service, use the first WI-FI service, and establish a WI-FI connection with the third electronic device through the first port, so that the first electronic device can project the screen to the third electronic device.

[0172] Method 2:

[0173] The first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. In one possible scenario, the first service is not idle, and the first electronic device does not use the first service to establish a WI-FI connection. Among them, "the first service is not idle, and the first electronic device does not use the first service to establish a WI-FI connection" can be understood as: the first electronic device uses the first service to access the AP. Exemplarily, when the first electronic device has 2 ports, the first electronic device uses the first WI-FI service to access the AP, and uses the second service to establish a WI-FI P2P connection with the second electronic device. Exemplarily, when the first electronic device has 3 ports, the first electronic device uses the first WI-FI service to access AP1, uses the second WI-FI service to access AP2, and uses the second service to establish a WI-FI P2P connection with the second electronic device.

[0174] In this scenario, there is no idle first service in the first electronic device, and the first electronic device is connected to the AP through the first service, and the first electronic device and the second electronic device are connected through a WI-FI P2P connection, which is a type of WI-FI connection defined in the embodiment of the present application. Therefore, in order to establish a WI-FI connection between the first electronic device and the third electronic device, the first electronic device can establish a WI-FI connection with the third electronic device through the second service.

[0175] In the second mode, when the first electronic device establishes a WI-FI connection with the third electronic device, the first electronic device uses the second service and can act as a GO or a GC. Accordingly, when the first electronic device is a GO, the third electronic device can act as a GC, and when the first electronic device is a GC, the third electronic device can act as a GO.

[0176] In one embodiment, the first electronic device can determine whether to establish a WI-FI connection with the third electronic device based on the first priority of the service collaboratively performed by the first electronic device and the second electronic device, and the second priority of the service collaboratively performed by the first electronic device and the third electronic device. If the first priority is higher than the second priority, the first electronic device determines not to preempt the second service, that is, determines not to establish a WI-FI connection with the third electronic device. If the first priority is lower than the second priority, the first electronic device determines to preempt the second service, that is, determines to establish a WI-FI connection with the third electronic device.

[0177] In one example, the first electronic device may store a priority list of services, and the first electronic device may determine the first priority and the second priority based on the services collaboratively performed by the first electronic device and the second electronic device, the services collaboratively performed by the first electronic device and the third electronic device, and the priority list of services. The setting of service priorities is not limited in the embodiments of the present application.

[0178] Among them, if the first priority is lower than the second priority, the first electronic device can disconnect the WI-FI P2P connection established with the second electronic device, and use the second service to establish a WI-FI P2P connection with the third electronic device. The description of establishing a WI-FI P2P connection between the first electronic device and the second electronic device can be referred to.

[0179] For example, Figure 7C Take the example of a first electronic device having two ports. For example, the first electronic device uses the WI-FI P2P service and establishes a WI-FI P2P connection with the second electronic device through the second port. The first electronic device uses the first WI-FI service and accesses the AP through the first port. For example, the service jointly performed by the first electronic device and the second electronic device is a shared file service. In this case, if the user triggers the first electronic device to project the screen to the third electronic device, the real-time requirement of the projection service is high, and the real-time requirement of the shared file is low, and the priority of the projection service is higher than the priority of the shared file. In this case, the first electronic device can determine to seize the second service, and use the second service to establish a WI-FI P2P connection with the third electronic device through the second port. Specifically, the first electronic device can use WI-FI FWK1, WI-FI P2P service, and WI-FI HAL1, and establish a WI-FI P2P connection with the third electronic device through the second port.

[0180] In one embodiment, in order to improve the user experience, if the first priority is lower than the second priority, the first electronic device may output a prompt message, the prompt message is used to prompt the user whether to agree that the first electronic device establishes a WI-FI connection with the third electronic device, and when the user is prompted to establish a WI-FI connection between the first electronic device and the third electronic device, the first electronic device and the second electronic device disconnect the WI-FI P2P connection, and stop executing the business that the first electronic device and the second electronic device jointly execute. In this embodiment, the user can trigger the first electronic device and the third electronic device to establish a WI-FI connection according to the prompt message, and accordingly, the first electronic device responds to the user's operation of triggering the first electronic device and the third electronic device to establish a WI-FI connection, disconnects the WI-FI P2P connection established with the second electronic device, and uses the second service to establish a WI-FI P2P connection with the third electronic device.

[0181] Method 3:

[0182] The first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device. In a possible scenario, the first service is not idle, and the first electronic device uses the first service to establish a WI-FI connection with the fifth electronic device. Exemplarily, in this scenario, if the first electronic device uses the first WI-FI service to access the AP, uses the second WI-FI service to establish a WI-FI connection with the fifth electronic device, and uses the second service to establish a WI-FI P2P connection with the second electronic device. Or, if the first electronic device uses the second WI-FI service to access the AP, uses the first WI-FI service to establish a WI-FI connection with the fifth electronic device, and uses the second service to establish a WI-FI P2P connection with the second electronic device. Exemplarily, in this scenario, if the first electronic device uses the first WI-FI service to establish a WI-FI connection with an electronic device, uses the second WI-FI service to establish a WI-FI connection with another electronic device, and uses the second service to establish a WI-FI P2P connection with the second electronic device, in this example, the electronic devices that the first electronic device uses the first WI-FI service and the second WI-FI service to establish a WI-FI connection are collectively referred to as the fifth electronic device.

[0183] In this scenario, there is no idle first service in the first electronic device, and the first electronic device establishes a WI-FI connection with the fifth electronic device through the first service (the first WI-FI service or the second WI-FI service). Because the WI-FI P2P connection established between the first electronic device and the second electronic device, and the WI-FI connection established between the first electronic device and the fifth electronic device, all belong to the WI-FI connection defined in the embodiment of the present application, in order to achieve a point-to-point connection between the first electronic device and the third electronic device, the first electronic device can establish a WI-FI connection with the third electronic device by preempting the first service or the second service.

[0184] Among them, in mode 3, when the first electronic device seizes the first service to establish a WI-FI connection with the third electronic device, the first electronic device uses the first service to establish a WI-FI connection with the third electronic device, and can act as a simulated GC or a simulated GO. When the first electronic device is a simulated GC, the third electronic device can act as a GO, and when the first electronic device is a simulated GO, the third electronic device is a GC.

[0185] In mode 3, when the first electronic device seizes the second service to establish a WI-FI connection with the third electronic device, the first electronic device can act as a GO or a GC in establishing a WI-FI connection with the third electronic device. Correspondingly, when the first electronic device is a GO, the third electronic device can act as a GC, and when the first electronic device is a GC, the third electronic device can act as a GO.

[0186] In an embodiment of the present application, the first electronic device can determine whether to preempt the first service or the second service based on the first priority, the second priority, and the third priority of the service collaboratively executed by the first electronic device and the fifth electronic device, and then determine whether to establish a WI-FI connection with the third electronic device.

[0187] If the first priority and the third priority are both lower than the second priority, the first electronic device may determine to preempt the first service or the second service to establish a WI-FI connection with the third electronic device. The first electronic device may disconnect the WI-FI P2P connection established with the second electronic device and use the second service to establish a WI-FI P2P connection with the third electronic device, or the first electronic device disconnects the WI-FI connection established with the fifth electronic device and uses the first service to establish a WI-FI connection with the third electronic device.

[0188] It should be noted that when the first electronic device uses the first WI-FI service to establish a WI-FI connection with a fifth electronic device, and the first electronic device uses the second service to establish a WI-FI connection with another fifth electronic device, when the first electronic device preempts the first service, it can preempt the first WI-FI service or the second service, or preempt the WI-FI service with the lowest service priority.

[0189] Among them, if the first priority and the third priority are both lower than the second priority, the first electronic device can preempt the service corresponding to the WI-FI connection with the lowest priority among the first priority and the third priority, and then the first electronic device can disconnect the WI-FI connection with the lowest priority, and use the service corresponding to the disconnected WI-FI connection to establish a WI-FI connection with the third electronic device. Exemplarily, if the first priority is lower than the third priority, the first electronic device can disconnect the WI-FI P2P connection established with the second electronic device, and use the second service to establish a WI-FI P2P connection with the third electronic device. If the third priority is lower than the first priority, the first electronic device disconnects the WI-FI connection established with the fifth electronic device, and uses the first service to establish a WI-FI connection with the third electronic device.

[0190] Among them, if the first priority is higher than the second priority, and the third priority is lower than the second priority, the first electronic device can determine to preempt the first service. Specifically, the first electronic device can disconnect the WI-FI connection established with the fifth electronic device and use the first service to establish a WI-FI connection with the third electronic device.

[0191] Among them, if the third priority is higher than the second priority, and the first priority is lower than the second priority, the first electronic device can determine to preempt the second service. Specifically, the first electronic device can disconnect the WI-FI P2P connection established with the second electronic device, and use the second service to establish a WI-FI P2P connection with the third electronic device.

[0192] If the first priority and the third priority are both higher than the second priority, the first electronic device may determine not to preempt the first service and the second service, that is, the first electronic device determines not to establish a WI-FI connection with the third electronic device.

[0193] For example, Fig.7DTake the example of a first electronic device having three ports, where the first electronic device uses the first WI-FI service and accesses the AP through the first port, the first electronic device uses the WI-FI P2P service and establishes a WI-FI P2P connection with the second electronic device through the second port, and the first electronic device uses the second WI-FI service and establishes a WI-FI connection with the fifth electronic device through the third port. Among them, if the service collaboratively performed by the first electronic device and the second electronic device is a video playback service, and the service collaboratively performed by the first electronic device and the fifth electronic device is a file sharing service, in this case, if the user triggers the first electronic device to project the screen to the third electronic device, assuming that the priority of the screen projection service is higher than the priority of the shared file and lower than the priority of the video playback service, the first electronic device can determine to preempt the second service, and use the second service to establish a WI-FI P2P connection with the third electronic device through the second port, so that the first electronic device can use the second service to project the screen to the fifth electronic device. It should be understood that Fig.7D The fifth electronic device is taken as an example as a notebook computer.

[0194] In one example, the third electronic device may be an electronic device with three ports or two ports, and the relevant description of the first electronic device may be referred to. In summary, in case 1 of scenario one, because the third electronic device has not established a WI-FI P2P connection, the first electronic device may use the first service or the second service to establish a WI-FI connection with the third electronic device. Specifically, the first electronic device may establish a WI-FI connection with the third electronic device through the first port, the second port, or the third port in the first electronic device, and the second port of the third electronic device.

[0195] Case 2: The role of the first electronic device in the WI-FI P2P connection established with the second electronic device is GC, the third electronic device has established a WI-FI P2P connection, and the role of the third electronic device in the established WI-FI P2P connection is GC or GO.

[0196] In case 2, the first electronic device can establish a WI-FI connection with the third electronic device by using the methods in methods 1 to 3. It is understandable that when the role of the third electronic device in the established WI-FI P2P connection is GC, the third electronic device can also establish a WI-FI connection with the first electronic device by referring to the methods in methods 1 to 3.

[0197] In situation 2, because the third electronic device has established a WI-FI P2P connection, the first electronic device can use the first service or the second service to establish a WI-FI connection with the third electronic device. Specifically, the first electronic device can establish a WI-FI connection with the third electronic device through the first port, the second port, or the third port in the first electronic device, and the second port of the third electronic device. Alternatively, the first electronic device can also establish a WI-FI connection with the third electronic device through the second port in the first electronic device, and the first port, the second port, or the third port of the third electronic device.

[0198] In situation 2, the first electronic device can negotiate their respective roles before establishing a WI-FI connection with the third electronic device. In one example, the role of the electronic device using the second service can be determined as GO, and the other electronic device can be determined as GC. For example, if the first electronic device determines to establish a WI-FI connection with the third electronic device by seizing the second service in the first electronic device, the role of the first electronic device can be determined as GO and the role of the third electronic device can be determined as GC when the first electronic device and the third electronic device establish a WI-FI connection.

[0199] In one example, if the first electronic device uses the second service in the first electronic device, and the third electronic device uses the second service in the third electronic device to establish a WI-FI connection, the electronic device initiating the WI-FI connection can be determined as the GO, and the other electronic device can be determined as the GC. Alternatively, the first electronic device and the third electronic device can also negotiate roles based on their respective device capabilities.

[0200] For example, if the first electronic device determines to establish a WI-FI connection by preempting the second service in the first electronic device, and the third electronic device determines to establish the second service in the third electronic device, if the first electronic device acts as the initiator of the WI-FI connection, then when the first electronic device and the third electronic device establish the WI-FI connection, the role of the first electronic device can be determined as GO, and the role of the third electronic device can be determined as GC.

[0201] Similarly, the way in which the first electronic device in scenario 2, as a GO, establishes a WI-FI connection with a third electronic device (GC or GO) that has established a WI-FI P2P connection can refer to the relevant description in scenario 2 of scenario 1. In addition, the way in which the first electronic device and the third electronic device negotiate roles in scenario 2 can refer to S603 and the relevant description in scenario 2.

[0202] In summary, the manner in which the first electronic device and the third electronic device establish a WI-FI connection can be summarized as shown in Table 1 below:

[0203] Table 1

[0204]

[0205] Referring to Table 1, the WI-FI service may be a first WI-FI service or a second WI-FI service.

[0206] Referring to Table 1, when the corner of the first electronic device in the WI-FI P2P connection established with the second electronic device is GC, and the third electronic device has not established a WI-FI P2P connection, the first electronic device can use methods 1-2 to establish a WI-FI connection with the third electronic device, and can refer to the descriptions in methods 1 to 3 above.

[0207] When the role of the first electronic device in the WI-FI P2P connection established with the second electronic device is GC or GO, and the third electronic device has established a WI-FI P2P connection, regardless of whether the role of the third electronic device is GC or GO, the 1A-3A methods can be used to establish a WI-FI connection with the third electronic device. In one example, in 1A-2A, the electronic device that seizes the WI-FI P2P service or establishes the WI-FI service of the WI-FI connection can be the initiator of the WI-FI connection, or any device that makes a WI-FI connection. In 3A, the electronic device that seizes the WI-FI P2P service or establishes the WI-FI service of the WI-FI connection can be any device that makes a WI-FI connection.

[0208] In the embodiment of the present application, the first electronic device can establish a WI-FI connection with the third electronic device through an idle first service or by preempting a service with an established WI-FI connection, so that the first electronic device as a GC can establish a WI-FI connection with other electronic devices, and the first electronic device as a GO can establish a WI-FI connection with an electronic device that has established a WI-FI P2P connection, so that the first electronic device can collaborate with other devices to perform services and expand the application of the first electronic device.

[0209] In addition, in S603, before the first electronic device establishes a WI-FI connection with the third electronic device, it can also negotiate the channel occupied by the WI-FI connection established by the first electronic device with the third electronic device. Exemplarily, when the first electronic device and the third electronic device negotiate roles, they can negotiate the channel occupied by the WI-FI connection.

[0210] In one embodiment, when the first electronic device is a device with WI-FI single-frequency capability, the first electronic device can establish a WI-FI P2P connection with the second electronic device on the first channel of the first frequency, and can establish a WI-FI connection with the third electronic device on the second channel of the first frequency. The second channel can be the same as or different from the first channel. When the second channel is different from the first channel, the communication efficiency of the first electronic device will be reduced. In an embodiment of the present application, when the first electronic device and the third electronic device negotiate the second channel, it is ensured that at least one of the "first electronic device and the second electronic device" and the "first electronic device and the third electronic device" are on the same frequency and channel to ensure the smooth progress of the business.

[0211] In one example, because the first electronic device has established a WI-FI P2P connection with the second electronic device, in order to ensure the smooth progress of the services collaboratively performed by the first electronic device and the second electronic device, the first electronic device and the third electronic device can ensure that the "first electronic device and the second electronic device" are on the same frequency and channel when negotiating the second channel, so as to ensure the smooth progress of the services collaboratively performed by the first electronic device and the second electronic device.

[0212] In one embodiment, when the first electronic device is a device with WI-FI dual-band capability, if the first electronic device establishes a WI-FI P2P connection with the second electronic device at the first frequency, the first electronic device can be connected to the WI-FI of the third electronic device at the second frequency. The first frequency and the second frequency can be different, for example, the first frequency can be 2.4G, and the second frequency can be 5G.

[0213] In the above embodiment, the communication method provided by the embodiment of the present application is described by taking the first electronic device having 2 ports or 3 ports as an example. In one embodiment, the communication method provided by the embodiment of the present application can also be applied to electronic devices with more ports. Exemplarily, the number of ports of the electronic device can be 4, 5, etc. In this example, one port in the electronic device can correspond to a WI-FI P2P service, and the remaining ports can correspond to one WI-FI service respectively.

[0214] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0215] In one embodiment, the present application also provides an electronic device, referring to Figure 8 , the electronic device may include: a processor 801 (such as a CPU), and a memory 802. The memory 802 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory. The memory 802 may store various instructions for completing various processing functions and implementing the method steps of the present application.

[0216] Optionally, the electronic device involved in the present application may further include: a power supply 803, a communication bus 804 and a communication port 805. The above-mentioned communication port 805 is used to realize the connection and communication between the electronic device and other peripherals. In the embodiment of the present application, the memory 802 is used to store computer executable program code, and the program code includes instructions; when the processor 801 executes the instruction, the instruction causes the processor 801 of the electronic device to perform the action in the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0217] In one embodiment, the electronic device may further include a display screen 806, and the display screen 806 is used to display an interface of the electronic device.

[0218] It should be noted that the modules or components described in the above embodiments may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors (digital signal processors, DSPs), or one or more field programmable gate arrays (FPGAs), etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program codes, such as a controller. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0219] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0220] The term "plurality" in this article refers to two or more than two. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and next associated objects are in an "or" relationship; in the formula, the character " / " indicates that the previous and next associated objects are in a "division" relationship. In addition, it should be understood that in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.

[0221] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.

[0222] It can be understood that in the embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

Claims

1. A communication method, characterized in that: Applied to a first electronic device, the method includes: In a case where the first electronic device has established a WI-FI P2P connection with the second electronic device, in response to an operation of triggering the first electronic device to establish a WI-FI connection with a third electronic device, sending device information of the first electronic device to the third electronic device, and receiving device information from the third electronic device; According to the device information of the first electronic device and the device information of the third electronic device, a WI-FI connection is established with the third electronic device, and at least one end of the WI-FI connection is a group manager GO or a group member GC.

2. The method according to claim 1, characterized in that In the WI-FI P2P connection established between the first electronic device and the second electronic device, the role of the first electronic device is GC.

3. The method according to claim 1, characterized in that: In the WI-FIP2P connection established between the first electronic device and the second electronic device, the role of the first electronic device is GO, and the third electronic device and the fourth electronic device have established a WI-FIP2P connection.

4. The method according to any one of claims 1 to 3, characterized in that The establishing a WI-FI connection with the third electronic device includes: Use the service in the first electronic device to establish a WI-FI connection with the third electronic device, where the service is the first service or the second service, the first service is a service for the first electronic device to access an access point to access the network, and the second service is a service for the first electronic device to establish a WI-FI P2P connection.

5. The method according to claim 4, characterized in that The first service is a WI-FI service, and the second service is a WI-FI P2P service.

6. The method according to claim 4 or 5, characterized in that: The using the service in the first electronic device to establish a WI-FI connection with the third electronic device includes: When the first service is idle, shielding a network access function provided by the first service and retaining a connection function provided by the first service; Use the connection function provided by the first service to establish a WI-FI connection with the third electronic device.

7. The method according to claim 6, characterized in that The first electronic device establishes a WI-FIP2P connection with the second electronic device using the second service; The first electronic device includes a first port and a second port, the first electronic device includes a first WI-FI service and the second service, the first WI-FI service corresponds to the first port, the second service corresponds to the second port, and the first service is the first WI-FI service.

8. The method according to claim 6, characterized in that The first electronic device establishes a WI-FIP2P connection with the second electronic device using the second service; The first electronic device includes a first port, a second port, and a third port, the first electronic device includes a first WI-FI service, a second WI-FI service, and the second service, the first WI-FI service corresponds to the first port, the second WI-FI service corresponds to the third port, the second service corresponds to the second port, and the first service is the first WI-FI service or the second WI-FI service.

9. The method according to claim 4 or 5, characterized in that: The first electronic device uses the second service to establish a WI-FI P2P connection with the second electronic device; and the use of the service in the first electronic device to establish a WI-FI connection with the third electronic device includes: When the first service is not idle and the first electronic device does not use the first service to establish a WI-FI connection, if the first priority of the service jointly performed by the first electronic device and the second electronic device is lower than the second priority of the service jointly performed by the first electronic device and the third electronic device, the WI-FI P2P connection established with the second electronic device is disconnected, and the second service is used to establish a WI-FI P2P connection with the third electronic device.

10. The method according to claim 9, characterized in that The method further comprises: When the first service is not idle and the first electronic device uses the first service to establish a WI-FI connection with a fifth electronic device, a WI-FI connection is established with the third electronic device according to the first priority, the second priority, and the third priority of the service collaboratively performed by the first electronic device and the fifth electronic device.

11. The method according to claim 10, characterized in that The establishing a WI-FI connection with the third electronic device according to the first priority, the second priority, and the third priority of the service collaboratively executed by the first electronic device and the fifth electronic device includes: If the first priority and the third priority are both lower than the second priority, disconnecting the established WI-FI P2P connection with the second electronic device, and using the second service to establish a WI-FI P2P connection with the third electronic device, or disconnecting the established WI-FI connection with the fifth electronic device, and using the first service to establish a WI-FI connection with the third electronic device; If the first priority and the third priority are both lower than the second priority, disconnecting the WI-FI connection with the lowest priority, and using the service corresponding to the disconnected WI-FI connection to establish a WI-FI connection with the third electronic device; If the first priority is higher than the second priority and the third priority is lower than the second priority, disconnecting the established WI-FI connection with the fifth electronic device and using the first service to establish a WI-FI connection with the third electronic device; If the third priority is higher than the second priority and the first priority is lower than the second priority, the established WI-FI P2P connection with the second electronic device is disconnected, and the second service is used to establish a WI-FI P2P connection with the third electronic device.

12. The method according to claim 10 or 11, characterized in that: The method further comprises: If the first priority and the third priority are both higher than the second priority, it is determined not to establish a WI-FI connection with the third electronic device.

13. The method according to any one of claims 1 to 12, characterized in that Before sending the device information of the first electronic device to the third electronic device and receiving the device information from the third electronic device, the method further includes: Establishing a Bluetooth channel with the third electronic device; The sending the device information of the first electronic device to the third electronic device and receiving the device information from the third electronic device includes: The device information of the first electronic device is sent to the third electronic device through the Bluetooth channel, and the device information is received from the third electronic device.

14. The method according to any one of claims 1 to 13, characterized in that The device information of the first electronic device is used to indicate the role of the first electronic device in the WI-FI P2P connection established with the second electronic device, and the device information of the third electronic device is used to indicate whether the third electronic device has established a WI-FI connection, and if the third electronic device has established a WI-FI connection, the device information of the third electronic device is also used to indicate the role of the third electronic device in the established WI-FI P2P connection; The establishing a WI-FI connection with the third electronic device according to the device information of the first electronic device and the device information of the third electronic device includes: According to the device information of the first electronic device and the device information of the third electronic device, negotiate the role of the first electronic device and the role of the third electronic device in the WI-FI connection established with the third electronic device; A WI-FI connection is established with the third electronic device according to the negotiated role of the first electronic device and the role of the third electronic device.

15. An electronic device, characterized in that: include: Processor and memory; The memory stores computer instructions; The processor executes the computer instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 14.

16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instruction, and when the computer program or instruction is executed, the method according to any one of claims 1 to 14 is implemented.