WiFi p2p connection method, electronic device, and medium

By identifying devices with weak switching capabilities within the device and having them establish a P2P connection using their STA channel, while devices with strong switching capabilities perform the channel switching, the problem of poor WiFi P2P connection performance caused by the group owner's weak channel switching capability is solved, resulting in better connection performance.

CN115988643BActive Publication Date: 2025-12-12HONOR DEVICE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210149135.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-14
Publication Date
2025-12-12
Estimated Expiration
2041-10-14

AI Technical Summary

Technical Problem

When the first and second devices are connected to routers on the same frequency but different channels, the group owner's channel switching capability is weak, resulting in poor WiFi P2P connection performance, which may cause problems such as slow file transfer rate, operation lag, severe video frame dropping, and high latency.

Method used

By identifying the device with weaker switching capabilities among the first and second devices, a P2P connection is established using its STA channel, and the device with stronger switching capabilities performs channel switching, thus ensuring optimized connection performance.

Benefits of technology

It improves the performance of WiFi P2P connections, avoiding problems such as slow file transfer rates, lag, severe video frame drops, and high latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115988643B_ABST
    Figure CN115988643B_ABST
Patent Text Reader

Abstract

The application provides a WiFi P2P connection method, an electronic device and a readable storage medium. First and second devices are connected to a network in the same frequency and different channels. The first device receives and responds to a first operation, obtains a same-frequency different-channel switching capability value of a first WiFi module of the first device, and establishes a connection channel with the second device. The first device receives a same-frequency different-channel switching capability value of a second WiFi module of the second device and a station STA channel of the second device connected to the network. The first device determines a device with weak switching capability according to the same-frequency different-channel switching capability value of the first WiFi module and the same-frequency different-channel switching capability value of the second WiFi module. If the second device has weak switching capability, the first device establishes a WiFi P2P connection according to the STA channel of the second device connected to the network. In this way, the STA channel and the P2P channel are switched by a device with strong switching capability, and the WiFi P2P connection performance of the first and second devices is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] The present application is a divisional application of a Chinese patent application with the application number 202111197472.7, the title of which is "WiFi P2P connection method, electronic device, program product and medium", and which was filed on October 14, 2021 with the Chinese Patent Office. TECHNICAL FIELD

[0002] The present application relates to the technical field of wireless connection, in particular to a WiFi P2P connection method, an electronic device and a computer readable storage medium. BACKGROUND

[0003] In a scenario where the first device and the second device are connected to the same frequency and different channels of a router, if the first device and the second device need to establish a WiFi P2P connection again, the station (STA) channel of the station in the first device and the second device that acts as a group owner (GO) is preferred as the channel for the WiFi P2P connection.

[0004] However, if the channel switching capability of the group owner is weak, and the group owner performs same frequency and different channel switching, the WiFi P2P connection performance of the first device and the second device will not be optimal, and problems such as slow file transfer rate, operation lag, serious video frame loss and large delay may occur. SUMMARY

[0005] The present application provides a WiFi P2P connection method, an electronic device, a computer program product and a computer readable storage medium, and aims to ensure that the WiFi P2P connection established by the first device and the second device has optimal connection performance.

[0006] In order to achieve the above-mentioned purpose, the present application provides the following technical solutions:

[0007] In a first aspect, the present application provides a WiFi P2P connection method applied to a first device, the first device and a second device being connected to a network in a same frequency and different channels, the WiFi P2P connection method comprising: receiving, by the first device, an operation of triggering the first device to establish a WiFi P2P connection with the second device, and in response to the operation, obtaining a WiFi module same frequency different channel switching capability value of the first device, and establishing a connection channel with the second device; receiving, by the first device, capability information of the second device and a station STA channel of the second device connected to the network, the capability information of the second device at least comprising: a WiFi module same frequency different channel switching capability value of the second device; determining, by the first device, a device with weak switching capability from the first device and the second device, by using the WiFi module same frequency different channel switching capability value of the first device and the WiFi module same frequency different channel switching capability value of the second device; and establishing, by the first device, a P2P connection between the first device and the second device by using a STA channel of the device with weak switching capability connected to the network. If the second device has weak switching capability, the first device establishes a WiFi P2P connection with the second device according to the STA channel of the second device connected to the network.

[0008] From the above, it can be seen that the first device and the second device use the STA channel of the device with weak switching capability as the channel for establishing the P2P connection, so that the device with weak switching capability does not need to perform channel switching when running in the WiFi STA mode and the WiFi P2P mode, and the device with strong switching capability performs channel switching between the STA channel and the P2P channel, so as to ensure that the WiFi P2P connection performance of the first device and the second device is optimal, and problems such as slow file transfer rate, operation lag, serious video frame loss, and large time delay are avoided.

[0009] In a possible implementation, the WiFi module same frequency different channel switching capability value of the first device comprises: a P2P channel working time length, a STA channel working time length, and a switching time consumption of the first device; and the WiFi module same frequency different channel switching capability value of the second device comprises: a P2P channel working time length, a STA channel working time length, and a switching time consumption of the first device.

[0010] In a possible implementation, the WiFi module same frequency different channel switching capability value of the first device comprises: a first value, the first value being used to represent the WiFi module same frequency different channel switching capability of the first device; and the WiFi module same frequency different channel switching capability value of the second device comprises: a second value, the second value being used to represent the WiFi module same frequency different channel switching capability of the first device.

[0011] In a possible implementation, the first device determines the device with weak switching capability from the first device and the second device by using the WiFi module same-frequency different-channel switching capability value of the first device and the WiFi module same-frequency different-channel switching capability value of the second device, including: the first device compares the P2P channel working time of the first device and the P2P channel working time of the second device, the STA channel working time of the first device and the STA channel working time of the second device, and the switching time consumption of the first device and the switching time consumption of the second device, respectively, to obtain three comparison results; and the first device determines the device with weak switching capability from the first device and the second device according to the three comparison results.

[0012] In a possible implementation, the first device determines the device with weak switching capability from the first device and the second device by using the WiFi module same-frequency different-channel switching capability value of the first device and the WiFi module same-frequency different-channel switching capability value of the second device, including: the first device compares the P2P channel working time of the first device and the P2P channel working time of the second device, the STA channel working time of the first device and the STA channel working time of the second device, and the switching time consumption of the first device and the switching time consumption of the second device, respectively, to obtain three comparison results; and the first device determines the device with weak switching capability from the first device and the second device according to the three comparison results.

[0013] In a possible implementation, the first device receives the capability information of the second device and the STA channel of the second device in the network sent by the second device, including: the first device receives the capability information of the second device and the STA channel of the second device in the network sent by the second device by using a Bluetooth connection channel.

[0014] In a possible implementation, the first device receives the capability information of the second device and the STA channel of the second device in the network sent by the second device, including: the first device receives the capability information of the second device and the STA channel of the second device in the network sent by the second device by using a P2P connection channel, and the P2P connection channel is established by the first device and the second device by establishing a P2P connection in a common channel.

[0015] In a possible implementation, before the first device establishes the P2P connection of the first device and the second device by using the STA channel of the device with weak switching capability in the network, the first device further determines that the STA channel of the device with weak switching capability in the network is a channel supported by the device with strong switching capability from the first device and the second device.

[0016] In a possible implementation, the WiFi P2P connection method provided in the aspect further includes: if the first device determines that the STA channel of the device with weak switching capability in the network is not a channel supported by the device with strong switching capability from the first device and the second device, the first device establishes the P2P connection of the first device and the second device by using the STA channel of the device with strong switching capability from the first device and the second device in the network.

