Communication method, electronic device and storage medium

By exchanging device information and negotiating roles on the basis of the established WI-FI P2P connection, WI-FI connections between devices are realized, which solves the problem in the existing technology that devices can no longer establish WI-FI P2P connections and realizes WI-FI connection between devices. Direct communication and business collaboration expand application scenarios.

WO2024174749A1PCT designated stage expired Publication Date: 2024-08-29HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/071044
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-24
Filing Date
2024-01-08
Publication Date
2024-08-29

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

Based on the established WI-FI P2P connection, the WI-FI connection between devices is realized by exchanging device information and negotiating roles, allowing devices to communicate point-to-point without AP or LAN, expanding application scenarios.

Benefits of technology

It realizes direct communication and collaborative service execution between devices without going through the LAN or AP, expanding the application scenarios and functions of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024071044_29082024_PF_FP_ABST
    Figure CN2024071044_29082024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present application are a communication method, an electronic device, and a storage medium. The communication method comprises: when a first electronic device and a second electronic device have already established a WI-FI P2P connection, in response to an operation of triggering the first electronic device and a third electronic device to establish a WI-FI connection, the first electronic device may send device information of the first electronic device to the third electronic device and receive device information from the third electronic device, the WI-FI connection being a WI-FI connection between devices; and according to the device information of the first electronic device and the device information of the third electronic device, establishing a WI-FI connection with the third electronic device. In the present application, the first electronic device that has already established a WI-FI P2P connection can also establish a WI-FI connection with other electronic devices, such that the first electronic device and the third electronic device can directly communicate with each other, and furthermore, the first electronic device can cooperatively execute a service with other electronic devices.
Need to check novelty before this filing date? Find Prior Art

Description

Communication method, electronic device, and storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on February 24, 2023, with application number 202310209565.X and application name “Communication Method, Electronic Device, and Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The embodiments of the present application relate to the field of communication technologies, and in particular to a communication method, an electronic device, and a storage medium. Background Art

[0003] Wi-Fi Direct (also known as Wi-Fi peer-to-peer (P2P)) is a Wi-Fi-based technology launched by the Wi-Fi Alliance that enables direct connections between devices. Devices can communicate one-to-one or one-to-many without the need for a local area network (LAN) or access point (AP).

[0004] Currently, for a device that has already established a Wi-Fi P2P connection, the device cannot establish a Wi-Fi P2P connection with other devices, which limits the execution of services between devices.

[0005] Summary of the Invention

[0006] An embodiment of the present application provides a communication method, an electronic device, and a storage medium. On the basis that an electronic device has already established a Wi-Fi P2P connection, the electronic device can establish a Wi-Fi connection with other electronic devices. The Wi-Fi connection can realize point-to-point communication between the electronic device and the other electronic devices.

[0007] In a 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, processor, etc. in the first electronic device. The following description will be made using the first electronic device as an example. In this method, when the first electronic device and the second electronic device have established a WI-FI P2P connection, 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. The first electronic device may send the device information of the first electronic device to the third electronic device, and receive device information from the third electronic device.

[0008] 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 a WI-FI P2P connection is included in a WI-FI connection.

[0009] 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 a "GO or GC." For example, taking a Wi-Fi connection established between a first electronic device and a third electronic device, when the first electronic device is a GO, the third electronic device can function as a GC or STA device; and when the first electronic device is a GC, the third electronic device can function as a GO or softAP. Correspondingly, when the third electronic device is a GO, the first electronic device can function as a GC or STA device; and when the third electronic device is a GC, the first electronic device can function as a GO or softAP.

[0010] 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 going 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 collaboratively perform services, thereby expanding the application of the first electronic device.

[0011] In one possible implementation, the communication method provided in the embodiments of the present application can be applied in the following two scenarios:

[0012] Scenario 1: In a Wi-Fi P2P connection established between the first electronic device and the second electronic device, the first electronic device plays the role of 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.

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

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

[0015] In this implementation, it can be achieved that the first electronic device serving as a GC can also establish a WI-FI connection with other electronic devices, and it can also be achieved that the first electronic device serving 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 serving 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 a GC, and the first electronic device serving 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 a GO.

[0016] 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, as shown below:

[0017] 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, 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.

[0018] It should be understood that the first service is a service used by the first electronic device to access the access point to access the network, which can be understood as: the first service can be used by 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 by the first electronic device to query the AP and exchange information with the AP, and the connection function is used by 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.

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

[0020] 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 the original service in the first electronic device.

[0021] The following describes a method for establishing a Wi-Fi connection between the first electronic device and the third electronic device:

