Method for establishing WIFI p2p connection, and electronic device

By obtaining DFS channel availability detection results in Wi-Fi P2P connections, channels can be directly established or switched, solving the problem of insufficient transmission rate, achieving higher data transmission efficiency and user response rate, improving user experience and saving power.

WO2026157667A1PCT designated stage Publication Date: 2026-07-30HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2025-12-16
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

Existing technologies have insufficient data transmission rates in Wi-Fi P2P connections, failing to meet users' ever-increasing demands for the performance of electronic devices.

Method used

By obtaining the detection results of whether the DFS channel is available, a Wi-Fi P2P connection can be established directly using the 5GHz channel of the first bandwidth when the detection result indicates that the DFS channel is available, or switched to the 5GHz channel of the second bandwidth when it is unavailable. Combined with the channel effectiveness detection results of other electronic devices, the channel selection can be optimized to improve the response rate and save power consumption.

Benefits of technology

It improved the transmission rate of business data and the response rate of user devices, enhanced the user experience, and saved power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025142911_30072026_PF_FP_ABST
    Figure CN2025142911_30072026_PF_FP_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the field of wireless communications, and particularly relate to a method for establishing a WiFi P2P connection, and an electronic device, which can increase the transmission rate of service data. The method comprises: establishing a communication connection with at least one second electronic device; receiving a first operation for triggering a first electronic device to perform a collaborative service with a third electronic device, wherein the third electronic device is one of the at least one second electronic device; in response to the first operation, acquiring a detection result indicating whether a DFS channel is available; and when the detection result indicates that the DFS channel is available, establishing a WiFi P2P connection with the third electronic device by means of a 5GHz channel of a first bandwidth, wherein the 5GHz channel of the first bandwidth comprises the DFS channel.
Need to check novelty before this filing date? Find Prior Art

Description

A method and electronic device for establishing a Wi-Fi P2P connection

[0001] This application claims priority to Chinese Patent Application No. 202510109337.4, filed with the State Intellectual Property Office of China on January 21, 2025, entitled "A Method and Electronic Device for Establishing a Wi-Fi P2P Connection", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of wireless communication, and more particularly to a method and electronic device for establishing a Wi-Fi P2P connection. Background Technology

[0003] With the widespread adoption of smart devices and the rapid development of internet technology, different electronic devices can exchange data and achieve device collaboration. Device collaboration can include various collaborative services such as screen extension, screen mirroring, super calling, screen mirroring, super notifications, multi-screen collaboration, keyboard and mouse sharing, file sharing, and remote control.

[0004] Wi-Fi peer-to-peer (P2P) connections offer the advantage of high transmission speeds, enabling electronic devices to establish and transmit collaborative service data. As electronic devices are continuously upgraded and users' performance requirements increase, the transmission rate of service data via Wi-Fi P2P connections needs further improvement. Summary of the Invention

[0005] This application provides a method and electronic device for establishing a Wi-Fi P2P connection, which can improve the transmission rate of service data.

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

[0007] In a first aspect, a method for establishing a Wi-Fi P2P connection is provided, applied to a first electronic device. The method includes: establishing a communication connection with at least one second electronic device; receiving a first operation to trigger cooperative services between the first electronic device and a third electronic device, the third electronic device being one of the at least one second electronic device; in response to the first operation, obtaining a detection result indicating whether a DFS channel is available; and, if the detection result indicates that the DFS channel is available, establishing a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of a first bandwidth, the 5GHz channel of the first bandwidth including the DFS channel.

[0008] In this application, in response to the first operation, the first electronic device can first obtain a detection result indicating whether the DFS channel is available. If the detection result indicates that the DFS channel is available, the first electronic device directly establishes a Wi-Fi P2P connection with the third electronic device via the first bandwidth of 5GHz. Since the first bandwidth of 5GHz has a faster transmission rate, the transmission efficiency of service data can be greatly improved. Furthermore, in this embodiment, in response to the first operation, the first electronic device does not need to detect whether the DFS channel is available, but directly obtains the detection result, which can improve the response rate of the first electronic device to the first operation and improve the user experience.

[0009] In one possible implementation of the first aspect, if the detection result indicates that the DFS channel is unavailable, a Wi-Fi P2P connection is established with a third electronic device via a 5GHz channel of a second bandwidth, where the second bandwidth is smaller than the first bandwidth and the 5GHz channel of the second bandwidth does not include the DFS channel. In the case of the DFS channel being unavailable, the first electronic device directly establishes a Wi-Fi P2P connection with the third electronic device via the 5GHz channel of the second bandwidth, which can improve the response rate of the first electronic device.

[0010] In one possible implementation of the first aspect, before receiving a first operation to trigger the first electronic device and the third electronic device to perform cooperative services, the first electronic device periodically performs channel validity checks on the DFS channel.

[0011] When the first electronic device performs channel validity detection on the DFS channel for a duration greater than or equal to a preset duration, in response to the first operation, the first electronic device can obtain the channel validity detection results of the DFS channel within the preset duration prior to the first moment. The first moment is the moment the first operation is received. If no radar signal is detected in the channel validity detection of the DFS channel within the preset duration prior to the first moment, the detection result is used to indicate that the DFS channel is available. If a radar signal is detected in the channel validity detection of the DFS channel within the preset duration prior to the first moment, the detection result is used to indicate that the DFS channel is unavailable. In this application, the first electronic device performs channel validity detection on the DFS channel in advance before receiving the first operation. Therefore, in response to the first operation, the first electronic device can directly obtain the channel validity detection results of the DFS channel within the preset duration prior to the first moment, and based on the results, establish a Wi-Fi P2P connection with the third electronic device through different channels. Because the channel validity of the DFS channel is detected in advance, in response to the first operation, the first electronic device does not need to detect whether the DFS channel is available, but directly obtains the detection result, which can improve the response rate of the first electronic device to the first operation and improve the user experience.

[0012] In one possible implementation of the first aspect, to save power consumption and battery life of the first electronic device, before receiving the first operation used to trigger the first electronic device to perform cooperative services with the third electronic device, the first electronic device periodically performs channel validity checks on the DFS channel while the screen is on. This balances response rate and power consumption.

[0013] In one possible implementation of the first aspect, the first electronic device can obtain the channel validity detection result of the fourth electronic device, and obtain the detection result of whether the DFS channel is available based on the channel validity detection result of the fourth electronic device.

[0014] Specifically, in response to the first operation, a query request is sent to the fourth electronic device. This query request requests the results of the fourth electronic device's channel validity detection of the DFS channel within a preset time period prior to the first moment. The fourth electronic device is one of at least one second electronic device, and the first moment is the moment the first operation is received. The first electronic device receives the channel validity detection results from the fourth electronic device and, based on these results, obtains a detection result indicating whether the DFS channel is available. In response to the first operation, the first electronic device does not need to perform channel validity detection on the DFS channel; instead, it directly obtains the fourth electronic device's DFS channel validity detection results and, based on these results, obtains a detection result indicating whether the DFS channel is available. This improves the response rate of the first electronic device to the first operation and enhances the user experience.

[0015] In one possible implementation of the first aspect, if the channel validity detection result of the fourth electronic device is used to indicate that no radar signal was detected during the channel validity detection of the DFS channel within a preset time period prior to the first moment, then the detection result is used to indicate that the DFS channel is available. If the channel validity detection result of the fourth electronic device is used to indicate that a radar signal was detected during the channel validity detection of the DFS channel within a preset time period prior to the first moment, then the detection result is used to indicate that the DFS channel is unavailable.

[0016] In one possible implementation of the first aspect, the channel validity detection result of the fourth electronic device is used to indicate that the channel validity detection results of the DFS channel within a first duration prior to the first moment are all negative for radar signals. In response to the channel validity detection result, a second duration of channel validity detection is performed on the DFS channel, the sum of the second duration and the first duration being a preset duration. A detection result is determined based on the result of the second duration of channel validity detection on the DFS channel. Specifically, if no radar signals are detected in all channel validity detections of the DFS channel within the second duration, the detection result is that the DFS channel is available; if a radar signal is detected in the second duration of channel validity detection, the detection result is that the DFS channel is unavailable. Since the first duration is less than the preset duration, the first electronic device cannot yet determine whether the DFS channel is available. In this case, the first electronic device only needs to perform a second duration of CAC (Continuous Acquisition). The first electronic device only needs to perform CAC for a duration shorter than the preset duration to identify whether the DFS channel is available based on the CAC result. This improves the response rate of the first electronic device.

[0017] In one possible implementation of the first aspect, the result of the channel validity detection of the fourth electronic device is used to indicate that the result of the channel validity detection of the DFS channel within a first time period before the first moment is that a radar signal was detected, and the detection result is used to indicate that the DFS channel is unavailable.

[0018] In one possible implementation of the first aspect, the channel validity detection result of the fourth electronic device is used to indicate that the fourth electronic device has not performed a channel validity detection. Then, in response to the channel validity detection result, the first electronic device acquires information about the working channel of the wireless access device and determines the detection result based on the working channel information. Specifically, if the working channel information indicates that the working channel is a DFS channel, the detection result is that the DFS channel is available; if the working channel information indicates that the working channel is not a DFS channel, the detection result is that the DFS channel is unavailable.

[0019] In one possible implementation of the first aspect, if the channel validity detection of the DFS channel by the first electronic device reaches a preset duration, the first electronic device can obtain the result of the channel validity detection of the DFS channel by the first electronic device within the preset duration before the first moment.

[0020] In one possible implementation of the first aspect, if the channel validity detection of the DFS channel by the first electronic device has not reached the preset time and the result of the channel validity detection is that no radar signal is detected, the first electronic device can obtain the channel validity detection result of the fourth electronic device, and obtain the detection result of whether the DFS channel is available based on the channel validity detection result of the fourth electronic device.

[0021] In one possible implementation of the first aspect, in response to the first operation, the first electronic device can acquire information about the operating channel of the wireless access device. Based on this information, it acquires a detection result indicating whether the DFS channel is available. Specifically, if the operating channel information indicates that the DFS channel is available, the first electronic device acquires the detection result indicating that the DFS channel is available. If the operating channel information indicates that the DFS channel is unavailable, the first electronic device acquires the detection result indicating that the DFS channel is unavailable. Since the wireless access device performs CAC before using the DFS channel, the first electronic device can prioritize acquiring the operating channel information of the wireless access device and identify whether the DFS channel is available based on this information. This can improve the response rate of the first electronic device and save power consumption.

[0022] In one possible implementation of the first aspect, the channel validity detection result of the fourth electronic device is used to indicate that the channel validity detection results for the DFS channel within a first duration prior to the first moment are all negative for radar signals, and the first duration is less than a preset duration. In response to the channel validity detection result, the first electronic device can acquire information about the operating channel of the wireless access device. Based on this operating channel information, it acquires a detection result indicating whether the DFS channel is available. Since the first duration is less than the preset duration, the first electronic device cannot determine whether the DFS channel is available based on the channel validity detection result of the fourth electronic device. In this case, the first electronic device can acquire information about the operating channel of the wireless access device and identify whether the DFS channel is available based on this operating channel information.