[0017] In a possible implementation, the first device and the second device do not all support the STA channel for the device with weak switching capability to enter the network, the first device and the second device establish the P2P connection of the first device and the second device by using the STA channel for the device with strong switching capability to enter the network in the first device and the second device, and the device with strong switching capability can run in the WiFi STA mode and the WiFi P2P mode without switching channels.

[0018] In a possible implementation, before the first device establishes the P2P connection of the first device and the second device by using the STA channel for the device with strong switching capability to enter the network in the first device and the second device, the method further includes: determining, by the first device, that the STA channel for the device with strong switching capability to enter the network in the first device and the second device is a channel supported by the device with weak switching capability in the first device and the second device.

[0019] In a possible implementation, the WiFi P2P connection method provided in the aspect further includes: determining, by the first device, that the STA channel for the device with strong switching capability to enter the network in the first device and the second device is not a channel supported by the device with weak switching capability in the first device and the second device, and then establishing, by the first device, the P2P connection of the first device and the second device by using a channel supported by both the first device and the second device.

[0020] In a possible implementation, after the first device establishes the P2P connection of the first device and the second device by using the STA channel for the device with weak switching capability to enter the network, the method further includes: determining, by the first device, that the P2P connection of the first device and the second device is not successfully established, and then establishing, by the first device, the P2P connection of the first device and the second device by using the STA channel for the device with strong switching capability in the first device and the second device.

[0021] In a possible implementation, the first device determines that the P2P connection of the first device and the second device is not successfully established, and the first device and the second device establish the P2P connection of the first device and the second device by using the STA channel for the device with strong switching capability to enter the network in the first device and the second device, which can ensure that the device with strong switching capability runs in the WiFi STA mode and the WiFi P2P mode without switching channels.

[0022] In a possible implementation, after the first device establishes the P2P connection of the first device and the second device by using the STA channel for the device with strong switching capability in the first device and the second device, the method further includes: determining, by the first device, that the P2P connection of the first device and the second device is not successfully established, and then establishing, by the first device, the P2P connection of the first device and the second device by using a channel supported by both the first device and the second device.

[0023] In a possible implementation, the method for calculating the WiFi module same-frequency different-channel switching capability value of the first device comprises the following steps: parsing the air interface log of the P2P test channel of the first device to obtain the working duration of the first device in the P2P test channel; parsing the air interface log of the STA test channel of the first device to obtain the working duration of the first device in the STA test channel; parsing the air interface log of the P2P test channel of the first device and the air interface log of the STA test channel of the first device to determine the time interval during which the first device has no packet in the STA test channel and the P2P test channel, and taking the time interval as the switching time consumption of the first device.

[0024] In a possible implementation, after the working duration of the P2P test channel of the first device and the working duration of the STA test channel of the first device are calculated, the method further comprises the following step: calculating the WiFi module same-frequency different-channel switching capability value of the first device by using the working duration of the P2P test channel of the first device, the working duration of the STA test channel of the first device, and the switching time consumption.

[0025] In a possible implementation, the method for calculating the WiFi module same-frequency different-channel switching capability value of the second device comprises the following steps: parsing the air interface log of the P2P test channel of the second device to obtain the working duration of the second device in the P2P test channel; parsing the air interface log of the STA test channel of the second device to obtain the working duration of the second device in the STA test channel; parsing the air interface log of the P2P test channel of the second device and the air interface log of the STA test channel of the second device to determine the time interval during which the second device has no packet in the STA test channel and the P2P test channel, and taking the time interval as the switching time consumption of the second device.

[0026] In a possible implementation, after the working duration of the P2P test channel of the second device and the working duration of the STA test channel of the second device are calculated, the method further comprises the following step: calculating the WiFi module same-frequency different-channel switching capability value of the second device by using the working duration of the P2P test channel of the second device, the working duration of the STA test channel of the second device, and the switching time consumption.

[0027] In a second aspect, the present application provides an electronic device, which comprises a first device, and the electronic device comprises one or more processors, a memory, and a wireless communication module; the memory and the wireless communication module are coupled to the one or more processors, the memory is configured to store computer program codes, the computer program codes comprise computer instructions, and when the one or more processors execute the computer instructions, the electronic device performs the WiFi P2P connection method provided in the first aspect or any one of the possible implementation manners of the first aspect.

[0028] In a third aspect, the present application provides a computer storage medium, configured to store a computer program, and when the computer program is executed, specifically configured to implement the WiFi P2P connection method provided in the first aspect or any one of the possible implementation manners of the first aspect.

[0029] In a fourth aspect, the present application provides a computer program product, when the computer program product is run on a computer, the computer is caused to execute the WiFi P2P connection method provided in the first aspect or any one of the possible implementation manners of the first aspect. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1 An application scenario diagram for establishing a connection between the first device and the second device provided in the present application;

[0031] Figure 2a A structural schematic diagram of the electronic device provided in the present application;

[0032] Figure 2b A software architecture diagram of the electronic device provided in the present application;

[0033] Figure 3 An application scenario diagram for testing the WiFi module inter-frequency inter-channel switching capability value of the electronic device provided in the present application;

[0034] Figure 4a An application scenario diagram for connecting a mobile phone and a PC provided in an embodiment of the present application;

[0035] Figure 4b A display diagram of multi-screen cooperation provided in an embodiment of the present application;

[0036] Figure 4c A mobile phone interface diagram of mobile phone screen projection provided in an embodiment of the present application;

[0037] Figure 4d A mobile phone interface diagram of file sharing provided in an embodiment of the present application;

[0038] Figure 4e A timing diagram of the WiFi P2P connection method provided in the first embodiment of the present application;

[0039] Figure 5 A timing diagram of the WiFi P2P connection method provided in the second embodiment of the present application. DETAILED DESCRIPTION

[0040] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. The terms used in the following embodiments are only for the purpose of describing the specific embodiments and are not intended to be limiting to the present application. As used in the specification and the appended claims of the present application, the singular forms “a,” “an,” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms “one or more” as used in the embodiments of the present application refer to one, two, or more than two; “and / or” describes the associated objects in the conjunctive relationship, which means that there can be three kinds of relationships; for example, A and / or B, which means that A exists alone, A and B exist together, B exists alone, and A, B can be singular or plural. The character “ / ” generally represents an “or” relationship between the associated objects.

[0041] In the present specification, the reference to “one embodiment” or “some embodiments” means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Therefore, the statements “in one embodiment”, “in some embodiments”, “in other some embodiments”, “in yet some embodiments” and the like appearing in various places in the specification are not necessarily all referring to the same embodiment, but mean “one or more but not all embodiments”, unless otherwise specifically emphasized. The terms “include”, “contain”, “have” and their variants mean “including but not limited to”, unless otherwise specifically emphasized.

[0042] The plurality of embodiments of the present application refers to more than or equal to two. It should be noted that in the description of the embodiments of the present application, the terms “first”, “second”, etc. are only used for the purpose of distinguishing the description and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.

[0043] In order to more clearly illustrate the technical solutions of the present application, the related concepts involved in the present application are explained as follows.

[0044] Frequency band, in the field of communication, frequency band refers to the frequency range of electromagnetic wave, and the commonly used frequency bands of WiFi include 2.4G, 5G, 6G and the like.