[0022] First, when the first service is idle, the first electronic device can block 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 blocks the network access function provided by the first service is to enable the first electronic device to use the network access function provided by the first service to query the AP and interact with the AP, and then access the AP. In this embodiment of the application, blocking 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.

[0023] In one possible implementation, the first electronic device establishes a Wi-Fi P2P connection with the second electronic device using the second service. The first electronic device includes a first port and a second port, and 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.

[0024] In one 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.

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

[0026] Second, 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.

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

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

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

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

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

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

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

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

[0035] 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 perform services.

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

[0037] 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 addition, 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.

[0038] The first electronic device may negotiate, based on the device information of the first electronic device and the device information of the third electronic device, the roles of the first electronic device and the third electronic device in the WI-FI connection established with the third electronic device. Furthermore, the first electronic device may establish the WI-FI connection with the third electronic device based on the negotiated roles of the first electronic device and the third electronic device.

[0039] In this implementation, the first electronic device that has established a WI-FI P2P connection can also negotiate with the third electronic device about the role in the WI-FI connection, and establish the 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.

[0040] 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 configured to store computer-executable program code, the program code including instructions; when the processor executes the instructions, the instructions cause the electronic device to perform the method described in the first aspect.

[0041] 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, module, or circuit for executing the method provided in the first aspect.

[0042] 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 described above.

[0043] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enables the computer to execute the method in the first aspect above.

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

[0045] In the communication method provided by the embodiments of the present application, when a first electronic device and a second electronic device have established a WI-FI P2P connection, the first electronic device establishes a WI-FI connection with a third electronic device based on device information of the first electronic device and 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 collaboratively perform services, thereby expanding the application of the first electronic device. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] FIG1 is a schematic diagram of a current WI-FI P2P connection between electronic devices;

[0047] FIG2A is a schematic diagram showing that GO can be connected to at least one GC;

[0048] FIG2B is a schematic diagram showing a GC that cannot connect to other devices;

[0049] FIG2C is another schematic diagram showing that the GC cannot connect to other devices;

[0050] FIG3 is a schematic diagram of a software architecture of an electronic device;

[0051] FIG4A is a connection diagram of an electronic device;

[0052] FIG4B is another connection diagram of an electronic device;

[0053] FIG5 is a block diagram of a software structure of an electronic device provided in an embodiment of the present application;

[0054] FIG6 is a flow chart of an embodiment of a communication method provided in an embodiment of the present application;

[0055] FIG7A is a connection diagram of an electronic device provided in an embodiment of the present application;

[0056] FIG7B is another connection diagram of the electronic device provided in an embodiment of the present application;

[0057] FIG7C is another connection diagram of the electronic device provided in an embodiment of the present application;

[0058] FIG7D is another connection diagram of the electronic device provided in an embodiment of the present application;

[0059] FIG8 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0061] Wi-Fi direct: Also known as Wi-Fi peer-to-peer (Wi-FI P2P), it allows electronic devices to communicate one-to-one or one-to-many without the need for a local area network or access point (AP).

[0062] 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 (BSS).

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

[0064] AP: 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.

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

[0066] Dynamic Host Configuration Protocol (DHCP), also known as Dynamic Host Configuration Protocol, is a network protocol for IP networks. It resides at the application layer of the OSI model and operates using the UDP protocol. DHCP has two main uses: first, for automatic IP address allocation within an intranet or Internet service provider, and second, for centralized management of all computers within an intranet by administrators.

[0067] Address Resolution Protocol (ARP): A protocol for obtaining a physical address based on an IP address. When a host sends a message, it broadcasts an ARP request containing the target IP address to all hosts on the local network and receives a reply message, thereby determining the target's physical address. Upon receiving the reply message, the host can store the IP and physical addresses in its local ARP cache for a specified period of time. The next request directly queries the ARP cache, saving resources.

[0068] The Address Resolution Protocol (ARP) relies on mutual trust between hosts on a network. Hosts on a local area network (LAN) can autonomously send ARP reply messages. Other hosts, upon receiving these replies, do not verify their authenticity and instead store them in their local ARP cache. This allows an attacker to send a bogus ARP reply message to a specific host, causing the information it sends to fail to reach the intended host or to reach the wrong host. This constitutes ARP spoofing. ARP commands can be used to query the local ARP cache for IP address and MAC address correspondences, as well as to add or delete static correspondences.

[0069] Protocols similar to ARP include Reverse Address Resolution Protocol (RARP), Proxy ARP, and Neighbor Discovery Protocol (NDP). In one example, NDP can be used to replace Address Resolution Protocol in IPv6.