[0023] In one possible implementation of the first aspect, the fourth electronic device is specifically a device among at least one of the second electronic devices that satisfies one or more of the following conditions: it has the capability to detect channel validity; its remaining battery power is greater than a threshold; and its wireless communication capability is greater than that of other second electronic devices.

[0024] In one possible implementation of the first aspect, after establishing a Wi-Fi P2P connection with a third electronic device via a 5GHz channel of the second bandwidth, the first electronic device periodically performs channel validity checks on the DFS channel. If the channel validity check of the DFS channel indicates that no radar signal is detected within a preset time period, the channel of the Wi-Fi P2P connection is switched from the 5GHz channel of the second bandwidth to the 5GHz channel of the first bandwidth.

[0025] In one possible implementation of the first aspect, the collaborative business satisfies one or more of the following conditions: the data volume is greater than a threshold; and the latency requirement is less than a threshold.

[0026] Secondly, a method for establishing a Wi-Fi P2P connection is provided, applied to a fourth electronic device. The method includes: receiving a query request from a first electronic device, the query request being used to request the result of the channel validity detection of the DFS channel by the fourth electronic device within a preset time period before a first moment, the first moment being the moment when the first electronic device receives the operation that triggers the cooperative service; sending the result of the channel validity detection to the first electronic device; wherein the result of the channel validity detection is used to indicate the result of the channel validity detection of the DFS channel within a third time period before the first moment, the third time period being less than or equal to the preset time period.

[0027] The channel validity detection result is used by the first electronic device to establish a Wi-Fi P2P connection with other electronic devices, such as a third electronic device. In other words, the first electronic device establishes a Wi-Fi P2P connection with other electronic devices, such as a third electronic device, based on the channel validity detection result.

[0028] Specifically, if the channel validity detection results for the DFS channel show no radar signal detected within a preset time period prior to the first moment, the first electronic device obtains the detection result that the DFS channel is available, and the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the 5GHz channel of the first bandwidth.

[0029] If the channel validity detection result of the DFS channel indicates that a radar signal was detected within a preset time period before the first moment, the first electronic device obtains the detection result that the DFS channel is unavailable, and the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0030] If the channel validity detection result of the DFS channel indicates that a radar signal was detected within the first time period before the first moment, the first electronic device obtains the detection result that the DFS channel is unavailable, and the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0031] If, during a first time period prior to the first moment, the channel validity detection results for the DFS channel show no radar signal detected, the first electronic device, in response to this channel validity detection result, performs a second time period channel validity detection on the DFS channel. The sum of the second time period and the first time period is a preset time period. Subsequently, the first electronic device obtains a detection result regarding the availability of the DFS channel based on the results of the second time period channel validity detection. If, during the second time period, no radar signal is detected in the DFS channel channel validity detection, the first electronic device obtains a detection result indicating that the DFS channel is available, and establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel with a first bandwidth. If, during the second time period, a radar signal is detected in the DFS channel channel validity detection, the first electronic device obtains a detection result indicating that the DFS channel is unavailable, and establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel with a second bandwidth.

[0032] If the channel validity test result indicates that the fourth electronic device did not perform a channel validity test on the DFS channel, the first electronic device obtains the operating channel information of the wireless access device. If the operating channel is the DFS channel, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a first bandwidth. If the operating channel is not the DFS channel, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a second bandwidth.

[0033] In this application, the fourth electronic device can receive a query request from the first electronic device and send the channel validity detection result to the first electronic device. At the time the query request is received, the fourth electronic device may be in different states. For example, the fourth electronic device may not have performed a channel validity detection. In this case, the channel validity detection result sent by the fourth electronic device indicates that the fourth electronic device did not perform a channel validity detection. Alternatively, the fourth electronic device may be performing a channel validity detection, and the detection duration may be greater than or equal to a preset duration. Or, the fourth electronic device may be performing a channel validity detection, and the detection duration may be less than the preset duration. In this case, the channel validity detection result sent by the fourth electronic device indicates the result of the channel validity detection of the DFS channel within a third duration prior to the first moment, where the third duration is less than or equal to the preset duration.

[0034] In one possible implementation of the second aspect, the fourth electronic device may receive indication information from the first electronic device, the indication information being used to instruct the DFS channel to perform channel validity detection. In response to the indication information, the fourth electronic device periodically performs channel validity detection on the DFS channel.

[0035] Thirdly, a wireless communication system is provided, including a first electronic device and at least one second electronic device; the first electronic device establishes a communication connection with the at least one second electronic device; the at least one second electronic device includes a third electronic device and a fourth electronic device; the first electronic device is configured to perform the method as described in any one of the first aspects; the fourth electronic device is configured to perform the method as described in any one of the first aspects; the third electronic device is configured to establish a Wi-Fi P2P connection with the first electronic device and perform collaborative services based on the Wi-Fi P2P connection.

[0036] Fourth aspect. An electronic device is provided, the electronic device comprising: a memory, a wireless communication module, and one or more processors; the wireless communication module receiving and transmitting data according to the control of the processor to realize communication between the electronic device and other electronic devices; the memory being coupled to the processor; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device causes the electronic device to perform the method as described in any one of the first aspect and / or the second aspect.

[0037] Fifthly, a chip system is provided that can be applied to an electronic device including memory. The chip system includes one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via lines. The interface circuits are used to receive signals from the aforementioned memory and send the signals to the processors, the signals including computer instructions stored in the memory. When the processor executes the computer instructions, the electronic device performs a method as described in the first aspect and / or the second aspect and any possible design configuration thereof.

[0038] A sixth aspect provides a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform a method as described in any one of the first and / or second aspects.

[0039] A seventh aspect is a computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of any one of the methods of the first aspect and / or the second aspect.

[0040] In understanding, the beneficial effects that can be achieved by the wireless communication system of the third aspect, the electronic device of any possible design of the fourth aspect, the chip system of the fifth aspect, the computer-readable storage medium of the sixth aspect, and the computer program product of the seventh aspect can be referred to as the beneficial effects of the first and second aspects and any possible design of them, which will not be repeated here. Attached Figure Description

[0041] Figure 1 is a schematic diagram of a wireless communication system provided in an embodiment of this application;

[0042] Figure 2 is a schematic diagram of a channel distribution in the 5GHz band provided in an embodiment of this application;

[0043] Figure 3 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;

[0044] Figure 4 is a schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;

[0045] Figure 5 is a schematic diagram of a method for establishing a Wi-Fi P2P connection provided in an embodiment of this application;

[0046] Figure 6 is a schematic diagram of an interface for triggering collaborative services between a first electronic device and a third electronic device, provided in an embodiment of this application.

[0047] Figure 7 is a schematic diagram of another interface for triggering collaborative services between the first electronic device and the third electronic device according to an embodiment of this application;

[0048] Figure 8 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application;

[0049] Figure 9 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application;

[0050] Figure 10 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application;

[0051] Figure 11 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application;

[0052] Figure 12 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application. Detailed Implementation

[0053] With the widespread adoption of smart devices and the rapid development of internet technology, different electronic devices can exchange data and achieve device collaboration. Collaborative services can include screen extension, screen mirroring, super calling, screen mirroring, super notifications, multi-screen collaboration, keyboard and mouse sharing, file sharing, remote control, and other collaborative features.

[0054] Collaborative services can be applied between electronic devices of the same or different types, based on communication connections between them. In other words, multiple electronic devices need to establish a connection before engaging in collaborative services. This connection can be wired or wireless. For example, multiple electronic devices can establish a wired connection via a universal serial bus (USB). Another example is that multiple electronic devices can establish a Bluetooth connection if they have Bluetooth enabled and are within a preset distance. Alternatively, multiple electronic devices can establish a WLAN Direct connection (also known as a Wi-Fi peer-to-peer, P2P) connection if they have WLAN enabled and are within a preset distance. Or, multiple electronic devices can connect to the same local area network (LAN) and synchronize data to achieve device collaboration. Alternatively, multiple electronic devices can establish near-field communication (NFC) connections, infrared (IR) connections, etc.

[0055] Among the aforementioned wired and various wireless connections, Wi-Fi P2P connections have the advantage of high transmission speed and are more suitable for transmitting large amounts of data. Therefore, collaborative services are generally implemented using Wi-Fi P2P connections.

[0056] Taking multiple electronic devices, including mobile phones and tablets, as an example. As shown in Figure 1, the mobile phone and tablet both enable WLAN. A Wi-Fi P2P connection is established between the two devices, allowing them to communicate directly and perform collaborative services. Alternatively, the mobile phone and / or tablet can connect to a router to access the internet. Of course, the mobile phone and tablet can also operate without a router.

[0057] In conventional technologies, electronic devices can establish Wi-Fi P2P connections with other electronic devices via channels included in the 2.4 GHz band. Alternatively, electronic devices can establish Wi-Fi P2P connections with other electronic devices via an 80 MHz 5 GHz channel. Electronic devices transmit service data based on either the channels included in the 2.4 GHz band or the 80 MHz 5 GHz channel.

[0058] When an electronic device establishes a Wi-Fi P2P connection on a 5GHz channel with an 80MHz bandwidth, assuming the device includes two sets of transmitting and receiving antennas, and theoretically, one set of transmitting and receiving antennas can achieve a maximum transmission rate of 600Mbps on an 80MHz 5GHz channel, then the maximum transmission rate of this electronic device on an 80MHz 5GHz channel can reach (600Mbps × 2) = 1200Mbps. With the upgrading of electronic devices, users' performance requirements are also increasing. Some electronic devices are equipped with WiFi 5 chips, which support the transmission of service data on channels with bandwidths greater than 80MHz, such as the first bandwidth 5GHz channel, thus significantly improving the transmission rate of service data.

[0059] Therefore, this application provides a method and electronic device for establishing a Wi-Fi P2P connection. The method is applied to a first electronic device. The first electronic device can establish a communication connection with at least one second electronic device. In response to a first operation, the first electronic device obtains a detection result indicating whether the DFS channel is available. If the detection result indicates that the DFS channel is available, the first electronic device establishes a Wi-Fi P2P connection with a third electronic device via a 5GHz channel of a first bandwidth. The 5GHz channel of the first bandwidth includes the DFS channel. The third electronic device is one of at least one second electronic device. As can be seen, in this application embodiment, the first electronic device, in response to the first operation, can first obtain a detection result indicating whether the DFS channel is available. If the detection result indicates that the DFS channel is available, the first electronic device directly establishes a Wi-Fi P2P connection with the third electronic device via the 5GHz channel of the first bandwidth. Since the 5GHz channel of the first bandwidth has a faster transmission rate, the transmission efficiency of service data can be greatly improved. Furthermore, in this application embodiment, in response to the first operation, the first electronic device does not need to detect whether the DFS channel is available, but directly obtains the detection result, which can improve the response rate of the first electronic device to the first operation and improve the user experience.