[0045] Channel refers to a channel for signal transmission in a communication system, and is formed by a transmission medium through which the signal is transmitted from a transmitting end to a receiving end. Each frequency band commonly used by WiFi is divided into multiple channels. For example, according to the IEEE 802.11 protocol, the 2.4 GHz Wi-Fi frequency band is divided into 13 overlapping channels, each channel having a width of 22 MHz (each channel has a frequency width of 20 MHz in the IEEE 802.11g standard and the IEEE 802.11n standard, and each channel has a frequency width of 22 MHz in the IEEE 802.10B standard); the 5 GHz Wi-Fi frequency band is divided into 201 channels.

[0046] WiFi P2P is a WiFi peer-to-peer (P2P) standard proposed by the WiFi alliance. WiFi P2P connections are generally created on demand when a user initiates P2P services.

[0047] WiFi STA mode refers to a mode in which an electronic device connects to a wireless access point (AP) to access the Internet.

[0048] WiFi P2P mode refers to a mode in which electronic devices are connected through WiFi P2P to establish a direct connection channel.

[0049] Group owner (GO) is a role similar to that of a wireless access point (AP) in WiFi P2P mode.

[0050] Group client (GC) is a role similar to that of a station device connecting to a wireless access point in WiFi STA mode in WiFi P2P mode.

[0051] Same frequency and different channels refer to the operation of an electronic device in WiFi STA mode and WiFi P2P mode in the same frequency band and different channels. The electronic device needs to be time-division switched between the working channel of the WiFi STA mode (referred to as the STA channel) and the working channel of the WiFi P2P mode (referred to as the P2P channel). For example, 100 ms / 100 ms time-division, with a switching time of 20 ms, indicating that the electronic device works in the STA channel for 100 ms, then switches to the P2P channel for 100 ms, and then switches to the STA channel again.

[0052] Figure 1In the application scenario shown, the first device (for example, a mobile phone) and the second device (for example, a PC) are connected to the same frequency but different channels of a router. Specifically, the first device is connected to a router 1 of a 5G frequency band 60 channel, and the second device is connected to a router 2 of a 5G frequency band 157 channel. When the first device and the second device establish a WiFi P2P connection, the channel of the station (STA) that is the group owner (GO) in the first device and the second device is used as the channel of the WiFi P2P connection. For example, Figure 1 In the application scenario shown, the second device is the GO, and the first device and the second device establish a P2P connection based on the 5G frequency band 157 channel.

[0053] Based on this, the second device is connected to the channel of the router 2, which is the same as the channel of the WiFi P2P connection established with the first device, and the second device does not need to switch channels. The first device is connected to the channel of the router 1, which is different from the channel of the WiFi P2P connection established with the second device, and the first device needs to switch between the two channels in time.

[0054] If the channel switching capability of the first device is weaker than that of the second device, the first device performs the same frequency and different channel switching, which may cause the WiFi P2P connection performance of the first device and the second device to be suboptimal, and may cause problems such as slow file transfer rate, operation lag, serious video frame loss, and large delay.

[0055] To solve the above problems, the embodiments of the present application provide a Wi-Fi P2P connection method. The Wi-Fi P2P connection method provided by the embodiments of the present application can be applied to mobile phones, tablet computers, desktop computers, laptop computers, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, personal digital assistants (PDAs), wearable electronic devices, smart watches, and other electronic devices.

[0056] Figure 2a An example of an electronic device provided by the embodiments of the present application is provided. For example, a mobile phone, the electronic device 200 can include a processor 210, an external memory interface 220, an internal memory 221, a display screen 230, an antenna 1, an antenna 2, a mobile communication module 240, and a wireless communication module 250.

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

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

[0059] Among them, the controller can be the nerve center and command center of the electronic device 200. The controller can generate operation control signals according to instruction operation codes and timing signals to complete the control of instruction fetching and instruction execution.

[0060] The video codec is used to compress or decompress digital video. The electronic device can support one or more video codecs. In this way, the electronic device can play or record videos in multiple encoding formats, such as moving picture experts group (MPEG) 1, MPEG 2, MPEG 3, MPEG 2, etc.

[0061] The NPU is a neural-network (NN) computing processor, which can quickly process input information by drawing on the structure of biological neural networks, such as the transmission mode between human brain neurons, and can also constantly self-learn. Through the NPU, the electronic device can realize intelligent cognition and other applications, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0062] The processor 210 can further include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. The memory can hold instructions or data that the processor 210 has just used or is using repeatedly. If the processor 210 needs to use the instructions or data again, it can be directly called from the memory. This avoids repeated access and reduces the waiting time of the processor 210, thereby improving the efficiency of the system.

[0063] In some embodiments, the processor 210 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0064] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 210 to the display 230, the camera 220, the wireless communication module 260, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, an MIPI interface, etc.

[0065] It can be understood that the interface connection relationship between the modules illustrated in the embodiments is only illustrative and does not constitute a structural limitation of the electronic device 200. In other embodiments of the present application, the electronic device 200 can also use different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0066] The external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 210 through the external memory interface 220 to realize data storage functions. For example, music, video, and other files can be saved in the external memory card.

[0067] The internal memory 221 can be used to store computer executable program codes, which include instructions. The processor 210 performs various functional applications and data processing of the electronic device 200 by executing the instructions stored in the internal memory 221. The internal memory 221 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program (e.g., a sound play function, an image play function, etc.) required for a function, etc. The data storage area can store data (e.g., audio data, a phone book, etc.) created during the use of the electronic device, etc. In addition, the internal memory 221 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one of a magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 210 performs various functional applications and data processing of the electronic device by executing the instructions stored in the internal memory 221 and / or the instructions stored in the memory disposed in the processor.

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

[0069] The display screen 230 is used to display images, videos, etc. The display screen 230 includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oled, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device can include 1 or N display screens 230, N being a positive integer greater than 1.

[0070] A series of graphical user interfaces (GUIs) can be displayed on the display screen 230 of the electronic device, and these GUIs are all home screens of the electronic device. Generally, the size of the display screen 230 of the electronic device is fixed, and only limited controls can be displayed in the display screen 230 of the electronic device. A control is a GUI element, which is a software component included in an application program, controls all data processed by the application program and interaction operations related to the data, and a user can interact with the control through direct manipulation to read or edit relevant information of the application program. Generally, a control can include an icon, a button, a menu, a tab, a text box, a dialog box, a status bar, a navigation bar, a Widget, and the like visual interface elements. For example, in the embodiments of the present application, the display screen 230 can display virtual keys (one-key arrangement, start arrangement, scene arrangement).

[0071] The electronic device can implement a photographing function through an ISP, a camera, a video codec, a GPU, a display screen 230, and an application processor.

[0072] The ISP is used to process data fed back by the camera 220. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be disposed in the camera 220.

[0073] The wireless communication function of the electronic device can be implemented through an antenna 1, an antenna 2, a mobile communication module 240, a wireless communication module 250, a modem processor, and a baseband processor.

[0074] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0075] The mobile communication module 240 can provide a solution for wireless communication including 2G / 3G / 2G / 5G, etc. applied to the electronic device. The mobile communication module 240 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 240 can receive an electromagnetic wave by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic wave, and transfer the processed electromagnetic wave to the modem processor to be demodulated. The mobile communication module 240 can also amplify a signal modulated by the modem processor, and radiate the amplified signal as an electromagnetic wave through the antenna 1. In some embodiments, at least part of the function modules of the mobile communication module 240 can be disposed in the processor 210. In some embodiments, at least part of the function modules of the mobile communication module 240 can be disposed in the same device as at least part of the modules of the processor 210.