[0070] The electronic devices in the embodiments of the present application may be referred to as user equipment (UE), terminals, and other devices with Wi-Fi P2P connection capabilities. For example, the electronic devices may be mobile phones, tablet computers (portable Android devices, PADs), personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices, vehicle-mounted devices, or wearable devices, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in smart homes, etc. The embodiments of the present application do not specifically limit the form of the electronic devices.

[0071] In one embodiment, electronic devices may be interconnected via other communication networks, such as a Bluetooth network, a ZigBee network, or a Near Field Communication (NFC) network.

[0072] Here, in conjunction with Figure 1, a brief description of the current process of WI-FI P2P connection between electronic devices is given. It should be understood that Figure 1 takes 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:

[0073] Step 1: Device 1 and device 2 establish a Bluetooth connection to establish a Bluetooth channel. This Bluetooth channel can be used as a signaling channel to transmit signaling for interaction between device 1 and device 2.

[0074] In step 2, device 1 and device 2 exchange signaling via the Bluetooth channel to determine whether a Wi-Fi P2P connection can be established with the other end. If a Wi-Fi P2P connection can be established with the other end, 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.

[0075] Step 3: Device 1 and device 2 may also exchange signaling via the Bluetooth channel to determine whether the two devices are in the same network. If device 1 and device 2 are in the same network, device 1 and device 2 may establish a Wi-Fi P2P connection to establish a Wi-Fi P2P connection channel, and device 1 and device 2 may collaborate to perform services via the Wi-Fi P2P connection channel. If the two devices are not in the same network, device 1 may prompt device 2 that its end is busy, or device 2 may prompt device 1 that its end is busy, and device 1 and device 2 will not establish a Wi-Fi P2P connection.

[0076] For example, 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.

[0077] If Device 1 and Device 2 are already 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. For example, referring to Figure 2A , in one example, Device 1, acting as a GO, can also add Device 3 to its GC list to establish a Wi-Fi P2P connection with Device 3 (e.g., a laptop), allowing Device 1 to share files with Device 3.

[0078] However, device 2, acting as a GC, can no longer establish a Wi-FI P2P connection with other devices. Referring to Figure 2B , if device 2 initiates a Wi-FI P2P connection with device 3, devices 2 and 3 can exchange signaling via the Bluetooth channel. However, as a GC, device 2 can no longer establish a Wi-FI P2P connection with device 3, and therefore, device 2 cannot share files with device 3. Similarly, referring to Figure 2C , if device 3 initiates a Wi-FI P2P connection with device 2, devices 2 and 3 can exchange signaling via the Bluetooth channel. However, as a GC, device 2 can no longer establish a Wi-FI P2P connection with device 3.

[0079] Similarly, device 1 as a GO is also unable to establish a WI-FI P2P connection with another GC. For example, if device 4 and device 5 also establish a WI-FI P2P connection, such as device 4 acts as a GC and device 5 acts 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, if device 1 as a GO is unable to establish a WI-FI P2P connection with device 5. In other words, the device currently acting as a GO cannot establish a WI-FI P2P connection with electronic devices (such as GC or GO) in other WI-FI P2P connections.

[0080] 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 to a WI-FI P2P connection, 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.

[0081] Figure 3 is a schematic diagram of a software architecture for an electronic device. Referring to Figure 3, the software system of an electronic device can adopt a layered architecture. The layered architecture can divide the terminal's software system into several layers, each with a clear role and division of labor. Layers communicate with each other through software ports.

[0082] In some embodiments, the electronic device may include an application layer (applications), an application framework layer (application framework), a hardware abstract layer (HAL), a kernel layer (kernel), 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. 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.

[0083] The application layer may include a series of application packages, and the application layer runs applications by calling the application programming interface (API) provided by the application framework layer. FIG3 illustrates an example in which the application layer includes applications.

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

[0085] The window manager manages windowed applications. It can determine the display size, determine whether a status bar is present, lock the screen, and take screenshots. Content providers store and retrieve data and make it accessible to applications. This data can include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and the phone book. The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images. The phone manager provides communication functions for electronic devices, such as managing call states (including connected and ended calls). The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, and video files. The notification manager enables applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically, without requiring user interaction. For example, the notification manager is used to notify users of download completions and message reminders. The notification manager can also be a notification that appears in the form of an icon or scrolling text in the status bar at the top of the system, such as a notification from an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, the electronic device 100 vibrates, an indicator light flashes, etc.