[0060] In this embodiment, the first electronic device can establish a Wi-Fi P2P connection with the third electronic device not only through a first channel, such as a 5GHz channel with a first bandwidth, for transmitting service data on the 5GHz channel of the first frequency band, but also through a second channel to establish a Wi-Fi P2P connection with the third electronic device for transmitting service data on the second channel. The channel transmission rate of the first channel is higher than that of the second channel. Both the first and second channels can be 5GHz channels, with the bandwidth of the first channel being higher than that of the second channel. For example, the first channel is a 5GHz channel with a first bandwidth, and the second channel is a 5GHz channel with a second bandwidth. The second bandwidth is lower than the first bandwidth, meaning the first bandwidth is higher than the second bandwidth. For example, the first bandwidth can be 160MHz and the second bandwidth can be 80MHz; or, for example, the first bandwidth can be 160MHz and the second bandwidth can be 40MHz; or, for example, the first bandwidth can be 160MHz and the second bandwidth can be 80MHz. In some embodiments, the first channel can be a 5GHz channel with a first bandwidth, and the second channel can be a 2.5GHz channel.

[0061] First, let's introduce the channel distribution of the 5GHz band with reference to Figure 2.

[0062] As shown in Figure 2, the 5GHz band ranges from 5170MHz to 5835MHz and can be divided into multiple channels, referred to as 5GHz channels, each with a bandwidth of 20MHz. For example, the 5170MHz-5330MHz band is divided into: Channel 36, Channel 40, Channel 44, Channel 48, Channel 52, Channel 56, Channel 60, and Channel 64. The 5490MHz-5730MHz band is divided into: Channel 100, Channel 104, Channel 108, Channel 112, Channel 116, Channel 120, Channel 124, Channel 128, Channel 132, Channel 136, Channel 140, and Channel 144. The 5735MHz-5835MHz band is divided into: Channel 149, Channel 153, Channel 157, Channel 161, and Channel 165.

[0063] To improve communication efficiency, adjacent channels can be merged to obtain channels with greater bandwidth. Continuing with Figure 2, taking the eight 20MHz channels divided into the 5170MHz-5330MHz range as an example, merging any two consecutive channels in this range yields four 40MHz 5GHz channels. Similarly, merging any four consecutive channels sequentially results in two 80MHz 5GHz channels. Merging eight consecutive channels creates a 160MHz channel. For example, merging channels 36, 40, 44, 48, 52, 56, 60, and 64 creates a 160MHz 5GHz channel. In other words, the 160MHz 5GHz channel consists of channels 36, 40, 44, 48, 52, 56, 60, and 64. Similarly, eight consecutive channels out of the 12 channels divided into 5490MHz-5730MHz bands can be combined into a single 160MHz 5GHz channel. For example, a 160MHz 5GHz channel could consist of channels 100, 104, 108, 112, 116, 120, 124, and 128. Or, for another example, a 160MHz 5GHz channel could consist of channels 116, 120, 124, 128, 132, 136, 140, and 144. In this embodiment, the first bandwidth 5GHz channel can be the 160MHz 5GHz channel shown in the examples above. The second bandwidth 5GHz channel can be the 80MHz 5GHz channel shown in the examples above.

[0064] Since the global radar system operates in the frequency bands of 5250MHz-5350MHz and 5470MHz-5725MHz, as shown in Figure 2, the operating channels of the global radar system, which can be simply referred to as radar channels, include channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, and 140 in the 5490MHz-5730MHz range, and channels 52, 56, 60, and 64 in the 5170MHz-5330MHz range. Therefore, it is obvious that when electronic devices communicate using a 160MHz 5GHz channel, this 5GHz channel will include radar signals. Radar channels in the 5GHz band can be called dynamic frequency selection (DFS) channels.

[0065] Therefore, to avoid radar signal interference, before configuring electronic devices to communicate using a 160MHz 5GHz channel, a Channel Availability Check (CAC) is performed to determine whether the DFS channel includes radar signals. If a radar signal is detected within the CAC detection period, it indicates that a radar signal exists on the DFS channel, and the electronic device will not use the first bandwidth 5GHz channel for data transmission. If no radar signal is detected within the CAC detection period, it indicates that the DFS channel does not include radar signals, and the electronic device can use the first bandwidth 5GHz channel for data transmission after the CAC. The CAC detection period can be, for example, a preset period of 60 seconds. It should be understood that the preset period can also be 90 seconds or 120 seconds, and this application embodiment does not specifically limit it in this way.

[0066] It should be understood that "DFS channel includes radar signals" in this application can be interpreted as "DFS channel transmits radar signals". "DFS channel does not include radar signals" can be interpreted as "DFS channel does not transmit radar signals". "Detecting whether DFS channel includes radar signals" can be interpreted as "detecting whether DFS channel transmits radar signals".

[0067] The method provided in this application can be applied to electronic devices with wireless communication capabilities. The aforementioned electronic devices (such as the first electronic device, the second electronic device, the fourth electronic device, and the third electronic device) may include mobile phones, tablets, laptops, personal computers (PCs), ultra-mobile personal computers (UMPCs), handheld computers, netbooks, smart home devices (e.g., smart TVs, smart screens, large screens, smart speakers, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (e.g., smartwatches, smart bracelets, etc.), in-vehicle devices, virtual reality devices, etc., and this application does not impose any limitations on these. In this application embodiment, the aforementioned electronic devices are electronic devices capable of running an operating system and installing applications. Optionally, the operating system running on the electronic device may be... system, system, Systems, etc.

[0068] Taking a mobile phone as an example, as shown in Figure 3, the electronic device 300 may include: a processor 310, a memory 320, a universal serial bus (USB) interface 330, a power management module 340, antennas such as antenna 1 and antenna 2, a communication module 350, a display screen 360, an audio module 370, a camera 380, a sensor module 390, etc.

[0069] Processor 310 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, memory, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). Different processing units may be independent devices or integrated into one or more processors. The controller may serve as the central nervous system and command center of the electronic device 300. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

[0070] The memory 320 can be used to store computer executable program code, which includes instructions. The processor 310 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 320. The memory 320 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, interface display, etc.). The data storage area may store data created during the use of the electronic device (such as notification messages). Furthermore, the memory 320 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0071] The power management module 340 is used to connect the battery to the processor 310. The power management module 340 receives battery and / or power input to power the processor 310, memory 320, communication module 350, display screen 360, and camera 380, etc. The power management module 340 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 340 may also be located within the processor 310.

[0072] The communication module 350 can provide wireless communication solutions for use on the electronic device 300, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The communication module 350 can be one or more devices integrating at least one communication processing module. The communication module 350 receives electromagnetic waves via an antenna, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to the processor 310. The communication module 350 can also receive signals to be transmitted from the processor 310, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via the antenna. In this embodiment, the wireless communication module 350 can establish one or more connections, including Wi-Fi, Bluetooth, and Wi-Fi peer-to-peer (P2P) connections, with other electronic devices. The wireless communication module 350 can also send signals to electronic devices with established connections.

[0073] In some embodiments, the antenna of the electronic device 300 is coupled to the communication module 350, enabling the electronic device 300 to communicate with networks and other devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BitTorrent, Global Navigation Satellite System (GNSS), WLAN, NFC, FM, and / or IR technologies. The GNSS may include Global Positioning System (GPS), BeiDou Navigation Satellite System (BDS), GLONASS, and / or Galileo.

[0074] In this embodiment, the communication module 350 can establish a connection with the communication module of at least one second electronic device. In response to the first operation, the processor 310 can obtain a detection result indicating whether the DFS channel is available. If the detection result indicates that the DFS channel is available, the processor 310 controls the communication module 350 to establish a Wi-Fi P2P connection with the communication module of the third electronic device via a 5GHz channel with a first bandwidth. If the detection result indicates that the DFS channel is unavailable, the processor 310 controls the communication module 350 to establish a Wi-Fi P2P connection with the communication module of the third electronic device via a 5GHz channel with a second bandwidth.

[0075] In response to the first operation, processor 310 can send a query request to the fourth electronic device via communication module 350. This query request is used to request the CAC result of the fourth electronic device for the DFS channel. The fourth electronic device can send the CAC result to communication module 350. Communication module 350 can then send the CAC result to processor 310. Processor 310 can then obtain a detection result regarding the availability of the DFS channel based on the CAC result.

[0076] In response to the first operation, processor 310 can also obtain information about the operating channel of the wireless access device through communication module 350. Based on the information about the operating channel of the wireless access device, processor 310 can also obtain a detection result regarding the availability of the DFS channel.

[0077] Electronic device 300 implements display functions through a GPU, display screen 360, and application processor. The GPU is a microprocessor for image processing, connecting the display screen 360 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 310 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0078] The display screen 360 is used to display images, videos, etc. The display screen 360 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini-LED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc.

[0079] Electronic device 300 can achieve shooting function through ISP, camera 380, video codec, GPU, display 360 and application processor.

[0080] The audio module 370 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal. The audio module 370 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 370 may be located in the processor 310, or some functional modules of the audio module 370 may be located in the processor 310.

[0081] The camera 380 is used to capture still images or videos. An object passes through the lens, generating an optical image that is projected onto a photosensitive element. This photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP (Image Signal Processor) for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP (Digital Signal Processor) for further processing. The DSP converts the digital image signal into standard image signals in formats such as RGB and YUV.

[0082] The sensor module 390 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors, etc.

[0083] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 300. In other embodiments, the electronic device 300 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0084] Taking the aforementioned electronic device 300 as an example, which is a mobile phone, the software system of the electronic device 300 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture... Taking the system as an example, the software structure of electronic device 300 is illustrated.

[0085] Figure 4 is a software structure block diagram of an electronic device 300 according to an embodiment of this application.

[0086] A layered architecture divides software into several layers, each with a clear role and function. 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 system libraries, and the kernel layer.

[0087] The application layer may include a series of application packages. These application packages may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, and desktop launcher. As shown in Figure 4, in this embodiment, the application layer may include device collaboration applications and sharing applications.

[0088] The application framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions. As shown in Figure 4, the application framework layer may include a Wi-Fi service module, a Bluetooth service module, and an input system.

[0089] The Wi-Fi service module provides a set of interfaces for applications or other software modules to control and implement Wi-Fi functionality. For example, applications or other software modules can use these interfaces to call the Wi-Fi service module to perform operations such as discovering devices, connecting to devices, and establishing Wi-Fi connections.

[0090] The Bluetooth service module provides a set of interfaces for applications or other software modules to control and implement Bluetooth functionality. For example, by calling the Bluetooth service module through these interfaces, operations such as turning Bluetooth on and off, searching for and pairing with other devices, and establishing Bluetooth connections can be performed.

[0091] The input system is used to recognize user operations on the touchscreen of electronic device 300 and convert the parameters input by the touchscreen driver into usable events, which are then passed to the relevant upper-layer modules. For example, the input system is used to recognize the touchscreen of electronic device 300 through the touchscreen driver and convert the touch parameters generated by the user's touch operation through the touchscreen into usable events, which are then passed to the upper-layer device collaboration application.

[0092] For example, in this embodiment, the input system recognizes a first operation input by the user, such as recognizing the first operation through a touchscreen driver, and reports the first operation to the device collaboration application. The device collaboration application can send a query request to the fourth electronic device through the communication module 350 to obtain the detection result of whether the 5GHz channel of the first bandwidth is available.