[0076] The wireless communication module 250 can provide a solution for wireless communication including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. applied to the electronic device. The wireless communication module 250 can be one or more devices integrated with at least one communication processing module. The wireless communication module 250 receives an electromagnetic wave via the antenna 2, performs frequency modulation and filtering on the electromagnetic wave signal, and transmits the processed signal to the processor 210. The wireless communication module 250 can also receive a signal to be transmitted from the processor 210, perform frequency modulation and amplification on the signal, and radiate the processed signal as an electromagnetic wave through the antenna 2.

[0077] In some embodiments, the WiFi module in the wireless communication module 250 is used to provide network access for the electronic device 200 in compliance with the Wi-Fi related standard protocol. The electronic device 200 can access a Wi-Fi access point through the WiFi module, and then access the Internet. The WiFi module can also serve as a Wi-Fi wireless access point, and can provide Wi-Fi network access for other devices. The Bluetooth module in the wireless communication module 250 is used to realize short-distance communication between the electronic device 200 and other devices.

[0078] The WiFi module can be an integrated circuit or a Wi-Fi chip, and the Bluetooth module can be an integrated circuit or a Bluetooth chip. The WiFi module and the Bluetooth module can be separate chips or integrated circuits, or can be integrated together. For example, in one embodiment, the WiFi module and the Bluetooth module can be integrated into the same chip. In another embodiment, the WiFi module, the Bluetooth module, and the processor can also be integrated into the same chip.

[0079] In addition, an operating system runs on the above components. For example, a HongMeng system, an iOS operating system, an Android operating system, a Windows operating system, etc. Application programs can be installed and run on the operating system.

[0080] Figure 2b is a software structure block diagram of an electronic device of an embodiment of the present application.

[0081] The layered architecture divides the software into several layers, each of which has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and the system library, and the kernel layer.

[0082] The application layer can include a series of application packages. As shown in Figure 2b The application packages can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, screen projection, multi-screen collaboration, and file sharing applications.

[0083] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications of the application layer. The application framework layer includes some pre-defined functions. As shown in Figure 2b The application framework layer can include window manager, content provider, phone manager, resource manager, notification manager, view system, etc. In some embodiments of the present application, the application framework layer can also include a perception service.

[0084] The window manager is used to manage the window program. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, and take a screenshot.

[0085] The content provider is used to store and obtain data, and makes the data accessible to the application. The data can include video, image, audio, dialed and received calls, browsing history and bookmarks, phonebook, etc.

[0086] The telephony manager is used to provide the communication function of the electronic device. For example, the management of the call status (including call connection, call hang-up, etc.).

[0087] The resource manager provides various resources for the application program, such as localized strings, icons, pictures, layout files, video files, etc.

[0088] The notification manager enables the application program to display notification information in the status bar, which can be used to convey the notification type of message, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the download completion, message reminder, etc. The notification manager can also be a notification in the form of a chart or a scroll bar text appearing in the top status bar of the system, such as the notification of the application program running in the background, and can also be a notification in the form of a dialogue window appearing on the screen. For example, the display interface prompts the text information in the status bar, issues a prompt sound, the electronic device vibrates, the indicator light flashes, etc.

[0089] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the application program. The display interface can be composed of one or more views. For example, the display interface including the SMS notification icon can include a view for displaying text and a view for displaying pictures.

[0090] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for the scheduling and management of the Android system. In some embodiments of the present application, the application cold start is run in the Android runtime, and the Android runtime obtains the optimization file state parameter of the application from this, and then the Android runtime can determine whether the optimization file is outdated due to system upgrade through the optimization file state parameter, and return the determination result to the application management and control module.

[0091] In some embodiments, in the Android runtime, the Android framework is responsible for providing an interface to the application program to query and use the capability of the WiFi module. The application program calls the interface of the framework to query the channel switching capability, and the framework calls the interface of the WiFi driver to query the channel switching capability.

[0092] The core library includes two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.

[0093] The application program layer and the application program framework layer run in the virtual machine. The virtual machine executes the java file of the application program layer and the application program framework layer into a binary file. The virtual machine is used to perform the management of the object life cycle, the management of the stack, the management of the thread, the management of the security and exception, and the garbage collection, etc.

[0094] The system library can include a plurality of functional modules. For example, a surface manager, media libraries, a three-dimensional graphics processing library (e.g., OpenGL ES), a two-dimensional graphics engine (e.g., SGL), and the like.

[0095] The surface manager is used to manage a display subsystem and provides fusion of 2D and 3D layers for a plurality of application programs.

[0096] The media libraries support playback and recording of a plurality of commonly used audio, video formats, and static image files. The media libraries can support a plurality of audio and video encoding formats, such as MPEG2, H.262, MP3, AAC, AMR, JPG, PNG, and the like.

[0097] The three-dimensional graphics processing library is used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, and the like.

[0098] The two-dimensional graphics engine is a drawing engine for 2D drawing.

[0099] The kernel layer is a layer between hardware and software. The kernel layer at least includes display drivers, camera drivers, audio drivers, sensor drivers, and WiFi drivers, and the like. The WiFi driver is used to drive a WiFi module and establish a WiFi connection.

[0100] It should be noted that although the embodiments of the present application are described by taking the Android system as an example, the basic principles are also applicable to electronic devices based on the Harmony, iOS, Windows, and the like operating systems.

[0101] First of all, it should be noted that the electronic device is pre-configured with a WiFi module same-frequency different-channel switching capability value for representing the channel switching capability of the electronic device. In some embodiments, the WiFi module same-frequency different-channel switching capability value is a numerical value, such as a percentage value, a decimal value, or a one-tenth value, and the larger the value, the stronger the channel switching capability of the electronic device. In one example, the WiFi module same-frequency different-channel switching capability value is a percentage value, wherein one hundred percent is a full score, indicating that the WiFi module same-frequency different-channel switching capability of the electronic device is the strongest, and zero is the lowest score, indicating that the WiFi module same-frequency different-channel switching capability of the electronic device is the weakest.

[0102] Table 1 below lists examples of the same-frequency different-channel switching capability values of several WiFi modules. In Table 1, the shorter the working time of the electronic device in the P2P channel and the STA channel, the shorter the switching time of the electronic device in switching between the P2P channel and the STA channel, and the stronger the same-frequency different-channel switching capability of the electronic device, and the larger the same-frequency different-channel switching capability value.

[0103] Table 1

[0104] P2P channel operating duration STA channel operating duration Switching time Intra-frequency inter-channel switching capability value 150 ms 150 ms 20 ms 40 100 ms 100 ms 15 ms 50 60 ms 60 ms 12 ms 60 30 ms 30 ms 7 ms 70 15 ms 15 ms 5 ms 80 10 ms 10 ms 3 ms 90

[0105] It should be further noted that the interval between the same-frequency different-channel switching capability values in Table 1 is an example and does not constitute a limitation on the interval between the same-frequency different-channel switching capability values of different electronic devices.

[0106] In some other embodiments, the WiFi module same-frequency different-channel switching capability value includes three values, i.e., the P2P channel working time, the STA channel working time and the switching time consumption of the electronic device.

[0107] The WiFi module same-frequency different-channel switching capability value can be stored in the permanent storage space of the electronic device. In some embodiments, the WiFi module same-frequency different-channel switching capability value is stored in the Settings.Global database of the electronic device. In some other embodiments, the WiFi module same-frequency different-channel switching capability value is stored in the read-only prop item added by the WiFi module.

[0108] The WiFi module same-frequency different-channel switching capability value can be determined according to the test results of the WiFi module used by the electronic device. Specifically, for an electronic device, a same-frequency different-channel scenario is constructed, i.e., the network connection and the P2P connection of the electronic device, and different channels in the same frequency band are used. Referring to Figure 3 , the first device is connected to the router 1 using the 60 channel of the 5G frequency band and is connected to the second device using the 157 channel of the 5G frequency band.