[0086] In one example, referring to FIG3 , the application framework layer may further include: WI-FI services, P2P services 1, and P2P services 2. WI-FI services are used to assist electronic devices in accessing an AP to enable them to access the Internet. Accessing the Internet with an electronic device can also be understood as accessing the network, connecting the electronic device to the network, or connecting the electronic device to the network. Accessing the AP with an electronic device can be understood as connecting the electronic device to the AP. P2P services 1 is used to assist electronic devices in establishing a WI-FI P2P connection.

[0087] It should be noted that in one embodiment, when device 1 and device 2 establish a Wi-FI P2P connection, in order to enable device 1 or device 2 to also establish a Wi-FI P2P connection with other devices, a P2P services 2 can be set up at the application framework layer. This P2P services 2 is 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 a device in another Wi-FI P2P connection, not only must P2P services 2 be set up on device 1 and device 2, but it must also be set up on the other devices in the Wi-FI P2P connection.

[0088] The hardware abstraction layer (HAL) can contain multiple library modules, such as a camera library module and a motor library module. The electronic device's hardware can load the corresponding library modules, enabling the application framework layer to access the device hardware. Device hardware can include motors, cameras, and other components within an electronic device.

[0089] The kernel layer is the layer between hardware and software. It drives the hardware, enabling it to operate. The kernel layer includes at least display drivers, camera drivers, audio drivers, sensor drivers, and motor drivers, though this embodiment of the application does not limit these.

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

[0091] Referring to Figure 3 , in this embodiment, a P2P services 2 can be set up at the application framework layer. This services 2 can assist the electronic device in establishing a Wi-Fi P2P connection with another device after a Wi-Fi P2P connection has already been established. However, this embodiment requires developers to build a complete set of P2P services logic to enable the electronic device to establish two Wi-Fi P2P connections, which is labor-intensive and costly.

[0092] 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 thus can expand the application of the device.

[0093] It is understood that multiple communication ports can be pre-set in an 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 simply referred to as ports for illustration.

[0094] In this embodiment, an electronic device with two ports and an electronic device with three ports are used as examples for explanation:

[0095] For example, if the electronic device has two ports, and the connection capabilities supported by the two ports are as follows: define WIFI_HAL_INTERFACE_COMBINATIONS{{{STA},1},{{AP},1}},\ {{{STA},1},{{P2P},1}}

[0096] 4A , an electronic device can connect to an AP as a STA device through port 1 "{{STA},1},{{AP},1}}". Furthermore, the electronic device can establish a Wi-Fi P2P connection with other electronic devices through port 2 "{{STA},1},{{P2P},1}}". 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 an electronic device acting as a GC to establish a WI-FI P2P connection with other devices, or if there is a need for an 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. In Figures 4A and 4B, the device that establishes a WI-FI P2P connection with the electronic device is a mobile phone, and the AP is a router as an example. It should be understood that an electronic device acting as a GC refers to an electronic device that plays the role of a GC in the WI-FI P2P connection established by the electronic device, and an electronic device acting as a GO refers to an electronic device that plays the role of a GO in the WI-FI P2P connection established by the electronic device.

[0098] For example, if the electronic device has three ports, and the connection capabilities supported by the three ports are as follows: define WIFI_HAL_INTERFACE_COMBINATIONS{{{STA},1},{{AP},1}},\ {{{STA},1},{{P2P},1}},\ {{{STA},2}}

[0099] 4B , an electronic device can connect to an AP as a STA device via port 1 ({{STA},1},{{AP},1}}). Furthermore, an electronic device can establish a Wi-Fi P2P connection with another electronic device via port 2 ({{STA},1},{{P2P},1}}).

[0100] 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 devices in other Wi-FI P2P connections, there is also a problem that both electronic devices can no longer establish a Wi-FI P2P connection.

[0101] 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 to assist electronic devices in accessing the network, and the second port is a port to assist electronic devices in establishing a Wi-Fi P2P connection.

[0102] At present, in one embodiment, whether it is an electronic device with 2 ports or an electronic device with 3 ports, the structure of the electronic device can be as shown in Figure 5. Figure 5 is a software structure block diagram of the electronic device provided in an embodiment of the present application. In one example, the "hardware abstraction layer" and the "kernel layer" in Figure 5 can be regarded as a layer of "hardware abstraction layer". Referring to 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 the relevant description in Figure 3.

[0103] Referring to 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, and this embodiment of the application will not be described in detail.