[0093] The system libraries include the core libraries and the virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.

[0094] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0095] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0096] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0097] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0098] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0099] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0100] A 2D graphics engine is a graphics engine for 2D drawing.

[0101] The kernel layer is the layer between hardware and software. The kernel layer can contain touchscreen drivers, display drivers, audio drivers, sensor drivers, etc.

[0102] The following describes a method for establishing a Wi-Fi P2P connection according to an embodiment of this application, with reference to the accompanying drawings. Figure 5 illustrates a method for establishing a Wi-Fi P2P connection according to an embodiment of this application. The method includes:

[0103] S1, the first electronic device establishes a communication connection with at least one second electronic device.

[0104] The first electronic device can establish a wired or wireless communication connection with at least one second electronic device, and this application does not specifically limit this. The wired communication connection can be, for example, a connection established using a general-purpose serial bus. The wireless communication connection can be, for example, a Bluetooth connection or a Wi-Fi connection. For example, if both the first and second electronic devices have Bluetooth enabled, after Bluetooth pairing, the first electronic device and the second electronic device establish a Bluetooth connection. As another example, if the first and second electronic devices are connected to the same wireless access device, such as a router, the first electronic device and the second electronic device establish a Wi-Fi connection.

[0105] Optionally, the first electronic device and the second electronic device can be electronic devices within the same trust ring. For example, the first electronic device and the second electronic device can log in to the same user account, forming a trust ring. Alternatively, the first electronic device and the second electronic device may not log in to the same account, but they can perform trusted authentication through a protocol, forming a trust ring.

[0106] S2, the first electronic device receives the first operation.

[0107] The first operation is used to trigger collaborative services between the first electronic device and the third electronic device. The third electronic device is one of at least one second electronic device. The first operation will be described below using an example where the first electronic device is a mobile phone and the third electronic device is a tablet computer, in conjunction with Figures 6 and 7.

[0108] In some embodiments, the mobile phone may include a device collaboration application. The device collaboration application includes a visual human-computer interaction interface to facilitate user initiation of device collaboration. This device collaboration application may be, for example, a trust ring application. After enabling the device collaboration function and wireless communication function, the interface of the device collaboration application may display the identifiers of connected electronic devices. For example, taking a trust ring application as an example, as shown in Figure 6, the mobile phone's control center interface 601 displays an application card 602 for the trust ring application. The application card 602 displays the identifiers of electronic devices belonging to the same trust ring as the mobile phone and connected to it. In response to the user clicking the application card 602, the mobile phone displays the control interface 603 of the trust ring application. The control interface 603 displays the mobile phone's identifier. The control interface 603 also displays the identifiers of electronic devices in the same trust ring as the mobile phone and connected to it, such as the identifiers of tablet computers and personal computers (PCs). It should be understood that this application does not limit the way the mobile phone displays the control interface 603 of the trust ring application; Figure 6 is only one possible example. In response to the user clicking the mobile phone's identifier, the mobile phone displays a collaboration list 604, which includes the names of collaboration services supported by the mobile phone. The first action could be a drag-and-drop operation where the phone drags the name of a collaborative service from the collaboration list to the icon on the tablet. For example, the first action could be dragging "Screen Sharing" from the phone's collaboration list to the icon on the tablet. In response to this first action, the phone and tablet share their screens.

[0109] In other embodiments, the mobile phone may include a sharing application, as shown in FIG7, where the phone displays an interface 701 of a gallery application. Interface 701 displays image 1 in a large image preview mode. In response to the user clicking the share button, the phone displays interface 702. Interface 702 includes a device list, which includes identifiers of electronic devices that have established a communication connection with the phone. A first operation may be the user clicking the identifier of an electronic device in the phone's device list. For example, the first operation may be the user clicking the identifier of a tablet computer in the device list. In response to this first operation, the phone and the tablet computer share files.

[0110] S3, in response to the first operation, obtains the detection result of whether the DFS channel is available.

[0111] There are three ways for the first electronic device to obtain the detection result of whether the DFS channel is available.

[0112] The first method involves the first electronic device acquiring the channel validity detection result of the DFS channel of the fourth electronic device, and then obtaining a detection result indicating whether the DFS channel is available based on the channel validity detection result of the fourth electronic device. The fourth electronic device is one of at least one second electronic device. The fourth electronic device and the third electronic device can be the same electronic device or different electronic devices; this application does not specifically limit this.

[0113] The second method is: the first electronic device obtains the channel validity detection result of the DFS channel of the first electronic device, and obtains the detection result of whether the DFS channel is available based on the channel validity detection result of the DFS channel.

[0114] The third method involves the first electronic device acquiring information about the working channel of the wireless access device and, based on this information, obtaining a detection result regarding the availability of the DFS channel. This will be explained in detail below with reference to the accompanying diagrams, and will not be repeated here.

[0115] S4, if the detection result of whether the DFS channel is available indicates that the DFS channel is available, establish a Wi-Fi P2P connection with the third electronic device through the 5GHz channel of the first bandwidth.

[0116] The first bandwidth 5GHz channel includes the DFS channel.

[0117] S5, if the detection result of whether the DFS channel is available indicates that the DFS channel is unavailable, establish a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0118] The second bandwidth 5GHz channel does not include the DFS channel.

[0119] In this process, the first electronic device and the third electronic device negotiate to establish a Wi-Fi P2P connection. For example, the first electronic device can send negotiation information to the third electronic device. This negotiation information includes the channel number (e.g., channel number), device information for the group owner (GO) device, and device information for the client (GC) device. The first and third electronic devices can then establish a Wi-Fi P2P connection based on this negotiation information.

[0120] As can be seen, in this embodiment of the application, the first electronic device can obtain a detection result indicating whether the DFS channel is available before establishing a Wi-Fi P2P connection with other electronic devices, such as a third electronic device. If the detection result indicates that the DFS channel is available, a Wi-Fi P2P connection is established with the third electronic device through a 5GHz channel with a first bandwidth. If the detection result indicates that the DFS channel is unavailable, a Wi-Fi P2P connection is established with the third electronic device through a 5GHz channel with a second bandwidth, where the second bandwidth is smaller than the first bandwidth.

[0121] In some embodiments, the first electronic device can obtain the channel validity detection result of the DFS channel of the fourth electronic device, and obtain a detection result indicating whether the DFS channel is available based on the channel validity detection result. For example, Figure 8 illustrates a method for establishing a Wi-Fi P2P connection according to an embodiment of this application. The method includes:

[0122] S21, the first electronic device establishes a communication connection with at least one second electronic device.

[0123] S22, the first electronic device instructs the fourth electronic device to perform CAC periodically in the first cycle.

[0124] CAC is used to detect whether the DFS channel includes radar signals. The first period can be 1 second. Optionally, the first period can be 0.5 seconds or 2 seconds, and this embodiment does not specifically limit this. For example, the first electronic device can send indication information to the fourth electronic device, which indicates that CAC should be performed on the DFS channel periodically in the first period. Optionally, in order to save power consumption and battery life of the fourth electronic device, the fourth electronic device can perform CAC on the DFS channel periodically in the first period while the screen is on.

[0125] The fourth electronic device is a device among at least one second electronic device that meets one or more of the following conditions: it has CAC capability, its remaining battery power is greater than a threshold, and its wireless communication capability is greater than the wireless communication capability of other second electronic devices.

[0126] The first electronic device can determine the fourth electronic device from at least one second electronic device. For example, if there is only one second electronic device, the first electronic device will use that second electronic device as the fourth electronic device. If there are multiple second electronic devices, the first electronic device can determine the fourth electronic device from at least one second electronic device based on the device information of the second electronic devices. This device information may include, for example, remaining battery power, chip capabilities, and CAC capabilities. Chip capabilities may include, for example, the chip's wireless communication capabilities. The chip's wireless communication capabilities can be characterized by parameters such as the chip's operating frequency band, supported wireless standards, maximum output power, and modulation method.

[0127] For example, when there are multiple second electronic devices, the first electronic device can use a second electronic device with more remaining power, stronger chip capabilities, and CAC capability as the fourth electronic device.

[0128] For example, when there are multiple second electronic devices, the first electronic devices can use a scoring mechanism to select the second electronic device with the highest score as the fourth electronic device. Table 1 shows one such scoring mechanism.

[0129] Table 1

[0130] The first electronic device can obtain device information of at least one second electronic device. For example, during the process of establishing a communication connection with at least one second electronic device, the first electronic device can obtain the device information of at least one second electronic device. Alternatively, after establishing a communication connection with at least one second electronic device, the first electronic device can request to obtain the device information of at least one second electronic device. Alternatively, at least one second electronic device can broadcast device information, which may be a Bluetooth broadcast or a Wi-Fi broadcast. This application does not limit the manner in which the first electronic device obtains the device information of at least one second electronic device.

[0131] Optionally, if the communication connection between the at least one second electronic device and the first electronic device is lost, the first electronic device may re-determine the fourth electronic device from the second electronic devices connected to the first electronic device and instruct the newly determined fourth electronic device to perform CAC periodically in a first cycle.

[0132] Optionally, if after establishing a communication connection with at least one second electronic device, another second electronic device establishes a communication connection with the first electronic device, the first electronic device may re-determine the fourth electronic device from among the second electronic devices connected to the first electronic device and instruct the newly determined fourth electronic device to perform CAC.

[0133] Optionally, after the fourth electronic device is identified, the first electronic device may broadcast a message to at least one second electronic device connected to the first electronic device. This message informs the second electronic device that the fourth electronic device is periodically performing CAC detection in a first cycle.

[0134] S23, in response, the fourth electronic device periodically performs CAC on the DFS channel in the first cycle.

[0135] For example, in response to an instruction from the first electronic device, the fourth electronic device periodically performs CAC on the DFS channel at a first cycle. Taking a first cycle of one second as an example, for instance, starting from the moment the instruction is received, the fourth electronic device continuously performs CAC on the DFS channel at 1-second intervals. Alternatively, to save power and battery life, when the fourth electronic device is in a screen-on state, the fourth electronic device continuously performs CAC on the DFS channel at 1-second intervals.

[0136] S24, in response to the first operation, the first electronic device sends a query request to the fourth electronic device.

[0137] In response to the first operation, the first electronic device can obtain the CAC result of the fourth electronic device on the DFS channel within a preset time period prior to the first moment. Here, the first moment can be the moment the first operation is received. The first electronic device can obtain a detection result regarding the availability of the DFS channel based on the CAC result of the fourth electronic device on the DFS channel within the preset time period prior to the first moment. In this embodiment, the preset time period prior to the first moment can be understood as a preset time period preceding the first moment.

[0138] Specifically, in response to the first operation, the first electronic device can send a query request to the fourth electronic device. The query request is used to request the CAC results of the fourth electronic device on the DFS channel within a preset time period prior to the first moment. Taking a preset time period of 60 seconds as an example, the query request is specifically used to request the CAC results of the fourth electronic device on the DFS channel within 60 seconds prior to the first moment.