[0109] The test device 1 captures the air interface log (sniffer log) on the 157 channel of the 5G frequency band, and at the same time, the test device 2 captures the air interface log (sniffer log) on the 60 channel of the 5G frequency band. Using the air interface logs captured by the test device 1 and the test device 2, the packet sending time of the first device on the two channels is calculated to obtain the working time of each channel, and the time interval during which the first device does not send packets on the two channels is analyzed, and the time interval is taken as the switching time consumption.

[0110] It should be further noted that if the WiFi module same-frequency different-channel switching capability value is represented by a numerical value, after the P2P channel working time, the STA channel working time and the switching time consumption of the first device are calculated, the WiFi module same-frequency different-channel switching capability value is calculated according to the numerical values of the P2P channel working time, the STA channel working time and the switching time consumption. Generally, the larger the three values of the P2P channel working time, the STA channel working time and the switching time consumption, the smaller the WiFi module same-frequency different-channel switching capability value.

[0111] In some embodiments, if the inter-frequency and inter-channel switching capability value is a percentage value, the following formula can be used for calculation.

[0112] Inter-frequency and inter-channel switching capability value = (10 ÷ P2P channel working time) × 30 + (10 ÷ STA channel working time) × 30 + (2 ÷ switching time) × 40.

[0113] Embodiment One

[0114] In this embodiment, the first device and the second device are connected with a router of inter-frequency and inter-channel, and the first device and the second device want to establish a P2P connection. The hardware architecture and the software architecture of the first device and the second device can be as shown in Figure 2a and Figure 2b The common application scenarios of the first device and the second device establishing a WiFi P2P connection include: multi-screen cooperation, mirror projection and file sharing. Multi-screen cooperation refers to: after one end device initiates multi-screen cooperation, it will scan the nearby devices that can be cooperated through BLE / WIFI P2P, and establish a P2P connection to realize double system same screen display. Mirror projection refers to: one end device initiates projection, scans a large screen device, and establishes a P2P connection to share the screen. File sharing refers to: one end device selects a file, and in the sharing, it can be selected to share to the opposite end device through P2P.

[0115] Referring to Figure 4a , this embodiment takes a mobile phone as an example for the first device, and takes a PC as an example for the second device.

[0116] In the application scenario of multi-screen cooperation, referring to Figure 4b , after the mobile phone opens the NFC function, it touches the specific label of the PC with the NFC area on the back of the mobile phone, the display screen of the mobile phone presents the PC to be connected, and the user manually determines the connection, so that the mobile phone and the PC establish a P2P connection. Of course, the triggering mode of the mobile phone and the PC for multi-screen cooperation is not limited to Figure 4b the mode shown, but the mobile phone can also be placed on the keyboard of the PC to trigger through Bluetooth discovery, or the multi-screen cooperation button on the PC can be clicked to trigger.

[0117] In the application scenario of mirror projection, referring to Figure 4c , after the mobile phone projection of the mobile phone is opened, the mobile phone can search for projection devices, and present the searched projection devices in the available device list, such as Figure 4c the PC shown. After the user clicks “PC”, the mobile phone is triggered to establish a P2P connection with the PC.

[0118] In the application scenario of file sharing, referring to Figure 4d, the honor sharing of the mobile phone is opened, the user clicks the opposite device "PC" found by the "honor sharing" for the file to be shared, such as the image 1 shown in the figure, the mobile phone and the PC establish a P2P connection, and the image 1 is sent to the PC through the honor sharing.

[0119] It can be understood that in the three application scenarios mentioned above, the initial step of establishing a P2P connection between the mobile phone and the PC is device discovery. The mobile phone and the PC can complete device discovery by one end sending a request frame and the other end receiving the request frame and returning a response frame.

[0120] In the multi-screen collaboration application scenario, the NFC function of the mobile phone is opened, the NFC area on the back of the mobile phone touches the specific label of the PC, the mobile phone sends a request frame, the PC receives the request frame sent by the mobile phone, and returns a response frame to the mobile phone, so that the mutual discovery of the mobile phone and the PC is completed. In some embodiments, the request frame and the response frame can carry indication information for indicating that a P2P connection is to be established to complete multi-screen collaboration and the like.

[0121] In the mirror projection application scenario, the mobile phone projection of the mobile phone is opened, the mobile phone sends a request frame, the PC receives the request frame sent by the mobile phone, and returns a response frame to the mobile phone, so that the mutual discovery of the mobile phone and the PC is completed. In some embodiments, the request frame and the response frame can carry indication information for indicating that a P2P connection is to be established to complete mirror projection and the like.

[0122] In the file sharing application scenario, after the honor sharing of the mobile phone is opened, the user clicks the "honor sharing", the mobile phone sends a request frame, the PC receives the request frame sent by the mobile phone, and returns a response frame to the mobile phone, so that the mutual discovery of the mobile phone and the PC is completed. In some embodiments, the request frame and the response frame can carry indication information for indicating that a P2P connection is to be established to complete file sharing and the like.

[0123] Based on the foregoing, the embodiments of the present application provide a WiFi P2P connection method, referring to Figure 4e , comprising:

[0124] S401, the first device acquires the WiFi module same frequency different channel switching capability value.

[0125] In this embodiment, after the first device is triggered to establish a P2P connection with the second device, the first device first executes step S401 to acquire the WiFi module same frequency different channel switching capability value stored by itself.

[0126] In some embodiments, after the first device and the second device complete device discovery, the first device can execute step S401 to acquire the WiFi module same frequency different channel switching capability value stored by itself. The following is described by taking the first device sending a request frame when performing device discovery and the second device sending a response frame as an example.

[0127] Specifically, the first device sends a request frame, and receives a response frame returned by the second device, the first device discovers the second device, and the first device can perform step S401 to obtain the WiFi module same-frequency different-channel switching capability value stored by the first device. As described above, the first device can obtain the WiFi module same-frequency different-channel switching capability value from the permanent storage space of the first device, such as the Settings.Global database of the first device or the read-only prop item newly added by the WiFi module.

[0128] It should be noted that the first device obtains the WiFi module same-frequency different-channel switching capability value through Figure 2b The multi-layer software architecture shown in the embodiment is used to obtain the WiFi module same-frequency different-channel switching capability value in the following manner:

[0129] Referring to Figure 2b When the application program of the first device, such as the application program of screen projection, multi-screen collaboration or file sharing, is triggered by the user, the interface of the framework of the Android runtime is called by the application program triggered by the user to query the WiFi module same-frequency different-channel switching capability value, the framework calls the interface of the WiFi driver, and the WiFi module same-frequency different-channel switching capability value is obtained. The WiFi driver obtains the WiFi module same-frequency different-channel switching capability value pre-stored by the electronic device, and uploads the WiFi module same-frequency different-channel switching capability value to the application program triggered by the user through the framework.

[0130] S402, the second device obtains the WiFi module same-frequency different-channel switching capability value.

[0131] Similarly, after the second device is triggered to establish a P2P connection with the first device, the second device also performs step S402 to obtain the WiFi module same-frequency different-channel switching capability value stored by the second device.

[0132] In some embodiments, after the device discovery is completed by the first device and the second device, the second device can perform step S402 to obtain the WiFi module same-frequency different-channel switching capability value stored by the second device.

[0133] Specifically, the second device receives the request frame sent by the first device, the second device discovers the first device, and the second device can perform step S402 to obtain the WiFi module same-frequency different-channel switching capability value of the second device. Of course, the second device can also perform step S402 after sending the response frame to the first device.