[0104] Referring to Figure 5 , the application framework layer may also include Wi-Fi 1 services, Wi-Fi P2P services, and Wi-Fi 2 services. Wi-Fi 1 services, Wi-Fi P2P services, and Wi-Fi 2 services may all be referred to as services in an electronic device. In one embodiment, Wi-Fi 1 services may be referred to as a first Wi-Fi service, and Wi-FI 2 services may be referred to as a second Wi-Fi service. In one embodiment, Wi-Fi 1 services and Wi-FI 2 services may also be referred to as station (STA) services.

[0105] Among them, WI-FI1 services and WI-FI2 services are used to assist electronic devices in accessing the network, such as assisting electronic devices in accessing an AP to connect to the network. WI-FI P2P services are used to assist electronic devices in establishing a WI-FI P2P connection. In the embodiments of the present application, WI-FI1 services and WI-FI2 services can also be used to assist electronic devices in establishing a WI-FI connection. This WI-FI connection has the same communication effect as a WI-FI P2P connection, and can achieve point-to-point communication between electronic devices.

[0106] In one embodiment, Wi-Fi 1 services and Wi-Fi 2 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 further include first services and second services, where the first services may include Wi-Fi 1 services and Wi-FI 2 services, and the second services may be Wi-FI P2P services.

[0107] The first service is a service for electronic devices to access an AP to access the Internet, 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 electronic devices with the function of accessing an AP to access the Internet, and the second service can provide electronic devices with the function of establishing a Wi-Fi P2P connection.

[0108] 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 P2P services, WI-FI FWK1, and WI-FI HAL1 to establish a WI-FI P2P connection with other electronic devices, reference can be made to the relevant description in the prior art. In addition, the electronic device can use WI-FI1 services, WI-FI FWK1 and WI-FI HAL1) to access the AP so that the electronic device can access the network.

[0109] In one embodiment, the application framework layer may further include a service scheduling module. The service scheduling module is configured 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 the steps performed by the electronic device shown in FIG6 may be considered steps performed by the service scheduling module in the electronic device.

[0110] 5 , the firmware layer may include firmware for driving three ports. The three ports may refer to the above descriptions of Port 1 to Port 3 .

[0111] 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 shown in Figure 5. For example, the electronic device may not run Wi-Fi 2 services, Wi-Fi FWK2, and Wi-Fi HAL2.

[0112] Alternatively, in one embodiment, an electronic device with two ports may not include WI-FI2 services, WI-FI FWK2, and WI-FI HAL2. Accordingly, an electronic device with two ports includes: a first port and a second port, wherein 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.

[0113] In the prior art, electronic devices can use WI-FI P2P services to establish WI-FI P2P connections with other electronic devices. However, because the WI-FI P2P services are occupied, the electronic device acting as a GC cannot establish a WI-FI P2P connection with other devices, and the electronic device acting as a GO cannot establish a WI-FI P2P connection with other electronic devices in the WI-FI P2P connection. In an embodiment of the present application, when the electronic device has already 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. This 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 an embodiment of the present application, when the electronic device has already 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 the WI-FI P2P services, thereby also achieving point-to-point communication between devices.

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

[0115] FIG6 is a flow chart of an embodiment of a communication method provided by an embodiment of the present application. Referring to FIG6 , the communication method provided by an embodiment of the present application may include:

[0116] S601: A first electronic device establishes a Wi-Fi P2P connection with a second electronic device.

[0117] The structure of the first electronic device may be as shown in FIG5 , and the structure of the second electronic device may be the same as or different from that of the first electronic device. The embodiment of the present application does not limit the structure of the second electronic device.

[0118] Both the first and second electronic devices have Wi-Fi P2P connection capabilities, i.e., both the first and second electronic devices can establish a Wi-Fi P2P connection. The process of establishing a Wi-Fi P2P connection between the first and second electronic devices can refer to the description of steps 1 to 3 in FIG1 , or to the description of the current standard protocol for establishing a Wi-Fi P2P connection between devices.

[0119] In one embodiment, referring to the structure of the first electronic device shown in FIG5 , 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 P2P services, and WI-FI FWK1. After the first electronic device and the second electronic device establish a WI-FI P2P connection, they can collaboratively perform services. The embodiment of the present application does not limit the services that the first electronic device and the second electronic device collaboratively perform, such as the service can be a screen projection service, a file sharing service, etc.

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

[0121] It should be understood that when the second electronic device acts as a GC or GO, it can also establish a Wi-Fi connection with other electronic devices, and reference can be made to the following description of the steps performed by the first electronic device in the following embodiments. The roles of the first electronic device and the second electronic device are negotiated between the first and second electronic devices, and the negotiation process can be described in the current standard protocol for Wi-Fi P2P connections between devices.