[0139] Before establishing a Wi-Fi P2P connection, the first electronic device sends channel information to the third electronic device, instructing the third electronic device to interact with the first electronic device on the indicated channel. The channel information could be, for example, a channel number. Therefore, before establishing a Wi-Fi P2P connection with the third electronic device, the first electronic device can obtain the CAC result of the fourth electronic device performing on the DFS channel within a preset time period prior to the first moment. Based on this result, it can establish a Wi-Fi P2P connection with the third electronic device either through a 5GHz channel with a first bandwidth or through a 5GHz channel with a second bandwidth. This allows the first electronic device to quickly identify whether the DFS channel is available and establish a Wi-Fi P2P connection through different channels, saving response time.

[0140] It should be understood that the availability of the DFS channel cannot be determined based on the result of a single CAC (Confirmation and Acquisition) query; it requires the result of a CAC query over a preset duration. Therefore, when a query request is received, the fourth electronic device may fall into one of five possible scenarios. These scenarios are described below with a preset duration of 60 seconds.

[0141] Scenario 1: The fourth electronic device has not yet performed CAC. For example, the fourth electronic device performs CAC while the screen is on. If the fourth electronic device receives a query request from the first electronic device while the screen is off, it has not performed CAC. In this case, the fourth electronic device can send detection result 'a' to the first electronic device. This detection result 'a' indicates that the fourth electronic device has not performed CAC on the DFS channel. In other words, detection result 'a' indicates that the fourth electronic device has not detected whether the DFS channel includes radar signals.

[0142] Scenario 2: The fourth electronic device is performing CAC and has not detected a radar signal within 60 seconds prior to the first moment. For example, at the moment the query request is received, the fourth electronic device is performing CAC and has been detecting for more than 60 seconds. If no radar signal is detected in any detection cycle within the 60 seconds prior to the first moment, the fourth electronic device sends detection result b to the first electronic device. Detection result b indicates that the result of CAC on the DFS channel within the 60 seconds prior to the first moment is that no radar signal was detected. Here, the first moment can be the moment when the fourth electronic device receives the query request. That is, the fourth electronic device takes the moment when it receives the query request as the first moment. For example, at the first moment, the fourth electronic device is performing CAC on the DFS channel and has been performing CAC for 90 seconds. For example, the first moment is 90.5 seconds, and the fourth electronic device identifies that no radar signal was detected in each detection cycle from 40 seconds to 90 seconds, the fourth electronic device sends detection result b to the first electronic device.

[0143] Scenario 3: The fourth electronic device detects a radar signal within 60 seconds before the first moment of CAC.

[0144] For example, at the first moment, the fourth electronic device has been performing CAC on the DFS channel for more than 60 seconds. If a radar signal is detected in any second within the 60 seconds prior to the first moment, the fourth electronic device sends a detection result c to the first electronic device. Detection result c indicates that the CAC result of the DFS channel within the 60 seconds prior to the first moment indicates that a radar signal has been detected. Continuing the previous example, if the fourth electronic device recognizes that a radar signal is detected in any second within any detection period from the 40th to the 90th second, the fourth electronic device sends detection result c to the first electronic device.

[0145] Scenario 4: The fourth electronic device is performing CAC, the detection time is less than 60 seconds, and a radar signal has been detected within the detection time.

[0146] At the first moment, if the fourth electronic device is performing CAC and the detected duration is less than 60 seconds, and a radar signal is detected in any detection cycle within the detected duration, the fourth electronic device sends a detection result d to the first electronic device. The detection result d indicates that the CAC result of the DFS channel within the first duration prior to the first moment indicates that a radar signal has been detected. The first duration is less than a preset duration. For example, if the detection cycle (first cycle) is 1 second, and the fourth electronic device is performing CAC for 20 seconds at the first moment, then the first moment is the 20.8th second. If the fourth electronic device identifies a radar signal detected in any second between the 1st and 20th second, it sends the detection result d to the first electronic device.

[0147] Scenario 5: The fourth electronic device is performing CAC, the detection time is less than 60 seconds, and no radar signal has been detected within the detection time.

[0148] At the first moment, if the fourth electronic device is performing CAC and the detected duration is less than 60 seconds, and no radar signal is detected in any detection cycle within the detected duration, the fourth electronic device sends a detection result e to the first electronic device. Detection result e indicates that the CAC result for the DFS channel within the first duration prior to the first moment is that no radar signal was detected. Continuing the previous example, for instance, if the fourth electronic device identifies that no radar signal was detected from the 1st second to the 20th second, the fourth electronic device sends a detection result d to the first electronic device. In this embodiment, the first duration prior to the first moment can be understood as the first duration preceding the first moment.

[0149] Upon receiving a query request, the fourth electronic device can send a CAC result to the first electronic device based on its own detection results. This CAC result can be a first detection result, a second detection result, a third detection result, a fourth detection result, and a fifth detection result. Specifically, the first detection result, such as detection result a, indicates that the fourth electronic device did not perform CAC. The second detection result, such as detection result b, indicates that the CAC results for the DFS channel within a preset time period before the first moment were all negative for radar signals. The third detection result, such as detection result c, indicates that the CAC results for the DFS channel within the preset time period before the first moment were negative for radar signals. The fourth detection result, such as detection result d, indicates that the CAC results for the DFS channel within a first time period before the first moment were negative for radar signals. The fifth detection result, such as detection result e, indicates that the CAC results for the DFS channel within the first time period before the first moment were all negative for radar signals.

[0150] The first electronic device can execute different logic based on the CAC result sent by the fourth electronic device and establish a Wi-Fi P2P connection with the third electronic device through different channels. The following sections describe different scenarios.

[0151] In case 1, the first electronic device and the fourth electronic device can perform the interaction method shown in S25-S27.

[0152] S25, in response to the query request, if the fourth electronic device has not performed CAC, the fourth electronic device sends the detection result to the first electronic device.

[0153] S26, in response to the first detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a second bandwidth.

[0154] S27, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0155] The first detection result indicates that the fourth electronic device has not performed CAC. In order to respond quickly to the user's first operation, after receiving the first detection result, the first electronic device can establish a Wi-Fi P2P connection with the third electronic device on a second bandwidth 5GHz channel. Subsequently, the first and third electronic devices can transmit service data based on the second bandwidth 5GHz channel. In this way, the user's operation can be responded to quickly.

[0156] Optionally, in response to the first detection result, the first electronic device may perform CAC (Continuous Acceleration and Consistency) on the DFS channel for a preset duration. If a radar signal is detected within the preset duration, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a second bandwidth. The first electronic device sends service data to the third electronic device based on the 5GHz channel with the second bandwidth. If no radar signal is detected within the preset duration, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a first bandwidth. The first electronic device sends service data to the third electronic device based on the 5GHz channel with the first bandwidth. The preset duration CAC can be understood as periodically detecting whether the DFS channel includes a radar signal for a first period and continuously detecting for a preset duration. In this embodiment, in response to the second detection result, since it is unknown whether the DFS is available, the first electronic device may first perform CAC for a preset duration. Afterwards, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device on a different channel based on the CAC result of the preset duration.

[0157] In case 2, the first electronic device and the fourth electronic device can perform the interaction method shown in S28-S210.

[0158] S28, in response to the query request, if the fourth electronic device has not detected a radar signal in the DFS channel within 60 seconds prior to the first moment, the fourth electronic device sends a second detection result to the first electronic device.

[0159] S29, in response to the second detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a first bandwidth.

[0160] S210, the first electronic device transmits service data to the third electronic device based on a 5GHz channel with a first bandwidth.

[0161] In response to the second detection result, the first electronic device determines that the DFS channel is available, and establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a first bandwidth. The first electronic device sends service data to the third electronic device based on the 5GHz channel with the first bandwidth. Thus, in response to the first operation, the first electronic device does not need to perform CAC (Confirmation and Acquisition). The first electronic device can directly establish a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a first bandwidth based on the CAC result of the fourth electronic device, which not only improves the response rate of the first electronic device but also increases the data transmission rate.

[0162] In case 3, the first electronic device and the fourth electronic device can perform the interaction method shown in S211-S213.

[0163] S211, in response to the query request, if the fourth electronic device detects a radar signal in the DFS channel 60 seconds before the first moment, the fourth electronic device sends a third detection result to the first electronic device.

[0164] S212, in response to the third detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0165] S213, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0166] In case 4, the first electronic device and the fourth electronic device can perform the interaction method shown in S214-S216.

[0167] S214, in response to the query request, if the fourth electronic device detects a radar signal in the DFS channel for a first duration before the first moment, the fourth electronic device sends a fourth detection result to the first electronic device.

[0168] S215, in response to the fourth detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0169] S216, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0170] In case 5, the first electronic device and the fourth electronic device can perform the interaction method shown in S217-S222.

[0171] S217, in response to the query request, if the fourth electronic device has not detected a radar signal in the DFS channel within the first time period before the first moment, the fourth electronic device sends a fifth detection result to the first electronic device.

[0172] S218, in response to the fifth detection result, the first electronic device performs CAC for a second duration.

[0173] The sum of the first duration and the second duration is the preset duration. The first electronic device performing CAC for the second duration can be understood as: the first electronic device periodically detects whether the DFS channel includes radar signals in the first cycle, and the continuous detection duration is the second duration.

[0174] The first electronic device can determine the availability of the DFS channel based on the CAC detection results for the second duration. For example, if the CAC result for the DFS channel within the second duration indicates that no radar signal is detected, then the availability of the DFS channel is determined to be that the DFS channel is available. Conversely, if the CAC result for the DFS channel within the second duration indicates that a radar signal is detected, then the availability of the DFS channel is determined to be that the DFS channel is unavailable.

[0175] S219, if no radar signal is detected in the DFS channel within the second time period, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the 5GHz channel of the first bandwidth.

[0176] S220, the first electronic device transmits service data to the third electronic device based on a 5GHz channel with a first bandwidth.

[0177] S221, if a radar signal is detected in the DFS channel within the second time period, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0178] S222, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0179] If the fourth electronic device has performed CAC for a first duration and has not detected a radar signal in the DFS channel within that first duration, the first electronic device can continue with CAC for a second duration. Based on the CAC result for the second duration, it can establish a Wi-Fi P2P connection with the third electronic device through a different channel. This not only improves the response rate of the first electronic device, but also, if the first electronic device has not detected a radar signal in the DFS channel within the second duration, it can establish a Wi-Fi P2P connection with the third electronic device through the 5GHz channel with the first bandwidth, thereby improving data transmission speed.