[0134] The second device obtains the WiFi module same-frequency different-channel switching capability value through the multi-layer software architecture in the manner as described above in step S401, and details are not repeated here.

[0135] S403, the first device and the second device establish a Bluetooth connection.

[0136] In this embodiment, the first device and the second device can adopt a conventional Bluetooth protocol to establish a Bluetooth connection. The specific implementation process of the first device and the second device to establish the Bluetooth connection is not described in this embodiment.

[0137] It should be further noted that the step S403 is not limited in the execution order with the step S401 and the step S402, Figure 4e It is shown that the first device and the second device perform the step S401 and the step S402 respectively, and then perform the step S403. It is known that the first device and the second device can also perform the step S403 first, and then perform the step S401 and the step S402 respectively.

[0138] S404, the first device sends the capability information of the first device and the STA channel of the first device to the second device by using the Bluetooth connection channel, and the capability information of the first device includes the WiFi module same frequency different channel switching capability value of the first device.

[0139] S405, the second device sends the capability information of the second device and the STA channel of the second device to the first device by using the Bluetooth connection channel, and the capability information of the second device includes the WiFi module same frequency different channel switching capability value of the second device.

[0140] After the step S404 and the step S405, the first device and the second device have exchanged the capability information and the STA channel of the opposite device, and the first device and the second device have the capability information and the STA channel of the opposite device.

[0141] In some embodiments, only one of the first device and the second device has the capability information and the STA channel of the opposite device. Based on this, one of the step S404 and the step S405 can not be executed.

[0142] It should be noted that the first device and the second device have the capability information and the STA channel of the opposite device, so as to determine the channel used by the first device and the second device to establish the P2P connection according to the capability information of the first device and the second device. Therefore, the device of the first device and the second device which performs the determination of the channel used by the P2P connection can receive the capability information and the STA channel of the opposite device sent by the opposite device by using the Bluetooth connection channel.

[0143] Generally, the step of determining the adopted channel of the P2P connection can be performed by the GO in the first device and the second device, based on which, the GO can not send its capability information and the channel of the in-network STA to the GC. The following is described by taking the first device as the GO as an example.

[0144] The first device and the second device can determine the GO and the GC through negotiation or pre-setting. When the first device and the second device establish the P2P connection to complete different P2P services, the GO determined by the first device and the second device is different.

[0145] In the application scenario of multi-screen cooperation, the PC or the PAD is generally used as the GO. In the application scenario of mirror projection, the large-screen device is generally used as the GO. In the application scenario of file sharing, the sending end is generally used as the GO.

[0146] In S406, the first device determines the device with weak switching capability in the first device and the second device by using the WiFi module same-frequency different-channel switching capability value of the first device and the WiFi module same-frequency different-channel switching capability value of the second device, and takes the STA channel of the determined device as the channel for establishing the P2P connection.

[0147] In the application scenario of multi-screen cooperation, the PC or the PAD is generally used as the GO. In the application scenario of mirror projection, the large-screen device is generally used as the GO. In the application scenario of file sharing, the sending end is generally used as the GO.

[0148] In one possible implementation, the WiFi module same-frequency different-channel switching capability value of the first device and the WiFi module same-frequency different-channel switching capability value of the second device are numerical values. When the first device performs this step to select the P2P connection channel, the first device compares the WiFi module same-frequency different-channel switching capability value of the first device and the WiFi module same-frequency different-channel switching capability value of the second device, determines the device with the smaller numerical value, and takes the STA channel of the device with the smaller numerical value as the channel for establishing the P2P connection between the first device and the second device.

[0149] In another possible implementation, the WiFi module same-frequency different-channel switching capability value of the first device includes the P2P channel working duration, the STA channel working duration and the switching time consumption of the first device, and the WiFi module same-frequency different-channel switching capability value of the second device includes the P2P channel working duration, the STA channel working duration and the switching time consumption of the second device. The first device performs corresponding comparison on the three numerical values contained in the WiFi module same-frequency different-channel switching capability value of the first device and the three numerical values contained in the WiFi module same-frequency different-channel switching capability value of the second device.

[0150] Specifically, the first device compares the P2P channel working time of the first device with the P2P channel working time of the second device, compares the STA channel working time of the first device with the STA channel working time of the second device, compares the switching time of the first device with the switching time of the second device, and obtains three comparison results.

[0151] According to the three comparison results, the first device selects the STA channel of the device with weak switching capability as the channel for establishing the P2P connection between the first device and the second device. It is known that the greater the P2P channel working time, the STA channel working time and the switching time of the two devices are, the weaker the switching capability of the device is. If one of the two devices has a large value in the P2P channel working time, the STA channel working time or the switching time, it means that the switching capability of the device is weak, and the comparison result indicates that the device wins. Therefore, the first device selects the device that wins in the three comparison results as the device with weak switching capability.

[0152] It should be noted that the STA channel of the device with weak switching capability is used as the channel for establishing the P2P connection between the first device and the second device, which means that the device with weak switching capability does not need to switch the channel when running the WiFi STA mode and the WiFi P2P mode, and the device with strong switching capability switches the STA channel and the P2P channel, so as to ensure that the WiFi P2P connection performance of the first device and the second device is optimal, and avoid problems such as slow file transfer rate, operation lag, serious video frame loss and large delay.

[0153] S407, the first device sends a notification message to the second device to notify the second device to establish the P2P connection in the selected channel.

[0154] In some embodiments, the notification message sent by the first device to the second device can carry the channel selected by the first device for establishing the P2P connection.

[0155] S408, the first device and the second device establish the P2P connection in the selected channel for establishing the P2P connection.

[0156] The first device and the second device can use a conventional method for establishing the P2P connection to establish the P2P connection in the selected channel for establishing the P2P connection, which will not be described here.

[0157] It should be further noted that before the first device and the second device establish the P2P connection in the selected channel for establishing the P2P connection, it is necessary to determine that the selected channel for establishing the P2P connection belongs to the channels supported by the first device and the second device.

[0158] Based on this, the first device acquires the channel supported by itself and the channel supported by the second device. In some embodiments, the capability information of the second device sent by the second device to the first device can also include the channel supported by the second device. The first device acquires the channel supported by the second device from the capability information of the second device.

[0159] It should also be noted that the capability information of the first device sent by the first device to the second device can also include the channel supported by the first device. The second device can also acquire the channel supported by the first device from the capability information of the first device.

[0160] The first device performs step S406 to obtain the STA channel of the device with weak switching capability among the first device and the second device, compares the STA channel with the channel supported by the device with strong switching capability among the first device and the second device, judges whether the STA channel is the channel supported by the device with strong switching capability among the first device and the second device, and performs the aforementioned step S407 if it is judged that the STA channel is the channel supported by the device with strong switching capability among the first device and the second device.

[0161] If it is judged that the STA channel is not the channel supported by the device with strong switching capability among the first device and the second device, it is judged whether the STA channel of the device with strong switching capability among the first device and the second device is the channel supported by the device with weak switching capability among the first device and the second device. If it is judged that the STA channel of the device with strong switching capability among the first device and the second device is the channel supported by the device with weak switching capability among the first device and the second device, the STA channel of the device with strong switching capability among the first device and the second device is taken as the channel for establishing P2P connection of the first device and the second device, and the aforementioned step S407 is performed.

[0162] If it is judged that the STA channel of the device with strong switching capability among the first device and the second device is not the channel supported by the device with weak switching capability among the first device and the second device, the first device selects a channel supported by both the first device and the second device from the channel supported by the first device and the channel supported by the second device as the channel for establishing P2P connection and performs the aforementioned step S407.