[0122] S602: In response to an operation 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.

[0123] 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 method 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 method in which the user triggers the first electronic device to establish a WI-FI direct connection with the third electronic device.

[0124] In other words, in response to the first electronic device initiating a Wi-Fi connection request to the third electronic device, or in response to receiving a Wi-Fi connection request 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 and third electronic devices can be understood as: the first electronic device sends the first electronic device's device information to the third electronic device, and the third electronic device sends the third electronic device's device information to the first electronic device. Correspondingly, the first electronic device can receive device information from the third electronic device.

[0125] In one embodiment, the first electronic device and the third electronic device can exchange device information via a Bluetooth channel. Referring to the process of establishing a Wi-Fi P2P connection shown in FIG1 , the first electronic device and the third electronic device can establish a Bluetooth connection to establish a Bluetooth channel and exchange device information via the Bluetooth channel. In one embodiment, the first electronic device and the third electronic device can also exchange device information via other means, such as by using a short-range communication method such as NFC.

[0126] 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 in the case where 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. For example, the device information of the third electronic device may include: role GO. The role GO can 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.

[0127] In one embodiment, the device information of the third electronic device may further include any of the following: whether the third electronic device can establish a Wi-Fi P2P connection, whether the Wi-Fi P2P connection supports multiplexing, and an identifier of the network to which the third electronic device belongs. Whether the Wi-Fi P2P connection supports multiplexing can be understood as: when the first and third electronic devices establish a Wi-Fi P2P connection, whether the first and third electronic devices can use the established Wi-Fi P2P connection channel to perform multiple services. If the Wi-Fi P2P connection supports multiplexing, the first and third electronic devices can use the established Wi-Fi P2P connection channel to perform multiple services. If the Wi-Fi P2P connection does not support multiplexing, the first and third electronic devices 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 indicates the network to which the third electronic device is connected. The network identifier may be, for example, the network name or the network IP address. In one example, when the third electronic device is not connected to a 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 include the identifier of the network to which the third electronic device belongs.

[0128] 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. The information on "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" may refer to the relevant description of the device information of the third electronic device.

[0129] In one embodiment, it may 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.

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

[0131] 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 already 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; alternatively, if the role of the first electronic device is GO and the third electronic device has already established a WI-FI P2P connection, the first electronic device will not establish a WI-FI P2P connection with the third electronic device.

[0132] In order to facilitate that the first electronic device serving as a GC can also establish a WI-FI connection with the third electronic device, and the first electronic device serving 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.

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

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

[0135] Similarly, in the following embodiments, it is mentioned that the third electronic device and the fifth electronic device establish a WI-FI connection. In the WI-FI connection, 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.

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

[0137] Scenario 1: The first electronic device plays the role of a GC in a Wi-Fi P2P connection established with a second electronic device. The third electronic device may not have established a Wi-Fi P2P connection, or may have established a Wi-Fi P2P connection. The third electronic device may play the role of a GC or a GO in the established Wi-Fi P2P connection. In one example, the device in the Wi-Fi P2P connection established with the third electronic device may be a fourth electronic device.

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

[0139] In one embodiment, when a first electronic device establishes a Wi-Fi connection with a third electronic device, the first electronic device may use a service in the first electronic device to establish a Wi-Fi connection with the third electronic device. The service may be a first service or a second service already in the first electronic device.

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

[0141] For example, if a first electronic device uses a second service to establish a Wi-Fi P2P connection with a second electronic device, and the second service is occupied, but the service collaboratively performed by the first and second electronic devices is a preset service, the first electronic device can temporarily disconnect the Wi-Fi P2P connection established between the first and second electronic devices and use the second service to establish a Wi-Fi P2P connection with a third electronic device. After the service collaboratively performed by the first and third electronic devices is completed, the first electronic device can use the second service to establish a Wi-Fi P2P connection with the second electronic device. The preset service can be a service with low real-time requirements, such as file sharing.

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

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

[0144] 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 an 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 acting 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 for WI-FI P2P connection, or to the relevant description in the following embodiments.

[0145] 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 an 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. Please refer to the relevant description of scenario 2 in scenario one below.

[0146] 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 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 costs and the workload of R&D personnel, but also achieves the purpose of collaborative execution of services by the first electronic device and the third electronic device, thereby expanding the application of the first electronic device.

[0147] The following uses scenario 1 as an example to illustrate how a first electronic device and a third electronic device establish a Wi-Fi connection:

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

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

[0150] Method 1:

[0151] 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 block 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.

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

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

