Method and electronic device for data transmission under Wi-Fi direct connection
By realizing Wi-Fi P2P connection multiplexing between GO devices and GC devices in the Wi-Fi P2P group, the problem of multiple Wi-Fi P2P service conflicts in the existing technology is solved and the normal transmission of multiple services is ensured. , improving user experience.
Patent Information
- Application Number
- CN202110745464.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-12-24
- Filing Date
- 2021-06-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-06-30
AI Technical Summary
Existing Wi-Fi P2P technology does not support multiple P2P roles on the same device, resulting in the inability to establish Wi-Fi P2P connections between GC devices in the same P2P group and between GC devices and devices outside the group, resulting in Multiple Wi-Fi P2P services conflict, affecting user experience.
By reusing Wi-Fi P2P connections between GO devices and GC devices in the P2P group, the number of services using the Wi-Fi P2P capability is counted, and the Wi-Fi P2P is removed when the number of services reaches 0. link to ensure that multiple services can be transmitted simultaneously.
It realizes the simultaneous coexistence of multiple Wi-Fi P2P services between devices in the P2P group, avoids business conflicts, improves user experience, and ensures the normal transmission of different services.
Smart Images

Figure CN114679732B_ABST
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the State Intellectual Property Office on December 24, 2020, with application number 202011555743.7 and application name “Method and electronic device for data transmission under Wi-Fi direct connection”, the entire contents of which are incorporated by reference in this application. Technical Field
[0002] The present application relates to the field of communications, and more specifically, to a method and electronic device for data transmission under Wi-Fi direct connection. Background Art
[0003] Wi-Fi Direct (wireless fidelity peer-to-peer, Wi-Fi P2P) technology is a wireless fidelity technology (wireless-fidelity, ) Alliance launched the "Wi-Fi DIRECT" standard protocol. Wi-Fi P2P can support two Wi-Fi devices to directly connect and communicate with each other without the intervention of a Wi-Fi hotspot.
[0004] A complete Wi-Fi P2P service includes three stages: Wi-Fi P2P device discovery, Wi-Fi P2P device connection, and Wi-Fi P2P device service data transmission. After the Wi-Fi P2P device connection is established, a P2P group is formed. Within the P2P group, devices are divided into two roles: P2P group owner (GO) and P2P group client (GC). According to current protocol specifications and device hardware limitations, current Wi-Fi P2P technology does not support multiple P2P roles on the same device. Therefore, Wi-Fi P2P devices cannot be established between GC devices in the same P2P group, and between GC devices and devices outside the group. In addition, Wi-Fi P2P applications (or services) on Android and WINDOWS systems currently manage Wi-Fi P2P links independently. The Wi-Fi P2P link on a device is managed and negotiated by each application independently. Due to resource limitations, only one Wi-Fi P2P underlying link will be generated. When a service occupies Wi-Fi P2P resources, when another Wi-Fi P2P-related service on the device also needs to use the Wi-Fi P2P link, there is no guarantee that the other Wi-Fi P2P-related service can be transmitted. For example, if there is a Wi-Fi P2P link established for the user's first service between two devices, if the user's second application between the two devices also needs to use the Wi-Fi P2P link, regardless of whether the second service is transmitted using the Wi-Fi P2P link, the Wi-Fi P2P link will be dismantled after the first service is transmitted. Therefore, there is no guarantee that the second service can be transmitted. This will lead to conflicts among multiple Wi-Fi P2P services, which seriously affects the user experience. Summary of the invention
[0005] The present application provides a method and electronic device for data transmission under Wi-Fi Direct connection, which can establish a transmission channel and transmit business data based on the Wi-Fi P2P connection within the P2P group between GC devices within the P2P group, or between GC devices within the P2P group and idle devices outside the P2P group, so that devices that can join the Wi-Fi P2P group can initiate connection and communication. In addition, by counting the number of services using Wi-Fi P2P capabilities on electronic devices, the Wi-Fi P2P link and Wi-Fi P2P group are dismantled only when the number of services using Wi-Fi P2P capabilities is 0, thereby solving the conflict problem between multiple Wi-Fi P2P services and improving the user experience.
[0006] In a first aspect, a method for data transmission under Wi-Fi Direct is provided, the method being applied to a system including a first electronic device and a second electronic device, the first electronic device being a GC device in a Wi-Fi Direct group, and the second electronic device being a GO device in the Wi-Fi Direct group; the method comprising: the first electronic device and the second electronic device transmitting data of a first service through a first Wi-Fi Direct link; the first electronic device receiving a first operation of a user, the first operation being used to send data of a second service to the second electronic device, the second service being different from the first service; the first electronic device sending the data of the second service to the second electronic device through the first Wi-Fi Direct link.
[0007] The first aspect provides a method for data transmission under Wi-Fi Direct, which multiplexes the Wi-Fi P2P connection of the second electronic device (GO device) and the first electronic device (GC device), so that the Wi-Fi P2P connection can transmit multiple different services at the same time, thereby realizing the coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, and improving the user experience. Different services will not affect each other, which improves the user experience.
[0008] For example, the first electronic device is a mobile phone B, the second electronic device is a large-screen device, the first service may be a screen projection service from the first electronic device to the second electronic device, and the second service may be a file sharing service from the first electronic device to the second electronic device.
[0009] According to the first aspect, in a possible implementation of the first aspect, after the first electronic device receives the first operation of the user, the method further includes: the first electronic device sends a Wi-Fi direct connection request to the second electronic device through the first connection, the Wi-Fi direct connection request including: information of the first electronic device, the Wi-Fi direct connection request is used to request to use the first Wi-Fi direct connection link to send data of the second service to the second electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the Wi-Fi direct connection request, the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends Wi-Fi direct connection request response information to the first electronic device, the Wi-Fi direct connection request response information including: group information of the Wi-Fi direct connection group and the IP address of the second electronic device; the first electronic device increases a reference count maintained by the first electronic device by one according to the Wi-Fi direct connection request response information, the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device. In this implementation, by multiplexing the Wi-Fi P2P capabilities of the second electronic device (GO device) and the first electronic device (GC device), the first electronic device and the second electronic device can sense that they are currently carrying multiple services. When any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after the multiple services are completed will the GO device be removed and the Wi-Fi P2P connection be disconnected, thereby ensuring that different services can be fully transmitted and completed, and multiple Wi-Fi P2P services between the first electronic device and the second electronic device can coexist at the same time, improving the user experience. Different services will not affect each other, improving the user experience.
[0010] According to the first aspect, or any implementation of the first aspect above, before the first electronic device sends a Wi-Fi direct connection request to the second electronic device, the method also includes: the first electronic device and the second electronic device establish the first connection, and the first connection includes: any one of a BLE connection, a Bluetooth connection, and a Wi-Fi connection.
[0011] According to the first aspect, or any implementation of the first aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: the second electronic device determines, based on the Wi-Fi direct connection request, that the first Wi-Fi direct connection link already exists between the second electronic device and the first electronic device. In this implementation, it can be ensured that the second service data is transmitted normally using the first Wi-Fi direct connection link.
[0012] According to the first aspect, or any implementation of the first aspect above, before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: the first electronic device determines that the first Wi-Fi direct link already exists between the second electronic device and the first electronic device. In this implementation, it can be ensured that the second service data is transmitted normally using the first Wi-Fi direct link.
[0013] According to the first aspect, or any implementation of the first aspect above, after the data transmission of the second service is completed or the data transmission of the first service is completed, the method also includes: the first electronic device subtracts one from the reference count maintained by the first electronic device; the second electronic device subtracts one from the reference count maintained by the second electronic device.
[0014] According to the first aspect, or any implementation of the first aspect above, when the reference count maintained by the second electronic device is 0, the third electronic device dismantles the Wi-Fi Direct group; or, when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the Wi-Fi Direct link with the second electronic device. In this implementation, by multiplexing the Wi-Fi P2P capabilities of the second electronic device (GO device) and the first electronic device (GC device), the first electronic device and the second electronic device can perceive that they are currently carrying multiple services, and when any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after the multiple services are completed, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be fully transmitted.
[0015] According to the first aspect, or any implementation of the first aspect above, the information of the first electronic device includes: at least one of: an identifier of the first electronic device, a current Wi-Fi Direct connection status of the first electronic device, a MAC address of a Wi-Fi Direct port of the first electronic device, a list of channels supported by the first electronic device, a frequency of a Wi-Fi hotspot to which the first electronic device is connected, and whether the first electronic device supports broadband.
[0016] According to the first aspect, or any implementation of the first aspect above, the system further includes a third electronic device, the third electronic device is an idle device outside the Wi-Fi Direct group, and after the data transmission of the second service is completed, the method further includes: the third electronic device receives a second operation of the user, the second operation is used to send data of the third service to the first electronic device; the third electronic device establishes a second Wi-Fi Direct link with the second electronic device; the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link; in response to receiving the data of the third service, the second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi Direct link. In this implementation, when the third electronic device (i.e., the idle device) outside the P2P group transmits service data to the first electronic device (i.e., the GC device) in the P2P group, a transmission channel can be established between the first electronic device (i.e., the GC device) in the P2P group and the third electronic device (i.e., the idle device) outside the P2P group, so as to realize the transmission of service data to the first electronic device through the second Wi-Fi Direct link and the first Wi-Fi Direct link, so as to realize the data transmission between the two based on the transmission channel.
[0017] Exemplarily, the transmission channel between the first electronic device (ie, the GC device) and the third electronic device (ie, the idle device) outside the P2P group is a socket transmission channel.
[0018] According to the first aspect, or any implementation of the first aspect above, before the third electronic device establishes the second Wi-Fi Direct link with the second electronic device, the method further includes: the first electronic device sends a third connection request to the second electronic device, the third connection request is used to request that the third electronic device be added to the Wi-Fi Direct group, and the third connection request includes information of the third electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the third connection request, and the reference count maintained by the third electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the third electronic device; the second electronic device sends third response information in response to the third connection request to the first electronic device, the third response information is used to indicate that the third electronic device is added to the Wi-Fi Direct group, and the third response information includes: an IP address assigned by the second electronic device to the third electronic device, group information of the Wi-Fi Direct group, and a MAC address of the third electronic device; the first electronic device increases a reference count maintained by the first electronic device by one according to the third response information, and the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device.
[0019] According to the first aspect, or any implementation of the first aspect above, before the first electronic device sends the third connection request to the second electronic device, the method also includes: the third electronic device and the first electronic device establish a second connection, and the second connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0020] According to the first aspect, or any implementation of the first aspect above, the method further includes: the third electronic device sends a fourth connection request to the first electronic device through the second connection, the fourth connection request includes information of the third electronic device; the first electronic device sends a fourth connection request response message to the third electronic device through the second connection, the fourth connection request response message includes: the IP address assigned by the second electronic device to the third electronic device, the group information of the Wi-Fi Direct group, the MAC address of the second electronic device, the IP address and port number of the first electronic device; in response to receiving the fourth connection request response message, the third electronic device establishes the second Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device. In this implementation, the third electronic device can join the P2P group according to the P2P group information and the MAC address of the second electronic device, so as to facilitate the establishment of a socket transmission channel with the first electronic device.
[0021] According to the first aspect, or any implementation of the first aspect above, before the second electronic device adds one to the reference count maintained by the first electronic device, the method further includes: the second electronic device determines that the third electronic device is a trusted device and determines that a Wi-Fi direct link exists between the second electronic device and the first electronic device according to the third connection request; before the first electronic device adds one to the reference count maintained by the first electronic device, the method further includes: the first electronic device determines that a Wi-Fi direct link exists between the first electronic device and the second electronic device according to the third response information. In this implementation, normal transmission of the third service data can be guaranteed.
[0022] According to the first aspect, or any implementation of the first aspect above, after the data transmission of the third service is completed, the method also includes: the first electronic device decrements the reference count maintained by the first electronic device by one; and the second electronic device decrements the reference count maintained by the second electronic device by one.
[0023] According to the first aspect, or any implementation of the first aspect above, the method further includes:
[0024] When the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group; or, when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the Wi-Fi Direct link with the second electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (i.e., GO device) in the P2P group are reused, and the first electronic device and the second electronic device can perceive that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other. When transmitting data, the second electronic device in the P2P group is used as a transfer. In addition, the transmission of services based on Wi-Fi P2P connections is realized, which solves the problem that GC devices in the P2P group and idle devices outside the P2P group cannot transmit data in the prior art, and improves the user experience.
[0025] According to the first aspect, or any implementation of the first aspect above, before the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link, the method further includes: the third electronic device sends a fifth connection request to the first electronic device through the second connection, the fifth connection request including: information of the third electronic device and an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group; the first electronic device increases a reference count maintained by the first electronic device by one according to the fifth connection request, and the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; the first electronic device sends a sixth connection request to the second electronic device, and the sixth connection request includes: information of the third electronic device and an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group; the second electronic device increases a reference count maintained by the second electronic device by one according to the sixth connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device. The second electronic device sends a sixth response message in response to the sixth connection request to the first electronic device, and the sixth response message includes: group information of the Wi-Fi Direct group, and at least one of indication information that the first electronic device and the third electronic device have Wi-Fi P2P connections with the second electronic device respectively; the first electronic device sends a fifth response message in response to the fifth connection to the third electronic device through the second connection, and the fifth response message includes: the IP address and port number of the first electronic device, and the identifier of the GO device connected to the first electronic device in the Wi-Fi Direct group; the third electronic device increases a reference count maintained by the third electronic device by one according to the fifth response message, and the reference count maintained by the third electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the third electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are multiplexed, and the first electronic device, the second electronic device, and the third electronic device can sense that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data is transmitted, the second electronic device in the P2P group is used as a transit. In addition, the transmission of services based on the Wi-Fi P2P connection is realized, which solves the problem that data cannot be transmitted between two GC devices in the P2P group in the prior art, and improves the user experience.
[0026] According to the first aspect, or any implementation of the first aspect above, before the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link, the method further includes: the third electronic device sends a seventh connection request to the second electronic device, the seventh connection request including information of the first electronic device; the second electronic device increases the reference count maintained by the second electronic device by one according to the seventh connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends seventh response information in response to the seventh connection request to the third electronic device, and the seventh response information includes: group information of the Wi-Fi Direct group, and at least one of indication information that the first electronic device and the third electronic device have Wi-Fi P2P connections with the second electronic device respectively; the third electronic device increases the reference count maintained by the third electronic device by one according to the seventh response information, and the reference count maintained by the third electronic device is used to indicate that the Wi-Fi P2P capability of the third electronic device is simultaneously used The number of services of P2P capability; the third electronic device sends an eighth connection request to the first electronic device through the second connection, and the eighth connection request includes: group information of the Wi-Fi direct group, and the identifier of the GO device connected to the third electronic device in the Wi-Fi direct group; the first electronic device increases the reference count maintained by the first electronic device by one according to the eighth connection request, and the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the first electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are reused, and the first electronic device, the second electronic device, and the third electronic device can perceive that the current Wi-Fi P2P capability of the first electronic device carries multiple services. After the multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data transmission is performed, the second electronic device in the P2P group is used as a transfer. Then, the transmission of services based on the Wi-Fi P2P connection is realized, which solves the problem that data cannot be transmitted between two GC devices in the P2P group in the prior art, and improves the user experience.
[0027] According to the first aspect, or any implementation of the first aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: the second electronic device determines that the third electronic device is a trusted device according to the sixth connection request, and determines that the third electronic device and the first electronic device are respectively connected to the second electronic device by Wi-Fi P2P; or, the second electronic device determines that the first electronic device is a trusted device according to the seventh connection request, and determines that the first electronic device and the third electronic device are respectively connected to the second electronic device by Wi-Fi P2P. In this implementation, the normal transmission of the third service data can be guaranteed.
[0028] According to the first aspect, or any implementation of the first aspect above, before the third electronic device increases the reference count maintained by the third electronic device by one, the method further includes: the third electronic device determines, based on the fifth response information, that the identifier of the GO device connected to the third electronic device in the Wi-Fi Direct group is the same as the identifier of the GO device connected to the first electronic device in the Wi-Fi Direct group; or, the third electronic device determines, based on the seventh response information, that the identifier of the GO device connected to the first electronic device in the Wi-Fi Direct group is the same as the identifier of the GO device connected to the third electronic device in the Wi-Fi Direct group. In this implementation, normal transmission of the third service data can be guaranteed.
[0029] According to the first aspect, or any implementation of the first aspect above, the method further includes: before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: the first electronic device determines, based on the sixth response information or the eighth connection request, that the identifier of the GO device connected to the first electronic device in the Wi-Fi Direct group is the same as the identifier of the GO device connected to the third electronic device in the Wi-Fi Direct group.
[0030] According to the first aspect, or any implementation of the first aspect above, after the data transmission of the third service is completed, the method also includes: the first electronic device subtracts one from the reference count maintained by the first electronic device; the second electronic device subtracts one from the reference count maintained by the second electronic device; and the third electronic device subtracts one from the reference count maintained by the third electronic device.
[0031] According to the first aspect, or any implementation of the first aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group; or, when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the first Wi-Fi Direct link between the first electronic device and the second electronic device; or, when the reference count maintained by the third electronic device is 0, the third electronic device disconnects the second Wi-Fi Direct link between the third electronic device and the second electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are reused, and the first electronic device, the second electronic device, and the third electronic device can perceive that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other.
[0032] According to the first aspect, or any implementation of the first aspect above, the information of the third electronic device includes: at least one of: an identifier of the third electronic device, a current Wi-Fi Direct connection status of the third electronic device, a MAC address of a Wi-Fi Direct port of the third electronic device, a list of channels supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband.
[0033] According to the first aspect, or any implementation of the first aspect above, the system also includes a fourth electronic device, which is an idle device outside the Wi-Fi Direct group, and the method also includes: the fourth electronic device receives a third operation of the user, and the third operation is used to send data of a fourth service to the second electronic device; the fourth electronic device establishes a third Wi-Fi Direct link with the second electronic device; and the fourth electronic device sends the data of the fourth service to the second electronic device through the third Wi-Fi Direct link.
[0034] According to the first aspect, or any implementation of the first aspect above, before the fourth electronic device establishes a third Wi-Fi Direct link with the second electronic device, the method further includes: the fourth electronic device sends a ninth connection request to the second electronic device through the third connection, the ninth connection request is used to request that the fourth electronic device be added to the Wi-Fi Direct group, and the ninth connection request includes information of the fourth electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the ninth connection request, the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends ninth response information in response to the ninth connection request to the fourth electronic device through the third connection, the ninth response information is used to indicate that the fourth electronic device is added to the Wi-Fi Direct group, and the ninth response information includes: an IP address assigned by the second electronic device to the fourth electronic device, group information of the Wi-Fi Direct group, and a MAC address of the second electronic device; the fourth electronic device establishes the third Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device. In this implementation, the fourth electronic device can join the P2P group according to the P2P group information and the MAC address of the second electronic device, and establish a Wi-Fi P2P connection with the second electronic device. In addition, by multiplexing the Wi-Fi P2P capability of the second electronic device (GO device), the second electronic device can sense that it currently carries multiple services, and when any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after multiple services are completed will the GO device be removed and the Wi-Fi P2P connection be disconnected, thereby ensuring that different services can be fully transmitted.
[0035] According to the first aspect, or any implementation of the first aspect above, before the fourth electronic device makes a ninth connection request to the second electronic device through the third connection, the method also includes: the fourth electronic device and the second electronic device establish the third connection, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0036] According to the first aspect, or any implementation of the first aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: the second electronic device determines that the fourth electronic device is a trusted device according to the ninth connection request, and determines that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device. In this implementation, it can be ensured that the fourth electronic device can smoothly establish a Wi-Fi P2P connection with the second electronic device, and the normal transmission of the fourth service data can be ensured.
[0037] According to the first aspect, or any implementation of the first aspect above, after the data transmission of the fourth service is completed, the method further includes: the second electronic device decrements a reference count maintained by the second electronic device by one.
[0038] According to the first aspect, or any implementation of the first aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group. In this implementation, by reusing the Wi-Fi P2P capability of the second electronic device (GO device), when any of the services is disconnected, the P2P group will not be actually removed and the Wi-Fi P2P connection will not be disconnected. Only after multiple services are completed, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be fully transmitted.
[0039] According to the first aspect, or any implementation of the first aspect above, it is characterized in that the information of the fourth electronic device includes: at least one of: an identifier of the fourth electronic device, a current Wi-Fi direct connection status of the fourth electronic device, a MAC address of a Wi-Fi direct port of the fourth electronic device, a list of channels supported by the fourth electronic device, a frequency of a Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports broadband.
[0040] In a second aspect, a method for data transmission under Wi-Fi Direct is provided, the method comprising: a second electronic device and a second electronic device transmit data of a first service through a first Wi-Fi Direct link; the second electronic device receives data of a second service sent by the first electronic device through the first Wi-Fi Direct link, the first electronic device is a GC device in a Wi-Fi Direct group, the second electronic device is a GO device in the Wi-Fi Direct group, and the second service is different from the first service.
[0041] The second aspect provides a method for data transmission under Wi-Fi Direct, which multiplexes the Wi-Fi P2P connection of the second electronic device (GO device) and the first electronic device (GC device), so that the Wi-Fi P2P connection can transmit multiple different services at the same time, thereby realizing the coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, and improving the user experience. Different services will not affect each other, which improves the user experience.
[0042] According to the second aspect, in a possible implementation manner of the second aspect, before the second electronic device receives data of a second service sent by the first electronic device through the first Wi-Fi direct link, the method includes: the second electronic device receives a Wi-Fi direct request sent by the first electronic device through the first connection, the Wi-Fi direct request including: information of the first electronic device, the Wi-Fi direct request being used to request to use the first Wi-Fi direct link to send data of the second service to the second electronic device; the second electronic device increments a reference count maintained by the second electronic device according to the Wi-Fi direct request, the reference count maintained by the second electronic device being used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends Wi-Fi direct request response information to the first electronic device, the Wi-Fi direct request response information including: group information of the Wi-Fi direct group and the IP address of the second electronic device. In this implementation, by multiplexing the Wi-Fi P2P capability of the second electronic device (GO device), the second electronic device can sense that it currently carries multiple services. When any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after the multiple services are completed will the GO device be removed and the Wi-Fi P2P connection be disconnected, thereby ensuring that different services can be fully transmitted and completed, and multiple Wi-Fi P2P services between the first electronic device and the second electronic device can coexist at the same time, improving the user experience. Different services will not affect each other, improving the user experience.
[0043] According to the second aspect, or any implementation of the second aspect above, before the second electronic device receives the Wi-Fi direct connection request sent by the first electronic device, the method also includes: the second electronic device and the first electronic device establish the first connection, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0044] According to the second aspect, or any implementation of the second aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: the second electronic device determines, based on the Wi-Fi direct connection request, that the first Wi-Fi direct connection link already exists between the second electronic device and the first electronic device. In this implementation, it can be ensured that the second service data is transmitted normally using the first Wi-Fi direct connection link.
[0045] According to the second aspect, or any implementation of the second aspect above, after the data transmission of the second service is completed or the data transmission of the first service is completed, the method further includes: the second electronic device decrements a reference count maintained by the second electronic device by one.
[0046] According to the second aspect, or any implementation of the second aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the third electronic device dismantles the Wi-Fi Direct group. In this implementation, by reusing the Wi-Fi P2P capability of the second electronic device (GO device), the first electronic device and the second electronic device can perceive that they are currently carrying multiple services, and when any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after the multiple services are completed, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be fully transmitted.
[0047] According to the second aspect, or any implementation of the second aspect above, the information of the first electronic device includes: at least one of: an identifier of the first electronic device, a current Wi-Fi Direct connection status of the first electronic device, a MAC address of a Wi-Fi Direct port of the first electronic device, a list of channels supported by the first electronic device, a frequency of a Wi-Fi hotspot to which the first electronic device is connected, and whether the first electronic device supports broadband.
[0048] According to the second aspect, or any implementation of the second aspect above, after the data transmission of the second service is completed, the method further includes: the second electronic device and the third electronic device establish a second Wi-Fi direct link, the third electronic device is an idle device outside the Wi-Fi direct group; the second electronic device receives the data of the third service sent by the third electronic device through the second Wi-Fi direct link; the second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi direct link. In this implementation, when the third electronic device (i.e., the idle device) outside the P2P group transmits service data to the first electronic device (i.e., the GC device) in the P2P group, the second electronic device can assist in establishing a transmission channel between the first electronic device (i.e., the GC device) in the P2P group and the third electronic device (i.e., the idle device) outside the P2P group, so as to transmit service data to the first electronic device through the second Wi-Fi direct link and the first Wi-Fi direct link, and realize data transmission between the two based on the transmission channel.
[0049] According to the second aspect, or any implementation of the second aspect above, before the second electronic device and the third electronic device establish a second Wi-Fi Direct link, the method further includes: the second electronic device receives a third connection request sent by the first electronic device, the third connection request is used to request that the third electronic device be added to the Wi-Fi Direct group, and the third connection request includes information of the third electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the third connection request, and the reference count maintained by the third electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the third electronic device; the second electronic device sends third response information in response to the third connection request to the first electronic device, the third response information is used to indicate that the third electronic device is added to the Wi-Fi Direct group, and the third response information includes: an IP address assigned by the second electronic device to the third electronic device, group information of the Wi-Fi Direct group, and a MAC address of the third electronic device.
[0050] According to the second aspect, or any implementation of the second aspect above, before the second electronic device increases the reference count maintained by the third electronic device by one, the method further includes: the second electronic device determines that the third electronic device is a trusted device according to the third connection request, and determines that a Wi-Fi direct link exists between the second electronic device and the first electronic device. In this implementation, normal transmission of the third service data can be guaranteed.
[0051] According to the second aspect, or any implementation of the second aspect above, after the data transmission of the third service is completed, the method further includes: the second electronic device decrements a reference count maintained by the second electronic device by one.
[0052] According to the second aspect, or any implementation of the second aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi direct group. In this implementation, the Wi-Fi P2P capability of the second electronic device (i.e., GO device) in the P2P group is reused, and the second electronic device can perceive that its current Wi-Fi P2P capability carries multiple services. After multiple services are completed, the P2P group will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other. When transmitting data, the second electronic device in the P2P group is used as a transfer. In addition, the transmission of services based on the Wi-Fi P2P connection is realized, which solves the problem that GC devices in the P2P group and idle devices outside the P2P group cannot transmit data in the prior art, and improves the user experience.
[0053] According to the second aspect, or any implementation of the second aspect above, before the second electronic device receives data of the third service sent by the third electronic device through the second Wi-Fi Direct link, the method also includes: the first electronic device sends a sixth connection request to the second electronic device, and the sixth connection request includes: information of the third electronic device and an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group; the second electronic device increases a reference count maintained by the second electronic device by one according to the sixth connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a sixth response message in response to the sixth connection request to the first electronic device, and the sixth response message includes: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively. In this implementation, the Wi-Fi P2P capability of the second electronic device is reused, and the second electronic device can sense that its current Wi-Fi P2P capability carries multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data is transmitted, the second electronic device in the P2P group is used as a transit to achieve the transmission of services based on the Wi-Fi P2P connection, which solves the problem of data transmission failure between two GC devices in the P2P group in the prior art and improves the user experience.
[0054] According to the second aspect, or any implementation of the second aspect above, before the second electronic device receives data of the third service sent by the third electronic device through the second Wi-Fi Direct link, the method also includes: the second electronic device receives a seventh connection request sent by the third electronic device, the seventh connection request including information of the first electronic device; the second electronic device increases a reference count maintained by the second electronic device according to the seventh connection request, the reference count maintained by the second electronic device being used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; the second electronic device sends seventh response information in response to the seventh connection request to the third electronic device, the seventh response information including: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively.
[0055] According to the second aspect, or any implementation of the second aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method also includes: the second electronic device determines, based on the sixth connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the third electronic device and the first electronic device, respectively, and the second electronic device; or, the second electronic device determines, based on the seventh connection request, that the first electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device, respectively, and the second electronic device.
[0056] According to the second aspect, or any implementation of the second aspect above, after the data transmission of the third service is completed, the method further includes: the second electronic device decrements a reference count maintained by the second electronic device by one.
[0057] According to the second aspect, or any implementation of the second aspect above, when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group. In this implementation, it is ensured that different services can be transmitted normally and different services will not affect each other.
[0058] According to the second aspect, or any implementation of the second aspect above, the information of the third electronic device includes: at least one of: an identifier of the third electronic device, a current Wi-Fi Direct connection status of the third electronic device, a MAC address of a Wi-Fi Direct port of the third electronic device, a list of channels supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband.
[0059] According to the second aspect, or any implementation of the second aspect above, the method also includes: the second electronic device establishes a third Wi-Fi direct link with the fourth electronic device, and the fourth electronic device is an idle device outside the Wi-Fi direct group; the second electronic device receives data of a fourth service sent by the fourth electronic device through the third Wi-Fi direct link.
[0060] According to the second aspect, or any implementation of the second aspect above, before the second electronic device establishes a third Wi-Fi Direct link with the fourth electronic device, the method further includes: the second electronic device receives a ninth connection request sent by the fourth electronic device through the third connection, the ninth connection request is used to request the fourth electronic device to be added to the Wi-Fi Direct group, and the ninth connection request includes information of the fourth electronic device; the second electronic device increases the reference count maintained by the second electronic device by one according to the ninth connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a ninth response message in response to the ninth connection request to the fourth electronic device through the third connection, the ninth response message is used to indicate that the fourth electronic device is added to the Wi-Fi Direct group, and the ninth response message includes: the IP address assigned by the second electronic device to the fourth electronic device, the group information of the Wi-Fi Direct group, and the MAC address of the second electronic device. In this implementation, the fourth electronic device can join the P2P group according to the P2P group information and the MAC address of the second electronic device, and establish a Wi-Fi P2P connection with the second electronic device. Moreover, by multiplexing the Wi-Fi P2P capability of the second electronic device (GO device), the second electronic device can sense that it is currently carrying multiple services. When any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after multiple services are completed will the GO device be removed and the Wi-Fi P2P connection be disconnected, thereby ensuring that different services can be transmitted completely.
[0061] According to the second aspect, or any implementation of the second aspect above, before the second electronic device receives the ninth connection request sent by the fourth electronic device through the third connection, the method also includes: the second electronic device and the fourth electronic device establish the third connection, and the third connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0062] According to the second aspect, or any implementation of the second aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method also includes: the second electronic device determines, based on the ninth connection request, that the fourth electronic device is a trusted device, and determines that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device.
[0063] According to the second aspect, or any implementation of the second aspect above, after the data transmission of the fourth service is completed, the method further includes: the second electronic device decrements a reference count maintained by the second electronic device by one.
[0064] According to the second aspect, or any implementation of the second aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group. In this implementation, by reusing the Wi-Fi P2P capability of the second electronic device (GO device), when any of the services is disconnected, the P2P group will not be actually removed and the Wi-Fi P2P connection will not be disconnected. Only after multiple services are completed, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be fully transmitted.
[0065] According to the second aspect, or any implementation of the second aspect above, the information of the fourth electronic device includes: at least one of: an identifier of the fourth electronic device, a current Wi-Fi Direct connection status of the fourth electronic device, a MAC address of a Wi-Fi Direct port of the fourth electronic device, a list of channels supported by the fourth electronic device, a frequency of a Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports broadband.
[0066] In a third aspect, a method for data transmission under Wi-Fi Direct is provided, the method being applied to a system including a first electronic device, a second electronic device, and a third electronic device, the first electronic device being a first GC device in a Wi-Fi Direct group, the third electronic device being a second GC device in the Wi-Fi Direct group, and the second electronic device being a GO device in the Wi-Fi Direct group, the method comprising: the third electronic device receiving a second operation of a user, the second operation being used to send data of a first service to the first electronic device; the third electronic device sending the data of the first service to the second electronic device through a second Wi-Fi Direct link; in response to receiving the data of the first service, the second electronic device sending the data of the first service to the first electronic device through a first Wi-Fi Direct link, the first Wi-Fi Direct link being a Wi-Fi Direct link between the second electronic device and the first electronic device. The second Wi-Fi Direct link is a Wi-Fi Direct link between the second electronic device and the third electronic device.
[0067] The method provided in the third aspect, in this implementation, when the third electronic device (GC device) in the P2P group transmits service data to the first electronic device (another GC device) in the P2P group, a transmission channel between the first electronic device and the third electronic device in the P2P group can be established, and when data is transmitted, the second electronic device in the P2P group is used as a transfer. Then, the transmission of services based on Wi-Fi P2P connection is realized, which solves the problem that data cannot be transmitted between two GC devices in the P2P group in the prior art, and improves the user experience.
[0068] According to the third aspect, in a possible implementation manner of the third aspect, before the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi direct link, the method further includes: the third electronic device sends a first Wi-Fi direct request to the first electronic device through the first connection, the first Wi-Fi direct request including: information of the third electronic device and an identifier of a GO device connected to the third electronic device in the Wi-Fi direct group; the first electronic device increases a reference count maintained by the first electronic device by one according to the first Wi-Fi direct request, the reference count maintained by the first electronic device being used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the first electronic device; the first electronic device sends a first connection request to the second electronic device, the first connection request including: information of the third electronic device and an identifier of a GO device connected to the third electronic device in the Wi-Fi direct group; the second electronic device increases a reference count maintained by the second electronic device by one according to the first connection request, the reference count maintained by the second electronic device being used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device. The number of services with P2P capability; the second electronic device sends first response information in response to the first connection request to the first electronic device, the first response information including: group information of the Wi-Fi Direct group, and at least one of indication information that the third electronic device and the first electronic device have Wi-Fi P2P connections with the second electronic device respectively; the first electronic device sends first Wi-Fi Direct response information in response to the first Wi-Fi Direct request to the third electronic device through the first connection, the first Wi-Fi Direct response information including: an IP address of the first electronic device and an identifier of a GO device connected to the first electronic device in the Wi-Fi Direct group; the third electronic device increases a reference count maintained by the third electronic device by one according to the first Wi-Fi Direct response information, the reference count maintained by the third electronic device being used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the first electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are multiplexed, and the first electronic device, the second electronic device, and the third electronic device can sense that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data is transmitted, the second electronic device in the P2P group is used as a transit. In addition, the transmission of services based on the Wi-Fi P2P connection is realized, which solves the problem that data cannot be transmitted between two GC devices in the P2P group in the prior art, and improves the user experience.
[0069] According to the third aspect, or any implementation of the third aspect above, the method further includes: the third electronic device sends a second connection request to the second electronic device, the second connection request including information of the first electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the second connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a second response message in response to the second connection request to the third electronic device, the second response message including: at least one of group information of the Wi-Fi Direct group, and indication information that the third electronic device and the first electronic device respectively have a Wi-Fi P2P connection with the second electronic device; the third electronic device increases a reference count maintained by the third electronic device by one according to the second response message, and the reference count maintained by the third electronic device is used to indicate that the Wi-Fi Direct group is simultaneously utilized. The number of services of P2P capability; the third electronic device sends a second Wi-Fi direct connection request to the first electronic device through the first connection, and the second Wi-Fi direct connection request includes: group information of the Wi-Fi direct connection group, and the identifier of the GO device connected to the third electronic device in the Wi-Fi direct connection group; the first electronic device increases the reference count maintained by the first electronic device by one according to the second Wi-Fi direct connection request, and the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the first electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are reused, and the first electronic device, the second electronic device, and the third electronic device can perceive that the current Wi-Fi P2P capability of the first electronic device carries multiple services. After the multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data transmission is performed, the second electronic device in the P2P group is used as a transfer. This enables the transmission of services based on Wi-Fi P2P connections, solves the problem in the prior art that data cannot be transmitted between two GC devices in a P2P group, and improves user experience.
[0070] According to the third aspect, or any implementation manner of the third aspect above, the method further includes: before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: the first electronic device determines, based on the first Wi-Fi direct connection request or the second response information, that the identifier of the GO device connected to the third electronic device in the Wi-Fi direct connection group is the same as the identifier of the GO device connected to the first electronic device in the Wi-Fi direct connection group.
[0071] According to the third aspect, or any implementation of the third aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method also includes: the second electronic device determines, based on the first connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the third electronic device and the first electronic device and the second electronic device, respectively; or, the second electronic device determines, based on the second connection request, that the first electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively.
[0072] According to the third aspect, or any implementation manner of the third aspect above, before the third electronic device increases the reference count maintained by the third electronic device by one, the method also includes: the third electronic device determines, based on the first Wi-Fi direct response information, that an identifier of a GO device connected to the third electronic device in the Wi-Fi direct group is the same as an identifier of a GO device connected to the first electronic device in the Wi-Fi direct group; or, the third electronic device determines, based on the second response information, that an identifier of a GO device connected to the third electronic device in the Wi-Fi direct group is the same as an identifier of a GO device connected to the first electronic device in the Wi-Fi direct group.
[0073] According to the third aspect, or any implementation of the third aspect above, the method further includes: the third electronic device and the first electronic device establish a first connection, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0074] According to the third aspect, or any implementation of the third aspect above, after the data transmission of the first service is completed, the method also includes: the third electronic device reduces the reference count maintained by the third electronic device by one; the first electronic device reduces the reference count maintained by the first electronic device by one; the second electronic device reduces the reference count maintained by the second electronic device by one.
[0075] According to the third aspect, or any implementation of the third aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group; or, when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the second Wi-Fi Direct link between the first electronic device and the second electronic device; or, when the reference count maintained by the third electronic device is 0, the third electronic device disconnects the first Wi-Fi Direct link between the third electronic device and the second electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device are multiplexed, and the first electronic device, the second electronic device, and the third electronic device can perceive that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other.
[0076] According to the third aspect, or any implementation of the third aspect above, the information of the third electronic device includes: at least one of: an identifier of the third electronic device, a current Wi-Fi direct connection status of the third electronic device, a MAC address of a Wi-Fi direct port of the third electronic device, a list of channels supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband; or,
[0077] The information of the first electronic device includes at least one of: an identification of the first electronic device, a current Wi-Fi Direct connection status of the first electronic device, a MAC address of a Wi-Fi Direct port of the first electronic device, a channel list supported by the first electronic device, a frequency of a Wi-Fi hotspot to which the first electronic device is connected, and whether the first electronic device supports broadband.
[0078] In a fourth aspect, a method for data transmission under Wi-Fi Direct is provided, the method being applied to a system including a first electronic device, a second electronic device, and a third electronic device, the third electronic device being an idle device outside a Wi-Fi Direct group, the first electronic device being a GC device within the Wi-Fi Direct group, and the second electronic device being a GO device within the Wi-Fi Direct group, the method comprising: the third electronic device receiving a first operation of a user, the first operation being used to send data of a first service to the first electronic device; in response to the first operation, the third electronic device establishing a first Wi-Fi Direct link with the second electronic device; the third electronic device sending the data of the first service to the second electronic device through a second Wi-Fi Direct link; in response to receiving the data of the first service, the second electronic device sending the data of the first service to the first electronic device through the first Wi-Fi Direct link, the first Wi-Fi Direct link being a Wi-Fi Direct link between the second electronic device and the first electronic device. The second Wi-Fi Direct link is a Wi-Fi Direct link between the second electronic device and the third electronic device.
[0079] The method provided in the fourth aspect, in this implementation, when a third electronic device (i.e., an idle device) outside the P2P group transmits business data to a first electronic device (i.e., a GC device) within the P2P group, the second electronic device can assist in establishing a transmission channel between the first electronic device (i.e., the GC device) within the P2P group and the third electronic device (i.e., the idle device) outside the P2P group, thereby realizing the transmission of business data to the first electronic device through the second Wi-Fi Direct link and the first Wi-Fi Direct link, and realizing data transmission between the two based on the transmission channel.
[0080] According to the fourth aspect, in a possible implementation manner of the third aspect, before the third electronic device establishes a first Wi-Fi Direct link with the second electronic device, the method further includes: the first electronic device sends a first connection request to the second electronic device, the first connection request is used to request that the third electronic device be added to the Wi-Fi Direct group, and the first connection request includes information of the third electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the first connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a first response message in response to the first connection request to the first electronic device, the first response message is used to indicate that the third electronic device is added to the Wi-Fi Direct group, and the first response message includes: an IP address assigned by the second electronic device to the third electronic device, group information of the Wi-Fi Direct group, and a MAC address of the second electronic device; the first electronic device increases a reference count maintained by the first electronic device by one according to the first response message, and the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the first electronic device. In this implementation, the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (i.e., GO device) in the P2P group are multiplexed, and the first electronic device and the second electronic device can sense that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other. When data is transmitted, the second electronic device in the P2P group is used as a transit. In addition, the transmission of services based on the Wi-Fi P2P connection is realized, which solves the problem in the prior art that GC devices in the P2P group and idle devices outside the P2P group cannot transmit data, thereby improving the user experience.
[0081] According to the fourth aspect, or any implementation of the fourth aspect above, before the third electronic device establishes a first Wi-Fi direct link with the second electronic device, the method also includes: the third electronic device and the first electronic device establish a first connection, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0082] According to the fourth aspect, or any implementation manner of the fourth aspect above, the method also includes: the first electronic device sends a second connection request to the third electronic device through the first connection, and the second connection request includes: the IP address assigned by the second electronic device to the third electronic device, the group information of the Wi-Fi Direct group, the MAC address of the second electronic device, the IP address and port number of the first electronic device; the third electronic device establishes the first Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device.
[0083] According to the fourth aspect, or any implementation of the fourth aspect above, the method further includes: before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: the second electronic device determines, based on the first connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi direct link exists between the second electronic device and the first electronic device.
[0084] According to the fourth aspect, or any implementation of the fourth aspect above, before the first electronic device increases the reference count maintained by the first electronic device by one, the method also includes: the second electronic device determines, based on the first response information, that a Wi-Fi direct link exists between the second electronic device and the first electronic device.
[0085] According to the fourth aspect, or any implementation of the fourth aspect above, after the data transmission of the first service is completed, the method also includes: the first electronic device decrements the reference count maintained by the first electronic device by one; the second electronic device decrements the reference count maintained by the second electronic device by one.
[0086] According to the fourth aspect, or any implementation of the fourth aspect above, the method also includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi direct group; or, when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the Wi-Fi direct link between the first electronic device and the second electronic device.
[0087] According to the fourth aspect, or any implementation of the fourth aspect above, the information of the third electronic device includes: at least one of: an identifier of the third electronic device, a current Wi-Fi Direct connection status of the third electronic device, a MAC address of a Wi-Fi Direct port of the third electronic device, a list of channels supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband.
[0088] In a fifth aspect, a method for data transmission under Wi-Fi Direct is provided, the method being applied to a system including a first electronic device, a second electronic device, and a fourth electronic device, the fourth electronic device being an idle device outside a Wi-Fi Direct group, the first electronic device being a GC device within the Wi-Fi Direct group, and the second electronic device being a GO device within the Wi-Fi Direct group, the method comprising: the fourth electronic device receiving a first operation of a user, the first operation being used to send data of a first service to the second electronic device; in response to the first operation, the fourth electronic device establishing a first Wi-Fi Direct link with the second electronic device; the fourth electronic device sending the data of the first service to the second electronic device through the first Wi-Fi Direct link.
[0089] The fifth aspect provides a method for data transmission under Wi-Fi Direct connection, which manages the P2P link of the second electronic device (GO device). When a Wi-Fi P2P service (or application) already exists between the second electronic device and the first electronic device (GC device) in the P2P group, when a fourth electronic device (idle device) outside the P2P group initiates a Wi-Fi P2P connection to the second electronic device (GO device) for additional service data transmission, the fourth electronic device can be added to the P2P group, thereby realizing the transmission of service data from the fourth electronic device (idle device) to the second electronic device (GO device).
[0090] According to the fifth aspect, in a possible implementation manner of the fifth aspect, the method further includes: the fourth electronic device sends a first connection request to the second electronic device through the first connection, the first connection request is used to request that the fourth electronic device be added to the Wi-Fi Direct group, and the first connection request includes information of the fourth electronic device; the second electronic device increases a reference count maintained by the second electronic device according to the first connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a first response message in response to the first connection request to the fourth electronic device through the first connection, the first response message is used to indicate that the fourth electronic device is added to the Wi-Fi Direct group, and the first response message includes: the IP address assigned by the second electronic device to the fourth electronic device, the group information of the Wi-Fi Direct group, and the MAC address of the second electronic device; the fourth electronic device establishes the first Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device. In this implementation, the second electronic device will reuse the Wi-Fi P2P capability of the second electronic device, so that the second electronic device can perceive that it is currently carrying multiple services. Only after the transmission of the multiple services is completed will the P2P group and the GO device be removed, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other, thereby improving the user experience.
[0091] According to the fifth aspect, or any implementation of the fifth aspect above, the fourth electronic device sends a first connection request to the second electronic device through a first connection, the first connection request is used to request that the fourth electronic device be added to the Wi-Fi Direct group, and the first connection request includes information of the fourth electronic device; the second electronic device increases a reference count maintained by the second electronic device by one according to the first connection request, and the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously use the Wi-Fi P2P capability of the second electronic device; the second electronic device sends a first response message in response to the first connection request to the fourth electronic device through the first connection, the first response message is used to indicate that the fourth electronic device is added to the Wi-Fi Direct group, and the first response message includes: an IP address assigned by the second electronic device to the fourth electronic device, group information of the Wi-Fi Direct group, and a MAC address of the second electronic device; the fourth electronic device establishes the first Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device.
[0092] According to the fifth aspect, or any implementation of the fifth aspect above, the method further includes: the fourth electronic device establishes a transmission channel based on the first Wi-Fi direct link with the second electronic device according to the IP address assigned by the second electronic device to the fourth electronic device and the MAC address of the second electronic device.
[0093] According to the fifth aspect, or any implementation of the fifth aspect above, the method further includes: the fourth electronic device and the second electronic device establish the first connection, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
[0094] According to the fifth aspect, or any implementation of the fifth aspect above, before the second electronic device increases the reference count maintained by the second electronic device by one, the method also includes: the second electronic device determines, based on the first connection request, that the fourth electronic device is a trusted device, and determines that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device.
[0095] According to the fifth aspect, or any implementation of the fifth aspect above, the second electronic device and the second electronic device transmit data of the second service through the second Wi-Fi direct link. After the data transmission of the first service is completed or the data transmission of the second service is completed, the method also includes: the second electronic device reduces the reference count maintained by the second electronic device by one.
[0096] According to the fifth aspect, or any implementation of the fifth aspect above, the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi direct group. In this implementation, by multiplexing the Wi-Fi P2P capability of the second electronic device (GO device), the second electronic device can perceive that it currently carries multiple services, and when any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. After multiple services are completed, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be fully transmitted.
[0097] According to the fifth aspect, or any implementation of the fifth aspect above, the information of the fourth electronic device includes: at least one of: an identifier of the fourth electronic device, a current Wi-Fi Direct connection status of the fourth electronic device, a MAC address of a Wi-Fi Direct port of the fourth electronic device, a list of channels supported by the fourth electronic device, a frequency of a Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports broadband.
[0098] In a sixth aspect, an electronic device is provided, comprising a unit for executing each step in the above second aspect or any possible implementation of the second aspect.
[0099] In a seventh aspect, an electronic device is provided, comprising at least one processor and a memory, wherein the at least one processor is used to execute the method in the above second aspect or any possible implementation of the second aspect.
[0100] In an eighth aspect, an electronic device is provided, comprising at least one processor and an interface circuit, wherein the at least one processor is used to execute the method in the above second aspect or any two possible implementations of the second aspect.
[0101] In a ninth aspect, a system for data transmission under Wi-Fi Direct connection is provided, the system comprising multiple electronic devices for executing the above first aspect or any possible implementation of the first aspect.
[0102] In a tenth aspect, a system for data transmission under Wi-Fi Direct connection is provided, the system comprising multiple electronic devices for executing the above third aspect or any possible implementation of the third aspect.
[0103] In an eleventh aspect, a system for data transmission under Wi-Fi Direct connection is provided, the system comprising multiple electronic devices for executing the above fourth aspect or any possible implementation of the fourth aspect.
[0104] In a twelfth aspect, a system for data transmission under Wi-Fi Direct connection is provided, the system comprising multiple electronic devices for executing the above fifth aspect or any possible implementation of the fifth aspect.
[0105] In the thirteenth aspect, a computer program product is provided, which includes a computer program, which, when executed by a processor, is used to execute the method in any one of the first to fifth aspects, or to execute the method in any possible implementation of any one of the first to fifth aspects.
[0106] In the fourteenth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed, it is used to execute the method in any one of the first to fifth aspects, or to execute the method in any possible implementation of any one of the first to fifth aspects.
[0107] In the fifteenth aspect, a chip is provided, comprising: a processor, for calling and running a computer program from a memory, so that a communication device equipped with the chip executes a method in any one of the first to fifth aspects, or for executing a method in any possible implementation of any one of the first to fifth aspects.
[0108] The method and electronic device for data transmission under Wi-Fi Direct provided by the present application, when data needs to be transmitted between GC devices in a P2P group, or between a GC in a P2P group and an idle device outside the P2P group, assists in establishing a transmission channel between the two devices and transmits business data through the intervention of a GO device, so that devices in the current Wi-Fi P2P group can initiate connection and communication, thereby changing the star network into a mesh network at the business layer. In addition, by counting the number of services using Wi-Fi P2P capabilities on the device, the Wi-Fi P2P link is removed only when the number of services using Wi-Fi P2P capabilities is 0, thereby solving the conflict problem between multiple Wi-Fi P2P services and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0109] Figure 1 It is a schematic diagram of the Wi-Fi P2P service system architecture on electronic devices in the prior art.
[0110] Figure 2 It is a schematic diagram of the connection and networking of Wi-Fi P2P devices.
[0111] Figure 3 It is a schematic diagram of a scenario architecture of a Wi-Fi P2P connection provided in an embodiment of the present application.
[0112] Figure 4 This is a schematic interface diagram of a Wi-Fi P2P discovery operation on a user-triggered device provided in an embodiment of the present application.
[0113] Figure 5 It is a schematic diagram of a Wi-Fi P2P service system architecture on an electronic device provided in an embodiment of the present application.
[0114] Figure 6 This is a schematic diagram of a communication system applicable to an embodiment of the present application, provided in an embodiment of the present application.
[0115] Figure 7 This is a schematic flowchart of a method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0116] Figure 8This is a schematic interface diagram of an example of a user performing file sharing operations provided in an embodiment of the present application.
[0117] Fig. 9 This is a schematic flowchart of another method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0118] Fig.10 This is a schematic diagram of another communication system applicable to the embodiment of the present application, provided in the embodiment of the present application.
[0119] Fig.11 This is a schematic flowchart of another method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0120] Fig.12 This is a schematic flowchart of another method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0121] Fig.13 This is a schematic diagram of another example of a communication system applicable to the embodiment of the present application, provided in the embodiment of the present application.
[0122] Fig.14 This is a schematic flowchart of a method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0123] Fig.15 This is a schematic diagram of another example of a communication system applicable to the embodiment of the present application, provided in the embodiment of the present application.
[0124] Fig.16 This is a schematic flowchart of another method for data transmission under Wi-Fi Direct connection provided in an embodiment of the present application.
[0125] Fig.17 It is a schematic block diagram of an example of an electronic device structure provided in an embodiment of the present application.
[0126] Fig.18 It is a schematic block diagram of an example of a communication device structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0127] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0128] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0129] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0130] In addition, various aspects or features of the present application can be implemented as methods, devices or products using standard programming and / or engineering techniques. The term "product" used in this application covers computer programs that can be accessed from any computer-readable device, carrier or medium. For example, computer-readable media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks or tapes, etc.), optical disks (e.g., compact discs (CDs), digital versatile discs (DVDs), etc.), smart cards and flash memory devices (e.g., erasable programmable read-only memory (EPROM), cards, sticks or key drives, etc.). In addition, the various storage media described herein may represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing and / or carrying instructions and / or data.
[0131] The technical solutions of the embodiments of the present application can be applied to various communication systems, for example: Global System of Mobile communication (GSM) system, Code Division Multiple Access (CDMA) system, Wideband Code Division Multiple Access (WCDMA) system, General Packet Radio Service (GPRS), Long Term Evolution (LTE) system, LTE Frequency Division Duplex (FDD) system, LTE Time Division Duplex (TDD), Universal Mobile Telecommunication System (UMTS), Worldwide Interoperability for Microwave Access (WiMAX) communication system, fifth generation (5G) system or new radio (NR), etc.
[0132] In addition, various aspects or features of the present application can be implemented as methods, devices or products using standard programming and / or engineering techniques. The term "product" used in this application covers computer programs that can be accessed from any computer-readable device, carrier or medium. For example, computer-readable media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks or tapes, etc.), optical disks (e.g., compact discs (CDs), digital versatile discs (DVDs), etc.), smart cards and flash memory devices (e.g., erasable programmable read-only memory (EPROM), cards, sticks or key drives, etc.). In addition, the various storage media described herein may represent one or more devices and / or other machine-readable media for storing information. The term "machine-readable medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing and / or carrying instructions and / or data.
[0133] Wi-Fi P2P technology is an important technology under the "Wi-Fi DIRECT" standard protocol launched by the Wi-Fi Alliance. Wi-Fi P2P can support two Wi-Fi devices to directly connect and communicate with each other without the intervention of a Wi-Fi hotspot.
[0134] Figure 1 The following is a diagram showing the Wi-Fi P2P service system architecture: Figure 1 As shown in Figure 1, the system architecture mainly includes: Wi-Fi chip (Chipset), Wi-Fi driver (Wi-Fi Driver), middleware, application framework layer (FRAMEWORK), and upper-layer application (application, APP). Among them, the Wi-Fi driver is responsible for connecting the Wi-Fi chip with the operating system of the terminal device, and the middleware is used to transfer all messages between the kernel state and the user state during the operation of the terminal device. One of the most widely used middlewares is wpa_supplicant. wpa_supplicant is an open source project, which was later modified by Google and introduced into the Android platform. It is a daemon process that runs independently in the device and is used for message transfer.
[0135] FRAMEWORK refers to some system capabilities running on the operating system of the terminal device. Taking the Android Open Source Project (AOSP) as an example, AOSP provides some related interfaces and services for operating Wi-Fi P2P. For example, Wi-Fi P2P-related services may include Wi-Fi P2P Service. The interface type corresponding to Wi-Fi P2P Service is the Wi-Fi P2P Manager type. The Wi-Fi P2P Manager type interface includes: providing interfaces such as discovering devices (discoverPeers) and connecting (connect). These interfaces can be used by users to directly control Wi-Fi P2P.
[0136] Upper-layer applications are applications that use the FRAMEWORK interface and can be directly accessed by users. They run on terminal devices and are windows for users to interact with terminal devices.
[0137] The connection protocol of Wi-Fi P2P is generally implemented in the Wi-Fi chip, and the FRAMEWORK layer in the terminal device interacts with the chip through the driver. For example, taking AOSP as an example, the FRAMEWORK layer uses wpa_supplicant to interact with the driver and support encryption authentication. The application layer provides several interface functions that can be directly called by developers / businesses. After the call, the chip can be driven to perform corresponding Wi-Fi P2P related operations. The FRAMEWORK layer itself is responsible for the message forwarding and coordination between the upper-layer application and the lower-layer hardware (including wpa_supplicant, Wi-Fi Driver, Chipset), connection management, etc. At present, the user's operation on Wi-Fi P2P is implemented by the application layer by calling the Wi-Fi P2P related interfaces and services in the FRAMEWORK.
[0138] A complete Wi-Fi P2P service includes three stages: Wi-Fi P2P device discovery, Wi-Fi P2P device connection, and Wi-Fi P2P device service data transmission. After the Wi-Fi P2P device connection is established, a P2P group (or also called a Wi-Fi P2P group) is formed. Within the P2P group, devices have two roles: P2P group owner (GO) and P2P group client (GC). At the same time, the protocol specification explains and restricts the Wi-Fi P2P connection method, which mainly includes the following three points:
[0139] (1) GO devices can only connect to GC and cannot establish connections with other GO devices;
[0140] (2) GC devices can only connect to GO devices and cannot establish connections with other GO or GC devices;
[0141] (3) There is an upper limit on the number of GO devices that can be connected to GC devices;
[0142] In addition to the limitations of the Wi-Fi DIRECT protocol itself, different chip manufacturers and different operating systems (such as Android, Windows, etc.) have some other restrictions on Wi-Fi P2P connections. For example, chip platforms such as HiSilicon do not support multiple P2P roles on the same device. Not supporting multiple P2P roles on the same device can be understood as: the same device cannot be a GO and GC at the same time; or, while a device is acting as a GO, the device cannot be a GO in another P2P group; or, while a device is acting as a GC, the device cannot be a GC in another P2P group. In addition, AOSP does not support the coexistence of multiple P2P roles on the same device. Therefore, if Figure 2 As shown, the current form of Wi-Fi P2P device connection and networking is limited to a star network centered on a GO device.
[0143] The current Wi-Fi P2P applications (or services) on the Android system all independently manage Wi-Fi P2P links. Specifically, when an application (such as a screen projection application, file sharing application, or office collaboration application) is started, the Wi-Fi P2P service is started by calling the scanning interface of FRAMEWORK, and the lower-level hardware (wpa_supplicant, Wi-FiDriver, Chipset) is used to start Wi-Fi P2P device discovery. After the Wi-Fi P2P device is discovered, the application starts the Wi-Fi P2P service by calling the connection interface of FRAMEWORK to connect the Wi-Fi P2P device and establish the Wi-Fi P2P link. At the end of the service, the application calls the connection interface of FRAMEWORK to start the Wi-Fi P2P service to delete the Wi-Fi P2P link.
[0144] However, AOSP does not do a perfect job in managing Wi-Fi P2P device connections. The interface it provides for services is open to all services, but there is only one physical connection between the underlying devices. When multiple applications (or services) operate or use the Wi-Fi P2P capabilities of the device at the same time, service conflicts will occur. In other words, the Wi-Fi P2P link on the device is managed and negotiated by each application alone. Due to resource limitations, only one Wi-Fi P2P underlying link will be generated. If a service occupies Wi-Fi P2P resources, another Wi-Fi P2P-related service on the device cannot guarantee complete transmission. This will lead to multiple Wi-Fi P2P service conflicts. For example, there are services 1 and 2 between two devices. If both devices are GC devices, after service 1 establishes a Wi-Fi P2P connection between the two devices, service 2 also wants to use the Wi-Fi P2P connection (or the Wi-Fi P2P capability). At this time, service 2 will fail to call the Wi-Fi P2P connection interface directly. If one of the two devices is a GO device and the other is a GC device, service 2 can directly use the Wi-Fi P2P connection established by service 1. Although communication between the two devices can be achieved, once the Wi-Fi P2P connection is disconnected after service 1 ends, the Wi-Fi P2P connection between the two devices will also be disconnected, and service 2 will also be interrupted. For another example, the problem of multi-service Wi-Fi P2P service conflicts between multiple devices, suppose: mobile phone A and a computer are working together, and mobile phone A and the computer have established a Wi-Fi P2P connection. At this time, the computer is a GO device or access point (AP) device, and mobile phone A is a GC device. In this case, mobile phone A cannot share files with another mobile phone B at the same time, and mobile phone A cannot receive files shared by mobile phone B.
[0145] The current way to establish a Wi-Fi P2P connection is to use the AOSP native interface, follow the Wi-Fi DIRECT standard protocol, start with Wi-Fi P2P device discovery, conduct a Wi-Fi P2P connection, and establish a Wi-Fi P2P-based transmission path after the connection is complete. When making a Wi-Fi P2P connection between devices, both devices must initiate P2P device discovery together, and after discovering the device, call the Wi-Fi P2P connection interface to connect. In this process, if one of the devices is a persistent group, then after the connection is established, the device in this persistent group will act as the GO device and the other device will act as the GC device. Otherwise, the roles of the GO device and the GC device will be determined based on the negotiation results of the two devices. Figure 3 The figure shows a schematic diagram of a Wi-Fi P2P connection scenario architecture provided by this application. Figure 3As shown, GO devices, GC1 devices, GC2 devices, and GC3 devices form a P2P group, and Wi-Fi P2P connections have been established between GO devices and GC1 devices, GC2 devices, and GC3 devices respectively. Idle device 1 and idle device 2 are two idle devices outside the P2P group, and no Wi-Fi P2P connection has been established between idle devices 1 and 2 and other devices. The GO devices in the P2P group transmit Wi-Fi P2P services with GC1 devices, GC2 devices, and GC3 devices respectively. Figure 3 In the architecture shown, there are four scenarios:
[0146] Scenario 1: A Wi-Fi P2P connection is established between two idle devices outside the P2P group. In scenario 1, it is equivalent to initiate the connection between idle device 1 and idle device 2. The example of idle device 1 initiating the Wi-Fi P2P connection is used for explanation. Before initiating the Wi-Fi P2P connection, idle device 1 and idle device 2 need to trigger the Wi-Fi P2P discovery operation at the same time. When idle device 1 discovers idle device 2 through the message broadcast by idle device 2, idle device 1 can call the connection command to establish the two Wi-Fi P2P connections with idle device 2.
[0147] Scenario 2: Establishing a Wi-Fi P2P connection between an idle device and a GO device in a P2P group. Take the establishment of a Wi-Fi P2P connection between idle device 1 and a GO device as an example. When idle device 1 initiates a connection to the GO device, since the GO device will continue to send broadcasts after establishing a P2P group, there is no need to trigger Wi-Fi P2P discovery on the GO device. Wi-Fi P2P discovery needs to be triggered on idle device 1. When idle device 1 discovers the GO device through the message broadcast by the GO device, idle device 1 can establish a Wi-Fi P2P connection to the GO device through a connection operation.
[0148] When the GO device initiates a Wi-Fi P2P connection to the idle device 1, similarly, the GO device and the idle device 1 need to trigger Wi-Fi P2P discovery at the same time. After the GO device discovers the idle device 1, the GO device can establish a Wi-Fi P2P connection with the idle device 1 through a connection operation.
[0149] For example, Figure 4 The diagram shown is a schematic interface diagram of a user triggering a Wi-Fi P2P discovery operation on an idle device or a GO device. Figure 4 As shown in a in the figure, the user can click the "Settings" icon on the idle device or GO device, and the interface displayed is as follows Figure 4As shown in b in Figure 1, the user clicks the "WLAN Direct" menu to trigger Wi-Fi P2P discovery. After the user clicks "WLAN Direct", the interface displayed is as follows Figure 4 As shown in c in FIG. 1 , the user clicks the “Stop” menu to stop Wi-Fi P2P discovery. Among the many available devices discovered, the user can click on any one of them. After the user clicks on the device, the device used by the user can establish a Wi-Fi P2P connection with the device.
[0150] For the above-mentioned scenarios 1 and 2, the Wi-Fi P2P connection can be established using the above-mentioned method for establishing a Wi-Fi P2P connection. After the Wi-Fi P2P connection is established, a path for transmitting data needs to be established. Since the current AOSP interface can only obtain the Internet Protocol (IP) address of the GO device, without relying on other communication means to assist in exchanging port numbers, the GO device side can only listen on a fixed port, and the GC device uses the GO device IP address and port number information to establish a socket connection for subsequent data transmission.
[0151] Scenario 3: Establish a Wi-Fi P2P connection between GC devices in a P2P group. For example, establish a Wi-Fi P2P connection between GC1 and GC2 in a P2P group. Using the above-mentioned method of establishing a Wi-Fi P2P connection, for scenario 3, the two devices have become GC devices. After the two GC devices trigger device discovery at both ends, they can discover each other. However, after initiating the device connection, the Wi-Fi P2P connection between the two GC devices will fail, and subsequent data transmission will not be possible.
[0152] Scenario 4: Wi-Fi P2P connection between GC devices in the P2P group and idle devices outside the P2P group. For example, a Wi-Fi P2P connection is established between the GC1 device in the P2P group and the idle device 1. Using the above-mentioned method of establishing a Wi-Fi P2P connection, for scenario 4, the GC1 device can connect the idle device 1 to the GO device through the invitation mode, but after the connection is completed, whether it is the original GC1 device or the idle device 1, if it does not use other communication methods to assist in transmitting information, it is impossible to obtain the other party's IP address, and thus it is impossible to establish a transmission channel.
[0153] Therefore, using the above-mentioned method of establishing a Wi-Fi P2P connection, for the above-mentioned scenarios 3 and 4, that is, between two GC devices, or between a GC device and a device outside the group, a Wi-Fi P2P connection cannot be established.
[0154] In view of this, the present application provides a method for Wi-Fi P2P connection. When data transmission is required between GC devices in a P2P group, or between GC in a P2P group and idle devices outside the P2P group, the GO device intervenes to assist in establishing a transmission channel between the two devices and transmit business data, so that the devices in the current Wi-Fi P2P group can initiate connection and communication, thereby changing the star network into a mesh network at the business layer. In addition, by counting the number of services using Wi-Fi P2P capabilities on the device, the Wi-Fi P2P link is dismantled only when the number of services using Wi-Fi P2P capabilities is 0, thereby solving the conflict problem between multiple Wi-Fi P2P services and improving the user experience.
[0155] The following is a specific example to illustrate the Wi-Fi P2P connection method provided by the present application.
[0156] It should be understood that the method provided in this application is mainly for the Wi-Fi P2P connection and networking scenarios in the Wi-Fi DIRECT standard protocol, and can be applied to devices using the Android operating system and the WINDOWS operating system using the Wi-Fi P2P technology of the Wi-Fi DIRECT standard protocol, and can also be applied to devices using the IOS operating system and the Hongmeng operating system, etc. The embodiments of this application are not limited here.
[0157] Figure 5 The diagram shown is an example of a Wi-Fi P2P service system architecture diagram provided by this application, such as Figure 5 As shown, the system architecture mainly includes: Wi-Fi chip (Chipset), Wi-Fi driver (Wi-Fi Driver), middleware, application framework layer (FRAMEWORK), communication module and upper-layer application (application, APP). Among them, the Wi-Fi P2P service in the FRAMEWORK layer also includes a P2P link management module. The P2P link management module is used to manage the Wi-Fi P2P capability (or Wi-Fi P2P link) of the device. The communication module is used for communication between the application layer and the FRAMEWORK layer. It should be understood that in the embodiment of the present application, the communication module can also be located in the FRAMEWORK layer.
[0158] Figure 6 The schematic diagram of a communication system applicable to an embodiment of the present application is shown in FIG. Figure 6As shown, the system includes: a first electronic device, a second electronic device and a third electronic device, wherein a Wi-Fi P2P connection has been established between the second electronic device and the first electronic device. In other words, the second electronic device and the first electronic device have formed a P2P group. In the P2P group, the second electronic device is a GO device or an AP device, and the first electronic device is a GC device. The third electronic device is an idle device outside the P2P group, and there is no Wi-Fi P2P connection between the third electronic device and other devices. Figure 6 In the example shown, the third electronic device is mobile phone B, the first electronic device is mobile phone A, and the second electronic device is a large-screen device (such as a smart TV, smart screen, etc.). Mobile phone A is projecting the screen to the large-screen device, and then mobile phone B (idle device) needs to initiate file sharing to mobile phone A. Mobile phone A and the large-screen device use a Wi-Fi P2P link for screen projection.
[0159] Figure 7 Shown is Figure 6 In the scenario shown, the present application provides a schematic flow chart of a Wi-Fi P2P connection method. In which, mobile phone A is projecting screen to a large-screen device, and the screen projection between mobile phone A and the large-screen device uses a Wi-Fi P2P link, such as Figure 7 As shown, the method includes: S101 to S127.
[0160] S101, the user opens the first application (i.e., the file management application) on mobile phone B, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c. Figure 8 Shown are operations for execution on mobile phone B.
[0161] S102, after the user clicks "Wi-Fi Direct", the first application on mobile phone B sends a device discovery request to the communication module in mobile phone B.
[0162] S103, after receiving the device discovery request, the communication module in mobile phone B starts a device discovery method such as Bluetooth low energy (BLE) scanning, classic Bluetooth scanning, wireless local area networks (WLAN) scanning or Wi-Fi P2P scanning to discover the device. In the embodiment of the present application, classic Bluetooth includes at least one of two types of Bluetooth: Bluetooth basic rate (BR) and Bluetooth enhanced data rate (EDR).
[0163] S104, after the communication module in mobile phone B scans the device, it sends the scanned device list to the first application on mobile phone B, where the device list includes device identifiers of one or more devices. For example, the displayed device list can be as follows: Figure 8 As shown in d.
[0164] S105, the user selects the device identifier of mobile phone A in the device list on the first application on mobile phone B. The device identifier of mobile phone A may be the device model, identification code, device name, device ID, etc. of mobile phone A. The device identifier of mobile phone A is used to uniquely identify mobile phone A.
[0165] S106 , after the user clicks the device identification of mobile phone A in the device list, the first application on mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone B. The Wi-Fi P2P connection request includes the device identification of mobile phone A.
[0166] S107, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone B first establishes a first connection with the communication module in mobile phone A. For example, the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0167] S108, the communication module in mobile phone B and the communication module in mobile phone A negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0168] S109, the communication module in mobile phone B stores the encryption key and decryption key.
[0169] S110, the communication module in mobile phone A stores the encryption key and the decryption key.
[0170] S111, the communication module in mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone A through the first connection, and the Wi-Fi P2P connection request is encrypted using an encryption key. The Wi-Fi P2P connection request includes: the device identification of mobile phone B, the current Wi-Fi P2P connection status of mobile phone B (the current Wi-Fi P2P connection status of mobile phone B includes: the status that mobile phone B currently has no Wi-Fi P2P connection with any device, and the connection status can be represented by 0; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GO, and the connection status can be represented by 1; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GC, and the connection status can be represented by 2. In this embodiment, mobile phone B currently has no Wi-Fi P2P connection, and the current Wi-Fi P2P connection status of mobile phone B is represented by 0), the media access control (MAC) address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B (for example, supporting 36 channels, corresponding to 5180MHz), the connection mode expected by mobile phone B (for example, mobile phone B expects to establish a Wi-Fi P2P connection as a GC, or mobile phone B expects to establish a Wi-Fi P2P connection as a GO P2P connection, in this embodiment, mobile phone B expects to establish a Wi-Fi P2P connection as a GC), the frequency of the Wi-Fi hotspot connected to mobile phone B, whether broadband is supported (for example, whether 160MHz is supported, if supported, it can be indicated by true, if not supported, it can be indicated by false), and at least one of the following information.
[0171] S112, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone A uses the decryption key to decrypt. The communication module in mobile phone A determines that mobile phone A is already a GC based on the stored connection information, and therefore cannot directly establish a Wi-Fi P2P connection with mobile phone B.
[0172] Specifically, after mobile phone A establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone A will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Therefore, the communication module in mobile phone A has maintained the existing connection information, which includes: the current Wi-Fi P2P connection status and role of mobile phone A (for example, mobile phone A already has a Wi-Fi P2P connection and the role is GC, which can be represented by 2), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device. As for the large-screen device, the communication module in the large-screen device will also receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is in the GO role, the connection information includes the Wi-Fi P2P connection status, role, and address information of the device (including mobile phone A) connected to itself (large-screen device), as well as the information of the P2P group. In the embodiment of the present application, the P2P group information includes: at least one of a service set identifier (SSID), a basic service set identifier (BSSID), a frequency, and a password (PASSWORD) of the P2P group.
[0173] S113, the communication module in mobile phone A sends a connection request to the communication module in the large-screen device, and the connection request is used to request that mobile phone B be added to the P2P group formed by mobile phone A and the large-screen device. The connection request includes at least one of: the device identification of mobile phone B, the current Wi-Fi P2P connection status of mobile phone B, the MAC address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B, the connection mode expected by mobile phone B, the frequency of the Wi-Fi hotspot connected by mobile phone B, whether mobile phone B supports broadband, etc.
[0174] S114, after receiving the connection request, the communication module in the large-screen device will verify whether mobile phone B is a trusted device, and determine whether the large-screen device has established a Wi-Fi P2P connection with mobile phone B.
[0175] S115, after determining that the large-screen device has not established a Wi-Fi P2P connection with mobile phone B, the large-screen device is a GO device, and mobile phone B is a trusted device (for example, mobile phone B and the large-screen device are logged into the same account, or mobile phone B and the large-screen device have been bound to each other in various ways (for example, by scanning a QR code, etc.), the communication module in the large-screen device sends a request to apply for reuse of the Wi-Fi P2P capability to the P2P link management module in the large-screen device. Optionally, the request to apply for reuse of the Wi-Fi P2P capability may include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A.
[0176] S116, after the P2P link management module in the large-screen device receives the request, as a possible implementation method, if the request for applying for reusing the Wi-Fi P2P capability includes indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request for applying for reusing the Wi-Fi P2P capability does not include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, since the communication module in the large-screen device has maintained the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the device connected to itself (including mobile phone A), the role and address information of these devices, P2P group information, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, or determine that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, and that the Wi-Fi P2P link supports the use of other services, then it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0177] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 1, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (screen projection service from mobile phone A to the large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection service from mobile phone A to the large-screen device and file sharing service from mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0178] S117, after the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in the large-screen device.
[0179] S118, after receiving the response information of the successful reuse of the P2P capability, the communication module in the large-screen device sends a connection request response information to the communication module in mobile phone A, and the connection request response information includes: the indication information of allowing mobile phone B to join the P2P group, the information of the P2P group composed of mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone B, the MAC address of the large-screen device and other information. It should be understood that the connection request response information may include: any one of the indication information of allowing mobile phone B to join the P2P group and the information of the P2P group composed of mobile phone A and the large-screen device, but does not have to include the indication information of allowing mobile phone B to join the P2P group and the information of the P2P group composed of mobile phone A and the large-screen device at the same time. Optionally, the connection request response information may also include: the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A.
[0180] S119, after receiving the connection request response information, the communication module in mobile phone A determines that mobile phone B can join the P2P group according to the indication information of allowing mobile phone B to join the P2P group, or the P2P group information. Since the Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be maintained by the two devices together, and the reuse of Wi-Fi P2P capability is for one device, only applying for Wi-Fi P2P capability reuse for a certain device can only ensure that the device will not actively disconnect the Wi-Fi P2P link during the service. The opposite device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, the communication module in mobile phone A also needs to send a request for applying for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone A. Optionally, the request for applying for reuse of Wi-Fi P2P capability can also include: indication information that a Wi-Fi P2P connection already exists between the large-screen device and mobile phone A.
[0181] S120, after the P2P link management module in mobile phone A receives the request, as a possible implementation method, if the request carries the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, the P2P link management module in mobile phone A can determine that mobile phone A can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request carries the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, and the P2P link management module in mobile phone A determines that the Wi-Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request does not carry the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, since the communication module in mobile phone A has maintained the existing connection information, the connection information includes: the current connection status and role of mobile phone A (for example: mobile phone A already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone A can obtain the connection information from the communication module, and then determine, based on the connection information, that a Wi-Fi P2P link already exists between mobile phone A and the large-screen device (the Wi-Fi P2P link for screen projection between mobile phone A and the large-screen device), or determine that a Wi-Fi P2P link already exists in mobile phone A (the Wi-Fi P2P link for screen projection between mobile phone A and the large-screen device), and that the Wi-Fi P2P link supports use by other services, then it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
[0182] Furthermore, mobile phone A can also maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone A. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone A is 1, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 1 service (screen projection service of mobile phone A to large-screen devices). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (screen projection service of mobile phone A to large-screen devices and file sharing service of mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone A will not disconnect the Wi-Fi P2P link, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone A disconnect the Wi-Fi P2P link.
[0183] S121, after the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone A.
[0184] S122, after receiving the response information, the communication module in mobile phone A sends a Wi-Fi P2P connection request response information to the communication module in mobile phone B through the first connection, and the Wi-Fi P2P connection request response information is encrypted using an encryption key. The Wi-Fi P2P connection request response information includes: instruction information allowing mobile phone B to join the P2P group, information about the P2P group composed of mobile phone A and the large-screen device (for example, the SSID, BSSID, frequency, PASSWORD, etc. of the P2P group), the IP address assigned by the large-screen device to mobile phone B, the MAC address of the large-screen device, the IP address of mobile phone A, and the port number information, etc., wherein the port number of mobile phone A is obtained by the communication module of mobile phone A by starting monitoring after the Wi-Fi P2P is established. It should be understood that the Wi-Fi P2P connection request response information may include: any one of the indication information allowing mobile phone B to join the P2P group, and the information of the P2P group consisting of mobile phone A and the large-screen device, but it is not necessary to include both the indication information allowing mobile phone B to join the P2P group and the information of the P2P group consisting of mobile phone A and the large-screen device.
[0185] S123, after the communication module in mobile phone B receives the Wi-Fi P2P connection request response information and decrypts it using the decryption key, it determines that it can join the P2P group based on the indication information allowing mobile phone B to join the P2P group, or the information of the P2P group composed of mobile phone A and the large-screen device, and then sends a request to join the P2P group to the P2P link management module in mobile phone B, and the request carries the P2P group information and the MAC address of the large-screen device.
[0186] S124, the P2P link management module in mobile phone B directly initiates a Wi-Fi P2P connection to the large-screen device through a connection interface (for example, a connect interface) based on the P2P group information and the MAC address of the large-screen device. After joining the P2P group, the P2P link management module in mobile phone B sends a response message to the communication module in mobile phone B, which is used to notify the communication module in mobile phone B that mobile phone B has successfully joined the P2P group.
[0187] S125. After receiving the response information, the communication module in mobile phone B sends a Wi-Fi P2P connection request response information to the first application on mobile phone B, which is used to notify the first application on mobile phone B that mobile phone B has successfully joined the P2P group. The Wi-Fi P2P connection request response information carries: the IP address assigned to mobile phone B by the large-screen device, the port number generated by mobile phone B itself, and the IP address and port number of mobile phone A.
[0188] S126, after mobile phone B joins the P2P group, mobile phone B has become a GC device. The first application on mobile phone B uses the IP address assigned to mobile phone B by the large-screen device and the port number generated by mobile phone B itself, combined with the IP address and port number information of mobile phone A, to establish a socket transmission channel with the first application on mobile phone A.
[0189] S127, the first application on mobile phone B starts sharing files with the first application on mobile phone A based on the socket transmission channel. After the file sharing service starts, mobile phone B first transmits the data of the shared file to the large-screen device, and the large-screen device then transmits the data of the shared file to mobile phone A, that is, the data flow of the file sharing service is: mobile phone B → large-screen device → mobile phone A. The data flow of the screen projection service is mobile phone A → large-screen device.
[0190] Figure 7 The method shown is the process of mobile phone B (idle device) initiating file sharing to mobile phone A (GC device). Fig. 9 Shown is Figure 6In the scenario shown, mobile phone A (GC device) needs to initiate a method of sharing a file with mobile phone B (idle device), wherein mobile phone A is projecting its screen to a large-screen device, and the projection between mobile phone A and the large-screen device uses a Wi-Fi P2P link. Fig. 9 As shown, the method includes: S201 to S228.
[0191] S201, the user opens the first application (i.e., the file management application) on mobile phone A, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c.
[0192] S202, after the user clicks "Wi-Fi Direct", the first application on mobile phone A sends a device discovery request to the communication module in mobile phone B.
[0193] S203, after receiving the device discovery request, the communication module in mobile phone A starts a device discovery method such as BLE scanning, BR scanning, WLAN scanning or Wi-Fi P2P scanning to discover the device.
[0194] S204, after the communication module in mobile phone A scans the device, it sends the scanned device list to the first application on mobile phone A. The device list includes device identifications of one or more devices.
[0195] S205, the user selects the device identifier of mobile phone B in the device list on the first application on mobile phone A, and the device identifier of mobile phone B may be the device model, identification code, device name, device ID, etc. of mobile phone B. The device identifier of mobile phone B is used to uniquely identify mobile phone B.
[0196] S206: After the user clicks the device identifier of mobile phone B in the device list, the first application on mobile phone A sends a Wi-Fi P2P connection request to the communication module in mobile phone A.
[0197] S207, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone A first establishes a first connection with the communication module in mobile phone B. For example, the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0198] S208, the communication module in mobile phone A and the communication module in mobile phone B negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0199] S209, the communication module in mobile phone A stores the encryption key and decryption key.
[0200] S210, the communication module in mobile phone B stores the encryption key and the decryption key.
[0201] S211, after mobile phone A establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone A will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Therefore, the communication module in mobile phone A has maintained the existing connection information, which includes: the device identification of mobile phone A, the current Wi-Fi P2P connection status and role of mobile phone A (for example, mobile phone A already has a Wi-Fi P2P connection and the role is GC, which can be represented by 2), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device. As for the large-screen device, the communication module in the large-screen device will also receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is a GO role, the connection information includes not only the Wi-Fi P2P connection status, role, and address information of the device (including mobile phone A) connected to itself (large-screen device), but also stores at least one of the information of the P2P group. In the embodiment of the present application, the information of the P2P group may be at least one of SSID, BSSID, frequency, and password. Therefore, the communication module in mobile phone A determines that mobile phone A is already a GC based on the connection information, and further determines that mobile phone A cannot directly establish a Wi-Fi P2P connection with mobile phone B.
[0202] S212, the communication module in mobile phone A sends a connection request to the communication module in the large-screen device (i.e., GO device), and the connection request is used to request that mobile phone B be added to the P2P group consisting of mobile phone A and the large-screen device. The connection request includes the identity information of mobile phone B. In the embodiment of the present application, the identity information of mobile phone B includes: the device identification of mobile phone B, the current Wi-Fi P2P connection status of mobile phone B, the MAC address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B (for example, supporting 36 channels, corresponding to 5180MHz), the connection mode expected by mobile phone B (for example, mobile phone B expects to establish a Wi-Fi P2P connection as a GC, or mobile phone B expects to establish a Wi-Fi P2P connection as a GO. In the present embodiment, mobile phone B expects to establish a Wi-Fi P2P connection as a GC), the frequency of the Wi-Fi hotspot connected by mobile phone B, whether broadband is supported (for example, whether 160MHz is supported, if supported, it can be indicated by true, if not supported, it can be indicated by false), and at least one of the following information. For example, the current Wi-Fi P2P connection status of mobile phone B includes: the status that mobile phone B currently has no Wi-Fi P2P connection with any device, and the connection status can be represented by 0; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GO, and the connection status can be represented by 1; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GC, and the connection status can be represented by 2. In this embodiment, mobile phone B currently has no Wi-Fi P2P connection, and the current Wi-Fi P2P connection status of mobile phone B is represented by 0. It should be understood that in the embodiment of the present application, mobile phone A can obtain information such as the current Wi-Fi P2P connection status of mobile phone B, the MAC address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B, and the connection method expected by mobile phone B through the first connection between mobile phone A and mobile phone B.
[0203] S213, after receiving the connection request, the communication module in the large-screen device (ie, GO device) will verify whether mobile phone B is a trusted device, and determine whether the large-screen device has established a Wi-Fi P2P connection with mobile phone B.
[0204] S214, after determining that the large-screen device has not established a Wi-Fi P2P connection with mobile phone B, the large-screen device is a GO device, and mobile phone B is a trusted device, the communication module in the large-screen device sends a request for applying for multiplexing of Wi-Fi P2P capabilities to the P2P link management module in the large-screen device. Optionally, the request for applying for multiplexing of Wi-Fi P2P capabilities may include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A.
[0205] S215, after the P2P link management module in the large-screen device receives the request, as a possible implementation method, if the request for applying for reuse of Wi-Fi P2P capability includes indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, it can be determined that the large-screen device can reuse Wi-Fi P2P capability. Or, as another possible implementation method, if the request for applying for reuse of Wi-Fi P2P capability does not include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, since the communication module in the large-screen device has maintained the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the device connected to itself (including mobile phone A), the role and address information of these devices, P2P group information, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, or determine that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, and that the Wi-Fi P2P link supports the use of other services, then it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0206] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 1, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (screen projection service from mobile phone A to the large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection service from mobile phone A to the large-screen device and file sharing service from mobile phone A to mobile phone B). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone A can still share files with mobile phone B normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0207] S216, after the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in the large-screen device.
[0208] S217, after receiving the response information of the successful reuse of the P2P capability, the communication module in the large-screen device sends a connection request response information to the communication module in mobile phone A, and the connection request response information includes: the indication information of allowing mobile phone B to join the P2P group, the information of the P2P group composed of mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone B, the MAC address of the large-screen device and other information. It should be understood that the connection request response information may include: any one of the indication information of allowing mobile phone B to join the P2P group and the information of the P2P group composed of mobile phone A and the large-screen device, but does not have to include the indication information of allowing mobile phone B to join the P2P group and the information of the P2P group composed of mobile phone A and the large-screen device at the same time. Optionally, the connection request response information may also include: the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A.
[0209] S218, after receiving the connection request response information, the communication module in mobile phone A determines that mobile phone B can join the P2P group according to the indication information of allowing mobile phone B to join the P2P group, or the P2P group information. Since the Wi-Fi P2P link between two devices needs to be maintained by the two devices together, and the reuse of Wi-Fi P2P capability is for one device, applying for the reuse of Wi-Fi P2P capability for only one device can only guarantee that the device will not actively disconnect the Wi-Fi P2P link during the service. The opposite device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, the communication module in mobile phone A also needs to send a request for applying for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone A. Optionally, the request for applying for reuse of Wi-Fi P2P capability can also include: indication information that a Wi-Fi P2P connection already exists between the large-screen device and mobile phone A.
[0210] S219, after the P2P link management module in mobile phone A receives the request, as a possible implementation method, if the request carries the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, the P2P link management module in mobile phone A can determine that mobile phone A can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request carries the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, and the P2P link management module in mobile phone A determines that the Wi-Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request does not carry the indication information that the large-screen device has a Wi-Fi P2P connection with mobile phone A, since the communication module in mobile phone A has maintained the existing connection information, the connection information includes: the current connection status and role of mobile phone A (for example: mobile phone A already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone A can obtain the connection information from the communication module, and then determine, based on the connection information, that a Wi-Fi P2P link already exists between mobile phone A and the large-screen device (the Wi-Fi P2P link for screen projection between mobile phone A and the large-screen device), or determine that a Wi-Fi P2P link already exists in mobile phone A (the Wi-Fi P2P link for screen projection between mobile phone A and the large-screen device), and that the Wi-Fi P2P link supports use by other services, then it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
[0211] Furthermore, mobile phone A can also maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone A. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone A is 1, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 1 service (screen projection service of mobile phone A to large-screen devices). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (screen projection service of mobile phone A to large-screen devices and file sharing service of mobile phone A to mobile phone B). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone A will not disconnect the Wi-Fi P2P link, and mobile phone A can still share files with mobile phone B normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone A disconnect the Wi-Fi P2P link.
[0212] S220: After the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone A.
[0213] S221, after receiving the response information, the communication module in mobile phone A sends a Wi-Fi P2P connection request to the communication module in mobile phone B through the first connection, and the Wi-Fi P2P connection request is encrypted using an encryption key. The Wi-Fi P2P connection request includes: indication information for allowing mobile phone B to join the P2P group, information about the P2P group composed of mobile phone A and the large-screen device (for example, the SSID, BSSID, frequency, PASSWORD, etc. of the P2P group), the IP address assigned by the large-screen device to mobile phone B, the MAC address of the large-screen device, the IP address of mobile phone A, and the port number information, etc. Among them, the port number of mobile phone A is obtained by the communication module of mobile phone A by starting monitoring after the Wi-Fi P2P is established. It should be understood that the Wi-Fi P2P connection request response information may include: indication information for allowing mobile phone B to join the P2P group, and any one of the information about the P2P group composed of mobile phone A and the large-screen device, without having to include both indication information for allowing mobile phone B to join the P2P group and information about the P2P group composed of mobile phone A and the large-screen device.
[0214] S222, after the communication module in mobile phone B receives the Wi-Fi P2P connection request response information and decrypts it using the decryption key, it determines that it can join the P2P group based on the indication information allowing mobile phone B to join the P2P group, or the information of the P2P group composed of mobile phone A and the large-screen device, and then sends a request to join the P2P group to the P2P link management module in mobile phone B, which carries the P2P group information and the MAC address of the large-screen device.
[0215] S223, the P2P link management module in mobile phone B directly initiates a Wi-Fi P2P connection to the large-screen device through a connection interface (for example, a connect interface) based on the P2P group information and the MAC address of the large-screen device. After joining the P2P group, the P2P link management module in mobile phone B sends a response message to the communication module in mobile phone B, which is used to notify the communication module in mobile phone B that mobile phone B has successfully joined the P2P group.
[0216] S224, after receiving the response information, the communication module in mobile phone B sends Wi-Fi P2P connection request response information to the communication module in mobile phone A through the first connection. The Wi-Fi P2P connection request response information is encrypted using an encryption key. The Wi-Fi P2P connection request response information includes: an indication that mobile phone B has successfully joined the P2P group, the IP address assigned to mobile phone B by the large-screen device, and the port number generated by mobile phone B itself.
[0217] S225, after receiving the Wi-Fi P2P connection request response information, the communication module in mobile phone A uses the decryption key to decrypt it and determines that mobile phone B has successfully joined the P2P group.
[0218] S226, the communication module in mobile phone A sends a Wi-Fi P2P connection request response message to the first application on mobile phone A, which is used to notify the first application on mobile phone A that mobile phone B has successfully joined the P2P group. The Wi-Fi P2P connection request response message carries: the IP address assigned by the large-screen device to mobile phone B and the port number generated by mobile phone B itself, the IP address and port number information of mobile phone A, etc.
[0219] S227, the first application on mobile phone A uses: the IP address and port number information of mobile phone A, combined with the IP address assigned to mobile phone B by the large-screen device, and the port number generated by mobile phone B itself, to establish a socket transmission channel with the first application on mobile phone B (i.e., file sharing).
[0220] S228, the first application on mobile phone A starts sharing files with the first application (i.e., file sharing application) on mobile phone B based on the socket transmission channel. After the file sharing service starts, mobile phone A first transmits the data of the shared file to the large-screen device, and the large-screen device then transmits the data of the shared file to mobile phone B, that is, the data flow of the file sharing service is: mobile phone A→large-screen device→mobile phone B. The data flow of the screen projection service is mobile phone A→large-screen device.
[0221] Optional, in Figure 7 and Fig. 9 In the method shown. In the case where there is a large amount of data traffic between mobile phone A and the large-screen device, the embodiment of the present application can also set the corresponding priorities according to different services, and give priority to high-priority services or take up a larger bandwidth for transmission, etc., to limit and balance the traffic, so that the screen projection service and the file sharing service can be balanced, so that the high-priority service can be transmitted quickly, further improving the user experience.
[0222] In an embodiment of the present application, the P2P group will be removed, that is, the GO device and the P2P group will be dismantled, only after both the file sharing service and the screen projection service are completed. In other words, the GO device and the P2P group will be dismantled only when the reference counts maintained by mobile phone A and the large-screen device are both 0. After any one of the file sharing service and the screen projection service is completed, the reference counts maintained by mobile phone A and the large-screen device are reduced to 1. Since the reference count is not 0, in this case, the GO device and the P2P group will not be dismantled, that is, the Wi-Fi P2P link between mobile phone A and the large-screen device will not be disconnected.
[0223] The Wi-Fi P2P connection method provided by the present application is that the first electronic device (i.e., GC device) in the P2P group and the third electronic device (i.e., idle device) outside the P2P group can discover each other using multiple discovery methods, and when the first electronic device in the P2P group and the third electronic device outside the P2P group cannot directly perform Wi-Fi P2P connection, the third electronic device will use the first electronic device as an intermediary device to assist itself in joining the P2P group where the first electronic device is located, or the first electronic device will serve as an intermediary device to assist the third electronic device in joining the P2P group where the GC device is located. At the same time, the first electronic device in the P2P group and the third electronic device outside the P2P group can both obtain the IP address and port number of the other party, and establish a socket transmission channel between the first electronic device in the P2P group and the third electronic device outside the P2P group, thereby realizing data transmission between the two based on the socket transmission channel. And the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (i.e., GO device) in the P2P group are multiplexed, and the first electronic device and the second electronic device can sense that their current Wi-Fi P2P capabilities carry multiple services. After multiple services are completed, the P2P group will be removed and the Wi-Fi P2P connection will be disconnected, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other. When transmitting data, the second electronic device in the P2P group is used as a transfer. In this way, the transmission of services based on Wi-Fi P2P connections is realized, which solves the problem in the prior art that GC devices in the P2P group and idle devices outside the P2P group cannot transmit data, thereby improving the user experience.
[0224] Fig.10 Another example of a communication system applicable to an embodiment of the present application is shown in FIG. Fig.10As shown, the system architecture includes: a first electronic device, a second electronic device and a third electronic device. The first electronic device and the third electronic device have established a Wi-Fi P2P connection with the second electronic device. In other words, the first electronic device, the second electronic device and the third electronic device have formed a P2P group. In the P2P group, the second electronic device is a GO device or an AP device, and the first electronic device and the third electronic device are both GC devices. Fig.10 In the example shown, the first electronic device is mobile phone A, the third electronic device is mobile phone B, and the second electronic device is a large-screen device (such as a smart TV). Mobile phone A and mobile phone B are both projecting their screens onto the large-screen device, and then mobile phone B (GC device) needs to initiate a file sharing service to mobile phone A (GC device).
[0225] Fig.11 Shown is Fig.10 In the scenario shown, the present application provides a schematic flow chart of a Wi-Fi P2P connection method. Among them, mobile phone A and mobile phone B are respectively projecting screens to a large-screen device through their respective Wi-Fi P2P connections. Fig.11 As shown, the method includes: S301 to S329.
[0226] S301, the user opens the first application (i.e., the file management application) on mobile phone B, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c.
[0227] S302, after the user clicks "Wi-Fi Direct", the first application on mobile phone B sends a device discovery request to the communication module in mobile phone B.
[0228] S303: After receiving the device discovery request, the communication module in mobile phone B starts a device discovery method such as BLE scanning, BR scanning, WLAN scanning or Wi-Fi P2P scanning to discover the device.
[0229] S304, after the communication module in mobile phone B scans the device, it sends the scanned device list to the first application on mobile phone B, where the device list includes device identifiers of one or more devices. For example, the displayed device list can be as follows: Figure 8 As shown in d.
[0230] S305, the user selects the device identifier of mobile phone A in the device list on the first application on mobile phone B, and the device identifier of mobile phone A may be the device model, identification code, device name, device ID, etc. of mobile phone A. The device identifier of mobile phone A is used to uniquely identify mobile phone A.
[0231] S306: The first application on mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone B.
[0232] S307, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone B first establishes a first connection with the communication module in mobile phone A. For example, the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0233] S308, the communication module in mobile phone B and the communication module in mobile phone A negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0234] S309, the communication module in mobile phone B stores the encryption key and decryption key.
[0235] S310, the communication module in mobile phone A stores the encryption key and the decryption key.
[0236] S311, after mobile phone B establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone B will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Therefore, the communication module of mobile phone B has maintained the existing connection information, which includes: the current Wi-Fi P2P connection status and role of mobile phone B (for example, mobile phone B already has a Wi-Fi P2P connection and the role is GC, which can be represented by 2), the role of the connected device (large-screen device) (GO), and the MAC address and identification of the large-screen device. As for the large-screen device, the communication module in the large-screen device will also receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is a GO role, the connection information includes the Wi-Fi P2P connection status, role, and address information of the devices (including mobile phone A and mobile phone B) connected to itself (large-screen device), as well as the information of the P2P group. In the embodiment of the present application, the P2P group information includes at least one of the SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, the communication module in mobile phone B determines that mobile phone B is already a GC based on the connection information, and further determines that mobile phone B cannot directly establish a Wi-Fi P2P connection with mobile phone A.
[0237] S312, the communication module in mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone A through the first connection, and the Wi-Fi P2P connection request is encrypted by an encryption key, and the Wi-Fi P2P connection request includes: the device identification of mobile phone B, the current Wi-Fi P2P connection status of mobile phone B, the MAC address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B (for example, supporting 36 channels, corresponding to 5180MHz), the frequency of the Wi-Fi hotspot connected to mobile phone B, whether broadband is supported (for example, whether 160MHz is supported, if supported, it can be indicated by true, if not supported, it can be indicated by false), the identification of the GO device to which mobile phone B is connected, and other information. For example, the current Wi-Fi P2P connection status of mobile phone B includes: the status that mobile phone B currently has no Wi-Fi P2P connection with any device, and the connection status can be represented by 0; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GO, and the connection status can be represented by 1; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GC, and the connection status can be represented by 2. In this embodiment, mobile phone B currently has a Wi-Fi P2P connection and the role of mobile phone B is GC, and the current Wi-Fi P2P connection status of mobile phone B is represented by 2.
[0238] S313, after receiving the connection request, the communication module in mobile phone A uses the decryption key to decrypt and obtain the content included in the connection request. After mobile phone A establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone A will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information, including: the current connection status and role of mobile phone A (for example: mobile phone A already has a Wi-Fi P2P connection and the role is GC, this information can be represented by 2), the role of the connected device (large-screen device) (GO) and the MAC address and identification of the large-screen device. Further, the communication module in mobile phone A determines whether the identification of the GO device connected to mobile phone B is the same as the identification of the GO device to which it is connected.
[0239] S314, when the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to itself, the communication module in mobile phone A can determine that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. Further, the communication module in mobile phone A sends a request for applying for multiplexing of Wi-Fi P2P capability to the P2P link management module in mobile phone A. Optionally, the request for applying for multiplexing of Wi-Fi P2P capability may also include: indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively.
[0240] S315, after the P2P link management module in mobile phone A receives the request, as a possible implementation method, if the request carries the indication information that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device respectively, the P2P link management module in mobile phone A can determine that a Wi-Fi P2P connection exists between mobile phone A and mobile phone B and the large-screen device respectively, and the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation method, if the request carries the indication information that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device respectively, and these two Wi-Fi P2P connections respectively support the use of other services, the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused. Alternatively, as another possible implementation, if the request does not carry the indication information that mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively, since the communication module in mobile phone A has stored the existing connection information, the connection information includes: the current connection status and role of mobile phone A (for example: mobile phone A already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone A can obtain the connection information from the communication module, and then determine that the identity of the GO device connected to mobile phone B is the same as the identity of the GO device connected to itself based on the connection information and the identity of the GO device connected to mobile phone B, then it can be determined that mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively, and the P2P link management module in mobile phone A determines that mobile phone A can reuse the Wi-Fi P2P capability.
[0241] Furthermore, mobile phone A can also maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone A. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone A is 1, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 1 service (screen projection service of mobile phone A to large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (screen projection service of mobile phone A to large-screen device and file sharing service of mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone A will not disconnect the Wi-Fi P2P link between mobile phone A and the large-screen device, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone A disconnect the Wi-Fi P2P link.
[0242] S316, after the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone A.
[0243] S317, after receiving the response information, the communication module in mobile phone A sends a Wi-Fi P2P connection request to the communication module in the large-screen device, and the Wi-Fi P2P connection request information is used to request: authorization for transmitting the first application data via the Wi-Fi P2P connection between mobile phone A and mobile phone B. The Wi-Fi P2P connection request information includes at least one of: the device identification of mobile phone B, the MAC address of the Wi-Fi P2P port of mobile phone B, the IP address and port number of mobile phone B, the identification of the GO device to which mobile phone B is connected, and the like.
[0244] S318, after receiving the Wi-Fi connection request, the communication module in the large-screen device will verify the mobile phone B. For example, it will verify whether the mobile phone B is a trusted device, and determine whether the large-screen device has established a Wi-Fi P2P connection with the mobile phone B.
[0245] S319, since the Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be maintained by both devices, and the reuse of Wi-Fi P2P capability is for one device, applying for Wi-Fi P2P capability reuse for only one device can only guarantee that the device will not actively disconnect the Wi-Fi P2P link during the service. The opposite device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, after determining that the large-screen device is a GO device, mobile phone B is a trusted device (for example, mobile phone B and the large-screen device are logged in with the same account, or mobile phone B and the large-screen device have been bound in various ways (for example, through QR code scanning, etc.), and the large-screen device has established a Wi-Fi P2P connection with mobile phone B, the communication module in the large-screen device will also send a request to apply for reuse of Wi-Fi P2P capability to the P2P link management module in the large-screen device. Optionally, the request for reusing the Wi-Fi P2P capability may include: indication information that Wi-Fi P2P links already exist between the large-screen device and the mobile phone B and the mobile phone A, respectively.
[0246] S320, after the P2P link management module in the large-screen device receives the request, as a possible implementation method, if the request for reusing the Wi-Fi P2P capability includes: indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, respectively, then the P2P link management module in the large-screen device can determine that the large-screen device can reuse the Wi-Fi P2P capability. Or, as another possible implementation method, if the request for reusing the Wi-Fi P2P capability does not include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, respectively, since the communication module in the large-screen device has stored the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the devices connected to itself (including mobile phone B and mobile phone A), the role and address information of these devices, the information of the P2P group, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that Wi-Fi P2P links already exist between the large-screen device and mobile phone B and mobile phone A, respectively, or determine that Wi-Fi P2P links already exist between the large-screen device and mobile phone A, respectively, and these two Wi-Fi P2P links support the use of other services, then it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0247] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection services of mobile phone A and mobile phone B to the large-screen device, respectively). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 3, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 3 services (screen projection services of mobile phone A and mobile phone B to the large-screen device, respectively, and file sharing services of mobile phone B to mobile phone A). After the value of the reference count becomes 3, if both screen projection services are disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both screen projection services and one file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0248] S321, after the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in the large-screen device.
[0249] S322, after receiving the response information, the communication module in the large-screen device sends a Wi-Fi P2P connection response information to the communication module in mobile phone A, and the connection response information includes: P2P group information. Optionally, the connection response information may also include: indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. In the embodiment of the present application, the P2P group information includes: at least one of the SSID, BSSID, frequency, and password (PASSWORD) of the P2P group.
[0250] S323, after receiving the Wi-Fi P2P connection response information, the communication module in mobile phone A determines, based on the P2P group information, that the data of the first application can be transmitted between mobile phone B and mobile phone B via the Wi-Fi P2P connection. The communication module in mobile phone A sends the Wi-Fi P2P connection response information to the communication module in mobile phone B via the first connection, and the Wi-Fi P2P connection information is encrypted using an encryption key. The Wi-Fi P2P connection information includes: the IP address and port number information of mobile phone A, the identifier of the GO device to which mobile phone A is connected, and other information. Optionally, the Wi-Fi P2P connection information may also include: indication information that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device, respectively.
[0251] S324, after receiving the Wi-Fi P2P connection information, the communication module in mobile phone B uses the decryption key to decrypt and obtain the content of the Wi-Fi P2P connection information. As a possible implementation method, if the Wi-Fi P2P connection information includes indication information that mobile phone B and mobile phone A are connected to the large-screen device respectively through Wi-Fi P2P, the communication module in mobile phone B determines that the data of the first application can be transmitted with mobile phone A through the Wi-Fi P2P connection according to the indication information that mobile phone B and mobile phone A are connected to the large-screen device respectively through Wi-Fi P2P. Or, as another possible implementation method, if the Wi-Fi P2P connection information does not include indication information that mobile phone B and mobile phone A are connected to the large-screen device respectively through Wi-Fi P2P, when the identifier of the GO device connected to mobile phone A is the same as the identifier of the GO device connected to itself, the communication module in mobile phone B can determine that mobile phone B and mobile phone A are connected to the large-screen device respectively through Wi-Fi P2P, thereby determining that the data of the first application can be transmitted with mobile phone A through the Wi-Fi P2P connection.
[0252] Since the Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be maintained by both devices, applying for Wi-Fi P2P capability reuse for only one device can only guarantee that the device will not actively disconnect the Wi-Fi P2P link during the service. The peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect service transmission. Therefore, the communication module in mobile phone B will also send a request for applying for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone B. Optionally, the request for applying for reuse of Wi-Fi P2P capability can also include: indication information that mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively.
[0253] S325, after the P2P link management module in mobile phone B receives the request, as a possible implementation method, if the request carries the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, the P2P link management module in mobile phone B can determine that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation method, if the request carries the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and these two Wi-Fi P2P connections respectively support the use of other services, then the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation method, if the request does not carry the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. Since the existing connection information is already stored in the communication module of mobile phone B, the connection information includes: the current connection status and role of mobile phone B (for example, mobile phone B already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone B can obtain the connection information from the communication module, and determine that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to itself, that is, it can be determined that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and the P2P link management module in mobile phone B determines that mobile phone B can reuse the Wi-Fi P2P capability.
[0254] Furthermore, mobile phone B can also maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone B. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone B is 1, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 1 service (screen projection service of mobile phone B to large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (screen projection service of mobile phone B to large-screen device and file sharing service of mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone B will not disconnect the Wi-Fi P2P link between mobile phone B and the large-screen device, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone B disconnect the Wi-Fi P2P link.
[0255] S326, after the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone B.
[0256] S327, after receiving the response information, the communication module in mobile phone B sends a Wi-Fi P2P connection request response information to the first application on mobile phone B. The Wi-Fi P2P connection request response information includes: indication information that the data of the first application can be transmitted between mobile phone B and mobile phone A via a Wi-Fi P2P connection, the IP address and port number of mobile phone A, and the port number information generated by mobile phone B itself.
[0257] S328, the first application on mobile phone B uses the IP address and port number information of mobile phone A, combined with the IP address of mobile phone B and the port number generated by mobile phone B itself, to establish a socket transmission channel with the first application on mobile phone A (for example, file sharing).
[0258] S329, the first application on mobile phone B starts sharing files with the first application on mobile phone A based on the socket transmission channel. After the file sharing service starts, mobile phone B first transmits the data of the shared file to the large-screen device, and the large-screen device then transmits the data of the shared file to mobile phone A, that is, the data flow of the file sharing service is: mobile phone B→large-screen device→mobile phone A. The data flow of the screen projection service of mobile phone A is mobile phone A→large-screen device, and the data flow of the screen projection service of mobile phone B is mobile phone B→large-screen device.
[0259] Optionally, as another possible implementation, Fig.12 Shown is Fig.10 In the scenario shown, the present application provides another schematic flow chart of a Wi-Fi P2P connection method. In which, mobile phone A and mobile phone B are respectively projecting screens to a large-screen device through their respective Wi-Fi P2P connections. Fig.12 As shown, the method includes: S401 to S429.
[0260] S401, the user opens the first application (i.e., the file management application) on mobile phone B, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c.
[0261] S402, after the user clicks "Wi-Fi Direct", the first application on mobile phone B sends a device discovery request to the communication module in mobile phone B.
[0262] S403: After receiving the device discovery request, the communication module in mobile phone B starts a device discovery method such as BLE scanning, BR scanning, WLAN scanning or Wi-Fi P2P scanning to discover the device.
[0263] S404, after the communication module in mobile phone B scans the device, it sends the scanned device list to the first application on mobile phone B, where the device list includes device identifiers of one or more devices. For example, the displayed device list can be as follows: Figure 8 As shown in d.
[0264] S405, the user selects the device identifier of mobile phone A in the device list on the first application on mobile phone B. The device identifier of mobile phone A may be the device model, identification code, device name, device ID, etc. of mobile phone A. The device identifier of mobile phone A is used to uniquely identify mobile phone A.
[0265] S406: The first application on mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone B.
[0266] S407, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone B first establishes a first connection with the communication module in mobile phone A. For example, the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0267] S408, the communication module in mobile phone B and the communication module in mobile phone A negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0268] S409, the communication module in mobile phone B stores the encryption key and decryption key.
[0269] S410, the communication module in mobile phone A stores the encryption key and the decryption key.
[0270] S411, after mobile phone B establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone B will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Therefore, the communication module of mobile phone B has maintained the existing connection information, which includes: the current Wi-Fi P2P connection status and role of mobile phone B (for example, mobile phone B already has a Wi-Fi P2P connection and the role is GC, which can be represented by 2), the role of the connected device (large-screen device) (GO), and the MAC address and identification of the large-screen device. As for the large-screen device, the communication module in the large-screen device will also receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is a GO role, the connection information includes the Wi-Fi P2P connection status, role, and address information of the devices (including mobile phone A and mobile phone B) connected to itself (large-screen device), as well as the information of the P2P group. In the embodiment of the present application, the P2P group information includes at least one of the SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, the communication module in mobile phone B determines that mobile phone B is already a GC based on the connection information, and further determines that mobile phone B cannot directly establish a Wi-Fi P2P connection with mobile phone A.
[0271] S412, the communication module in mobile phone B sends a connection request to the communication module in the large-screen device, and the connection request includes at least one of: the device identification of mobile phone A, the MAC address of the Wi-Fi P2P port of mobile phone A, and the IP address information of mobile phone A. The connection request is used to request: requesting that the first application data be transmitted between mobile phone A and mobile phone B via the Wi-Fi P2P connection. It should be understood that in the embodiment of the present application, mobile phone B can obtain information such as the MAC address of the Wi-Fi P2P port of mobile phone A and the IP address of mobile phone A through the first connection between mobile phone B and mobile phone A.
[0272] S413, after receiving the connection request, the communication module in the large-screen device will verify mobile phone A. For example, it will verify whether mobile phone A is a trusted device and determine whether the large-screen device has established a connection with mobile phone A.
[0273] S414, after determining that the large-screen device is a GO device, mobile phone A is a trusted device (for example, mobile phone A and the large-screen device are logged into the same account, or mobile phone A and the large-screen device have been bound in various ways (for example, by scanning a QR code, etc.), and the large-screen device has established a Wi-Fi P2P connection with mobile phone A, the communication module in the large-screen device sends a request for applying for reuse of Wi-Fi P2P capabilities to the P2P link management module in the large-screen device. Optionally, the request for reuse of Wi-Fi P2P capabilities may include: indication information that Wi-Fi P2P links already exist between the large-screen device and mobile phone B and mobile phone A, respectively.
[0274] S415, after the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request for reusing the Wi-Fi P2P capability includes: indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, then the P2P link management module in the large-screen device can determine that the large-screen device can reuse the Wi-Fi P2P capability. Or, as another possible implementation, if the request for reusing the Wi-Fi P2P capability does not include indication information that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, since the communication module in the large-screen device has stored the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the devices connected to itself (including mobile phone B and mobile phone A), the role and address information of these devices, the information of the P2P group, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that Wi-Fi P2P links already exist between the large-screen device and mobile phone B and mobile phone A, respectively, or determine that Wi-Fi P2P links already exist between the large-screen device and mobile phone A, respectively, and these two Wi-Fi P2P links support the use of other services, then it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0275] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection services of mobile phone A and mobile phone B to the large-screen device, respectively). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 3, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 3 services (screen projection services of mobile phone A and mobile phone B to the large-screen device, respectively, and file sharing services of mobile phone B to mobile phone A). After the value of the reference count becomes 3, if both screen projection services are disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both screen projection services and one file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0276] S416: After the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in the large-screen device.
[0277] S417, after receiving the response information, the communication module in the large-screen device sends a connection request response information to the communication module in mobile phone B, and the connection request response information includes: indication information allowing mobile phone A and mobile phone B to transmit the data of the first application via a Wi-Fi P2P connection, as well as P2P group information and the identifier of the GO device to which mobile phone A is connected. Optionally, the connection request response information also includes: indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. In an embodiment of the present application, the P2P group information includes: at least one of the SSID, BSSID, frequency, and password (PASSWORD) of the P2P group.
[0278] S418, after receiving the connection request response information, the communication module in mobile phone B determines that the data of the first application can be transmitted between mobile phone A and mobile phone B through the Wi-Fi P2P connection according to the indication information of allowing the data of the first application to be transmitted between mobile phone A and mobile phone B through the Wi-Fi P2P connection. Since the Wi-Fi P2P link (or Wi-Fi P2P connection) between the two devices needs to be maintained by the two devices together, and the reuse of Wi-Fi P2P capability is for one device, only applying for the reuse of Wi-Fi P2P capability for a certain device can only ensure that the device will not actively disconnect the Wi-Fi P2P link during the service continuation, and the opposite device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, the communication module in mobile phone B will also send a request to apply for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone B. The request for reuse of Wi-Fi P2P capability includes the identifier of the GO device to which mobile phone A is connected. Optionally, the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that the mobile phone B and the mobile phone A have Wi-Fi P2P connections with the large-screen device respectively.
[0279] S419, after the P2P link management module in mobile phone B receives the request, as a possible implementation, if the request carries the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, the P2P link management module in mobile phone B can determine that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation, if the request carries the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and these two Wi-Fi P2P connections respectively support the use of other services, then the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation, if the request does not carry the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. Since the communication module in mobile phone B has stored the existing connection information, the connection information includes: the current connection status and role of mobile phone B (for example, mobile phone B already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone B can obtain the connection information from the communication module, and then determine that the identifier of the GO device connected to mobile phone A is the same as the identifier of the GO device connected to itself based on the connection information. The communication module in mobile phone B can determine that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, and the P2P link management module in mobile phone B determines that mobile phone B can reuse the Wi-Fi P2P capability.
[0280] Furthermore, mobile phone B can also maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone B. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone B is 1, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 1 service (screen projection service of mobile phone B to large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (screen projection service of mobile phone B to large-screen device and file sharing service of mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone B will not disconnect the Wi-Fi P2P link between mobile phone B and the large-screen device, and mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone B disconnect the Wi-Fi P2P link.
[0281] S420: After the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone B.
[0282] S421, after receiving the response information, the communication module in mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone A through the first connection, and the Wi-Fi P2P connection request response information is encrypted by the encryption key. The Wi-Fi P2P connection request: P2P group information, the identifier of the GO device to which mobile phone B is connected. Optionally, the Wi-Fi P2P connection may also include: indication information that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device respectively.
[0283] S422, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone A uses the decryption key to decrypt, obtain the content included in the Wi-Fi P2P connection request, and determine whether the identifier of the GO device to which mobile phone B is connected is the same as the identifier of the GO device to which it is connected. As a possible implementation, if the Wi-Fi P2P connection information includes indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively, the communication module in mobile phone B determines that the data of the first application can be transmitted between mobile phone A and mobile phone B through the Wi-Fi P2P connection based on the indication information that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A and the large-screen device respectively. Alternatively, as another possible implementation method, if the Wi-Fi P2P connection information does not include indication information that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device respectively, when the identifier of the GO device connected to mobile phone A is the same as the identifier of the GO device connected to itself, the communication module in mobile phone B can determine that a Wi-Fi P2P connection exists between mobile phone B and mobile phone A and the large-screen device respectively, thereby determining that the data of the first application can be transmitted between mobile phone A and mobile phone A via the Wi-Fi P2P connection.
[0284] S423, after determining that mobile phone B can transmit the data of the first application through the Wi-Fi P2P connection with mobile phone A. Since the Wi-Fi P2P link (or Wi-Fi P2P connection) between the two devices needs to be maintained by the two devices together, applying for Wi-Fi P2P capability reuse for only one device can only guarantee that the device will not actively disconnect the Wi-Fi P2P link during the service. The opposite device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, the communication module in mobile phone A will also send a request for applying for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone A. The request for reuse of Wi-Fi P2P capability may also include: indication information that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to mobile phone A, or at least one of the indication information that mobile phone B and mobile phone A have Wi-Fi P2P connections with large-screen devices respectively and the identifier of the GO device connected to mobile phone B.
[0285] S424, after the P2P link management module in mobile phone A receives the request, as a possible implementation method, if the request carries: indication information that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to mobile phone A, or indication information that mobile phone B and mobile phone A are respectively connected to the large-screen device with Wi-Fi P2P, the P2P link management module in mobile phone A can determine that there are Wi-Fi P2P connections between mobile phone A and mobile phone B and the large-screen device, and the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation method, if the request carries: indication information that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to mobile phone A, or indication information that there are Wi-Fi P2P connections between mobile phone B and mobile phone A and the large-screen device, and these two Wi-Fi P2P connections each support the use of other services, the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused. Alternatively, as another possible implementation, if the request does not carry the indication information that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to mobile phone A, or the indication information that mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively. Since the communication module in mobile phone A has stored the existing connection information, the connection information includes: the current connection status and role of mobile phone A (for example: mobile phone A already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone A can obtain the connection information from the communication module, and then determine that the identifier of the GO device connected to mobile phone B is the same as the identifier of the GO device connected to itself based on the connection information, then it can be determined that mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively, and the P2P link management module in mobile phone B determines that mobile phone B can reuse the Wi-Fi P2P capability.
[0286] Furthermore, mobile phone A can also maintain a reference count, which is used to indicate the number of services (or applications) that use the Wi-Fi P2P capability of mobile phone A at the same time. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone A is 1, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 1 service (screen projection service from mobile phone A to large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (screen projection service from mobile phone A to large-screen device and file sharing service from mobile phone B to mobile phone A). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone A will not disconnect the Wi-Fi P2P link between mobile phone A and the large-screen device) Mobile phone B can still share files with mobile phone A normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will mobile phone A disconnect the Wi-Fi P2P link.
[0287] S425, after the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone A.
[0288] S426, after receiving the response information, the communication module in mobile phone A sends Wi-Fi P2P connection request response information to the communication module in mobile phone B, and the Wi-Fi P2P connection request response information is encrypted by the encryption key. The Wi-Fi P2P connection request response information includes: indication information allowing mobile phone A and mobile phone B to transmit data of the first application via the Wi-Fi P2P connection, the IP address and port number information of mobile phone A, etc.
[0289] S427, after receiving the Wi-Fi P2P connection request response information, the communication module in mobile phone B sends a Wi-Fi P2P connection request response information to the first application on mobile phone B. The Wi-Fi P2P connection request response information includes: instruction information allowing mobile phone A and mobile phone B to transmit data of the first application via a Wi-Fi P2P connection, the IP address and port number information of mobile phone A, the port number generated by mobile phone B itself, etc.
[0290] S428, the first application on mobile phone B uses the IP address and port number information of mobile phone A, combined with the IP address of mobile phone B and the port number generated by mobile phone B itself, to establish a socket transmission channel with the first application on mobile phone A (for example, file sharing).
[0291] S429, the first application on mobile phone B starts sharing files with the first application on mobile phone A based on the socket transmission channel. After the file sharing service starts, mobile phone B first transmits the data of the shared file to the large-screen device, and the large-screen device then transmits the data of the shared file to mobile phone A, that is, the data flow of the file sharing service is: mobile phone B→large-screen device→mobile phone A. The data flow of the screen projection service is mobile phone A→large-screen device and mobile phone B→large-screen device.
[0292] In the embodiment of the present application, after the three services of one file sharing service and two screen projection services are completed, that is, when the reference count maintained by the large-screen device is 0, the P2P group and the GO device will be removed. After the completion of one file sharing service and any one of the two screen projection services, the reference counts maintained by mobile phone A, mobile phone B and the large-screen device are all reduced to 1. Since the reference count is not 0, in this case, the GO device and the P2P group will not be removed.
[0293] The Wi-Fi P2P connection method provided by the present application can use multiple discovery methods to discover each other between the first electronic device (GC device) and the third electronic device (another GC device) in the P2P group, and when the first electronic device and the third electronic device in the P2P group cannot directly perform Wi-Fi P2P connection, the first electronic device uses the second electronic device (GO device) in the P2P group as an intermediary device to assist itself and the third electronic device in establishing a socket transmission channel, thereby forming the basis for the two to communicate. At the same time, the first electronic device and the third electronic device in the P2P group can obtain each other's IP address and port number, thereby realizing data transmission between the two based on the socket transmission channel. And the Wi-Fi P2P capabilities of the first electronic device, the second electronic device and the third electronic device are reused, and the first electronic device, the second electronic device and the third electronic device can perceive that the current Wi-Fi P2P capabilities of the first electronic device, the second electronic device and the third electronic device carry multiple services. After the multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thereby ensuring that different services can be transmitted normally and different services will not affect each other. When data transmission is performed, the second electronic device in the P2P group is used as a transfer. This enables the transmission of services based on Wi-Fi P2P connections, solves the problem in the prior art that data cannot be transmitted between two GC devices in a P2P group, and improves user experience.
[0294] Fig.13 Another example of a communication system applicable to an embodiment of the present application is shown in FIG. Fig.13As shown, the system architecture includes: a first electronic device, a second electronic device and a fourth electronic device, wherein a Wi-Fi P2P connection has been established between the second electronic device and the first electronic device. In other words, the second electronic device and the first electronic device have formed a P2P group. In the P2P group, the second electronic device is a GO device or an AP device, and the first electronic device is a GC device. The fourth electronic device is an idle device outside the P2P group, and there is no Wi-Fi P2P connection between the fourth electronic device and other devices. Fig.13 In the example shown, the fourth electronic device is mobile phone C, the first electronic device is mobile phone A, and the second electronic device is a large-screen device (such as a smart TV). Mobile phone A is projecting the screen to the large-screen device, and then mobile phone C (idle device) needs to initiate file sharing to the large-screen device. Mobile phone A and the large-screen device use a Wi-Fi P2P link to project the screen.
[0295] Fig.14 Shown is Fig.13 In the scenario shown, the present application provides a schematic flow chart of a Wi-Fi P2P connection method. Fig.14 As shown, the method includes: S501 to S522.
[0296] S501, mobile phone A and the large-screen device have transmitted the business data of the second application (i.e., the screen projection application) based on the established Wi-Fi P2P connection.
[0297] S502, the user opens the first application (i.e., the file management application) on the mobile phone C, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c.
[0298] S503, after the user clicks "Wi-Fi Direct", the first application on mobile phone C sends a device discovery request to the communication module in mobile phone C.
[0299] S504: After receiving the device discovery request, the communication module in the mobile phone C starts a device discovery method such as BLE scanning, BR scanning, WLAN scanning or Wi-Fi P2P scanning to discover the device.
[0300] S505, after the communication module in mobile phone C scans the device, it sends the scanned device list to the first application on mobile phone C, where the device list includes device identifiers of one or more devices. For example, the displayed device list can be as follows: Figure 8 As shown in d.
[0301] S506, the user selects the device identifier of the large-screen device in the device list on the first application on the mobile phone C. The device identifier of the large-screen device may be the device model, identification code, device name, device ID, etc. The device identifier of the large-screen device is used to uniquely identify the large-screen device.
[0302] S507, after the user clicks the device identifier of the large-screen device in the device list, the first application on the mobile phone C sends a Wi-Fi P2P connection request to the communication module in the mobile phone C.
[0303] S508, after receiving the Wi-Fi P2P connection request, the communication module in the mobile phone C first establishes a request for a first connection with the communication module in the large-screen device. For example, the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0304] S509, the communication module in mobile phone C and the communication module in the large-screen device negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0305] S510, the communication module in mobile phone C stores the encryption key and the decryption key.
[0306] S511, the communication module in the large-screen device stores the encryption key and the decryption key.
[0307] S512, the communication module in the mobile phone C sends a Wi-Fi P2P connection request to the communication module in the large-screen device through the first connection. The Wi-Fi P2P connection request is encrypted using an encryption key. The Wi-Fi P2P connection request includes: device information of mobile phone C (such as device ID, etc.), current Wi-Fi P2P connection status of mobile phone C (the current Wi-Fi P2P connection status of mobile phone C includes: the status that mobile phone C currently has no Wi-Fi P2P connection with any device, and the connection status can be represented by 0; the status that mobile phone C currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone C is GO, and the connection status can be represented by 1; the status that mobile phone C currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone C is GC, and the connection status can be represented by 2. In this embodiment, mobile phone C currently has no Wi-Fi P2P connection, and the current Wi-Fi P2P connection status of mobile phone C is represented by 0), the MAC address of the Wi-Fi P2P port of mobile phone C, the channel list supported by mobile phone C (for example, supporting 36 channels, corresponding to 5180MHz), the connection mode expected by mobile phone C (for example, mobile phone C expects to establish a Wi-Fi P2P connection as a GC, or mobile phone C expects to establish a Wi-Fi P2P connection as a GO. In this embodiment, mobile phone C expects to establish a Wi-Fi P2P connection as a GC. P2P connection), the frequency of the Wi-Fi hotspot connected to mobile phone C, whether broadband is supported (for example, whether 160MHz is supported, which can be indicated by true if supported and false if not).
[0308] S513, after receiving the Wi-Fi P2P connection request, the communication module in the large-screen device uses the decryption key to decrypt, and verifies whether mobile phone C is a trusted device, and determines whether the large-screen device has established a Wi-Fi P2P connection with mobile phone C.
[0309] S514, after mobile phone A establishes a Wi-Fi P2P connection with the large-screen device, the large-screen device has maintained the existing connection information, which includes: the Wi-Fi P2P connection status with the device connected to itself (including mobile phone A), the role (GC) and the address information of these devices, the information of the P2P group, etc. After determining that the large-screen device has not established a Wi-Fi P2P connection with mobile phone C, the large-screen device is a GO device, and mobile phone C is a trusted device (for example, mobile phone C and the large-screen device are logged in to the same account, or mobile phone C and the large-screen device have been bound to each other in various ways (for example, through QR code scanning, etc.), the communication module in the large-screen device sends a request to apply for reuse of the Wi-Fi P2P capability to the P2P link management module in the large-screen device. Optional. The request to apply for reuse of the Wi-Fi P2P capability includes: there is a Wi-Fi P2P connection between the large-screen device and mobile phone A, and the large-screen device is a GO device.
[0310] S515, after the P2P link management module in the large-screen device receives the request, as a possible implementation method, if the request for applying for reuse of Wi-Fi P2P capability includes: there is a Wi-Fi P2P connection between the large-screen device and mobile phone A, and the large-screen device is a GO device, then it can be determined that the large-screen device can reuse Wi-Fi P2P capability. Or, as another possible implementation method, if the request for applying for reuse of Wi-Fi P2P capability does not include: there is a Wi-Fi P2P connection between the large-screen device and mobile phone A, and the large-screen device is a GO device, since the communication module in the large-screen device has maintained the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the device connected to itself (including mobile phone A), the role and address information of these devices, P2P group information, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that there is a Wi-Fi P2P connection between the large-screen device and mobile phone A, and that the large-screen device is a GO device, that is, it is determined that the P2P group exists, and it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0311] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 1, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (screen projection service from mobile phone A to the large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection service from mobile phone A to the large-screen device, and file sharing service from mobile phone C to the large-screen device). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone C can still share files with the large-screen device normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0312] S516, after the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in the large-screen device.
[0313] S517, the communication module in the large-screen device receives the response information, and sends a Wi-Fi P2P connection request response information to the communication module in the mobile phone C through the first connection, and the Wi-Fi P2P connection request response information is encrypted using an encryption key. The Wi-Fi P2P connection request response information includes: indication information for allowing mobile phone C to join the P2P group, information about the P2P group composed of mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone C, the IP address and port number of the large-screen device, etc. It should be understood that the Wi-Fi P2P connection request response information may include: any one of the indication information for allowing mobile phone C to join the P2P group and the information about the P2P group composed of mobile phone A and the large-screen device, and does not have to include both the indication information for allowing mobile phone C to join the P2P group and the information about the P2P group composed of mobile phone A and the large-screen device.
[0314] S518, after the communication module in mobile phone C receives the connection request response information and decrypts it using the decryption key, it determines that it can join the P2P group, and then sends a request to join the P2P group to the P2P link management module in mobile phone C. The request carries the P2P group information and the IP address and port number of the large-screen device.
[0315] S519, the P2P link management module in mobile phone C directly initiates a Wi-Fi P2P connection to the large-screen device through the connection interface based on the P2P group information and the IP address and port number of the large-screen device. After joining the P2P group, the P2P link management module in mobile phone C sends a response message to the communication module in mobile phone C, which is used to notify the communication module in mobile phone C that mobile phone C has successfully joined the P2P group.
[0316] S520, after receiving the response information, the communication module in mobile phone C sends a Wi-Fi P2P connection request response information to the first application on mobile phone C, which is used to notify the first application on mobile phone C that mobile phone C has successfully joined the P2P group. The Wi-Fi P2P connection request response information carries: the IP address assigned by the large-screen device to mobile phone C, the port number generated by mobile phone C itself, and the IP address and port number of the large-screen device.
[0317] S521, after mobile phone C joins the P2P group, the first application (i.e., the file sharing application) on mobile phone C uses the IP address assigned by the large-screen device to mobile phone C and the port number generated by mobile phone C itself, combined with the IP address and port number of the large-screen device, to establish a socket transmission channel with the first application (file sharing application) on the large-screen device.
[0318] S522, the first application on mobile phone C starts sharing files with the first application on the large-screen device based on the socket transmission channel. After the file sharing service starts, the data flow of the file sharing service is: mobile phone C → large-screen device. The data flow of the screen projection service is mobile phone A → large-screen device.
[0319] In the embodiment of the present application, the P2P group will be removed, that is, the GO device and the P2P group will be dismantled, only after both the file sharing service and the screen projection service are completed. In other words, the GO device and the P2P group will be dismantled only when the reference count maintained by the large-screen device is 0. After either the file sharing service or the screen projection service is completed, the reference count maintained by the large-screen device is reduced to 1. Since the reference count is not 0, in this case, the GO device and the P2P group will not be dismantled.
[0320] The Wi-Fi P2P connection method provided by the present application manages the P2P link of the second electronic device (GO device). When a Wi-Fi P2P service (or application) already exists between the second electronic device and the first electronic device (GC device) in the P2P group, when a fourth electronic device (idle device) outside the P2P group initiates a Wi-Fi P2P connection to the second electronic device (GO device) to transmit other service data, the second electronic device multiplexes the Wi-Fi P2P capability of the second electronic device, so that the second electronic device can perceive that it currently carries multiple services. After the transmission of the multiple services is completed, the P2P group and the GO device will be removed, thereby ensuring that different services can be transmitted and completed, and different services will not affect each other, thereby improving user experience.
[0321] Fig.15 Another example of a communication system applicable to an embodiment of the present application is shown in FIG. Fig.15 As shown, the system architecture includes: a first electronic device and a second electronic device, wherein a Wi-Fi P2P connection has been established between the first electronic device and the second electronic device. In other words, the first electronic device and the second electronic device have formed a group, in which the second electronic device is a GO device or an AP device, and the first electronic device is a GC device. Fig.15 In the example shown, the first electronic device is mobile phone B and the second electronic device is a large-screen device (such as a smart TV). Mobile phone B (GC device) is projecting the screen to the large-screen device (GO device), and then mobile phone B needs to initiate file sharing to the large-screen device.
[0322] Fig.16 Shown is Fig.15 In the scenario shown, the present application provides a schematic flow chart of a Wi-Fi P2P connection method. Fig.16 As shown, the method includes: S601 to S625.
[0323] S601, mobile phone B and the large-screen device have transmitted the business data of the second application (i.e., the screen projection application) based on the established Wi-Fi P2P connection.
[0324] S602: The user opens the first application (i.e., the file management application) on mobile phone B, for example, Figure 8 As shown in a, select the file to be shared (for example, file 1), click "Share", and select the sharing method as "Wi-Fi Direct". Figure 8 As shown in b and c.
[0325] S603, after the user clicks "Wi-Fi Direct", the first application on mobile phone B sends a device discovery request to the communication module in mobile phone B.
[0326] S604, after receiving the device discovery request, the communication module in mobile phone B starts discovering devices by means of discovering devices such as classic Bluetooth, BLE scanning, WLAN scanning or Wi-Fi P2P scanning. In the embodiment of the present application, classic Bluetooth includes at least one of two types of Bluetooth: BRD and EDR.
[0327] S605, after the communication module in mobile phone B scans the device, it sends the scanned device list to the first application on mobile phone B, where the device list includes device identifiers of one or more devices. For example, the displayed device list can be as follows: Figure 8 As shown in d.
[0328] S606, the user selects the device identifier of the large-screen device in the device list on the first application on mobile phone B, and the device identifier of the large-screen device may be the device model, identification code, device name, device ID, etc. The device identifier of the large-screen device is used to uniquely identify the large-screen device.
[0329] S607, after the user clicks the device identification of the large-screen device in the device list, the first application on mobile phone B sends a Wi-Fi P2P connection request to the communication module in mobile phone B. The Wi-Fi P2P connection request includes the device identification of mobile phone A.
[0330] S608, after receiving the Wi-Fi P2P connection request, the communication module in mobile phone B first establishes a request for a first connection with the communication module in the large-screen device. For example, the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, etc. This embodiment of the application is not limited here.
[0331] S609, the communication module in mobile phone B and the communication module in the large-screen device negotiate keys based on the first connection to obtain encryption keys and decryption keys, thereby completing security authentication based on the first connection.
[0332] S610, the communication module in mobile phone B stores the encryption key and the decryption key.
[0333] S611, the communication module in the large-screen device stores the encryption key and the decryption key.
[0334] S612, after mobile phone B establishes a Wi-Fi P2P connection with the large-screen device, the communication module in mobile phone B will receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Therefore, the communication module in mobile phone B has maintained the existing connection information, which includes: the current Wi-Fi P2P connection status and role of mobile phone B (for example, mobile phone B already has a Wi-Fi P2P connection and the role is GC, which can be represented by 2), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device. As for the large-screen device, the communication module in the large-screen device will also receive a connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is a GO role, the connection information includes the Wi-Fi P2P connection status, role, and address information of the device (including mobile phone B) connected to itself (large-screen device), as well as the information of the P2P group. In the embodiment of the present application, the P2P group information includes: at least one of the service set identifier (SSID), basic service set identifier (BSSID), frequency, and password (PASSWORD) of the P2P group. Therefore, the communication module in mobile phone B determines that mobile phone B is already a GC based on the stored connection information, and determines that it already has a Wi-Fi P2P connection (existing Wi-Fi P2P connection) corresponding to the second application between itself and the large-screen device.
[0335] S613, the communication module in mobile phone B sends a Wi-Fi P2P connection request to the communication module in the large-screen device through the first connection. The Wi-Fi P2P connection request is used to request: authorization to allow mobile phone B to use the existing Wi-Fi P2P connection to transmit the service data of the first application. The Wi-Fi P2P connection request is encrypted using an encryption key. The Wi-Fi P2P connection request includes: the device identification of mobile phone B, the current Wi-Fi P2P connection status of mobile phone B (the current Wi-Fi P2P connection status of mobile phone B includes: the status that mobile phone B currently has no Wi-Fi P2P connection with any device, and the connection status can be represented by 0; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GO, and the connection status can be represented by 1; the status that mobile phone B currently has a Wi-Fi P2P connection with other devices, and the role of mobile phone B is GC, and the connection status can be represented by 2. In this embodiment, mobile phone B currently has a Wi-Fi P2P connection, and the role is GC, and the current Wi-Fi P2P connection status of mobile phone B is represented by 2), the media access control (MAC) address of the Wi-Fi P2P port of mobile phone B, the channel list supported by mobile phone B (for example, supporting 36 channels, corresponding to 5180MHz), the connection mode expected by mobile phone B (for example, mobile phone B expects to establish a Wi-Fi P2P connection as a GC, or mobile phone B expects to establish a Wi-Fi P2P connection as a GO P2P connection, in this embodiment, mobile phone B expects to establish a Wi-Fi P2P connection as a GC), the frequency of the Wi-Fi hotspot connected to mobile phone B, whether broadband is supported (for example, whether 160MHz is supported, if supported, it can be indicated by true, if not supported, it can be indicated by false), and at least one of the following information.
[0336] S614, after the communication module in the large-screen device receives the Wi-Fi P2P connection request, it uses the decryption key to decrypt. After mobile phone B establishes a Wi-Fi P2P connection with the large-screen device, the large-screen device has also maintained the existing connection information, which includes: the Wi-Fi P2P connection status of the devices connected to itself (including mobile phone B), the role and address information of these devices, the information of the P2P group, etc. Therefore, the large-screen device can determine, based on the connection information, that the large-screen device and mobile phone B are in a P2P group, and that a Wi-Fi P2P connection already exists between itself and mobile phone B. The Wi-Fi P2P connection is used to transmit the data stream for mobile phone B to project the screen to the large-screen device.
[0337] S615, the communication module in the large-screen device sends a request for applying for multiplexing of Wi-Fi P2P capability to the P2P link management module in the large-screen device. Optionally, the request for applying for multiplexing of Wi-Fi P2P capability includes: indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device.
[0338] S616, after the P2P link management module in the large-screen device receives the request, as a possible implementation method, if the request carries the indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device, the P2P link management module in mobile phone B can determine that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device, and the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused. Or, as another possible implementation method, if the request does not carry the indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device, since the communication module in the large-screen device has stored the existing connection information, the connection information includes: the Wi-Fi P2P connection status with the device connected to itself (including mobile phone B), the role and address information of these devices, the information of the P2P group, etc. The P2P link management module in the large-screen device can obtain the connection information from the communication module, and then determine, based on the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B, or determine that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B, and that the Wi-Fi P2P link supports the use of other services, then it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
[0339] Furthermore, the large-screen device can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by the large-screen device is 1, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (screen projection service from mobile phone B to the large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (screen projection service from mobile phone B to the large-screen device and file sharing service from mobile phone B to the large-screen device). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not dismantle the P2P group, and mobile phone B can still share files with the large-screen device normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, will the large-screen device dismantle the P2P group.
[0340] S617, after the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the Wi-Fi P2P capability to the communication module in the large-screen device.
[0341] S618, after receiving the response information of the successful reuse of the Wi-Fi P2P capability, the communication module in the large-screen device sends a Wi-Fi P2P connection request response information to the communication module in mobile phone B through the first connection, and the Wi-Fi P2P connection request response information is encrypted using an encryption key. The Wi-Fi P2P connection request response information includes: indication information allowing mobile phone B to use the existing Wi-Fi P2P connection to transmit the service data of the first application, information about the P2P group composed of mobile phone B and the large-screen device, and information such as the IP address and port number of the large-screen device.
[0342] S619, after receiving the connection request response information and decrypting it using the decryption key, the communication module in mobile phone B determines that mobile phone B can use the existing Wi-Fi P2P connection to transmit the service data of the first application.
[0343] S620, since the Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be maintained by both devices, and the reuse of Wi-Fi P2P capability is for one device, applying for Wi-Fi P2P capability reuse for only one device can only guarantee that the device will not actively disconnect the Wi-Fi P2P link during the service. The peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission. Therefore, the communication module in mobile phone B will also send a request for applying for reuse of Wi-Fi P2P capability to the P2P link management module in mobile phone B. Optionally, the request for applying for reuse of Wi-Fi P2P capability includes: indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device.
[0344] S621, after the P2P link management module in mobile phone B receives the request, as a possible implementation, if the request for reusing the Wi-Fi P2P capability includes: indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device, then the P2P link management module in mobile phone B can determine that mobile phone B can reuse the Wi-Fi P2P capability. Or, as another possible implementation, if the request for reusing the Wi-Fi P2P capability does not include indication information that a Wi-Fi P2P connection exists between mobile phone B and the large-screen device, since the communication module in mobile phone B has stored the existing connection information, the connection information includes: the current connection status and role of mobile phone B (for example: mobile phone B already has a Wi-Fi P2P connection and the role is GC), the role of the connected device (large-screen device) (GO), and the MAC address of the large-screen device, etc. The P2P link management module in mobile phone B can obtain the connection information from the communication module, and thus according to the connection information, it can be determined that mobile phone B can reuse the Wi-Fi P2P capability.
[0345] Furthermore, mobile phone B can maintain a reference count, which is used to indicate the number of services (or applications) that simultaneously use the Wi-Fi P2P capability of mobile phone B. Before determining that the Wi-Fi P2P capability can be reused, the value of the reference count maintained by mobile phone B is 1, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 1 service (screen projection service of mobile phone B to large-screen device). After determining that the Wi-Fi P2P capability can be reused, the value of the reference count is increased by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (screen projection service of mobile phone B to large-screen device and file sharing service of mobile phone B to large-screen device). After the value of the reference count becomes 2, if the screen projection service is disconnected, the reference count becomes 1. Since the reference count is not 0, mobile phone B will not disconnect the Wi-Fi P2P link between the large-screen device and the large-screen device, and mobile phone B can still share files with the large-screen device normally. Only when the reference count becomes 0, that is, when both the screen projection service and the file sharing service are disconnected, mobile phone B will not disconnect the Wi-Fi P2P connection with the large-screen device.
[0346] S622: After the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused, it sends a response message of successful reuse of the P2P capability to the communication module in mobile phone B.
[0347] S623, the communication module in mobile phone B receives the response information of successful reuse of P2P capability, and sends Wi-Fi P2P connection request response information to the first application on mobile phone B, which is used to notify the first application on mobile phone B that the service data of the first application can be transmitted using the existing Wi-Fi P2P connection. The Wi-Fi P2P connection request response information includes the IP address and port number of the large-screen device, as well as the port number generated by mobile phone B itself and other information.
[0348] S624, after the first application on mobile phone B receives the Wi-Fi P2P connection request response information, it uses the IP address of mobile phone B and the port number generated by mobile phone B itself, combined with the IP address and port number of the large-screen device, to establish a socket transmission channel with the first application (file sharing application) on the large-screen device.
[0349] S625, the first application on mobile phone B starts sharing files with the first application on the large-screen device based on the socket transmission channel. After the file sharing service starts, the data flow of the file sharing service is: mobile phone B → large-screen device. The data flow of the screen projection service is mobile phone B → large-screen device.
[0350] In an embodiment of the present application, the P2P group will be removed, that is, the GO device and the P2P group will be dismantled, only after both the file sharing service and the screen projection service are completed. In other words, the GO device and the P2P group will be dismantled when the reference count maintained by the large-screen device and mobile phone B is 0. After any one of the file sharing service and the screen projection service is completed, the reference count maintained by mobile phone B and the large-screen device is reduced to 1. Since the reference count is not 0, in this case, the GO device and the P2P group will not be dismantled, that is, the Wi-Fi P2P connection between the large-screen device and mobile phone B will not be dismantled.
[0351] The Wi-Fi P2P connection method provided by the present application reuses the Wi-Fi P2P capabilities of the first electronic device (GO device) and the second electronic device (GC device), so that the first electronic device and the second electronic device can sense that they are currently carrying multiple services. When any of the services is disconnected, it will not actually cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. Only after the multiple services are completed will the GO device be removed and the Wi-Fi P2P connection be disconnected, thereby ensuring that different services can be fully transmitted and completed, and realizing the coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, thereby improving the user experience. Different services will not affect each other, thereby improving the user experience.
[0352] It should be understood that the above is only to help those skilled in the art better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. According to the above examples given, those skilled in the art can obviously make various equivalent modifications or changes, for example, some steps of the above methods may not be necessary, or some new steps may be added. Or a combination of any two or any multiple embodiments of the above. Such modifications, changes or combined solutions also fall within the scope of the embodiments of the present application.
[0353] It should also be understood that the division of the methods, situations, categories and embodiments in the embodiments of the present application is only for the convenience of description and should not constitute a special limitation. The features of various methods, categories, situations and embodiments can be combined without contradiction.
[0354] It should also be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0355] It should also be understood that the above description of the embodiments of the present application focuses on emphasizing the differences between the various embodiments. The same or similar points that are not mentioned can be referenced to each other. For the sake of brevity, they will not be repeated here.
[0356] The above combination Figure 1-Figure 16 An embodiment of a method for transmitting data under Wi-Fi Direct provided by an embodiment of the present application is described, and an electronic device provided by an embodiment of the present application is described below.
[0357] In this embodiment, the electronic device (including the first electronic device, the second electronic device, the third electronic device, and the fourth electronic device) can be divided into functional modules according to the above method. For example, it can be divided into various functional modules corresponding to various functions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0358] It should be noted that the relevant contents of each step involved in the above method embodiment can all be referred to the functional description of the corresponding functional module, which will not be repeated here.
[0359] The electronic device provided in the embodiment of the present application is used to perform the above-mentioned method embodiment to provide any method for data transmission under Wi-Fi direct connection, so the same effect as the above-mentioned implementation method can be achieved. In the case of an integrated unit, the electronic device may include a processing module, a storage module and a communication module. Among them, the processing module can be used to control and manage the actions of the electronic device. For example, it can be used to support the electronic device to execute the steps performed by the processing unit. The storage module can be used to support the storage of program codes and data, etc. The communication module can be used to support the communication between the electronic device and other devices.
[0360] Among them, the processing module can be a processor or a controller. It can implement or execute various exemplary logic boxes, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, etc.
[0361] For example, Fig.17 FIG. 1 is a schematic diagram showing the hardware structure of an example of an electronic device 700 provided in the present application. The electronic device 700 may be the first terminal device, the second terminal device or the third terminal device mentioned above. Fig.14 As shown, the electronic device 700 may include a processor 710, an external memory interface 720, an internal memory 721, a universal serial bus (USB) interface 730, a charging management module 740, a power management module 741, a battery 742, an antenna 1, an antenna 2, a wireless communication module 750, and the like.
[0362] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 700. In other embodiments of the present application, the electronic device 700 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0363] The processor 710 may include one or more processing units. For example, the processor 710 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent components or integrated into one or more processors. In some embodiments, the electronic device 700 may also include one or more processors 710. The controller may generate an operation control signal based on the instruction opcode and the timing signal to complete the control of fetching and executing instructions.
[0364] In some embodiments, the processor 710 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM card interface, and / or a USB interface, etc. Among them, the USB interface 730 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 2530 can be used to connect a charger to charge the electronic device 700, and can also be used to transmit data between the electronic device 700 and peripheral devices.
[0365] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 700. In other embodiments of the present application, the electronic device 700 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0366] The wireless communication function of the electronic device 700 can be implemented through the antenna 1, the antenna 2 and the wireless communication module 750.
[0367] The wireless communication module 750 can provide wireless communication solutions including Wi-Fi (including Wi-Fi sensing and Wi-Fi AP), Bluetooth (BT), wireless data transmission modules (for example, 433MHz, 868MHz, 715MHz) applied to the electronic device 700. The wireless communication module 750 can be one or more devices integrating at least one communication processing module. The wireless communication module 750 receives electromagnetic waves via antenna 1 or antenna 2 (or, antenna 1 and antenna 2), filters and frequency modulates the electromagnetic wave signals, and sends the processed signals to the processor 710. The wireless communication module 750 can also receive the signal to be sent from the processor 710, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through antenna 1 or antenna 2.
[0368] The external memory interface 720 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 700. The external memory card communicates with the processor 710 through the external memory interface 720 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0369] The internal memory 721 may be used to store one or more computer programs, which include instructions. The processor 710 may enable the electronic device 700 to perform the method for data transmission under Wi-Fi Direct provided in some embodiments of the present application, as well as various applications and data processing, etc. by running the above instructions stored in the internal memory 721. The internal memory 721 may include a code storage area and a data storage area. Among them, the code storage area may store an operating system. The data storage area may store data created during the use of the electronic device 700, etc. In addition, the internal memory 721 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage components, a flash memory component, a universal flash storage (UFS), etc. In some embodiments, the processor 710 may enable the electronic device 700 to perform any of the methods for data transmission under Wi-Fi Direct provided in the embodiments of the present application, as well as other applications and data processing by running instructions stored in the internal memory 721, and / or instructions stored in a memory provided in the processor 710.
[0370] The electronic device 700 includes, but is not limited to, a smart TV, a large-screen device, a mobile phone, a tablet computer, a notebook, a large-screen TV, a smart home appliance, a PDA, a POS, a car computer, etc. The present application embodiment is not limited here.
[0371] It should be understood that the specific process of the electronic device 700 performing the above corresponding steps can be referred to in conjunction with the above Figure 7 , Fig. 9 , Fig.11 , Fig.12 , Fig.14 , Fig.16 For the sake of brevity, the relevant descriptions of the steps executed by the first electronic device, the second electronic device, the third electronic device or the fourth electronic device described in each embodiment are not repeated here.
[0372] Fig.18 A schematic block diagram of another example of a communication device 800 provided in an embodiment of the present application is shown. The communication device 800 may correspond to the first electronic device, the second electronic device, the third electronic device, or the fourth electronic device described in each embodiment of the above-mentioned methods, or may be a chip or component applied to the first electronic device, the second electronic device, the third electronic device, or the fourth electronic device. In addition, each module or unit in the communication device 800 is respectively used to execute each action or processing process performed by the first electronic device, the second electronic device, the third electronic device, or the fourth electronic device described in each of the above-mentioned methods, such as Fig.18 As shown, the communication device 800 may include: a processing unit 810 and a communication unit 820. Optionally, the communication device 800 may also include a storage unit 830.
[0373] It should be understood that the specific process of each unit in the communication device 800 performing the above corresponding steps can be referred to in conjunction with the above Figure 7 , Fig. 9 , Fig.11 , Fig.12 , Fig.14 and Fig.16 For the sake of brevity, the relevant descriptions of the steps executed by the first electronic device, the second electronic device, the third electronic device or the fourth electronic device described in each embodiment are not repeated here.
[0374] Optionally, the communication unit 820 may include a receiving unit (module) and a sending unit (module), which are used to perform the steps of receiving information and sending information by the first terminal device, the second terminal device, or the third terminal device in the aforementioned various method embodiments. The storage unit 830 is used to store instructions executed by the processing unit 810 and the communication unit 820. The processing unit 810, the communication unit 820, and the storage unit 830 are connected in communication, the storage unit 830 stores instructions, the processing unit 810 is used to execute the instructions stored in the storage unit 830, and the communication unit 820 is used to perform specific signal transmission and reception under the drive of the processing unit 810.
[0375] It should be understood that the communication unit 820 may be a transceiver, an input / output interface or an interface circuit, etc., for example, Fig.17 The wireless communication module 750 in the illustrated embodiment is implemented. The storage unit may be a memory, for example, Fig.17 The processing unit 810 may be implemented by the external memory interface 720 or the internal memory 721 in the embodiment shown. Fig.17 In the illustrated embodiment, the processor 710 may be implemented by the processor 710 and the internal memory 721 .
[0376] It should also be understood that Fig.18 The communication device 800 shown may be the first electronic device, the second electronic device, the third electronic device or the fourth electronic device mentioned above, or the first electronic device, the second electronic device, the third electronic device or the fourth electronic device may include Fig.18 The communication device 800 is shown.
[0377] It should also be understood that the division of units in the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And the units in the device can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some units can also be implemented in the form of software calling through processing elements, and some units can be implemented in the form of hardware. For example, each unit can be a separately established processing element, or it can be integrated in a certain chip of the device. In addition, it can also be stored in the memory in the form of a program, and called and executed by a certain processing element of the device. The processing element here can also be called a processor, which can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each unit above can be implemented by an integrated logic circuit of hardware in the processor element or in the form of software calling through a processing element. In one example, the unit in any of the above devices may be one or more integrated circuits configured to implement the above method, such as one or more application specific integrated circuits (ASIC), or one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA), or a combination of at least two of these integrated circuit forms. For another example, when the unit in the device can be implemented in the form of a processing element scheduler, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call a program. For another example, these units can be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0378] An embodiment of the present application also provides a system for data transmission under Wi-Fi Direct connection, the system comprising: the first electronic device and the second electronic device provided in the above method embodiment, and optionally, the system may also include the third electronic device or the fourth electronic device provided in the above method embodiment.
[0379] The embodiment of the present application also provides a computer-readable storage medium for storing computer program code, the computer program including instructions for executing any one of the methods for transmitting data under Wi-Fi Direct provided in the above-mentioned embodiment of the present application. The readable medium may be a read-only memory (ROM) or a random access memory (RAM), which is not limited in the embodiment of the present application.
[0380] The present application also provides a computer program product, which includes instructions. When the instructions are executed, the first electronic device, the second electronic device, the third electronic device or the fourth electronic device performs corresponding operations in the above method.
[0381] The embodiment of the present application also provides a chip located in a communication device, the chip comprising: a processing unit and a communication unit, the processing unit, for example, may be a processor, the communication unit, for example, may be an input / output interface, a pin or a circuit, etc. The processing unit may execute computer instructions to enable the communication device to execute any of the methods for transmitting data under Wi-Fi Direct provided in the embodiments of the present application.
[0382] Optionally, the computer instructions are stored in a storage unit.
[0383] Optionally, the storage unit is a storage unit within the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip within the terminal, such as a ROM or other types of static storage devices that can store static information and instructions, random RAM, etc. Among them, the processor mentioned in any of the above can be a CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the above-mentioned feedback information transmission method. The processing unit and the storage unit can be decoupled and respectively set on different physical devices, and connected by wired or wireless means to implement the respective functions of the processing unit and the storage unit to support the system chip to implement the various functions in the above-mentioned embodiments. Alternatively, the processing unit and the memory can also be coupled on the same device.
[0384] Among them, the communication device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0385] It is understood that the memory in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a ROM, a programmable read-only memory (programmable ROM, PROM), an erasable programmable read-only memory (erasable PROM, EPROM), an electrically erasable programmable read-only memory (electrically EPROM, EEPROM) or a flash memory. The volatile memory can be a RAM, which is used as an external cache. There are many different types of RAM, such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (synch link DRAM, SLDRAM) and direct memory bus random access memory (direct rambus RAM, DRRAM).
[0386] Various objects such as various messages / information / equipment / network elements / systems / devices / actions / operations / processes / concepts that may appear in this application are named. It can be understood that these specific names do not constitute a limitation on the relevant objects. The names assigned may change with factors such as scenarios, contexts or usage habits. The understanding of the technical meaning of the technical terms in this application should be mainly determined from the functions and technical effects embodied / executed in the technical scheme.
[0387] In the various embodiments of the present application, unless otherwise specified or provided for in any logical conflict, the terms and / or descriptions between the different embodiments are consistent and may be referenced to each other, and the technical features in the different embodiments may be combined to form new embodiments according to their inherent logical relationships.
[0388] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0389] The method in the embodiment of the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer program or instruction can be stored in a computer-readable storage medium or transmitted via the computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server that integrates one or more available media.
[0390] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0391] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0392] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0393] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0394] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a readable storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned readable storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0395] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for data transmission under Wi-Fi direct connection, characterized in that: The method is applied to a system including a first electronic device and a second electronic device, wherein the first electronic device is a GC device in a Wi-Fi Direct group, and the second electronic device is a GO device in the Wi-Fi Direct group; the method includes: During the process of transmitting the data of the first service by the first electronic device and the second electronic device through the first Wi-Fi Direct link, The first electronic device receives a first operation of a user, the first operation is used to send data of a second service to the second electronic device, the second service is different from the first service; after receiving the first operation, the first electronic device increases a reference count maintained by the first electronic device by one, the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the first electronic device; The second electronic device increases the reference count maintained by the second electronic device by one, where the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; The first electronic device sends data of the second service to the second electronic device through the first Wi-Fi Direct link; Among them, after the data transmission of the first service is completed or the data transmission of the second service is completed, the first electronic device reduces the reference count maintained by the first electronic device by one, and the second electronic device reduces the reference count maintained by the second electronic device by one; when the reference count maintained by the first electronic device is 0, the first electronic device disconnects the Wi-Fi Direct link between the first electronic device and the second electronic device; or, when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group.
2. The method according to claim 1, characterized in that After the first electronic device receives a first operation by the user, the method further includes: The first electronic device sends a Wi-Fi direct connection request to the second electronic device through a first connection, where the Wi-Fi direct connection request includes: information of the first electronic device, and the Wi-Fi direct connection request is used to request to send data of the second service to the second electronic device using the first Wi-Fi direct connection link; The second electronic device incrementing the reference count maintained by the second electronic device by one comprises: The second electronic device increases a reference count maintained by the second electronic device by one according to the Wi-Fi Direct connection request; The second electronic device sends Wi-Fi Direct request response information to the first electronic device, where the Wi-Fi Direct request response information includes: group information of the Wi-Fi Direct group and an IP address of the second electronic device; After receiving the first operation, the first electronic device incrementing the reference count maintained by the first electronic device by one comprises: The first electronic device increases the reference count maintained by the first electronic device by one according to the Wi-Fi Direct request response information.
3. The method according to claim 2, characterized in that Before the first electronic device sends a Wi-Fi direct connection request to the second electronic device, the method further includes: The first electronic device and the second electronic device establish the first connection, where the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
4. The method according to claim 2 or 3, characterized in that: Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the Wi-Fi Direct request, that the first Wi-Fi Direct link already exists between the second electronic device and the first electronic device.
5. The method according to claim 2 or 3, characterized in that: Before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: The first electronic device determines that the first Wi-Fi Direct link already exists between the second electronic device and the first electronic device.
6. The method according to claim 2 or 3, characterized in that: The information of the first electronic device includes at least one of: an identification of the first electronic device, a current Wi-Fi Direct connection status of the first electronic device, a MAC address of a Wi-Fi Direct port of the first electronic device, a list of channels supported by the first electronic device, a frequency of a Wi-Fi hotspot to which the first electronic device is connected, and whether the first electronic device supports broadband.
7. The method according to any one of claims 1 to 3, characterized in that The system further includes a third electronic device, where the third electronic device is an idle device outside the Wi-Fi Direct group. Before the first Wi-Fi Direct link is disconnected, the method further includes: The third electronic device receives a second operation of the user, where the second operation is used to send data of a third service to the first electronic device; The third electronic device establishes a second Wi-Fi direct link with the second electronic device; The third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link; In response to receiving the data of the third service, the second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi Direct link.
8. The method according to claim 7, characterized in that Before the third electronic device establishes the second Wi-Fi Direct link with the second electronic device, the method further includes: The first electronic device sends a third connection request to the second electronic device, where the third connection request is used to request that the third electronic device be added to the Wi-Fi Direct group, and the third connection request includes information about the third electronic device; The second electronic device increases a reference count maintained by the second electronic device by one according to the third connection request, where the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; The second electronic device sends third response information in response to the third connection request to the first electronic device, the third response information is used to indicate that the third electronic device is added to the Wi-Fi Direct group, and the third response information includes: an IP address allocated by the second electronic device to the third electronic device, group information of the Wi-Fi Direct group, and a MAC address of the third electronic device; The first electronic device increases a reference count maintained by the first electronic device by one according to the third response information, where the reference count maintained by the first electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the first electronic device.
9. The method according to claim 8, characterized in that Before the first electronic device sends the third connection request to the second electronic device, the method further includes: The third electronic device establishes a second connection with the first electronic device, where the second connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
10. The method according to claim 9, characterized in that The method further comprises: The third electronic device sends a fourth connection request to the first electronic device through the second connection, where the fourth connection request includes information of the third electronic device; The first electronic device sends a fourth connection request response message to the third electronic device through the second connection, wherein the fourth connection request response message includes: the IP address assigned by the second electronic device to the third electronic device, the group information of the Wi-Fi Direct group, the MAC address of the second electronic device, and the IP address and port number of the first electronic device; In response to receiving the fourth connection request response information, the third electronic device establishes the second Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device.
11. The method according to any one of claims 8 to 10, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the third connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi direct link exists between the second electronic device and the first electronic device; Before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: The first electronic device determines, according to the third response information, that a Wi-Fi direct link exists between the first electronic device and the second electronic device.
12. The method according to any one of claims 8 to 10, characterized in that After the data transmission of the third service is completed, the method further includes: The first electronic device reduces the reference count maintained by the first electronic device by one; The second electronic device decrements the reference count maintained by the second electronic device by one.
13. The method according to claim 7, characterized in that Before the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link, the method further includes: The third electronic device sends a fifth connection request to the first electronic device through the second connection, wherein the fifth connection request includes: information of the third electronic device and an identifier of a GO device to which the third electronic device is connected in the Wi-Fi Direct group; The first electronic device increases the reference count maintained by the first electronic device by one according to the fifth connection request; The first electronic device sends a sixth connection request to the second electronic device, where the sixth connection request includes: information of the third electronic device and an identifier of a GO device to which the third electronic device is connected in the Wi-Fi Direct group; The second electronic device increases the reference count maintained by the second electronic device by one according to the sixth connection request; The second electronic device sends sixth response information in response to the sixth connection request to the first electronic device, the sixth response information including: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively; The first electronic device sends, via the second connection, fifth response information in response to the fifth connection to the third electronic device, the fifth response information including: an IP address and a port number of the first electronic device, and an identifier of a GO device to which the first electronic device is connected in the Wi-Fi Direct group; The third electronic device increases a reference count maintained by the third electronic device by one according to the fifth response information, where the reference count maintained by the third electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the third electronic device.
14. The method according to claim 7, characterized in that Before the third electronic device sends the data of the third service to the second electronic device through the second Wi-Fi Direct link, the method further includes: The third electronic device sends a seventh connection request to the second electronic device, where the seventh connection request includes information of the first electronic device; The second electronic device increases the reference count maintained by the second electronic device by one according to the seventh connection request; The second electronic device sends seventh response information in response to the seventh connection request to the third electronic device, the seventh response information including: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device respectively; The third electronic device increases a reference count maintained by the third electronic device by one according to the seventh response information, where the reference count maintained by the third electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the third electronic device; The third electronic device sends an eighth connection request to the first electronic device through the second connection, wherein the eighth connection request includes: group information of the Wi-Fi Direct group and an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group; The first electronic device increases the reference count maintained by the first electronic device by one according to the eighth connection request.
15. The method according to claim 13, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the sixth connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the third electronic device and the first electronic device and the second electronic device, respectively.
16. The method according to claim 14, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the seventh connection request, that the first electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively.
17. The method according to claim 13 or 15, characterized in that Before the third electronic device increases the reference count maintained by the third electronic device by one, the method further includes: The third electronic device determines, according to the fifth response information, that an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group is the same as an identifier of a GO device connected to the first electronic device in the Wi-Fi Direct group.
18. The method according to claim 14 or 16, characterized in that Before the third electronic device increases the reference count maintained by the third electronic device by one, the method further includes: The third electronic device determines, according to the seventh response information, that an identifier of a GO device connected to the first electronic device in the Wi-Fi Direct group is the same as an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group.
19. The method according to claim 13 or 15, characterized in that: Before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: The first electronic device determines, according to the sixth response information, that an identifier of a GO device connected to the first electronic device in the Wi-Fi Direct group is the same as an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group.
20. The method according to claim 14 or 16, characterized in that Before the first electronic device increases the reference count maintained by the first electronic device by one, the method further includes: The first electronic device determines, according to the eighth connection request, that an identifier of a GO device connected to the first electronic device in the Wi-Fi Direct group is the same as an identifier of a GO device connected to the third electronic device in the Wi-Fi Direct group.
21. The method according to any one of claims 13 to 16, characterized in that After the data transmission of the third service is completed, the method further includes: The first electronic device reduces the reference count maintained by the first electronic device by one; The second electronic device reduces the reference count maintained by the second electronic device by one; The third electronic device reduces the reference count maintained by the third electronic device by one.
22. The method according to claim 21, characterized in that The method further comprises: When the reference count maintained by the third electronic device is 0, the third electronic device disconnects the second Wi-Fi Direct link between the third electronic device and the second electronic device.
23. The method according to claim 8, 9, 10, 13 or 15, characterized in that The information of the third electronic device includes at least one of: an identification of the third electronic device, a current Wi-Fi Direct connection status of the third electronic device, a MAC address of a Wi-Fi Direct port of the third electronic device, a channel list supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband.
24. The method of claim 1, 2, 3, 8, 9, 10, 13, 14, 15, 16 or 22, wherein: The system further includes a fourth electronic device, where the fourth electronic device is an idle device outside the Wi-Fi Direct group, and the method further includes: The fourth electronic device receives a third operation of the user, where the third operation is used to send data of a fourth service to the second electronic device; The fourth electronic device establishes a third Wi-Fi direct link with the second electronic device; The fourth electronic device sends the data of the fourth service to the second electronic device through the third Wi-Fi Direct link.
25. The method according to claim 24, characterized in that Before the fourth electronic device establishes a third Wi-Fi Direct link with the second electronic device, the method further includes: The fourth electronic device sends a ninth connection request to the second electronic device through the third connection, wherein the ninth connection request is used to request to add the fourth electronic device to the Wi-Fi Direct group, and the ninth connection request includes information of the fourth electronic device; The second electronic device increases the reference count maintained by the second electronic device by one according to the ninth connection request; The second electronic device sends, through the third connection, ninth response information in response to the ninth connection request to the fourth electronic device, the ninth response information being used to instruct the fourth electronic device to be added to the Wi-Fi Direct group, the ninth response information including: an IP address allocated by the second electronic device to the fourth electronic device, group information of the Wi-Fi Direct group, and a MAC address of the second electronic device; The fourth electronic device establishes the third Wi-Fi Direct link with the second electronic device according to the group information of the Wi-Fi Direct group and the MAC address of the second electronic device.
26. The method according to claim 25, characterized in that Before the fourth electronic device sends a ninth connection request to the second electronic device through the third connection, the method further includes: The fourth electronic device and the second electronic device establish the third connection, and the third connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
27. The method according to claim 25 or 26, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, based on the ninth connection request, that the fourth electronic device is a trusted device and that no Wi-Fi direct link exists between the second electronic device and the fourth electronic device.
28. The method according to claim 25 or 26, characterized in that After the data transmission of the fourth service is completed, the method further includes: The second electronic device decrements the reference count maintained by the second electronic device by one.
29. The method according to claim 25 or 26, characterized in that The information of the fourth electronic device includes at least one of: an identification of the fourth electronic device, a current Wi-Fi Direct connection status of the fourth electronic device, a MAC address of a Wi-Fi Direct port of the fourth electronic device, a channel list supported by the fourth electronic device, a frequency of a Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports broadband.
30. A method for data transmission under Wi-Fi direct connection, characterized in that: The method comprises: The second electronic device and the first electronic device transmit data of the first service through the first Wi-Fi Direct link; The second electronic device receives data of a second service sent by the first electronic device through the first Wi-Fi Direct link, the first electronic device is a GC device in a Wi-Fi Direct group, the second electronic device is a GO device in the Wi-Fi Direct group, and the second service is different from the first service; The second electronic device increases the reference count maintained by the second electronic device by one, where the reference count maintained by the second electronic device is used to indicate the number of services that simultaneously utilize the Wi-Fi P2P capability of the second electronic device; After the data transmission of the first service is completed or the data transmission of the second service is completed, the second electronic device reduces the reference count maintained by the second electronic device by one, and when the reference count maintained by the second electronic device is 0, the second electronic device dismantles the Wi-Fi Direct group.
31. The method according to claim 30, characterized in that Before the second electronic device receives data of a second service sent by the first electronic device through the first Wi-Fi Direct link, the method includes: The second electronic device receives, through the first connection, a Wi-Fi direct connection request sent by the first electronic device, wherein the Wi-Fi direct connection request includes information about the first electronic device, and the Wi-Fi direct connection request is used to request to send data of a second service to the second electronic device by using the first Wi-Fi direct connection link; The second electronic device incrementing the reference count maintained by the second electronic device by one comprises: The second electronic device increases a reference count maintained by the second electronic device by one according to the Wi-Fi Direct connection request; The second electronic device sends Wi-Fi Direct request response information to the first electronic device, where the Wi-Fi Direct request response information includes: group information of the Wi-Fi Direct group and an IP address of the second electronic device.
32. The method according to claim 31, characterized in that Before the second electronic device receives the Wi-Fi direct connection request sent by the first electronic device, the method further includes: The second electronic device establishes the first connection with the first electronic device, and the first connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
33. The method according to claim 31 or 32, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the Wi-Fi Direct request, that the first Wi-Fi Direct link already exists between the second electronic device and the first electronic device.
34. The method according to claim 31 or 32, characterized in that The information of the first electronic device includes at least one of: an identification of the first electronic device, a current Wi-Fi Direct connection status of the first electronic device, a MAC address of a Wi-Fi Direct port of the first electronic device, a list of channels supported by the first electronic device, a frequency of a Wi-Fi hotspot to which the first electronic device is connected, and whether the first electronic device supports broadband.
35. The method according to any one of claims 30 to 32, characterized in that Before the first Wi-Fi Direct link is disconnected, the method further includes: The second electronic device and the third electronic device establish a second Wi-Fi Direct link, and the third electronic device is an idle device outside the Wi-Fi Direct group; The second electronic device receives data of a third service sent by the third electronic device through the second Wi-Fi direct link; The second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi Direct link.
36. The method according to claim 35, characterized in that Before the second electronic device and the third electronic device establish a second Wi-Fi Direct link, the method further includes: The second electronic device receives a third connection request sent by the first electronic device, where the third connection request is used to request to add the third electronic device to the Wi-Fi Direct group, and the third connection request includes information of the third electronic device; The second electronic device increases the reference count maintained by the second electronic device by one according to the third connection request; The second electronic device sends third response information in response to the third connection request to the first electronic device, where the third response information is used to instruct the third electronic device to be added to the Wi-Fi Direct group, and the third response information includes: an IP address allocated by the second electronic device to the third electronic device, group information of the Wi-Fi Direct group, and a MAC address of the third electronic device.
37. The method according to claim 36, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the third connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi direct link exists between the second electronic device and the first electronic device.
38. The method according to claim 36 or 37, characterized in that After the data transmission of the third service is completed, the method further includes: The second electronic device decrements the reference count maintained by the second electronic device by one.
39. The method according to claim 35, characterized in that Before the second electronic device receives the data of the third service sent by the third electronic device through the second Wi-Fi Direct link, the method further includes: The first electronic device sends a sixth connection request to the second electronic device, where the sixth connection request includes: information of the third electronic device and an identifier of a GO device to which the third electronic device is connected in the Wi-Fi Direct group; The second electronic device increases the reference count maintained by the second electronic device by one according to the sixth connection request; The second electronic device sends sixth response information in response to the sixth connection request to the first electronic device, the sixth response information including: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device respectively.
40. The method according to claim 35, characterized in that Before the second electronic device receives the data of the third service sent by the third electronic device through the second Wi-Fi Direct link, the method further includes: The second electronic device receives a seventh connection request sent by the third electronic device, where the seventh connection request includes information of the first electronic device; The second electronic device increases the reference count maintained by the second electronic device by one according to the seventh connection request; The second electronic device sends seventh response information in response to the seventh connection request to the third electronic device, the seventh response information including: group information of the Wi-Fi Direct group, and at least one of indication information that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device respectively.
41. The method according to claim 39, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the sixth connection request, that the third electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the third electronic device and the first electronic device and the second electronic device, respectively.
42. The method according to claim 40, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, according to the seventh connection request, that the first electronic device is a trusted device, and determines that a Wi-Fi P2P connection exists between the first electronic device and the third electronic device and the second electronic device, respectively.
43. The method according to any one of claims 39 to 42, characterized in that After the data transmission of the third service is completed, the method further includes: The second electronic device decrements the reference count maintained by the second electronic device by one.
44. The method of claim 36, 37 or 39, wherein: The information of the third electronic device includes at least one of: an identification of the third electronic device, a current Wi-Fi Direct connection status of the third electronic device, a MAC address of a Wi-Fi Direct port of the third electronic device, a channel list supported by the third electronic device, a frequency of a Wi-Fi hotspot to which the third electronic device is connected, and whether the third electronic device supports broadband.
45. The method of claim 30, 31, 32, 36, 37, 39, 40, 41 or 42, wherein: The method further comprises: The second electronic device establishes a third Wi-Fi Direct link with a fourth electronic device, and the fourth electronic device is an idle device outside the Wi-Fi Direct group; The second electronic device receives data of a fourth service sent by the fourth electronic device through the third Wi-Fi Direct link.
46. The method according to claim 45, characterized in that Before the second electronic device establishes a third Wi-Fi Direct link with the fourth electronic device, the method further includes: The second electronic device receives, through the third connection, a ninth connection request sent by the fourth electronic device, wherein the ninth connection request is used to request that the fourth electronic device be added to the Wi-Fi Direct group, and the ninth connection request includes information of the fourth electronic device; The second electronic device increases the reference count maintained by the second electronic device by one according to the ninth connection request; The second electronic device sends, via the third connection, a ninth response message in response to the ninth connection request to the fourth electronic device, wherein the ninth response message is used to instruct the fourth electronic device to be added to the Wi-Fi Direct group, and the ninth response message includes: an IP address assigned by the second electronic device to the fourth electronic device, group information of the Wi-Fi Direct group, and a MAC address of the second electronic device.
47. The method according to claim 46, characterized in that Before the second electronic device receives the ninth connection request sent by the fourth electronic device through the third connection, the method further includes: The second electronic device and the fourth electronic device establish the third connection, where the third connection includes: any one of a Bluetooth connection and a Wi-Fi connection.
48. The method according to claim 46 or 47, characterized in that Before the second electronic device increases the reference count maintained by the second electronic device by one, the method further includes: The second electronic device determines, based on the ninth connection request, that the fourth electronic device is a trusted device and that no Wi-Fi direct link exists between the second electronic device and the fourth electronic device.
49. The method according to claim 46 or 47, characterized in that After the data transmission of the fourth service is completed, the method further includes: The second electronic device decrements the reference count maintained by the second electronic device by one.
50. The method according to claim 46 or 47, characterized in that The information of the fourth electronic device includes at least one of: an identification of the fourth electronic device, a current Wi-Fi Direct connection status of the fourth electronic device, a MAC address of a Wi-Fi Direct port of the fourth electronic device, a channel list supported by the fourth electronic device, a frequency of a Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports broadband.
51. An electronic device, characterized in that: include: Processor and memory; The processor is coupled to a memory, wherein the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the method according to any one of claims 30 to 50 is performed.
52. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 29.
53. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 30 to 50.
54. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory, so that a communication device equipped with the chip executes a method as claimed in any one of claims 1 to 29.
55. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory, so that a communication device equipped with the chip executes a method as claimed in any one of claims 30 to 50.
Citation Information
Cited By
Data transmission method under wi-fi peer-to-peer, and electronic device
WO2022135187A1