[0180] In the embodiment shown in Figure 8, after receiving the first detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a 5GHz channel with a second bandwidth in order to quickly respond to the first operation. Further, to improve the data transmission rate, after establishing the Wi-Fi P2P connection with the third electronic device through the 5GHz channel with the second bandwidth, the first electronic device performs CAC on the DFS channel, periodically detecting whether the DFS channel contains radar signals in a first cycle. If no radar signal is detected on the DFS channel for a consecutive preset duration, the first electronic device switches the Wi-Fi P2P connection channel from the 5GHz channel with the second bandwidth to the 5GHz channel with the first bandwidth to improve the data transmission rate. In this example, as long as the first electronic device does not detect a radar signal in the DFS channel for a consecutive preset duration, it can switch the Wi-Fi P2P connection channel from the 5GHz channel with the second bandwidth to the 5GHz channel with the first bandwidth. In other embodiments, if the first electronic device does not detect a radar signal in the DFS channel for a consecutive preset duration, it further identifies whether the currently ongoing collaborative service meets the conditions. When the cooperative service conditions are met, the first electronic device switches the Wi-Fi P2P connection channel from a 5GHz channel with a second bandwidth to a 5GHz channel with a first bandwidth. The cooperative service meeting conditions indicate that the cooperative service involves large data volumes and / or has high latency requirements. Figure 9 provides an example diagram of another method for establishing a Wi-Fi P2P connection, which includes:

[0181] S31, the first electronic device establishes a communication connection with at least one second electronic device.

[0182] S32, the first electronic device instructs the fourth electronic device to perform CAC periodically in a first cycle.

[0183] S33, in response, the fourth electronic device periodically performs CAC on the DFS channel in the first cycle.

[0184] S34, in response to the first operation, the first electronic device sends a query request to the fourth electronic device.

[0185] S35, in response to the query request, if the fourth electronic device has not performed CAC, the fourth electronic device sends the first detection result to the first electronic device.

[0186] S36, in response to the first detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0187] S37, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0188] S31-S37 are similar to S21-S27 in Figure 8, and will not be described again here.

[0189] Furthermore, the first electronic device can execute S38 to detect whether the DFS channel is available.

[0190] S38, the first electronic device periodically detects whether the DFS channel includes radar signals in a first cycle.

[0191] The first electronic device can execute S35 and S37 simultaneously. In this application, "simultaneously" can be understood as executing the two actions at the same time. Alternatively, it can be understood as the time difference between executing the two actions being within a preset range, such as within 0.2 seconds.

[0192] S39, the first electronic device identifies whether the currently ongoing collaborative service meets the conditions.

[0193] The conditions can be: the collaborative service is a Class I service; the collaborative service is a latency-sensitive service with a latency greater than a threshold; or the service identifier of the collaborative service is one or more of the Class I identifiers. Meeting these conditions indicates that the collaborative service has a large data volume and / or high latency requirements.

[0194] The first electronic device can identify whether the currently ongoing collaborative service meets the conditions based on information from previously ongoing collaborative services.

[0195] In some embodiments, the condition is that the collaborative service is a first type of service. The information about the collaborative service can be the type of collaborative service. Services can be classified into first type and second type services according to their data volume. First type services can be services with data volume greater than a threshold. Second type services can be services with data volume less than or equal to the threshold. First type services may include file sharing services, and second type services may include: screen extension services, screen casting services, super call services, screen mirroring services, super notification services, multi-screen collaboration services, keyboard and mouse sharing services, remote control services, etc. The first electronic device has a built-in mapping relationship between service types and channel types. Channel types include a first channel, such as a 5GHz channel with a first bandwidth, and a second channel, such as a 5GHz channel with a second bandwidth. This mapping relationship can be: first type services correspond to the first channel, and second type services correspond to the second channel. Optionally, first type services include file sharing services with data volume greater than or equal to the threshold. Second type services include file sharing services, screen extension services, screen casting services, super call services, screen mirroring services, super notification services, multi-screen collaboration services, and keyboard and mouse sharing services, etc., with data volume less than the threshold.

[0196] The first electronic device can obtain the service type of the ongoing collaborative service. For example, the processor of the first electronic device can obtain the service type of the collaborative service from an application such as a device collaboration application or a sharing application. The first electronic device identifies whether the ongoing collaborative service is a first-type service based on its type. If the collaborative service is a first-type service, the first electronic device identifies that the collaborative service meets the conditions. If the collaborative service is not a first-type service, the first electronic device identifies that the collaborative service does not meet the conditions.

[0197] In other embodiments, the condition is that the collaborative service is a latency-sensitive service and the latency is greater than a threshold. Based on the service's sensitivity to latency, services can be divided into latency-sensitive services and latency-insensitive services. Latency-sensitive services may include: screen extension services, screen projection services, super call services, screen mirroring services, super notification services, multi-screen collaboration services, keyboard and mouse sharing services, remote control services, etc. Latency-insensitive services may include file sharing services, etc. If the currently ongoing collaborative service is a latency-sensitive service and its latency is greater than the threshold, the first electronic device identifies that the collaborative service meets the condition. If the currently ongoing collaborative service is not a latency-sensitive service and / or its latency is less than or equal to the threshold, the first electronic device identifies that the collaborative service meets the condition.

[0198] In this embodiment of the application, latency-sensitive services refer to services that have high requirements for data transmission latency, and whose normal operation may be affected by small changes in latency.

[0199] In some embodiments, the service identifier of the collaborative service is taken as a first identifier. The information of the collaborative service can be a service identifier. The service identifier may include a first identifier and a second identifier. The first identifier indicates that the service data of the collaborative service is transmitted through a 5GHz channel with a first bandwidth. The second identifier indicates that the service data of the collaborative service is transmitted through a 5GHz channel with a second bandwidth. For example, the first identifier can be 0, and the second identifier can be 1. The first electronic device can acquire the service identifier of the ongoing collaborative service. If the service identifier of the collaborative service is the first identifier, the first electronic device identifies that the collaborative service meets the conditions. If the service identifier of the collaborative service is not the second identifier, the first electronic device identifies that the collaborative service does not meet the conditions.

[0200] The information regarding the aforementioned collaborative services can be included in the Quality of Service (QoS) message. That is, the QoS message includes one or more of the following: service type, service data volume, latency requirements, and service identifier. The first electronic device can obtain the QoS message. For example, in response to the first operation, an application such as a device collaboration application or a sharing application will send a QoS message to the processor of the first electronic device.

[0201] S310, if the current collaborative service meets the conditions and no radar signal is detected on the DFS channel within a preset duration, the first electronic device switches the Wi-Fi P2P connection channel from the second bandwidth 5GHz channel to the first bandwidth 5GHz channel.

[0202] If no radar signal is detected on the DFS channel within a consecutive preset time period, indicating that the DFS channel is available, then the first electronic device switches the Wi-Fi P2P connection channel from the second bandwidth 5GHz channel to the first bandwidth 5GHz channel, provided that the current cooperative service meets the conditions and the DFS channel is available.

[0203] Taking a preset duration of 60 seconds as an example, "no radar signal detected in the DFS channel for 60 consecutive seconds" means that no radar signal is detected in the DFS channel for a period of 60 seconds starting from the moment no radar signal is detected. Taking a first cycle of 1 second as an example, if CAC starts at second 1, and no radar signal is detected in second 1, and no radar signal is detected in the subsequent second 2, third, ..., 60th seconds, then the first electronic device determines that the DFS channel is available and performs the aforementioned channel switching action. For example, if CAC starts at second 1, and no radar signal is detected from second 1 to second 19, and a radar signal is detected at second 20, then from second 20 onwards, no radar signal is detected in the subsequent second 21, second 22, ..., 80th seconds, then the first electronic device determines that the DFS channel is available and performs the aforementioned channel switching action. In other words, only when no radar signal is detected in the DFS channel for 60 consecutive seconds can the first electronic device use the first bandwidth 5GHz channel to transmit service data. In other words, the first electronic device performs CAC periodically in the first cycle. Only if no radar signal is detected in the 5GHz channel of the first bandwidth for a continuous 60 seconds can the first electronic device use the 5GHz channel of the first bandwidth to transmit service data.

[0204] The first electronic device can track the duration of periods without detected radar signals. For example, starting from the moment no radar signal is detected for the first time, the first electronic device begins recording the detection result every second. If, within a continuous 60 seconds, the detection result for each second indicates that no radar signal is detected, the first electronic device can switch the Wi-Fi P2P connection channel from the second bandwidth 5GHz channel to the first bandwidth 5GHz channel. Alternatively, for example, if the detection result for each second from the 1st to the 20th second indicates that no radar signal is detected, and the detection result for the 20th second indicates that a radar signal is detected, then the first electronic device restarts recording from the next moment when no radar signal is detected, until no radar signal is detected for a continuous 60 seconds, at which point the aforementioned switching action is performed.

[0205] S311, the first electronic device transmits service data to the third electronic device based on a 5GHz channel with a first bandwidth.

[0206] Optionally, the above method also includes: if the conditions for the currently ongoing collaborative service are not met, the first electronic device continues to transmit service data with the third electronic device based on the 5GHz channel of the second bandwidth.

[0207] Optionally, the above method further includes: if a radar signal is detected in the DFS channel for a continuous preset duration, the first electronic device continues to transmit service data with the third electronic device based on the second bandwidth 5GHz channel.

[0208] As can be seen, without the fourth electronic device performing CAC, the first electronic device can establish a Wi-Fi P2P connection with the third electronic device via the second bandwidth 5GHz channel. The first electronic device will synchronously initiate CAC. If no radar signal is detected on the DFS channel for a continuous preset time period and the ongoing cooperative service meets the conditions, the Wi-Fi P2P connection channel will be switched from the second bandwidth 5GHz channel to the first bandwidth 5GHz channel. This can improve data transmission rate, meet latency requirements, and improve user experience.

[0209] In this embodiment, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of the second bandwidth in response to a first detection result. The first electronic device simultaneously performs CAC (Continuous Accuracy Control). Afterwards, the first electronic device switches the channel of the Wi-Fi P2P connection based on the CAC result. In other embodiments, regardless of the reason for the first electronic device establishing a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of the second bandwidth, the first electronic device can perform CAC after establishing the Wi-Fi P2P connection and switch the channel of the Wi-Fi P2P connection based on the CAC result. For example, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of the second bandwidth in response to a third or fourth detection result. Or, for example, the first electronic device performs CAC for a second duration in response to a fifth detection result, and within the second duration, a radar signal is detected on the DFS channel; the first electronic device then establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of the second bandwidth. In these cases, the first electronic device can simultaneously perform CAC after establishing a Wi-Fi P2P connection with the third electronic device via a 5GHz channel of the second bandwidth. The first electronic device switches the channel of the Wi-Fi P2P connection based on the CAC result. For example, if the CAC result indicates that the DFS channel is available, the first electronic device switches the channel of the Wi-Fi P2P connection from a 5GHz channel with a second bandwidth to a 5GHz channel with a first bandwidth. Optionally, after switching the channel of the Wi-Fi P2P connection from the 5GHz channel with a second bandwidth to the 5GHz channel with a first bandwidth, the first electronic device can continue to perform CAC. If the CAC result indicates that the 5GHz channel with a first bandwidth is unavailable, the channel of the Wi-Fi P2P connection is switched from the 5GHz channel with a first bandwidth to the 5GHz channel with a second bandwidth.