[0163] It should also be noted that the first device and the second device establish P2P connection by using the channel selected in step S406. If it is found that the establishment of P2P connection fails in the process of establishing P2P connection, it indicates that one of the first device and the second device does not support the channel, and then the first device and the second device need to reestablish P2P connection by using other channels.

[0164] In some embodiments, the first device judges whether the P2P connection between the first device and the second device is successful or not. If the first device judges that the P2P connection is not successful, the first device uses the STA channel of the device with stronger switching capability as the channel for establishing the P2P connection, and re-establishes the P2P connection.

[0165] If the P2P connection between the first device and the second device is not successful even if the STA channel of the device with stronger switching capability is used, the first device selects a channel supported by both the first device and the second device from the channels supported by the first device and the channels supported by the second device as the channel for establishing the P2P connection.

[0166] In some embodiments, the capability information of the first device in step S404 can further include the channels supported by the first device, and the capability information of the second device in step S405 can also include the channels supported by the second device. The first device selects a channel supported by both the first device and the second device from the channels supported by the first device and the channels supported by the second device as the channel for establishing the P2P connection.

[0167] It should be further noted that in some embodiments, the first device can judge whether the P2P connection between the first device and the second device is successful or not by sending a request to the second device and receiving a response returned by the second device.

[0168] If the first device sends a request to the second device and receives a response returned by the second device within a specified time period, the first device judges that the P2P connection between the first device and the second device is successful, otherwise, the first device judges that the P2P connection between the first device and the second device is not successful.

[0169] Embodiment Two

[0170] Another embodiment of the present application further provides a WiFi P2P connection method, referring to Figure 5 , comprising:

[0171] S501, the first device and the second device establish a P2P connection by using a common channel.

[0172] In some embodiments, after the first device and the second device complete device discovery, the first device and the second device can execute step S501 to establish a P2P connection by using a common channel. The present embodiment is also described by taking the example that the first device sends a request frame when performing device discovery and the second device sends a response frame.

[0173] Specifically, the first device sends a request frame, the second device receives the request frame and returns a response frame to the first device, the first device receives the response frame returned by the second device, and the first device and the second device can execute step S501 to establish a P2P connection by using a common channel.

[0174] It should be noted that the public channel belongs to the channel that the electronic devices all support to establish the P2P connection, and in general, the public channel in the 2.4G frequency band is selected, such as channel 1, channel 6 and channel 11 in the 2.4G frequency band. The first device and the second device first establish the P2P connection by using the public channel, so that the first device and the second device can successfully establish the P2P connection, and the first device and the second device can exchange information by using the P2P connection channel.

[0175] In addition, the P2P connection between the first device and the second device established in this step can be understood as a temporary connection.

[0176] S502, the first device acquires the WiFi module same-frequency different-channel switching capability value.

[0177] S503, the second device acquires the WiFi module same-frequency different-channel switching capability value.

[0178] In this embodiment, the content of steps S502 and S503 can refer to the content of steps S401 and S402 of the aforementioned embodiment one, and will not be described here again.

[0179] It should be further noted that steps S502 and S503 can not be limited to Figure 5 The execution position shown can also be that after the first device and the second device complete the device discovery, steps S502 and S503 are first executed, and then step S501 is executed. Of course, after the first device and the second device complete the device discovery, the first device and the second device can also execute steps S501, S502 and S503 in parallel.

[0180] S504, the first device sends the capability information of the first device and the STA channel of the first device to the second device by using the P2P connection channel, and the capability information of the first device includes the WiFi module same-frequency different-channel switching capability value of the first device.

[0181] S505, the second device sends the capability information of the second device and the STA channel of the second device to the first device by using the P2P connection channel, and the capability information of the second device includes the WiFi module same-frequency different-channel switching capability value of the second device.

[0182] In this embodiment, the first device and the second device establish the P2P connection by executing step S501, so that the first device and the second device can exchange the capability information and the STA channel of themselves by using the established P2P connection channel.

[0183] The same as the first preceding embodiment, one of the steps S504 and S505 can not be performed. In some embodiments, only the device that determines the channel for establishing the formal P2P connection between the first device and the second device by using the WiFi module inter-frequency inter-channel switching capability value of the first device and the WiFi module inter-frequency inter-channel switching capability value of the second device can receive the capability information of the opposite device and the network access STA channel of the opposite device sent by the opposite device.

[0184] S506, the first device determines the device with weak switching capability in the first device and the second device by using the WiFi module inter-frequency inter-channel switching capability value of the first device and the WiFi module inter-frequency inter-channel switching capability value of the second device, and takes the STA channel of the determined device as the channel for establishing the P2P connection.

[0185] In the embodiment, the specific implementation process of the step S506 can refer to the content of the step S406 in the first preceding embodiment, which will not be described here again.

[0186] S507, the first device sends a notification message to the second device to notify the second device to disconnect the P2P connection between the first device and the second device, and to establish the P2P connection in the selected channel for establishing the P2P connection.

[0187] In some embodiments, the notification message sent by the first device to the second device can carry the channel for establishing the P2P connection selected by the first device.

[0188] S508, the first device and the second device establish the P2P connection in the selected P2P connection channel.

[0189] The first device and the second device disconnect the temporary P2P connection established in the step S501, and reconnect the P2P connection in the selected P2P connection channel.

[0190] It should be further noted that before the first device and the second device establish the P2P connection in the selected channel for establishing the P2P connection, it is necessary to determine that the selected channel for establishing the P2P connection belongs to the channels supported by the first device and the second device.

[0191] Based on this, the first device acquires the channels supported by itself and the channels supported by the second device. In some embodiments, the capability information of the second device sent by the second device to the first device can further include the channels supported by the second device. The first device acquires the channels supported by the second device from the capability information of the second device.

[0192] It should be further noted that the capability information of the first device sent by the first device to the second device can also include the channels supported by the first device. The second device can also acquire the channels supported by the first device from the capability information of the first device.

[0193] The first device performs step S406 to obtain the STA channel of the device with weak switching capability among the first device and the second device, compares the STA channel with the channel supported by the device with strong switching capability among the first device and the second device, judges whether the STA channel is the channel supported by the device with strong switching capability among the first device and the second device, and if it is judged that the STA channel is the channel supported by the device with strong switching capability among the first device and the second device, performs the aforementioned step S407.

[0194] If it is judged that the STA channel is not the channel supported by the device with strong switching capability among the first device and the second device, the STA channel of the device with strong switching capability among the first device and the second device is judged whether it is the channel supported by the device with weak switching capability among the first device and the second device. If it is judged that the STA channel of the device with strong switching capability among the first device and the second device is the channel supported by the device with weak switching capability among the first device and the second device, the STA channel of the device with strong switching capability among the first device and the second device is taken as the channel for establishing the P2P connection of the first device and the second device, and the aforementioned step S407 is performed.

[0195] If it is judged that the STA channel of the device with strong switching capability among the first device and the second device is not the channel supported by the device with weak switching capability among the first device and the second device, the first device selects a channel supported by both the first device and the second device from the channels supported by the first device and the channels supported by the second device as the channel for establishing the P2P connection, and performs the aforementioned step S407.

[0196] It should be further noted that the first device and the second device establish the P2P connection by using the channel for establishing the P2P connection selected in step S406. If it is found that the P2P connection fails to be established during the process of establishing the P2P connection, it indicates that one of the first device and the second device does not support the channel, and then the first device and the second device need to reestablish the P2P connection by using other channels.