[0154] In an embodiment of the present application, in order for a first electronic device to establish a Wi-Fi connection with a third electronic device using a first service, it is necessary to shield the network access function provided by the first service. 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 roaming functions, detecting 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. In this way, 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.

[0155] 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 block the roaming function of the first electronic device. If the first electronic device includes a roaming function and a function for detecting Internet access capabilities, the first electronic device may block the roaming function and the function for detecting Internet access capabilities of the first electronic device.

[0156] In method 1, when a first electronic device establishes a Wi-Fi connection with a third electronic device, the first electronic device uses the first service and can act as a STA device. The first electronic device blocks the network access function provided by the first service. Therefore, the STA device can simulate a gateway (GC) and the third electronic device can act as a gateway (GO). The simulated GC and GO can establish a Wi-Fi connection.

[0157] Alternatively, when the first electronic device establishes a Wi-Fi connection with the third electronic device, the third electronic device can act as a gateway (GC), and the first electronic device, using the first service, can act as a softAP. The softAP can be considered a simulated gateway (GO), which can establish a Wi-Fi connection with the gateway (GC).

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

[0159] 4A , in one possible scenario, a first electronic device uses a first Wi-Fi service and connects to an AP as a STA device through port 1 “{{STA}, 1}, {{AP}, 1}}”. The first electronic device uses a Wi-Fi P2P service and establishes a Wi-Fi P2P connection with a second electronic device through port 2 “{{STA}, 1}, {{P2P}, 1}}”.

[0160] 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-FI HAL 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).

[0161] 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 block 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 Figures 7A-7D are illustrated by taking the second electronic device as a mobile phone and the third electronic device as a smart screen as an example.

[0162] 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}}". 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, if the first WI-FI service is idle, the first electronic device can block 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.

[0163] Similarly, when the first electronic device has three ports, in one possible scenario, the first electronic device is not connected to an AP. 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 and second WI-FI services are idle. The first electronic device can block 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 block 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}}".

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

[0165] Referring to a in Figure 7B, the first WI-FI service and the second WI-FI service are 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 cast the screen to the third electronic device, the first electronic device can block 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, or the first electronic device can block 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 a in Figure 7B takes the example of the first electronic device using the first WI-FI service to establish a WI-FI connection with the third electronic device.

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

[0167] 4B , the first electronic device may 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 may 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}}".

[0168] Referring to b in Figure 7B, 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.

[0169] Method 2:

[0170] 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. Here, "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 two 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 three 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.

[0171] 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 connection between the first electronic device and the second electronic device is 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.

[0172] In the second method, 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 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.

[0173] In one embodiment, the first electronic device may 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, i.e., 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, i.e., determines to establish a Wi-FI connection with the third electronic device.

[0174] 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 the services. The setting of service priorities is not limited in the embodiments of the present application.

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

[0176] For example, in FIG7C , the first electronic device has two ports as an example. For example, the first electronic device uses a 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 collaboratively 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 screen projection service is high, and the real-time requirement of the shared file is low, and the priority of the screen projection service is higher than the priority of the shared file. In this case, 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. 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.

[0177] In one embodiment, to improve user experience, if the first priority is lower than the second priority, the first electronic device may output a prompt message, the prompt message being used to prompt the user whether to agree to the first electronic device establishing 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 services that the first electronic device and the second electronic device collaboratively execute. In this embodiment, the user may trigger the first electronic device and the third electronic device to establish a WI-FI connection based on the prompt message, and accordingly, the first electronic device, in response 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.

[0178] Method 3:

[0179] A first electronic device uses a second service to establish a WI-FI P2P connection with a second electronic device. In one possible scenario, 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. Exemplarily, in this scenario, if the first electronic device uses the first WI-FI service to access an AP, uses the second WI-FI service to establish a WI-FI connection with a fifth electronic device, and uses the second service to establish a WI-FI P2P connection with the second electronic device. Alternatively, if the first electronic device uses the second WI-FI service to access an AP, uses the first WI-FI service to establish a WI-FI connection with a 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 to which the first electronic device establishes a WI-FI connection using the first WI-FI service and the second WI-FI service can be collectively referred to as fifth electronic devices.

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

[0181] 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 and can act as a simulated GC or simulated GO during the Wi-Fi connection established between the first and third electronic devices. When the first electronic device is a simulated GC, the third electronic device can act as a GO; when the first electronic device is a simulated GO, the third electronic device is a GC.

[0182] 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 during the Wi-Fi connection between the first and third electronic devices. Correspondingly, when the first electronic device acts as a GO, the third electronic device can act as a GC, and when the first electronic device acts as a GC, the third electronic device can act as a GO.