[0210] Optionally, after establishing a Wi-Fi P2P connection between the first electronic device and the third electronic device on a 5GHz channel with a second bandwidth, the first electronic device can continuously acquire the CAC results of the fourth electronic device and switch the channel of the Wi-Fi P2P connection based on the CAC results of the fourth electronic device. For example, the first electronic device can periodically send query requests to the fourth electronic device, and the fourth electronic device can respond by sending detection results to the first electronic device upon receiving the query requests. Upon receiving a second detection result, the first electronic device switches the channel of the Wi-Fi P2P connection from the 5GHz channel with a second bandwidth to the 5GHz channel with a first bandwidth. Optionally, after switching the channel of the Wi-Fi P2P connection from the 5GHz channel with a second bandwidth to the 5GHz channel with a first bandwidth, the first electronic device can continuously acquire the CAC results of the fourth electronic device. Upon receiving a third detection result, the first electronic device switches the channel of the Wi-Fi P2P connection from the 5GHz channel with a first bandwidth to the 5GHz channel with a second bandwidth.

[0211] The preceding text, in conjunction with Figures 8 and 9, described how the first electronic device obtains the CAC result of the DFS channel of the fourth electronic device before establishing a Wi-Fi P2P connection with the third electronic device, and obtains a detection result regarding the availability of the DFS channel based on the CAC result. Subsequently, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through different channels based on the DFS channel availability detection result.

[0212] Optionally, before establishing a Wi-Fi P2P connection with the third electronic device, the first electronic device obtains the CAC result of its DFS channel and obtains a detection result as to whether the DFS channel is available based on the CAC result of the DFS channel.

[0213] Figure 10 illustrates another method for establishing a Wi-Fi P2P connection according to an embodiment of this application. The method includes:

[0214] S41, the first electronic device establishes a communication connection with at least one second electronic device.

[0215] S41 is the same as S1, so it will not be repeated here.

[0216] S42, the first electronic device performs CAC on the DFS channel periodically in the first cycle while the screen is on.

[0217] That is, the first electronic device performs CAC on the DFS channel periodically in the screen-on state for a first cycle. Optionally, S42 can also be: the first electronic device performs CAC on the DFS channel periodically in the first cycle.

[0218] S43, receive first operation.

[0219] S41 is the same as S4, so it will not be repeated here.

[0220] At the moment of receiving the first operation, i.e. the first moment, the duration of continuous CAC detection of the DFS channel by the first electronic device may be greater than or equal to 60 seconds. In this case, the first electronic device can determine whether the DFS channel is available based on the CAC detection result of the first electronic device, such as the electronic device can execute S44-S45.

[0221] S44, in response to the first operation, if the result of CAC on the DFS channel within a preset time period before the first moment is that no radar signal is detected, a Wi-Fi P2P connection is established with the third electronic device through the 5GHz channel of the first bandwidth.

[0222] The CAC result is used to indicate that the DFS channel is available, and the first electronic device can establish a Wi-Fi P2P connection with the third electronic device through the 5GHz channel with the first bandwidth.

[0223] S45, in response to the first operation, if the result of CAC on the DFS channel within a preset time period before the first moment is that a radar signal is detected, a Wi-Fi P2P connection is established with the third electronic device through the second bandwidth 5GHz channel.

[0224] The CAC result is used to indicate that the DFS channel is unavailable, and the first electronic device can establish a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0225] Optionally, at the first moment, the continuous detection duration of CAC on the DFS channel by the first electronic device may be less than a preset duration, and no radar signal is detected. In this case, the first electronic device can obtain the CAC result of the DFS channel of the fourth electronic device. Then, based on the CAC result of the DFS channel of the fourth electronic device, a detection result indicating whether the DFS channel is available is obtained. That is, if the CAC performed by the first electronic device on the DFS channel has not reached the preset duration, and the results of the CAC performed so far show no radar signal detected, the first electronic device can execute the method shown in Figure 8 or Figure 9 to obtain the CAC result of the DFS channel from the fourth electronic device. Optionally, in this embodiment, upon receiving the fifth detection result, the first electronic device can compare the first duration with the continuous detection duration of CAC on the DFS channel by the first electronic device (referred to as the fourth duration). If the first duration is greater than or equal to the fourth duration, the first electronic device performs CAC on the DFS channel for a second duration, and based on the result of the CAC for the second duration, establishes a Wi-Fi P2P connection with the third electronic device through a different channel. If the first duration is less than the fourth duration, the first electronic device performs a fifth duration of CAC detection on the DFS channel and establishes a Wi-Fi P2P connection with the third electronic device through a different channel based on the result of the fifth duration of CAC. The sum of the fifth and fourth durations is a preset duration. For example, with a preset duration of 60 seconds, at the first moment, the first electronic device performs a fourth duration of CAC on the DFS channel, such as 40 seconds, and does not detect a radar signal. In response to the first operation, the first electronic device sends a query request to the fourth electronic device. In response to the query request, the fourth electronic device sends a fifth detection result to the first electronic device. For example, the fifth detection result indicates that no radar signal was detected within the first duration, such as 50 seconds, before the first moment. The first electronic device can also perform only a second duration of CAC, such as 10 seconds, and establish a Wi-Fi P2P connection with the third electronic device through a different channel based on the result of the 10-second CAC. For example, the fifth detection result indicates that no radar signal was detected within the first duration, such as 30 seconds, before the first moment. The first electronic device can perform a fifth CAC for a duration of 20 seconds, and based on the detection result of the 20-second CAC, establish a Wi-Fi P2P connection with the third electronic device through different channels.

[0226] Optionally, if the communication system comprising the first and second electronic devices further includes a wireless access device, in response to the first operation, before establishing a Wi-Fi P2P connection with the third electronic device, the first electronic device obtains information about the working channel of the wireless access device, and based on this information, obtains a detection result indicating whether the DFS channel is available. Based on this detection result, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through a different channel. For example, if the working channel information indicates that the working channel is a DFS channel, the detection result indicates that the DFS channel is available. If the working channel information indicates that the working channel is not a DFS channel, the detection result indicates that the DFS channel is unavailable. In other words, if the working channel is a DFS channel, the detection result indicates that the DFS channel is available. If the working channel is not a DFS channel, the detection result indicates that the DFS channel is unavailable.

[0227] The wireless access device can be a router. For example, a router can transmit 2.4GHz Wi-Fi signals or 5GHz Wi-Fi signals. After powering on, the router operates on the 5GHz channel of the first bandwidth, or, before switching from the 2.4GHz channel to the 5GHz channel of the first bandwidth, it can perform CAC (Content Acquisition and Control). If the router detects that the DFS (Distributed Fibre Channel) is available, it will operate on the 5GHz channel of the first bandwidth and transmit signals using that channel. If the router detects that the 5GHz channel of the first bandwidth is unavailable, it will operate on the 2.4GHz channel and transmit signals using that channel. Optionally, some routers can also operate on the 5GHz channel of the second bandwidth if the 5GHz channel of the first bandwidth is unavailable.

[0228] The following description refers to Figure 11, which illustrates another method for establishing a Wi-Fi P2P connection according to an embodiment of this application. This method includes:

[0229] S51, the first electronic device establishes a communication connection with at least one second electronic device.

[0230] S52, receive the first operation.

[0231] S53, in response to the first operation, obtains information about the operating channel of the wireless access device.

[0232] The first electronic device may or may not establish a communication connection with the wireless access device. Correspondingly, the first electronic device can obtain information about the operating channel of the wireless access device in two ways.

[0233] One method involves the first electronic device sending a query request to the wireless access device to obtain information about the wireless access device's operating channel. In response to the query request, the wireless access device sends its operating channel information back to the first electronic device. Another method involves receiving a broadcast from the wireless access device that includes information about the wireless access device's operating channel.

[0234] Channel information may include, for example, the frequency band and the channel number.

[0235] S54, the first electronic device identifies whether the working channel of the wireless access device is the DFS channel.

[0236] The first electronic device identifies whether the channel is a 5GHz channel of the first bandwidth based on the information of the wireless access device's operating channel.

[0237] S55, when the wireless access device operates on the DFS channel, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the 5GHz channel of the first bandwidth.

[0238] When the wireless access device operates on the DFS channel, indicating that the DFS channel is available, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the 5GHz channel of the first bandwidth.

[0239] S56, the first electronic device transmits service data to the third electronic device based on a 5GHz channel with a first bandwidth.

[0240] S57, when the wireless access device is not operating on the DFS channel, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0241] If the wireless access device is not operating on the DFS channel, indicating that the DFS channel is unavailable, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel.

[0242] S58, the first electronic device transmits service data to the third electronic device based on the second bandwidth 5GHz channel.

[0243] For example, if the wireless access device operates on a 5GHz channel with a second bandwidth, indicating that the DFS channel is unavailable, the first electronic device connects to the third electronic device via a 5GHz channel with a second bandwidth using Wi-Fi P2P. As another example, if the wireless access device operates on a 2.5GHz channel, indicating that the DFS channel is unavailable, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device via a 5GHz channel with a second bandwidth.

[0244] Optionally, if the communication system consisting of the first electronic device and the second electronic device also includes a wireless access device, the first electronic device may not perform CAC initially, and may not execute the method steps after S22 or S32 in Figure 8 or Figure 9. In response to the first operation, the first electronic device can directly obtain information about the working channel of the wireless access device. Based on the working channel of the wireless access device, the first electronic device establishes a Wi-Fi P2P connection with the third electronic device through different channels. Furthermore, after establishing a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel, the first electronic device can begin performing CAC on the DFS channel and switch the channel of the Wi-Fi P2P connection based on the CAC result. Refer to the preceding description; further details are omitted here. Alternatively, after establishing a Wi-Fi P2P connection with the third electronic device through the second bandwidth 5GHz channel, the first electronic device can continue to obtain information about the working channel of the wireless access device. For example, the first electronic device can periodically obtain information about the working channel of the wireless access device. When the wireless access device operates on a 5GHz channel with a first bandwidth, the first electronic device switches the channel of the Wi-Fi P2P connection from a 5GHz channel with a second bandwidth to a 5GHz channel with a first bandwidth.

[0245] Optionally, if the communication system consisting of the first and second electronic devices also includes a wireless access device, the first electronic device can also perform CAC (Continuous Access Control). If, at a first moment, the first electronic device's continuous detection time for CAC on the DFS channel is less than a preset time and no radar signal is detected, the first electronic device does not know whether the DFS channel is available because its detection time is less than the preset time. In this case, the first electronic device can obtain information about the working channel of the wireless access device and establish a Wi-Fi P2P connection with the third electronic device through a different channel based on this information.

[0246] Optionally, when the communication system consisting of the first and second electronic devices includes a wireless access device, the first electronic device can execute the method shown in Figure 8 or Figure 9 to obtain the CAC result of the fourth electronic device on the DFS channel, and establish a Wi-Fi P2P connection with the third electronic device through different channels based on the CAC result of the fourth electronic device on the DFS channel. Optionally, when the first electronic device receives the first detection result, since the first detection result indicates that the fourth electronic device has not performed CAC, the first electronic device can obtain the information of the working channel of the wireless access device, and establish a Wi-Fi P2P connection with the third electronic device through different channels based on the information of the working channel of the wireless access device, as described above, and will not be repeated here.