[0197] In some embodiments, the first device judges whether the P2P connection is successfully established by using the channel for establishing the P2P connection selected by the first device and the second device. If the first device judges that the P2P connection fails, the first device takes the STA channel of the device with strong switching capability among the first device and the second device as the channel for establishing the P2P connection, and reestablishes the P2P connection.

[0198] If the P2P connection is not successfully established by using the STA channel of the device with strong switching capability among the first device and the second device, the first device selects a channel supported by both the first device and the second device from the channels supported by the first device and the channels supported by the second device as the channel for establishing the P2P connection.

[0199] In some embodiments, the capability information of the first device in step S504 can further include channels supported by the first device, and the capability information of the second device in step S505 can further include channels supported by the second device. The first device filters out channels supported by both the first device and the second device from the channels supported by the first device and the channels supported by the second device, and takes the channels as channels for establishing the P2P connection.

[0200] It should be further noted that in some embodiments, the first device can determine whether the P2P connection between the first device and the second device is successful by sending a request to the second device and receiving a response returned by the second device.

[0201] If the first device sends a request to the second device and receives a response returned by the second device within a specified time period, the first device determines that the P2P connection between the first device and the second device is successful, otherwise, the first device determines that the P2P connection between the first device and the second device fails.

[0202] Another embodiment of the present application further provides a computer readable storage medium, which stores instructions, and when the instructions are run on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

[0203] Another embodiment of the present application further provides a computer program product containing instructions, and when the computer program product is run on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

Claims

1. A WiFi P2P connection method, characterized in that, The WiFi P2P connection method is applied to a first device and a second device, and the first device and the second device are connected to a network in a same frequency and different channels. The first device receives an operation of triggering the first device to establish a WiFi P2P connection with the second device. The first device acquires a first WiFi module same frequency and different channel switching capability value of the first device in response to the operation, and establishes a Bluetooth connection channel with the second device or a P2P connection channel with the second device by using a public channel. The first device receives a second WiFi module same frequency and different channel switching capability value of the second device and a station STA channel of the second device connected to the network through the Bluetooth connection channel or the P2P connection channel established with the first device. The first device determines a device with weak switching capability from the first device and the second device according to the first WiFi module same frequency and different channel switching capability value and the second WiFi module same frequency and different channel switching capability value. If the second device has weak switching capability, the first device establishes a WiFi P2P connection with the second device according to the station STA channel of the second device connected to the network. 2.The WiFi P2P connection method of claim 1, wherein, The first device determines a device with weak switching capability from the first device and the second device according to the first WiFi module same frequency and different channel switching capability value and the second WiFi module same frequency and different channel switching capability value, including: The first device respectively compares a P2P channel working time length of the first device and a P2P channel working time length of the second device, a STA channel working time length of the first device and a STA channel working time length of the second device, and a switching time length of the first device and a switching time length of the second device, to obtain three comparison results. The first device determines a device with weak switching capability from the first device and the second device according to the three comparison results. 3.The WiFi P2P connection method of claim 1, wherein, The first device determines a device with weak switching capability from the first device and the second device according to the first WiFi module same frequency and different channel switching capability value and the second WiFi module same frequency and different channel switching capability value, including: The first device compares the first value and the second value to determine a device with smaller value as the device with weak switching capability. 4.The WiFi P2P connection method of any one of claims 1 to 3, wherein, Before the first device establishes the WiFi P2P connection with the second device according to the station STA channel of the second device connected to the network, the method further includes: The first device determines a station (STA) channel in which the second device is connected to a network, which is a channel supported by the first device.

5. The WiFi P2P connection method of claim 4, wherein, Further comprising: The first device determines a station (STA) channel in which the second device is connected to a network, which is not a channel supported by the first device, and then the first device establishes a WiFi P2P connection between the first device and the second device by using a station (STA) channel in which the first device is connected to a network. 6.The WiFi P2P connection method of claim 5, wherein, Before the first device establishes a WiFi P2P connection between the first device and the second device by using a station (STA) channel in which the first device is connected to a network, further comprising: The first device determines a station (STA) channel in which the first device is connected to a network, which is a channel supported by the second device. 7.The WiFi P2P connection method of claim 6, wherein, Further comprising: The first device determines a station (STA) channel in which the first device is connected to a network, which is not a channel supported by the second device, and then the first device establishes a WiFi P2P connection between the first device and the second device by using a channel supported by both the first device and the second device. 8.The WiFi P2P connection method of any one of claims 1-3, wherein, After the first device establishes a WiFi P2P connection between the first device and the second device according to a station (STA) channel in which the second device is connected to a network, further comprising: The first device determines that the WiFi P2P connection between the first device and the second device is not successfully established, and then the first device establishes a WiFi P2P connection between the first device and the second device by using a station (STA) channel in which the first device is connected to a network. 9.The WiFi P2P connection method of claim 8, wherein, After the first device establishes a WiFi P2P connection between the first device and the second device by using a station (STA) channel in which the first device is connected to a network, further comprising: The first device determines that the WiFi P2P connection between the first device and the second device is not successfully established, and then the first device establishes a WiFi P2P connection between the first device and the second device by using a channel supported by both the first device and the second device. 10.The WiFi P2P connection method according to any one of claims 1 to 3, characterized in that, The method for calculating the same-frequency and different-channel switching capability value of the first WiFi module of the first device comprises: Parses the air interface log of the P2P test channel of the first device to obtain the working duration of the first device in the P2P test channel; Parses the air interface log of the STA test channel of the first device to obtain the working duration of the first device in the STA test channel; Parses the air interface log of the P2P test channel of the first device and the air interface log of the STA test channel of the first device to determine the time interval during which the first device has no packet in both the STA test channel and the P2P test channel, and takes the time interval as the switching time consumption of the first device. 11.The WiFi P2P connection method of claim 10, wherein, Further comprising: The first device determines a station (STA) channel in which the second device is connected to a network, which is a channel supported by the first device.

12. The WiFi P2P connection method according to any one of claims 1 to 3, characterized in that, The method for calculating the same-frequency and different-channel switching capability value of the second WiFi module of the second device comprises: Parses the air interface log of the P2P test channel of the second device to obtain the working duration of the second device in the P2P test channel; parsing the air interface log of the STA test channel of the second device to obtain the working duration of the second device on the STA test channel; parsing the air interface log of the P2P test channel of the second device and the air interface log of the STA test channel of the second device to determine the time interval during which the second device has no packet transmission on both the STA test channel and the P2P test channel, and taking the time interval as the switching time consumption of the second device.

13. The WiFi P2P connection method of claim 12, wherein, Further comprising: calculating the second WiFi module inter-frequency and inter-channel switching capability value of the second device based on the working duration of the P2P test channel of the second device, the working duration of the STA test channel, and the switching time consumption.

14. An electronic device, comprising: The electronic device comprises a first device, and the electronic device comprises: one or more processors, a memory, and a wireless communication module; the memory and the wireless communication module are coupled with the one or more processors, the memory is configured to store computer program code, the computer program code comprises computer instructions, when the one or more processors execute the computer instructions, the electronic device executes the WiFi P2P connection method as claimed in any one of claims 1 to 13.

15. A computer storage medium, comprising, A computer program for storing, when executed, specifically for implementing the WiFi P2P connection method as claimed in any one of claims 1 to 13.

Citation Information

Patent Citations

  • Apparatus, system and method of selecting a wireless communication channel

    CN106063345A

  • Display apparatus and method of setting operating channel of the same

    CN108605374A

  • Roaming to share a communication channel

    CN109565893A