[0183] 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 performed 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.

[0184] If both the first priority and the third priority are 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. Alternatively, the first electronic device may 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.

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

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

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

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

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

[0190] For example, in FIG7D , a first electronic device having three ports is taken as an example. For example, 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. 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 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, 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 in FIG7D , the fifth electronic device is taken as an example of a laptop computer.

[0191] 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 1, 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 of the first electronic device and the second port of the third electronic device.

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

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

[0194] In case 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 in the third electronic device.

[0195] In case 2, the first electronic device may 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 may be determined as GO, and the other electronic device may be determined as GC. For example, if the first electronic device determines to establish a Wi-Fi connection with the third electronic device by preempting the second service in the first electronic device, then when the first electronic device and the third electronic device establish a Wi-Fi connection, the role of the first electronic device may be determined as GO, and the role of the third electronic device may be determined as GC.

[0196] In one example, if a first electronic device uses a second service on the first electronic device, and a third electronic device uses a second service on the third electronic device, to establish a Wi-Fi connection, the electronic device initiating the Wi-Fi connection can be designated as the GO, and the other electronic device as the GC. Alternatively, the first and third electronic devices can negotiate roles based on their respective device capabilities.

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

[0198] Similarly, in Scenario 2, the manner in which the first electronic device, 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 Case 2 of Scenario 1. In addition, the manner 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 Case 2.

[0199] 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:

[0200] Table 1

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

[0202] 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 a 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.

[0203] When the role of the first electronic device in the WI-FI P2P connection established with the second electronic device is a GC or GO, and the third electronic device has already established a WI-FI P2P connection, regardless of the role of the third electronic device is a GC or GO, the WI-FI connection with the third electronic device can be established using methods 1A-3A. 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 establishes the 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 establishes the WI-FI connection.

[0204] In an 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.

[0205] In addition, in S603, before establishing a Wi-Fi connection with the third electronic device, the first electronic device may also negotiate the channel occupied by the Wi-Fi connection established between the first electronic device and the third electronic device. For example, when the first electronic device and the third electronic device negotiate roles, they may negotiate the channel occupied by the Wi-Fi connection.

[0206] 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 this 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.

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

[0208] In one embodiment, when the first electronic device is a device with Wi-Fi dual-band capabilities, if the first electronic device establishes a Wi-Fi P2P connection with a second electronic device at a first frequency, the first electronic device can then establish a Wi-Fi connection with a third electronic device at a 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.

[0209] 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. For example, the electronic device can have 4, 5, etc. ports. In this example, one port of the electronic device can correspond to a Wi-Fi P2P service, and the remaining ports can each correspond to a Wi-Fi service.

[0210] 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 relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0211] In one embodiment, the present application also provides an electronic device. Referring to FIG8 , the electronic device may include a processor 801 (e.g., 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 storage. The memory 802 may store various instructions for performing various processing functions and implementing the method steps of the present application.

[0212] Optionally, the electronic device involved in this application may further include: a power supply 803, a communication bus 804, and a communication port 805. The communication port 805 is used to enable communication between the electronic device and other peripheral devices. In the embodiment of the present application, the memory 802 is used to store computer-executable program code, which includes instructions; when the processor 801 executes the instructions, the instructions cause the processor 801 of the electronic device to perform the actions in the above-mentioned method embodiment. The implementation principles and technical effects are similar and will not be repeated here.

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

[0214] 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), one or more microprocessors (digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code, 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).

[0215] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, 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 the computer program instructions are loaded and executed 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 device. 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, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. 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 drive (SSD)).

[0216] The term "plurality" in this article refers to two or more. The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: 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 the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.

[0217] It will be understood that the various numerical numbers involved in the embodiments of the present application are merely distinctions for the convenience of description and are not intended to limit the scope of the embodiments of the present application.

[0218] 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-FI P2P 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-FI P2P 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 a first service or a 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-FI P2P 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-FI P2P 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 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.

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 WI-FI P2P connection established with the second electronic device is disconnected, and a WI-FI P2P connection is established with the third electronic device using the second service.

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.

Citation Information

Patent Citations

  • Method and device for establishing Wi-Fi point-to-point connection

    CN111372325A

  • Communication method and system and electronic equipment

    CN114679708A

  • Method for establishing wi-fi p2p connection, and electronic device

    WO2022228207A1

  • Communication method and electronic device

    WO2023284650A1

Cited By

  • P2P connection method and device

    CN122002639A