[0247] Optionally, if the first electronic device receives the fifth detection result, since the fifth detection result indicates that the fourth electronic device did not detect a radar signal within a first duration before the first moment, and since the first duration is less than a preset duration, the first electronic device also cannot determine whether the DFS channel is available. In this case, the first electronic device can also obtain information about the working channel of the wireless access device and establish a Wi-Fi P2P connection with the third electronic device through different channels based on the information about the working channel of the wireless access device.

[0248] As can be seen, the method for establishing a Wi-Fi P2P connection provided in this application embodiment allows a first electronic device to quickly respond to a user's first operation by utilizing the CAC results of other electronic devices. When the DFS channel is available, a Wi-Fi P2P connection is established with a third electronic device on a 5GHz channel with a first bandwidth. This not only improves response speed but also increases the transmission rate of service data.

[0249] Figure 12 is a schematic diagram of another method for establishing a Wi-Fi P2P connection provided in an embodiment of this application. The method shown in Figure 12 is applied to a fourth electronic device. The method includes:

[0250] S61, the fourth electronic device establishes a communication connection with the first electronic device.

[0251] The communication connection can be a wired communication connection or a wireless communication connection.

[0252] S62, Instruction information sent from the first electronic device to the fourth electronic device.

[0253] This instruction information is used to instruct the first electronic device to periodically perform CAC on the DFS channel in a first cycle.

[0254] S63, in response to the instruction information, the fourth electronic device periodically performs CAC on the DFS channel in the first cycle.

[0255] Optionally, S63 can also be: in response to the indication information, periodically perform CAC on the DFS channel in the screen-on state for a first cycle.

[0256] S64, the first electronic device sends a query request to the fourth electronic device.

[0257] This query request is used to obtain the channel validity detection results of the DFS channel by the fourth electronic device within a preset time period prior to the first time. In response to this query request, the first electronic device takes the time when it receives the query request as the first time and sends the CAC result to the first electronic device based on its own situation.

[0258] S65, in response to the query request, sends the result of CAC to the first electronic device.

[0259] As discussed above, at the first moment, the fourth electronic device may be in different states. For example, the fourth electronic device may not be performing CAC. Alternatively, the fourth electronic device may be performing CAC, and the detection duration may be greater than or equal to a preset duration. Or, the fourth electronic device may be performing CAC, and the detection duration may be less than the preset duration. In these cases, the CAC results sent by the fourth electronic device (such as the first detection result, second detection result, third detection result, fourth detection result, and fifth detection result) are used to indicate the CAC result of the DFS channel within a third duration prior to the first moment. This third duration is less than or equal to the preset duration, and is greater than or equal to 0. A third duration of 0 indicates that the fourth electronic device has not performed CAC. In this embodiment, the third duration prior to the first moment can be understood as the third duration preceding the first moment.

[0260] The fourth electronic device can continuously and periodically perform CAC on the DFS channel, providing the first electronic device with the CAC result whenever the first electronic device needs the detection result of whether the DFS channel is available. In this way, the first electronic device can obtain the CAC result promptly without performing CAC for a preset duration, improving the response speed of the first electronic device and thus enhancing the user experience.

[0261] This application provides a wireless communication system, including a first electronic device and at least one second electronic device; the first electronic device establishes a communication connection with at least one second electronic device; the at least one second electronic device includes a third electronic device and a fourth electronic device; the first electronic device is used to perform various functions or steps in the above method embodiments and the fourth electronic device is used to perform various functions or steps in the above method embodiments; the third electronic device is used to establish a Wi-Fi P2P connection with the first electronic device and perform collaborative services based on the Wi-Fi P2P connection.

[0262] This application provides an electronic device, which includes a memory and one or more processors. The memory stores computer program code. The computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can perform various functions or steps performed by the mobile phone in the above method embodiments. The structure of this electronic device can be referred to the structure of the electronic device 300 shown in FIG3.

[0263] This application also provides a computer storage medium that includes computer instructions. When the computer instructions are executed on the electronic device (electronic device 300 as shown in FIG3), the electronic device causes the electronic device to perform the various functions or steps in the above method embodiments.

[0264] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps described in the above method embodiments.

[0265] This application also provides a chip system including at least one processor and at least one interface circuit. The processor and the interface circuit are interconnected via lines. For example, the interface circuit can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit can be used to send signals to other devices (e.g., the processor). Exemplarily, the interface circuit can read instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application does not specifically limit this.

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

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

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

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

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

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

Claims

1. A method for establishing a Wi-Fi P2P connection, characterized in that, Applied to a first electronic device, the method includes: Establish a communication connection with at least one second electronic device; Receive a first operation for triggering the first electronic device and the third electronic device to perform collaborative services, wherein the third electronic device is one of the at least one second electronic device; In response to the first operation, obtain the detection result of whether the DFS channel is available; If the detection result indicates that the DFS channel is available, a Wi-Fi P2P connection is established with the third electronic device through a 5GHz channel of a first bandwidth, the 5GHz channel of the first bandwidth including the DFS channel.

2. The method according to claim 1, characterized in that, The method further includes: If the detection result indicates that the DFS channel is unavailable, a Wi-Fi P2P connection is established with the third electronic device through a 5GHz channel with a second bandwidth, the second bandwidth being smaller than the first bandwidth, and the 5GHz channel of the second bandwidth not including the DFS channel.

3. The method according to claim 1 or 2, characterized in that, Before receiving the first operation for triggering the first electronic device and the third electronic device to perform collaborative services, the method further includes: The DFS channel is periodically tested for channel validity. The detection result is the result of the first electronic device detecting the channel validity of the DFS channel within a preset time period before the first moment, where the first moment is the moment when the first operation is received. If no radar signal is detected during channel validity checks of the DFS channel within a preset time period prior to the first moment, the detection result indicates that the DFS channel is available; if a radar signal is detected during channel validity checks of the DFS channel within a preset time period prior to the first moment, the detection result indicates that the DFS channel is unavailable.

4. The method according to claim 1 or 2, characterized in that, The step of obtaining the detection result of whether the DFS channel is available includes: A query request is sent to a fourth electronic device, the query request being used to request the result of the fourth electronic device's channel validity detection of the DFS channel within a preset time period before the first moment, the fourth electronic device being one of the at least one second electronic device, and the first moment being the moment when the first operation is received; Receive the channel validity detection result from the fourth electronic device; The detection result is obtained based at least on the result of the channel validity detection.

5. The method according to claim 4, characterized in that, The channel validity detection result is used to indicate that no radar signal was detected in the channel validity detection of the DFS channel within a preset time period before the first time moment, and the detection result is used to indicate that the DFS channel is available; the channel validity detection result is used to indicate that a radar signal was detected in the channel validity detection of the DFS channel within a preset time period before the first time moment, and the detection result is used to indicate that the DFS channel is unavailable.

6. The method according to claim 4 or 5, characterized in that, The channel validity detection result is used to indicate that no radar signal was detected in the channel validity detection of the DFS channel within a first duration before the first moment, and the first duration is less than the preset duration; Based at least on the results of the channel validity detection, the detection results are obtained, including: In response to the result of the channel validity detection, a second duration of channel validity detection is performed on the DFS channel, the sum of the second duration and the first duration being the preset duration; The detection result is determined based on the result of the channel validity detection performed on the DFS channel for a second duration; Wherein, if no radar signal is detected in the channel validity detection of the DFS channel during the second time period, the detection result is that the DFS channel is available; if a radar signal is detected in the channel validity detection of the DFS channel during the second time period, the detection result is that the DFS channel is unavailable.

7. The method according to claim 6, characterized in that, The result of the channel validity detection is used to indicate that the channel validity detection result of the DFS channel within a first time period before the first moment is that a radar signal was detected, and the detection result is used to indicate that the DFS channel is unavailable.

8. The method according to any one of claims 4-7, characterized in that, The result of the channel validity detection is used to indicate that the fourth electronic device did not perform channel validity detection; Based at least on the results of the channel validity detection, the detection results are obtained, including: In response to the result of the channel validity detection, information about the operating channel of the wireless access device is obtained; The detection result is determined based on the information of the working channel; Wherein, if the information of the working channel indicates that the working channel is the DFS channel, the detection result is that the DFS channel is available; if the information of the working channel indicates that the working channel is not the DFS channel, the detection result is that the DFS channel is unavailable.

9. The method according to any one of claims 4-8, characterized in that, Before sending the query request to the fourth electronic device, the method further includes: It is determined that the channel validity detection performed by the first electronic device on the DFS channel has not reached the preset duration, and the result of the channel validity detection performed is that no radar signal was detected.

10. The method according to any one of claims 4-9, characterized in that, The fourth electronic device is specifically one of the at least one second electronic device that satisfies one or more of the following conditions: It has the capability to detect channel validity; The remaining battery power is greater than the threshold; Its wireless communication capability is greater than that of other secondary electronic devices.

11. The method according to any one of claims 2-10, characterized in that, After establishing a Wi-Fi P2P connection with the third electronic device via a 5GHz channel with a second bandwidth, the method further includes: The DFS channel is periodically tested for channel validity. If the channel validity detection result of the DFS channel within a preset time period indicates that no radar signal is detected, the channel of the Wi-Fi P2P connection will be switched from the second bandwidth 5GHz channel to the first bandwidth 5GHz channel.

12. The method according to claim 11, characterized in that, The collaborative service meets one or more of the following conditions: The amount of data exceeds the threshold; It is a latency-sensitive service and the latency is greater than the threshold.

13. A method for establishing a Wi-Fi P2P connection, characterized in that, Applied to a fourth electronic device, the method includes: A query request is received from the first electronic device. The query request is used to request the result of the channel validity detection of the DFS channel by the fourth electronic device within a preset time period before the first moment. The first moment is the moment when the first electronic device receives the operation that triggers the cooperative service. The channel validity detection result is sent to the first electronic device; the channel validity detection result is used by the first electronic device to establish a Wi-Fi P2P connection with other electronic devices. The result of the channel validity detection is used to indicate the result of the channel validity detection of the DFS channel within a third time period before the first time, wherein the third time period is less than or equal to the preset time period.

14. The method according to claim 13, characterized in that, Before receiving a query request from the first electronic device, the method further includes: Receive indication information from the first electronic device, the indication information being used to instruct channel validity detection of the DFS channel; In response to the indication information, the DFS channel is periodically checked for channel validity.

15. A wireless communication system, characterized in that, It includes a first electronic device and at least one second electronic device; the first electronic device establishes a communication connection with the at least one second electronic device; the at least one second electronic device includes a third electronic device and a fourth electronic device; the first electronic device is used to perform the method as described in any one of claims 1-12; The fourth electronic device is used to perform the method as described in any one of claims 13-14; the third electronic device is used to establish a Wi-Fi P2P connection with the first electronic device and to perform collaborative services based on the Wi-Fi P2P connection.

16. An electronic device, characterized in that, The electronic device includes: a memory, a wireless communication module, and one or more processors; the wireless communication module receives and transmits data according to the control of the processor to realize communication between the electronic device and other electronic devices; the memory is coupled to the processor; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1-14.

17. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-14.

18. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-14.