WO2022135187A1 - Wi-Fi直连下数据传输的方法和电子设备 - Google Patents

Wi-Fi直连下数据传输的方法和电子设备 Download PDF

Info

Publication number
WO2022135187A1
WO2022135187A1 PCT/CN2021/137212 CN2021137212W WO2022135187A1 WO 2022135187 A1 WO2022135187 A1 WO 2022135187A1 CN 2021137212 W CN2021137212 W CN 2021137212W WO 2022135187 A1 WO2022135187 A1 WO 2022135187A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
connection
mobile phone
direct
group
Prior art date
Application number
PCT/CN2021/137212
Other languages
English (en)
French (fr)
Inventor
董继阳
张波
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP21909184.0A priority Critical patent/EP4247041A4/en
Publication of WO2022135187A1 publication Critical patent/WO2022135187A1/zh
Priority to US18/340,689 priority patent/US20230337303A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/02Services making use of location information
    • H04W4/023Services making use of location information using mutual or relative location information between multiple location based services [LBS] targets or of distance thresholds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/02Arrangements for optimising operational condition
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/02Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
    • H04W84/10Small scale networks; Flat hierarchical networks
    • H04W84/12WLAN [Wireless Local Area Networks]

Definitions

  • the present application relates to the field of communications, and more particularly, to a method and electronic device for data transmission under Wi-Fi direct connection.
  • Wi-Fi direct connection wireless fidelity peer-to-peer, Wi-Fi P2P
  • Wi-Fi P2P wireless fidelity technology
  • Wi-Fi DIRECT An important technology under the "Wi-Fi DIRECT" standard protocol launched by the alliance, Wi-Fi P2P can support two Wi-Fi devices to directly connect and communicate with each other's devices without the intervention of Wi-Fi hotspots .
  • 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.
  • a P2P group is formed.
  • the device has two roles of P2P group manager (group owner, GO) and P2P group client (group client, GC). distinguish.
  • group owner group owner
  • P2P group client group client, GC.
  • the 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.
  • Wi-Fi P2P applications (or also called services) on Android and WINDOWS systems independently manage Wi-Fi P2P links.
  • the Wi-Fi P2P link on a device is independently managed and negotiated by each application. Due to resource constraints, only one underlying Wi-Fi P2P link will be generated. One service occupies Wi-Fi P2P resources. When Wi-Fi P2P related services also need to use the Wi-Fi P2P link, there is no guarantee that another Wi-Fi P2P related service can be transmitted.
  • Wi-Fi P2P link For example, for 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 the second Whether the transmission of the service using the Wi-Fi P2P link is completed, after the transmission of the first service is completed, the Wi-Fi P2P link will be removed. Therefore, it cannot be guaranteed that the transmission of the second service can be completed. This will lead to multi-Wi-Fi P2P service conflicts, which seriously affects the user experience.
  • the present application provides a method and electronic device for data transmission under Wi-Fi direct connection, which can enable between GC devices in a P2P group, or between a GC in a P2P group and an idle device outside the P2P group
  • the transmission channel can be established based on the Wi-Fi P2P connection in the P2P group and the service data can be transmitted, so that the devices that can join the Wi-Fi P2P group can initiate connection and communication.
  • the Wi-Fi P2P capability on the electronic device, only when the number of services using the Wi-Fi P2P capability is 0 will the Wi-Fi P2P link and the Wi-Fi P2P group be removed. group, which solves the conflict between multiple Wi-Fi P2P services and improves user experience.
  • a method for data transmission under Wi-Fi direct connection is provided.
  • the method is applied to a system including a first electronic device and a second electronic device, and the first electronic device is a Wi-Fi direct connection group.
  • the GC device inside, the second electronic device is a GO device in the Wi-Fi direct connection group; the method includes: the first electronic device and the second electronic device transmit through the first Wi-Fi direct connection link the data of the first service; the first electronic device receives the user's first operation, the first operation is used to send the data of the second service to the second electronic device, the second service is different from the first service; the first The electronic device sends the data of the second service to the second electronic device through the first Wi-Fi direct link.
  • the method for data transmission under the Wi-Fi direct connection provided by the first aspect by multiplexing the Wi-Fi P2P connection of the second electronic device (GO device) and the first electronic device (GC device), so that the Wi-Fi
  • the P2P connection can transmit a variety of different services at the same time, realizes the simultaneous coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, and improves the user experience. Different services will not affect each other, which improves the user experience.
  • 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 of the first electronic device to the second electronic device.
  • the second service may be a file sharing service from the first electronic device to the second electronic device.
  • the method further includes: the first electronic device sends a request to the second electronic device through the first connection
  • the electronic device sends a Wi-Fi direct connection request, 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 use the first Wi-Fi direct connection link to
  • the second electronic device sends the data of the second service; the second electronic device adds one to the reference count maintained by the second electronic device according to the Wi-Fi direct connection request, and the reference count maintained by the second electronic device is used for Indicates the number of services using the Wi-Fi P2P capability of the second electronic device at the same time; the second electronic device sends a Wi-Fi direct connection request response message to the first electronic device, and the Wi-Fi direct connection request response message includes: the The group information of the Wi-Fi direct connection group and the IP address of the second electronic device; the first electronic device adds one to the reference count maintained
  • the first electronic device and the second electronic device can perceive the current It carries multiple services, and when any one 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.
  • the removal of the GO device and the disconnection of the Wi-Fi P2P connection ensure that different services can be completely transmitted, and multiple Wi-Fi P2P services between the first electronic device and the second electronic device can be simultaneously Coexistence improves user experience. Different services will not affect each other, which improves the user experience.
  • the method 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 The second electronic device establishes the first connection, and the first connection includes any one of a BLE connection, a Bluetooth connection, and a Wi-Fi connection.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the Wi-Fi -Fi direct connection request, determining that the first Wi-Fi direct connection link already exists between the second electronic device and the first electronic device. In this implementation manner, it can be ensured that the second service data is normally transmitted by using the first Wi-Fi direct link.
  • the method further includes: the first electronic device determines the first electronic device The first Wi-Fi direct link already exists between the second electronic device and the first electronic device. In this implementation manner, it can be ensured that the second service data is normally transmitted by using the first Wi-Fi direct link.
  • the method further includes: the first electronic device The reference count maintained by the first electronic device is decremented by one; the second electronic device decrements the reference count maintained by the second electronic device by one.
  • the third electronic device when the reference count maintained by the second electronic device is 0, the third electronic device removes the Wi-Fi Direct group; or, in the 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.
  • the first electronic device and the second electronic device can perceive the current It carries multiple services, and when any one 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.
  • the removal of the GO device and the disconnection of the Wi-Fi P2P connection ensure that different services can be completely transmitted.
  • the information of the first electronic device includes: the identifier of the first electronic device, the current Wi-Fi direct connection status of the first electronic device, the The MAC address of the Wi-Fi direct port of the first electronic device, the list of channels supported by the first electronic device, the frequency of the Wi-Fi hotspot connected to the first electronic device, and whether the first electronic device supports at least one of broadband A sort of.
  • the system further includes a third electronic device, where the third electronic device is an idle device outside the Wi-Fi Direct group, and is used in the second service
  • the method further includes: the third electronic device receives a second operation of the user, and the second operation is used to send the data of the third service to the first electronic device; the third electronic device communicates with the first electronic device.
  • the second electronic device establishes a second Wi-Fi direct link; 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 third The data of the service, the second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi direct link.
  • the third electronic device (ie, idle device) outside the P2P group transmits service data to the first electronic device (ie, the GC device) in the P2P group
  • the third electronic device in the P2P group can be established.
  • a transmission channel between an electronic device (ie a GC device) and a third electronic device (ie an idle device) outside the P2P group, so as to realize the second Wi-Fi Direct link and the first Wi-Fi Direct link The route transmits service data to the first electronic device, thereby realizing data transmission between the two based on the transmission channel.
  • 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.
  • the method before the third electronic device and the second electronic device establish the second Wi-Fi direct link, the method further includes: the first The 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 the third electronic device device information; the second electronic device adds one to the reference count maintained by the second electronic device according to the third connection request, and the reference count maintained by the third electronic device is used to indicate that the third electronic device Wi- The number of services of Fi P2P capability; the second electronic device sends third response information in response to the third connection request to the first electronic device, and the third response information is used to indicate that the third electronic device is added to the Wi-Fi direct connection group, the third response information includes: the IP address allocated by the second electronic device to the third electronic device, the group information of the Wi-Fi direct connection group, the information of the third electronic device In the MAC address; the first electronic device adds one to the reference count maintained
  • the method before the first electronic device sends the third connection request to the second electronic device, the method further includes: the third electronic device and the first electronic device.
  • An electronic device establishes a second connection, where the second connection includes any one of a Bluetooth connection and a Wi-Fi connection.
  • the method further includes: 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 fourth connection request response information to the third electronic device through the second connection, and the fourth connection request response information includes: the second electronic device is the third electronic device The IP address assigned by the three electronic devices, 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 In response to the 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. In this implementation manner, 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 establishing a socket transmission channel with the first electronic device.
  • the method before the second electronic device increments the reference count maintained by the first electronic device by one, the method further includes: the second electronic device according to the first electronic device Three connection requests, determining that the third electronic device is a trusted device, and determining that there is a Wi-Fi direct link between the second electronic device and the first electronic device; Before the reference count maintained by the device is incremented by one, the method further includes: determining, by the first electronic device, 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 manner, normal transmission of the third service data can be guaranteed.
  • the method further 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.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes 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.
  • the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (ie the GO device) in the P2P group are multiplexed, and the first electronic device and the second electronic device can perceive the current Its own 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, thus ensuring that different services can be transmitted.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that the GC equipment in the P2P group and the idle equipment outside the P2P group cannot transmit data in the prior art is solved, and the user experience is improved.
  • the The method further includes: the third electronic device sends a fifth connection request to the first electronic device through the second connection, and the fifth connection request includes: the information of the third electronic device and the information of the third electronic device in the Wi- The identifier of the GO device connected in the Fi direct connection group; the first electronic device adds one to the reference count maintained by the first electronic device according to the fifth connection request, and the reference count maintained by the first electronic device is used to represent The number of services that use the Wi-Fi P2P capability of the second electronic device at the same time; the first electronic device sends a sixth connection request to the second electronic device, and the sixth connection request includes: the information of the third electronic device and the first electronic device.
  • the first electronic device sends fifth response information in response to the fifth connection to the third electronic device through the second connection, the fifth response information: the IP address and port number of the first electronic device , the identifier of the GO device that the first electronic device is connected to within the Wi-Fi direct connection group; the third electronic device adds one to the reference count maintained by the third electronic device according to the fifth response information, and the third electronic device adds one to the reference count maintained by the third electronic device.
  • 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 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that data cannot be transmitted between two GC devices in a P2P group in the prior art is solved, and the user experience is improved.
  • the 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 sends the seventh connection request to the second electronic device according to the seventh connection request.
  • the reference count maintained by the second electronic device is increased by one, and the reference count maintained by the second electronic device is used to indicate the number of services using the Wi-Fi P2P capability of the second electronic device at the same time; the second electronic device reports to the third electronic device Sending seventh response information in response to the seventh connection request, the seventh response information includes: group information of the Wi-Fi Direct group, the first electronic device and the third electronic device and the second electronic device respectively There is at least one of the indication information of Wi-Fi P2P connection between the electronic devices; the third electronic device adds one to the reference count maintained by the third electronic device according to the seventh response information, and the reference count maintained by the third electronic device is increased by one.
  • the reference count is used to indicate the number of services using the Wi-Fi P2P capability of the third electronic device at the same time; the third electronic device sends an eighth connection request to the first electronic device through the second connection, and the eighth connection request includes: The group information of the Wi-Fi direct connection group, the identifier of the GO device connected by the third electronic device in the Wi-Fi direct connection group; the first electronic device according to the eighth connection request, the first electronic device.
  • the reference count maintained by an electronic device is incremented by one, 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.
  • 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that data cannot be transmitted between two GC devices in a P2P group in the prior art is solved, and the user experience is improved.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the first Sixth connection request, determine that the third electronic device is a trusted device, and determine that there is a Wi-Fi P2P connection between the third electronic device and the first electronic device and the second electronic device respectively; or, the second electronic device According to the seventh connection request, the device determines that the first electronic device is a trusted device, and determines that there is a Wi-Fi P2P connection between the first electronic device and the third electronic device and the second electronic device, respectively. In this implementation manner, normal transmission of the third service data can be guaranteed.
  • the method further includes: the third electronic device according to the first 5.
  • Response information determine that the identity of the GO device connected by the third electronic device in the Wi-Fi Direct group is the same as the identity of the GO device connected by the first electronic device in the Wi-Fi Direct group;
  • the third electronic device determines, according to the seventh response information, the identity of the GO device connected to the first electronic device in the Wi-Fi Direct group and the identity of the third electronic device in the Wi-Fi Direct group
  • the GO devices connected within the group have the same identification. In this implementation manner, normal transmission of the third service data can be guaranteed.
  • the method further includes: before the first electronic device increments the reference count maintained by the first electronic device by one, the method further includes: the first electronic device The electronic device determines, according to the sixth response information or the eighth connection request, the identity of the GO device connected by the first electronic device in the Wi-Fi Direct group and the third electronic device in the Wi-Fi Direct connection The GO devices connected within the group have the same identities.
  • the method further 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; the third electronic device decrements the reference count maintained by the third electronic device by one.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes 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 with the second electronic device; or, in the third When the reference count maintained by the electronic device is 0, the third electronic device disconnects the second Wi-Fi direct link with the second electronic device.
  • 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the information of the third electronic device includes: the identifier of the third electronic device, the current Wi-Fi direct connection status of the third electronic device, the The MAC address of the Wi-Fi direct port of the third electronic device, the list of channels supported by the third electronic device, the frequency of the Wi-Fi hotspot connected to the third electronic device, and whether the third electronic device supports at least one of broadband A sort of.
  • 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, and the third operation is used to send the data of the fourth service to the second electronic device; the fourth electronic device establishes a third Wi-Fi direct connection with the second electronic device link; the fourth electronic device sends the data of the fourth service to the second electronic device through the third Wi-Fi direct link.
  • the method further includes: the fourth electronic device The device makes a ninth connection request to the second electronic device through the third connection, and the ninth connection request is used to request that the fourth electronic device be added to the Wi-Fi direct connection group, and the ninth connection request includes the Information of the fourth electronic device; the second electronic device adds one to the reference count maintained by the second electronic device according to the ninth connection request, and the reference count maintained by the second electronic device is used to indicate that the second electronic device is used simultaneously The number of services of the Wi-Fi P2P capability of the 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, and the ninth response information is used to indicate The fourth electronic device is added to the Wi-Fi direct connection group, and the ninth response information includes: the IP address assigned by the second electronic device to the fourth electronic device, the group of the Wi-Fi direct connection group group information, the MAC
  • the fourth electronic device may 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.
  • the second electronic device can perceive that it currently carries multiple services, and when any one of the services is disconnected, it will not be used. It will really cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. After multiple services are completed, the removal of the GO device and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring different The business can be completed in a complete transmission.
  • the method before the fourth electronic device requests the ninth connection to the second electronic device through the third connection, the method further includes: the fourth electronic device The third connection is established with the second electronic device, and the first connection includes any one of a Bluetooth connection and a Wi-Fi connection.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the first 9. A connection request, determining that the fourth electronic device is a trusted device, and determining that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device. In this implementation manner, 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.
  • the method further includes: the second electronic device decrements the reference count maintained by the second electronic device by one .
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes the Wi-Fi Direct group .
  • the second electronic device removes the Wi-Fi Direct group .
  • the information of the fourth electronic device includes: an identifier of the fourth electronic device, a current Wi-Fi direct connection of the fourth electronic device Connection status, the MAC address of the Wi-Fi direct port of the fourth electronic device, the list of channels supported by the fourth electronic device, the frequency of the Wi-Fi hotspot connected to the fourth electronic device, whether the fourth electronic device supports At least one of Broadband.
  • a method for data transmission under Wi-Fi direct connection includes: a second electronic device and a second electronic device transmit data of a first service through a first Wi-Fi direct connection link; the The second electronic device receives data of the second service sent by the first electronic device through the first Wi-Fi direct link, the first electronic device is a GC device in the Wi-Fi direct group, and the second electronic device is a GC device in the Wi-Fi direct group.
  • the electronic device is a GO device in the Wi-Fi Direct group, and the second service is different from the first service.
  • the Wi-Fi The P2P connection can transmit a variety of different services at the same time, realizes the simultaneous coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, and improves the user experience. Different services will not affect each other, which improves the user experience.
  • the The method before the second electronic device receives the data of the second service sent by the first electronic device through the first Wi-Fi direct link, the The method includes: the second electronic device receives a Wi-Fi direct connection request sent by the first electronic device through a first connection, where the Wi-Fi direct connection request includes: information of the first electronic device, the Wi-Fi direct connection request The 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 sends the second electronic device to the second electronic device according to the Wi-Fi direct connection request The maintained reference count is increased by one, 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 Wi-Fi to the first electronic device Direct connection request response information, the Wi-Fi direct connection request response information includes: group information of the Wi-Fi direct connection group and the IP address of the second electronic device.
  • the second electronic device 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 any one 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 the multiple services are completed, the removal of the GO device and the disconnection of the Wi-Fi P2P connection will be performed. , thereby ensuring that different services can be completely transmitted, realizing the simultaneous coexistence of multiple Wi-Fi P2P services between the first electronic device and the second electronic device, and improving user experience. Different services will not affect each other, which improves the user experience.
  • the method 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 The first connection is established with the first electronic device, where the first connection includes any one of a Bluetooth connection and a Wi-Fi connection.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the Wi-Fi -Fi direct connection request, determining that the first Wi-Fi direct connection link already exists between the second electronic device and the first electronic device. In this implementation manner, it can be ensured that the second service data is normally transmitted by using the first Wi-Fi direct link.
  • the method further includes: the second electronic device The reference count maintained by the second electronic device is decremented by one.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the third electronic device removes the Wi-Fi Direct group .
  • the first electronic device and the second electronic device can perceive that they currently carry multiple services, among which When any one 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 the multiple services are completed, the removal of the GO device and the Wi-Fi connection will be performed. The disconnection of the P2P connection ensures that different services can be completely transmitted.
  • the information of the first electronic device includes: the identifier of the first electronic device, the current Wi-Fi direct connection status of the first electronic device, the The MAC address of the Wi-Fi direct port of the first electronic device, the list of channels supported by the first electronic device, the frequency of the Wi-Fi hotspot connected to the first electronic device, and whether the first electronic device supports at least one of broadband A sort of.
  • the method further includes: establishing a second Wi-Fi between the second electronic device and the third electronic device and establishing a second Wi-Fi A direct connection link, the third electronic device is an idle device outside the Wi-Fi direct connection group; the second electronic device receives the third electronic device sent by the third electronic device through the second Wi-Fi direct connection link The data of the service; the second electronic device sends the data of the third service to the first electronic device through the first Wi-Fi direct link.
  • the second electronic device can assist in establishing the P2P group
  • the Fi direct link transmits service data to the first electronic device, so as to realize data transmission between the two based on the transmission channel.
  • the method further includes: the second electronic device The 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 the third electronic device information; the second electronic device adds one to the reference count maintained by the second electronic device according to the third connection request, and the reference count maintained by the third electronic device is used to indicate that the third electronic device Wi-Fi is used at the same time The number of P2P capable services; 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 -Fi direct connection group, the third response information includes: the IP address allocated by the second electronic device to the third electronic device, the group information of the Wi-Fi direct connection group, and the MAC address of the third electronic device address.
  • the method before the second electronic device increments the reference count maintained by the third electronic device by one, the method further includes: the second electronic device according to the first Three connection requests, determining that the third electronic device is a trusted device, and determining that there is a Wi-Fi direct link between the second electronic device and the first electronic device. In this implementation manner, normal transmission of the third service data can be guaranteed.
  • the method further includes: the second electronic device decrements the reference count maintained by the second electronic device by one .
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes the Wi-Fi Direct group .
  • the Wi-Fi P2P capability of the second electronic device (ie, the GO device) in the P2P group is multiplexed, and the second electronic device can perceive that its current Wi-Fi P2P capability carries multiple
  • the removal of the P2P group and the disconnection of the Wi-Fi P2P connection will be performed after multiple services are completed, thus ensuring that different services can be transmitted, and different services will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that the GC equipment in the P2P group and the idle equipment outside the P2P group cannot transmit data in the prior art is solved, and the user experience is improved.
  • the The method further includes: the first electronic device sending a sixth connection request to the second electronic device, the sixth connection request including: information of the third electronic device and the third electronic device being in the Wi-Fi Direct group The identifier of the connected GO device; the second electronic device adds one to the reference count maintained by the second electronic device according to the sixth connection request, and the reference count maintained by the second electronic device is used to indicate that the second electronic device is used at the same time.
  • the Wi-Fi P2P capability of the second electronic device is multiplexed, and the second electronic device can perceive that its current Wi-Fi P2P capability carries multiple services. Only then will the P2P group be removed and the Wi-Fi P2P connection disconnected, thus ensuring that different services can be transmitted normally, and different services will not affect each other.
  • the second electronic device in the P2P group is used as a relay to realize the transmission of services based on the Wi-Fi P2P connection, which solves the problem of inability between two GC devices in the P2P group in the prior art.
  • the problem of transferring data improves the user experience.
  • the 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, according to the seventh connection request, sends the The reference count maintained by the second electronic device is increased by one, and the reference count maintained by the second electronic device is used to indicate the number of services using the Wi-Fi P2P capability of the second electronic device at the same time; the second electronic device reports to the third electronic device
  • the device sends seventh response information in response to the seventh connection request, and the seventh response information includes: the group information of the Wi-Fi Direct group, the first electronic device and the third electronic device and the third electronic device respectively. At least one of the indication information of Wi-Fi P2P connection exists between the two electronic devices.
  • the method further includes: the second electronic device according to the first Sixth connection request, determine that the third electronic device is a trusted device, and determine that there is a Wi-Fi P2P connection between the third electronic device and the first electronic device and the second electronic device respectively; or, the second electronic device According to the seventh connection request, the device determines that the first electronic device is a trusted device, and determines that there is a Wi-Fi P2P connection between the first electronic device and the third electronic device and the second electronic device, respectively.
  • the method further includes: the second electronic device decrements the reference count maintained by the second electronic device by one .
  • the second electronic device when the reference count maintained by the second electronic device is 0, the second electronic device removes the Wi-Fi Direct group. In this implementation manner, it is ensured that different services can be transmitted normally, and different services will not affect each other.
  • the information of the third electronic device includes: the identifier of the third electronic device, the current Wi-Fi direct connection status of the third electronic device, the The MAC address of the Wi-Fi direct port of the third electronic device, the list of channels supported by the third electronic device, the frequency of the Wi-Fi hotspot connected to the third electronic device, and whether the third electronic device supports at least one of broadband A sort of.
  • the method further includes: establishing a third Wi-Fi direct link between the second electronic device and the fourth electronic device, where the fourth electronic device is The idle device outside the Wi-Fi direct connection group; the second electronic device receives the data of the fourth service sent by the fourth electronic device through the third Wi-Fi direct connection link.
  • the method 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 The device receives the ninth connection request sent by the fourth 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 connection group, and the ninth connection request Including the information of the fourth electronic device; the second electronic device adds one to the reference count maintained by the second electronic device according to the ninth connection request, and the reference count maintained by the second electronic device is used to represent the simultaneous use of the first electronic device.
  • the ninth response information includes: the IP address assigned by the second electronic device to the fourth electronic device, the Wi-Fi Direct group group information, and the MAC address of the second electronic device.
  • the fourth electronic device may 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.
  • the second electronic device can perceive that it currently carries multiple services, and when any one of the services is disconnected, it will not be used. It will really cause the removal of the P2P group and the disconnection of the Wi-Fi P2P connection. After multiple services are completed, the removal of the GO device and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring different The business can be completed in a complete transmission.
  • the method 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 The 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.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the first 9. A connection request, determining that the fourth electronic device is a trusted device, and determining that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device.
  • the method further includes: the second electronic device decrements the reference count maintained by the second electronic device by one .
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes the Wi-Fi Direct group .
  • the second electronic device removes the Wi-Fi Direct group .
  • the Wi-Fi P2P capabilities of the second electronic device GO device
  • the Wi-Fi P2P connection will be disconnected only after multiple services are completed, thus ensuring that different services can be completely transmitted.
  • the information of the fourth electronic device includes: the identifier of the fourth electronic device, the current Wi-Fi direct connection status of the fourth electronic device, the The MAC address of the Wi-Fi direct connection port of the fourth electronic device, the list of channels supported by the fourth electronic device, the frequency of the Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports at least one of broadband A sort of.
  • a third aspect provides a method for data transmission under Wi-Fi direct connection, the method is applied to a system including a first electronic device, a second electronic device and a third electronic device, the first electronic device The device is the first GC device in the Wi-Fi Direct group, the third electronic device is the second GC device in the Wi-Fi Direct group, and the second electronic device is the Wi-Fi Direct group A GO device in a group, the method includes: the third electronic device receives a second operation of the user, the second operation is used to send the data of the first service to the first electronic device; the third electronic device passes the second Wi-Fi - the Fi direct link sends the data of the first service to the second electronic device; in response to receiving the data of the first service, the second electronic device sends the data of the first service to the first electronic device through the first Wi-Fi direct link The device sends data of the first service, and the first Wi-Fi direct link is a Wi-Fi direct link between the second electronic device and the first electronic device.
  • the second Wi-Fi direct link is
  • 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
  • the second electronic device in the P2P group is used as a relay during data transmission.
  • the transmission of services based on the Wi-Fi P2P connection is realized, the problem that data cannot be transmitted between two GC devices in a P2P group in the prior art is solved, and the user experience is improved.
  • the The method further includes: the third electronic device sends a first Wi-Fi direct connection request to the first electronic device through the first connection, where the first Wi-Fi direct connection request includes: information of the third electronic device and the The identifier of the GO device connected by 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 first Wi-Fi direct connection request, The reference count maintained by the first electronic device is used to represent 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, and the first connection request Including: the information of the third electronic device and the identifier of the GO device connected by the third electronic device in the Wi-Fi direct connection group; the second electronic device according to the first connection request, the second electronic device The maintained reference count
  • the first response information of the first connection request includes: the group information of the Wi-Fi Direct group, the relationship between the third electronic device and the first electronic device and the second electronic device respectively At least one of the indication information that there is a Wi-Fi P2P connection between them; the first electronic device sends the first Wi-Fi in response to the first Wi-Fi direct connection request to the third electronic device through the first connection Direct connection response information, the first Wi-Fi direct connection response information: the IP address of the first electronic device, the identifier of the GO device that the first electronic device is connected to within the Wi-Fi direct connection group; the third The electronic device adds one to the reference count maintained by the third electronic device according to the first Wi-Fi direct connection response information, and the reference count maintained by the third electronic device is used to indicate that the first electronic device Wi-Fi P2P is used at the same time Ability business number.
  • 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that data cannot be transmitted between two GC devices in a P2P group in the prior art is solved, and the user experience is improved.
  • the method further includes: the third electronic device sends a second connection request to the second electronic device, where the second connection request includes the first electronic device information; the second electronic device adds one to the reference count maintained by the second electronic device according to the second connection request, and the reference count maintained by the second electronic device is used to indicate that the second electronic device Wi-Fi is used at the same time The number of services of the P2P capability; the second electronic device sends second response information in response to the second connection request to the third electronic device, where the second response information includes: the group of the Wi-Fi Direct group information, at least one of the indication information that there is a Wi-Fi P2P connection between the third electronic device and the first electronic device and the second electronic device respectively; the third electronic device according to the second response information, the The reference count maintained by the third electronic device is increased by one, and the reference count maintained by the third electronic device is used to indicate the number of services that utilize the Wi-Fi P2P capability of the third electronic device at the same time;
  • the first electronic device sends a second connection request to the second electronic
  • 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the second electronic device in the P2P group is used as a relay. And then realize the transmission of the service based on the Wi-Fi P2P connection, solve the problem that data cannot be transmitted between two GC devices in the P2P group in the prior art, and improve the user experience.
  • the method further includes: before the first electronic device increments the reference count maintained by the first electronic device by one, the method further includes: the first electronic device The electronic device determines, according to the first Wi-Fi direct connection request or the second response information, the identity of the GO device connected by the third electronic device in the Wi-Fi direct connection group and the identity of the first electronic device in the Wi-Fi direct connection group. - The GO devices connected in the Fi Direct group have the same identification.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the first A connection request, determining that the third electronic device is a trusted device, and determining that there is a Wi-Fi P2P connection between the third electronic device and the first electronic device and the second electronic device respectively; or, the second electronic device According to the second connection request, the device determines that the first electronic device is a trusted device, and determines that there is a Wi-Fi P2P connection between the first electronic device and the third electronic device and the second electronic device, respectively.
  • the method further includes: the third electronic device according to the first A Wi-Fi Direct response message, determining the identity of the GO device connected to the third electronic device in the Wi-Fi Direct group and the GO device connected to the first electronic device in the Wi-Fi Direct group
  • the identifiers of the devices are the same; or, the third electronic device determines, according to the second response information, the identifiers of the GO devices connected by the third electronic device in the Wi-Fi Direct group and the first electronic device in the Wi-Fi Direct group.
  • the GO devices connected in the Fi Direct group have the same identification.
  • the method further includes: establishing a first connection between the third electronic device and the first electronic device, where the first connection includes: a Bluetooth connection, a Wi-Fi connection any of the connections.
  • the method further includes: the third electronic device decrements the reference count maintained by the third electronic device by one ; 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.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes 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 with the second electronic device; or, in the third When the reference count maintained by the electronic device is 0, the third electronic device disconnects the first Wi-Fi direct link with the second electronic device.
  • 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 the current
  • the Wi-Fi P2P capability of the Wi-Fi P2P can carry multiple services. After multiple services are completed, the P2P group removal and the disconnection of the Wi-Fi P2P connection will be performed, thus ensuring that different services can be transmitted normally. Different businesses will not affect each other.
  • the information of the third electronic device includes: the identifier of the third electronic device, the current Wi-Fi direct connection status of the third electronic device, the The MAC address of the Wi-Fi direct port of the third electronic device, the list of channels supported by the third electronic device, the frequency of the Wi-Fi hotspot connected to the third electronic device, and whether the third electronic device supports at least one of broadband a; or,
  • the information of the first electronic device includes: the identifier of the first electronic device, the current Wi-Fi direct connection status of the first electronic device, the MAC address of the Wi-Fi direct port of the first electronic device, the first electronic device At least one of a list of channels supported by the electronic device, a frequency of a Wi-Fi hotspot connected to the first electronic device, and whether the first electronic device supports broadband.
  • a method for data transmission under Wi-Fi direct connection is provided, and the method is applied to a system including a first electronic device, a second electronic device and a third electronic device, where the third electronic device is Wi-Fi
  • the third electronic device is Wi-Fi
  • the first electronic device is the GC device in the Wi-Fi direct connection group
  • the second electronic device is the GO device in the Wi-Fi direct connection group
  • the method includes : the third electronic device receives the user's first operation, the first operation is used to send the data of the first service to the first electronic device; in response to the first operation, the third electronic device and the second electronic device establishing a first Wi-Fi direct link; the third electronic device sends the data of the first service to the second electronic device through the second Wi-Fi direct link; in response to receiving the data of the first service,
  • the second electronic device sends data of the first service to the first electronic device through a first Wi-Fi direct link, where the first Wi-Fi direct link is the second electronic device and the first electronic device Wi-Fi Direct link
  • the second The electronic device can assist in establishing a transmission channel between the first electronic device (ie the GC device) in the P2P group and the third electronic device (ie the idle device) outside the P2P group, so as to realize direct connection through the second Wi-Fi The link and the first Wi-Fi direct link transmit service data to the first electronic device, so as to realize data transmission based on the transmission channel between the two.
  • the method 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 The device sends a first connection request to the second electronic device, the first connection request is used to request the third electronic device to be added to the Wi-Fi Direct group, and the first connection request includes the third electronic device information; the second electronic device adds one to the 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 that the second electronic device Wi-Fi is used at the same time The number of services of the P2P capability; the second electronic device sends first response information in response to the first connection request to the first electronic device, where the first response information is used to instruct the third electronic device to join the Wi-Fi -Fi direct connection group, the first response information includes: the IP address allocated by the second electronic device to the third electronic device, the group information of the Wi-Fi direct connection group, and the MAC address of the second electronic device address;
  • the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (ie the GO device) in the P2P group are multiplexed, and the first electronic device and the second electronic device can perceive the current Its own Wi-Fi P2P capability carries multiple services.
  • the P2P group will be removed and the Wi-Fi P2P connection will be disconnected, thus ensuring that different services can be transmitted. , different services will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that the GC equipment in the P2P group and the idle equipment outside the P2P group cannot transmit data in the prior art is solved, and the user experience is improved.
  • the method before the third electronic device establishes the first Wi-Fi direct link with the second electronic device, the method further includes: the third electronic device The device establishes a first connection with the first electronic device, and the first connection includes any one of a Bluetooth connection and a Wi-Fi connection.
  • the method further includes: the first electronic device sends a second connection request to the third electronic device through the first connection, the second connection request Including: 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 of the first electronic device number; 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.
  • the method further includes: before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device The electronic device determines, according to 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.
  • the method before the first electronic device increments the reference count maintained by the first electronic device by one, the method further includes: the second electronic device according to the first electronic device In response to the information, it is determined that a Wi-Fi direct link exists between the second electronic device and the first electronic device.
  • the method further 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.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes 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.
  • the information of the third electronic device includes: the identifier of the third electronic device, the current Wi-Fi direct connection status of the third electronic device, the The MAC address of the Wi-Fi direct port of the third electronic device, the list of channels supported by the third electronic device, the frequency of the Wi-Fi hotspot connected to the third electronic device, and whether the third electronic device supports at least one of broadband A sort of.
  • a method for data transmission under Wi-Fi direct connection is provided, and the method is applied to a system including a first electronic device, a second electronic device and a fourth electronic device, where the fourth electronic device is Wi-Fi
  • the idle device outside the direct connection group the first electronic device is the GC device in the Wi-Fi direct connection group, the second electronic device is the GO device in the Wi-Fi direct connection group, and the method includes : the fourth electronic device receives the user's first operation, the first operation is used to send the data of the first service to the second electronic device; in response to the first operation, the fourth electronic device and the second electronic device A first Wi-Fi direct link is established; the fourth electronic device sends data of the first service to the second electronic device through the first Wi-Fi direct link.
  • the method for data transmission under Wi-Fi direct connection provided by the fifth aspect, by managing the P2P link of the second electronic device (GO device), between the second electronic device and the first electronic device (GC) in the P2P group
  • the fourth electronic device (idle device) outside the P2P group initiates a Wi-Fi P2P connection to the second electronic device (GO device) to
  • the fourth electronic device can be added to the P2P group to realize the transmission of service data from the fourth electronic device (idle device) to the second electronic device (GO device).
  • the method further includes: the fourth electronic device makes a first connection request to the second electronic device through the first connection, where the first connection request is used for Request to add the fourth electronic device to the Wi-Fi direct connection group, the first connection request includes information of the fourth electronic device; the second electronic device according to the first connection request, the second electronic device The reference count maintained by the device is increased by one, 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 fourth electronic device sends first response information in response to the first connection request, where the first response information is used to instruct the fourth electronic device to be added to the Wi-Fi Direct group, and the first response information includes: The IP address allocated 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 is connected according to the Wi-Fi Direct The group information of the group and the MAC address of the second electronic device establish
  • 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, and transmits the multiple services.
  • the P2P group and the GO device will be removed, thus ensuring that different services can be transmitted, and different services will not affect each other, improving user experience.
  • the fourth electronic device sends a first connection request to the second electronic device through the first connection, and the first connection request is used to request the fourth electronic device
  • the electronic device is added to the Wi-Fi direct connection group, and the first connection request includes information of the fourth electronic device;
  • the second electronic device counts the reference maintained by the second electronic device according to the first connection request Plus one, the reference count maintained by the second electronic device is used to represent the number of services that utilize the Wi-Fi P2P capability of the second electronic device at the same time;
  • the second electronic device sends a message to the fourth electronic device through the first connection
  • the first response information is used to instruct the fourth electronic device to be added to the Wi-Fi Direct group, and the first response information includes: the second electronic device The IP address assigned 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 is based on the group of the Wi-Fi Direct group information, the MAC
  • the method further includes: the IP address assigned by the fourth electronic device to the fourth electronic device according to the second electronic device, and the second electronic device and establishes a transmission channel based on the first Wi-Fi direct link with the second electronic device.
  • the method further includes: establishing the first connection between the fourth electronic device and the second electronic device, where the first connection includes: a Bluetooth connection, a Wi- Any of the Fi connections.
  • the method before the second electronic device increments the reference count maintained by the second electronic device by one, the method further includes: the second electronic device according to the first A connection request, determining that the fourth electronic device is a trusted device, and determining that there is no Wi-Fi direct link between the second electronic device and the fourth electronic device.
  • the second electronic device and the second electronic device transmit data of the second service through the second Wi-Fi direct link, and the first service After the data transmission of the second service is completed or the data transmission of the second service is completed, the method further includes: the second electronic device decrements the reference count maintained by the second electronic device by one.
  • the method further includes: when the reference count maintained by the second electronic device is 0, the second electronic device removes the Wi-Fi Direct group .
  • the second electronic device 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, wherein When any one 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 removal of the GO device and the Wi-Fi connection will be performed. The disconnection of the P2P connection ensures that different services can be completely transmitted.
  • the information of the fourth electronic device includes: the identifier of the fourth electronic device, the current Wi-Fi direct connection status of the fourth electronic device, the The MAC address of the Wi-Fi direct connection port of the fourth electronic device, the list of channels supported by the fourth electronic device, the frequency of the Wi-Fi hotspot to which the fourth electronic device is connected, and whether the fourth electronic device supports at least one of broadband A sort of.
  • an electronic device comprising a unit for performing each step in the above second aspect or any possible implementation manner of the second aspect.
  • an electronic device in a seventh aspect, includes at least one processor and a memory, where the at least one processor is configured to execute the method in the above second aspect or any possible implementation manner of the second aspect.
  • an electronic device in an eighth aspect, includes at least one processor and an interface circuit, and the at least one processor is configured to execute the method in the second aspect or any two possible implementations of the second aspect .
  • a system for data transmission under Wi-Fi direct connection including a plurality of electronic devices for performing the above first aspect or any possible implementation manner of the first aspect.
  • a tenth aspect provides a system for data transmission under Wi-Fi direct connection, where the system includes a plurality of electronic devices for implementing the above third aspect or any possible implementation manner of the third aspect.
  • a system for data transmission under Wi-Fi direct connection includes a plurality of electronic devices for performing the above fourth aspect or any possible implementation manner of the fourth aspect.
  • a twelfth aspect provides a system for data transmission under Wi-Fi direct connection, where the system includes a plurality of electronic devices for implementing the fifth aspect or any possible implementation manner of the fifth aspect.
  • a thirteenth aspect provides a computer program product, the computer program product comprising a computer program, when executed by a processor, for performing the method in any one of the first to fifth aspects, or , for performing the method in any possible implementation manner of any one of the first aspect to the fifth aspect.
  • a fourteenth aspect provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed, is used to execute any one of the first to fifth aspects.
  • a fifteenth aspect provides a chip, the chip comprising: a processor for calling and running a computer program from a memory, so that a communication device installed with the chip executes any one of the first to fifth aspects The method, or a method for performing any possible implementation manner of any one of the first aspect to the fifth aspect.
  • the method and electronic device for data transmission under Wi-Fi direct connection require data transmission between GC devices in a P2P group, or between a GC in a P2P group and an idle device outside the P2P group At this time, through the intervention of the GO device, it helps to establish 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.
  • the star network becomes a mesh network.
  • the Wi-Fi P2P link is removed only when the number of services using the Wi-Fi P2P capability is 0. The conflict between Fi P2P services improves the user experience.
  • FIG. 1 is a schematic diagram of a Wi-Fi P2P service system architecture on an electronic device in the prior art.
  • Figure 2 is a schematic diagram of the form of Wi-Fi P2P device connection and networking.
  • FIG. 3 is a schematic diagram of an example of a scenario architecture of a Wi-Fi P2P connection provided by an embodiment of the present application.
  • FIG. 4 is a schematic interface diagram of an example of a user-triggered Wi-Fi P2P discovery operation on a device provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of an example of a Wi-Fi P2P service system architecture on an electronic device provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of an embodiment of the present application providing an example of a communication system applicable to the embodiment of the present application.
  • FIG. 7 is a schematic flowchart of an example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 8 is a schematic interface diagram of an example of a user performing an operation to share a file according to an embodiment of the present application.
  • FIG. 9 is a schematic flowchart of another example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of another example of a communication system applicable to an embodiment of the present application provided by an embodiment of the present application.
  • FIG. 11 is a schematic flowchart of another example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 12 is a schematic flowchart of another example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of another example of a communication system applicable to an embodiment of the present application provided by an embodiment of the present application.
  • FIG. 14 is a schematic flowchart of an example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 15 is a schematic diagram of another example of a communication system applicable to an embodiment of the present application provided by an embodiment of the present application.
  • FIG. 16 is a schematic flowchart of another example of a method for data transmission under Wi-Fi direct connection provided by an embodiment of the present application.
  • FIG. 17 is a schematic block diagram of an example of the structure of an electronic device provided by an embodiment of the present application.
  • FIG. 18 is a schematic block diagram of an example of the structure of a communication device provided by an embodiment of the present application.
  • first and second are only used for descriptive purposes, and should not be construed as indicating or implying relative importance or implicitly indicating the number of indicated technical features.
  • a feature defined as “first” or “second” may expressly or implicitly include one or more of that feature.
  • plural means two or more.
  • various aspects or features of the present application may be implemented as a method, apparatus or article of manufacture using standard programming and/or engineering techniques.
  • article of manufacture encompasses a computer program accessible from any computer readable device, carrier or medium.
  • computer readable media may include, but are not limited to: magnetic storage devices (eg, hard disks, floppy disks, or magnetic tapes, etc.), optical disks (eg, compact discs (CDs), digital versatile discs (DVDs) etc.), smart cards and flash memory devices (eg, erasable programmable read-only memory (EPROM), card, stick or key drives, etc.).
  • various storage media described herein can 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.
  • GSM Global System of Mobile communication
  • CDMA Code Division Multiple Access
  • CDMA Wideband Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • GSM Global System of Mobile communication
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • GPRS General Packet Radio Service
  • LTE Long Term Evolution
  • FDD Frequency Division Duplex
  • TDD Time Division Duplex
  • UMTS Universal Mobile Telecommunication System
  • WiMAX Worldwide Interoperability for Microwave Access
  • 5G 5th Generation
  • 5G 5th Generation
  • New Radio New Radio
  • various aspects or features of the present application may be implemented as a method, apparatus, or article of manufacture using standard programming and/or engineering techniques.
  • article of manufacture encompasses a computer program accessible from any computer readable device, carrier or medium.
  • computer readable media may include, but are not limited to: magnetic storage devices (eg, hard disks, floppy disks, or magnetic tapes, etc.), optical disks (eg, compact discs (CDs), digital versatile discs (DVDs) etc.), smart cards and flash memory devices (eg, erasable programmable read-only memory (EPROM), card, stick or key drives, etc.).
  • various storage media described herein can 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.
  • 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 without the intervention of Wi-Fi hotspots. Connect and communicate directly with the counterpart device.
  • FIG. 1 shows the Wi-Fi P2P service system architecture diagram.
  • the system architecture mainly includes: Wi-Fi chip (Chipset), Wi-Fi driver (Wi-Fi Driver), middleware, Application framework layer (FRAMEWORK), and upper application (application, APP).
  • the Wi-Fi driver is responsible for connecting the Wi-Fi chip with the operating system of the terminal device
  • the middleware is used for the transfer of all messages between the kernel state and the user state during the operation of the terminal device.
  • the most widely used middleware 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.
  • Wi-Fi P2P related services can include Wi-Fi P2P Service, the interface type corresponding to Wi-Fi P2P Service is Wi-Fi P2P management (Manager) type, and the interface of Wi-Fi P2P Manager type includes: discoverPeers), connect (connect) and other interfaces, these interfaces can be directly controlled by the user to Wi-Fi P2P.
  • Wi-Fi P2P Service the interface type corresponding to Wi-Fi P2P Service
  • the interface type corresponding to Wi-Fi P2P Service is Wi-Fi P2P management (Manager) type
  • the interface of Wi-Fi P2P Manager type includes: discoverPeers), connect (connect) and other interfaces, these interfaces can be directly controlled by the user to Wi-Fi P2P.
  • Upper-layer applications are applications that users who use the FRAMEWORK interface can directly contact. They run on the terminal device and are the windows for the user to interact with the terminal device.
  • the Wi-Fi P2P connection protocol is generally implemented in the Wi-Fi chip, and the FRAMEWORK layer in the terminal device interacts with the chip through the driver.
  • the FRAMEWORK layer is used to interact with the driver and support encryption authentication through wpa_supplicant.
  • the application layer provides several interface functions that can be directly called by developers/businesses. After calling, the chip can execute the corresponding Wi-Fi function through the driver.
  • -Fi P2P related operations the FRAMEWORK layer itself is responsible for the message transfer and coordination, connection management, etc. between the upper-layer application and the lower-layer hardware (including wpa_supplicant, Wi-Fi Driver, Chipset).
  • the user's operation of Wi-Fi P2P is realized by the application layer by calling the Wi-Fi P2P related interfaces and services in FRAMEWORK.
  • 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.
  • a P2P group (or also called a Wi-Fi P2P group) is formed after the Wi-Fi P2P device connection is established.
  • the device has two roles: P2P group manager (group owner, GO) and P2P group client (group client, GC).
  • P2P group manager group owner, GO
  • P2P group client group client, GC
  • GO devices can only be connected to GC, and cannot establish connections with other GO devices
  • Wi-Fi P2P connections In addition to the limitations of the Wi-Fi DIRECT protocol itself, different chip manufacturers and different operating systems (such as Android, Windows, etc.) also have some other limitations on Wi-Fi P2P connections. For example, chip platforms such as HiSilicon do not support the same device.
  • a variety of P2P roles on . Not supporting multiple P2P roles on the same device can be understood as: the same device cannot act as GO and GC at the same time; or, during the period when one device acts as a GO, the device cannot act as a GO in another P2P group; or , while a device is serving as a GC, the device cannot serve as a GC in another P2P group.
  • AOSP does not support the coexistence of multiple P2P roles on the same device. Therefore, as shown in Figure 2, the current form of Wi-Fi P2P device connection and networking is limited to a star network centered on GO devices.
  • Wi-Fi P2P applications on Android systems independently manage Wi-Fi P2P links.
  • the Wi-Fi P2P service is started by calling the scan interface of FRAMEWORK when an application (such as a screen-casting application, a file sharing application, or an office collaboration application, etc.) is started, and the lower-layer hardware (wpa_supplicant, Wi-Fi Driver, Chipset) is used to start the service.
  • 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.
  • the application calls the connection interface of FRAMEWORK to start the Wi-Fi P2P service to delete the Wi-Fi P2P link.
  • AOSP is not perfect in the management of Wi-Fi P2P device connections.
  • the interface it provides for services is open to all services, but there is only one physical connection between underlying devices.
  • the Wi-Fi P2P link on the device is independently managed and negotiated by each application. Due to resource constraints, only one underlying Wi-Fi P2P link will be generated.
  • One service occupies Wi-Fi P2P resources.
  • Another Wi-Fi P2P related service cannot guarantee complete transmission. This will lead to the multi-Wi-Fi P2P service conflict problem. For example, service 1 and service 2 exist between two devices.
  • both devices are GC devices, after service 1 establishes a Wi-Fi P2P connection between the two devices, service 2 also uses the Wi-Fi P2P connection (or use the Wi-Fi P2P capability), at this time, service 2 will directly fail to call the Wi-Fi P2P connection interface. 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 the communication between the two devices can be realized, once service 1 ends, it will be disconnected. Wi-Fi P2P connection, the Wi-Fi P2P connection between the two devices is also disconnected immediately, and business 2 is also interrupted. Another example is the multi-service Wi-Fi P2P service conflict between multiple devices.
  • Mobile phone A and the computer are working together in office, and mobile phone A and the computer have established a Wi-Fi P2P connection.
  • the computer is a GO device or access Access point (AP) device
  • mobile phone A is a GC device, in this case, mobile phone A cannot share files to another mobile phone B at the same time, and mobile phone A cannot receive files shared by mobile phone B.
  • AP access Access point
  • the current way to establish a Wi-Fi P2P connection is to use the AOSP native interface.
  • Wi-Fi DIRECT standard protocol starting from the Wi-Fi P2P device discovery, a Wi-Fi P2P connection is established. After the connection is completed, a Wi-Fi P2P-based connection is established. transmission path.
  • both devices When making a Wi-Fi P2P connection between devices, both devices must initiate P2P device discovery together. After the device is discovered, the Wi-Fi P2P connection interface is called to connect. In this process, if one of the devices is a persistent group, after the connection is established, the device in the persistent group will be used as the GO device, and the peer device will be used as the GC device.
  • FIG. 3 is a schematic diagram of a scenario architecture of a Wi-Fi P2P connection provided by the present application.
  • 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.
  • the idle device 1 and the idle device 2 are two idle devices outside the P2P group, and no Wi-Fi P2P connection is established between the idle device 1 and the idle device 2 and other devices.
  • the GO device in the P2P group transmits Wi-Fi P2P services with the GC1 device, the GC2 device, and the GC3 device respectively.
  • Wi-Fi P2P connection is performed between two idle devices outside the P2P group.
  • Fi P2P connection is used as an example to illustrate.
  • idle device 1 and idle device 2 need to trigger the Wi-Fi P2P discovery operation at the same time.
  • idle device 1 discovers idle device 2 through the message broadcast by idle device 2, idle device 1
  • the connect command can be invoked to establish two Wi-Fi P2P connections with idle device 2.
  • Scenario 2 A Wi-Fi P2P connection is established between an idle device and a GO device in a P2P group.
  • Wi-Fi P2P connection established between idle device 1 and 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 use the GO device.
  • Trigger Wi-Fi P2P discovery on Wi-Fi P2P discovery needs to be triggered on the idle device 1.
  • the idle device 1 can establish a Wi-Fi P2P connection to the GO device through the connection operation.
  • the GO device 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 be established through the connection operation. Wi-Fi P2P connection with idle device 1.
  • Figure 4 shows a schematic interface diagram of a user triggering a Wi-Fi P2P discovery operation on an idle device or a GO device.
  • the user can click the "Settings” icon on the idle device or the GO device, and the displayed interface is shown in b in Figure 4.
  • the user clicks the "WLAN Direct” menu to Trigger Wi-Fi P2P discovery.
  • the displayed interface is as shown in c in Figure 4, and the user clicks the "Stop” menu to stop the Wi-Fi P2P discovery.
  • the user can click on any one of the devices, and after the user clicks the device, the device used by the user can perform a Wi-Fi P2P connection with the device.
  • a Wi-Fi P2P connection can be established by using the above-mentioned method for establishing a Wi-Fi P2P connection.
  • a data transmission path needs to be established.
  • the interface of the GO device can only obtain the Internet Protocol (IP) address of the GO device. Therefore, without relying on other communication means to assist in exchanging port numbers, the GO device side can only monitor on a fixed port, and the GC device can monitor it on the fixed port.
  • IP Internet Protocol
  • Wi-Fi P2P connections are established between GC devices in a P2P group.
  • a Wi-Fi P2P connection is established between GC1 and GC2 in a P2P group.
  • the two devices have become GC devices. After the two GC devices trigger device discovery at both ends, they can discover each other.
  • the Wi-Fi P2P connection between the GC devices will fail, and subsequent data transmission cannot be performed.
  • 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.
  • 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 the information is transmitted without the assistance of other communication methods, the IP address of the other party cannot be obtained, so that the transmission channel cannot be established.
  • Wi-Fi P2P cannot be established. connect.
  • the present application provides a method for Wi-Fi P2P connection, which requires data transmission between GC devices in a P2P group, or between a GC in a P2P group and an idle device outside the P2P group At this time, through the intervention of the GO device, it helps to establish 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.
  • the star network becomes a mesh network.
  • the Wi-Fi P2P link is removed only when the number of services using the Wi-Fi P2P capability is 0. The conflict between Fi P2P services improves the user experience.
  • the method provided in this application is mainly aimed at the Wi-Fi P2P connection and networking scenarios in the Wi-Fi DIRECT standard protocol, and can be applied to the Android operation of the Wi-Fi P2P technology using the Wi-Fi DIRECT standard protocol. It can also be applied to devices using IOS operating system and Hongmeng operating system, etc.
  • the embodiments of the present application are not limited herein.
  • FIG. 5 shows an example of a Wi-Fi P2P service system architecture diagram provided for this application.
  • the system architecture mainly includes: a Wi-Fi chip (Chipset), a Wi-Fi driver (Wi-Fi Driver) ), middleware, application framework layer (FRAMEWORK), communication module and upper layer application (application, APP).
  • the Wi-Fi P2P service of 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 this embodiment of the present application, the communication module may also be located in the FRAMEWORK layer.
  • FIG. 6 is a schematic diagram of a communication system applicable to an embodiment of the present application.
  • 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.
  • the P2P group the second electronic device is a GO device or an AP device
  • 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.
  • FIG. 6 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.
  • the second electronic device is a GO device or
  • the third electronic device is mobile phone B as an example
  • the first electronic device is mobile phone A as an example
  • the second electronic device is a large-screen device (such as a smart TV, smart screen, etc.) as an example.
  • Phone A is projecting to a large-screen device, and then phone B (idle device) needs to initiate file sharing to phone A.
  • the Wi-Fi P2P link is used for screen projection between mobile phone A and the large-screen device.
  • FIG. 7 is a schematic flowchart of an example of a Wi-Fi P2P connection method provided by the present application in the scenario shown in FIG. 6 .
  • the mobile phone A is projecting the screen to the large-screen device, and the mobile phone A and the large-screen device are using a Wi-Fi P2P link for screen casting.
  • the method includes: S101 to S127.
  • the user opens the first application (ie, the file management application) on the mobile phone B, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • Figure 8 shows the operations for execution on handset B.
  • the first application on the mobile phone B sends a device discovery request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B starts bluetooth low energy (BLE) scanning, classic Bluetooth scanning, wireless local area networks (WLAN) scanning or Wi-Fi P2P Scan and other ways to discover devices to discover devices.
  • BLE bluetooth low energy
  • classic Bluetooth includes at least one of two types of Bluetooth, a Bluetooth basic rate (bluetooth basic rate, BR) and a Bluetooth enhanced data rate (bluetooth enhanced data rate, EDR).
  • the communication module in the mobile phone B scans the devices, it sends the scanned device list to the first application on the mobile phone B, where the device list contains device identifiers of one or more devices.
  • the displayed device list may be as shown in d in FIG. 8 .
  • the user selects the device identification of the mobile phone A in the device list on the first application on the mobile phone B, and the device identification of the mobile phone A may be the device model, identification code, device name, device ID (device ID) of the mobile phone A, etc. .
  • the device identifier of the mobile phone A is used to uniquely identify the mobile phone A.
  • the first application on the mobile phone B will send a Wi-Fi P2P connection request to the communication module in the mobile phone B.
  • the Wi-Fi P2P connection request includes the device identification of the mobile phone A.
  • the communication module in the mobile phone B first establishes a first connection with the communication module in the mobile phone A.
  • the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone B and the communication module in the mobile phone A negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone B stores the encryption key and the decryption key.
  • the communication module in the mobile phone A stores the encryption key and the decryption key.
  • the communication module in the mobile phone B sends a Wi-Fi P2P connection request to the communication module in the mobile phone A through the first connection, where the Wi-Fi P2P connection request is encrypted by 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: mobile phone B does not currently have any Wi-Fi P2P connection with any device).
  • the state of the Fi P2P connection which can be represented by 0; the current Wi-Fi P2P connection between mobile phone B and other devices, and the role of mobile phone B is the GO state, the connection state can be represented by 1; the current state of mobile phone B There is a Wi-Fi P2P connection with other devices, and the role of mobile phone B is the state of GC, and the connection state can be represented by 2.
  • mobile phone B currently has no Wi-Fi P2P connection, and mobile phone B currently has no Wi-Fi P2P connection.
  • the Wi-Fi P2P connection status is represented by 0), the media access control (MAC) address of the Wi-Fi P2P port of mobile phone B, the list of channels supported by mobile phone B (for example, to support 36 channels, corresponding to 5180MHz),
  • the connection method 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).
  • mobile phone B expects to establish a Wi-Fi P2P connection as a GC.
  • At least one of the information such as the identity to establish a Wi-Fi P2P connection), the frequency of the Wi-Fi hotspot connected to the mobile phone B, whether it supports broadband (for example, whether it supports 160MHz, if it is supported, it can be represented by true, if it is not supported, it can be represented by false), etc. .
  • the communication module in the 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, so it cannot directly establish a Wi-Fi P2P connection with mobile phone B.
  • the communication module in mobile phone A will receive the connection status change notification reported by the FRAMEWORK layer.
  • the existing connection information has been maintained in the communication module, and the connection information 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, this information can be used 2), the role of the connected device (large-screen device) (for GO), and the MAC address of the large-screen device, etc.
  • the communication module in the large-screen device will also receive the connection status change notification reported by the FRAMEWORK layer, which carries basic connection information.
  • the connection information In addition to the Wi-Fi P2P connection status, role, and address information of the device (including mobile phone A) connected to itself (large-screen device), it also includes the information of the P2P group.
  • 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. A sort of.
  • the communication module in the mobile phone A sends a connection request to the communication module in the large-screen device, where the connection request is used to request that the mobile phone B be added to the P2P group formed by the mobile phone A and the large-screen device.
  • the 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 list of channels supported by mobile phone B, the expected connection method of mobile phone B, and mobile phone B At least one of the frequency of the connected Wi-Fi hotspot and whether mobile phone B supports broadband.
  • the communication module in the large-screen device 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.
  • the large-screen device is a GO device, and the mobile phone B is a trusted device (for example, the mobile phone B and the large-screen device log in to the same account, or After mobile phone B and the large-screen device have been bound by various means (such as scanning QR code, etc.), the communication module in the large-screen device sends an application for multiplexing Wi-Fi to the P2P link management module in the large-screen device.
  • - Fi P2P capability request may include indication information that a Wi-Fi P2P link already exists between the large-screen device and the mobile phone A.
  • the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request for multiplexing the Wi-Fi P2P capability includes that Wi-Fi already exists between the large-screen device and the mobile phone A -Indication information of the Fi P2P link, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the connection information includes: Wi-Fi P2P connection status, role and address information of these devices, P2P group information, etc. with their connected devices (including mobile phone A).
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, so as to determine, according to the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, or determine the large-screen device If there is a Wi-Fi P2P link between the existing and mobile phone A, and the Wi-Fi P2P link supports other services, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • the value of the reference count maintained by the large-screen device is 1, which means that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (the projection of mobile phone A to the large-screen device). business).
  • 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 (the screen casting service of mobile phone A to the large-screen device).
  • the large-screen device will not remove the P2P group, and the mobile phone B can still share with the mobile phone A normally. document. Only when the reference count becomes 0, that is, the screen casting service and the file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device sends a response message indicating that the multiplexing of the P2P capability is successful to the communication module in the large-screen device.
  • connection request response information includes: allowing mobile phone B to join the P2P group Instruction information, information about the P2P group formed by mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone B, and the MAC address of the large-screen device.
  • the connection request response information may include: any one of the indication information that allows mobile phone B to join the P2P group and the information of the P2P group formed by mobile phone A and the large-screen device, and does not necessarily include allowing mobile phone B to join the P2P group at the same time. Indication information of the group, and information of the P2P group formed by mobile phone A and large-screen devices.
  • the connection request response information may further include: indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone A.
  • the communication module in the mobile phone A determines that the mobile phone B can join the P2P group according to the instruction information that allows the 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 jointly maintained by these two devices, the multiplexing of Wi-Fi P2P capabilities is for one device, only Applying for Wi-Fi P2P capability multiplexing for a certain device can only ensure that the device will not actively disconnect the Wi-Fi P2P link during the service existence, and the peer device cannot guarantee that the Wi-Fi will not be actively disconnected. The P2P link will eventually affect the service transmission.
  • the communication module in mobile phone A also needs to send a request for multiplexing the Wi-Fi P2P capability to the P2P link management module in mobile phone A.
  • the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone A.
  • the P2P link management module in the mobile phone A receives the request, as a possible implementation, if the request carries: the indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone A, Then 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 manner, if the request carries: indication information that a Wi-Fi P2P connection exists between the large-screen device and mobile phone A, and the P2P link management module in mobile phone A determines the Wi-Fi P2P connection - If the Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
  • 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 role of mobile phone A.
  • the P2P link management module in mobile phone A can obtain the connection information from the communication module, so as to determine that there is a Wi-Fi P2P link between mobile phone A and the large-screen device according to the connection information (the one between the mobile phone A and the large-screen device). screen-casting Wi-Fi P2P link), or, determine that mobile phone A currently has a Wi-Fi P2P link (the Wi-Fi P2P link for screen-casting between mobile phone A and the large-screen device), and the Wi-Fi P2P link - If the Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
  • the mobile phone A may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone A.
  • the reference count maintained by mobile phone A is 1, indicating that mobile phone A's own Wi-Fi P2P capability carries one service (mobile phone A's screencasting service to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (the screen casting service of mobile phone A to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 2 if the screencasting service is disconnected, the reference count becomes 1. Since the reference count is not 0, the mobile phone A will not disconnect the Wi-Fi P2P link, and the mobile phone B can still operate normally. Share the file to phone A. Mobile phone A will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen-casting service and the file-sharing service are disconnected.
  • the P2P link management module in the mobile phone A sends a response message that the multiplexing of the P2P capability is successful to the communication module in the mobile phone A.
  • the Wi-Fi P2P connection request response information includes: indication information for allowing mobile phone B to join the P2P group, information on the P2P group formed by mobile phone A and the large-screen device (for example, the SSID, BSSID, frequency, PASSWORD, etc.
  • the Wi-Fi P2P connection request response information may include: any one of the indication information that allows mobile phone B to join the P2P group, and the information of the P2P group formed by mobile phone A and the large-screen device, and it is not necessary to include the permission to join the P2P group at the same time.
  • the P2P link management module in the mobile phone B directly initiates a Wi-Fi P2P connection to the large-screen device through a connection interface (such as a connect interface), and joins P2P After the group is formed, the P2P link management module in the mobile phone B sends a response message to the communication module in the mobile phone B, which is used to notify the communication module in the mobile phone B that the mobile phone B has successfully joined the P2P group.
  • a connection interface such as a connect interface
  • the communication module in the mobile phone B sends the Wi-Fi P2P connection request response information to the first application on the mobile phone B, which is used to notify the first application on the mobile phone B that the mobile phone B joins the P2P group If successful, the Wi-Fi P2P connection request response information carries: the IP address assigned by the large-screen device to mobile phone B, the port number generated by mobile phone B, the IP address and port number of mobile phone A.
  • mobile phone B after mobile phone B joins the P2P group, mobile phone B has become a GC device, and 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, combined with the IP address of mobile phone A and port number information, etc., establish a socket transmission channel with the first application on the mobile phone A.
  • the first application on the mobile phone B starts file sharing to the first application on the mobile phone A based on the socket transmission channel.
  • the 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 the mobile phone A, that is, the data flow of the file sharing service is: mobile phone B ⁇ large screen screen device ⁇ mobile phone A.
  • the data flow of the screen projection service is mobile phone A ⁇ large screen device.
  • FIG. 7 is a flow of file sharing that mobile phone B (idle device) needs to initiate to mobile phone A (GC device).
  • Fig. 9 shows a schematic flowchart of a method for mobile phone A (GC device) to initiate file sharing to mobile phone B (idle device) in the scenario shown in Fig. 6 , wherein mobile phone A is projecting to a large Screen devices, mobile phone A and large-screen devices use the Wi-Fi P2P link for screen projection.
  • the method includes: S201 to S228.
  • the user opens the first application (ie, the file management application) on the mobile phone A, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • the file management application ie, the file management application
  • the first application on the mobile phone A sends a device discovery request to the communication module in the mobile phone B.
  • the communication module in the mobile phone A starts a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • the device list contains the device IDs of one or more devices.
  • the user selects the device identification of the mobile phone B in the device list on the first application on the mobile phone A, and the device identification of the mobile phone B can be the device model, identification code, device name, device ID (device ID) of the mobile phone B, etc. .
  • the device identifier of the mobile phone B is used to uniquely identify the mobile phone B.
  • the first application on the mobile phone A sends a Wi-Fi P2P connection request to the communication module in the mobile phone A.
  • the communication module in the mobile phone A first establishes a first connection with the communication module in the mobile phone B.
  • the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone A and the communication module in the mobile phone B negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone A stores the encryption key and the decryption key.
  • the communication module in the mobile phone B stores the encryption key and the decryption key.
  • the communication module in the mobile phone A will receive the connection status change notification reported by the FRAMEWORK layer, and the notification carries the basic connection information. Therefore, the communication of the mobile phone A
  • the existing connection information has been maintained in the module, and the connection information includes: the device ID 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 , the information can be represented by 2), the role of the connected device (large-screen device) (as GO), and the MAC address of the large-screen device, etc.
  • the communication module in the large-screen device will also receive the connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is the GO role, the connection information In addition to including the Wi-Fi P2P connection status, role and address information of the device (including mobile phone A) connected to itself (large-screen device), at least one of the information of the P2P group is also stored. In this embodiment of the present application, the information of the P2P group may be at least one of SSID, BSSID, frequency, and password (PASSWORD). Therefore, according to the connection information, the communication module in mobile phone A determines that mobile phone A is already a GC, and further determines that mobile phone A cannot directly establish a Wi-Fi P2P connection with mobile phone B.
  • SSID SSID
  • BSSID frequency
  • PASSWORD password
  • the communication module in the mobile phone A sends a connection request to the communication module in the large-screen device (ie the GO device), where the connection request is used to request that the mobile phone B be added to the P2P group formed by the mobile phone A and the large-screen device.
  • the connection request includes the identity information of the mobile phone B.
  • the identity information of the mobile phone B includes: the device identification of the mobile phone B, the current Wi-Fi P2P connection status of the mobile phone B, and the information of the Wi-Fi P2P port of the mobile phone B.
  • MAC address the list of channels supported by mobile phone B (for example, to support 36 channels, corresponding to 5180MHz), the connection method expected by mobile phone B (for example, mobile phone B expects to establish a Wi-Fi P2P connection as GC, or mobile phone B expects to be GO).
  • Establish a Wi-Fi 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 it supports broadband (for example, whether it supports 160MHz, if Support can be represented by true, if not, it can be represented by false) at least one of the information.
  • the current Wi-Fi P2P connection status of mobile phone B includes: mobile phone B does not currently have a Wi-Fi P2P connection with any device, and the connection status can be represented by 0; mobile phone B currently has a Wi-Fi P2P connection with other devices.
  • -Fi P2P connection, and the role of mobile phone B is GO status the connection status can be represented by 1; there is currently a Wi-Fi P2P connection between mobile phone B and other devices, and the role of mobile phone B is GC status, the connection The state can be represented by 2.
  • the mobile phone B currently has no Wi-Fi P2P connection, and the current Wi-Fi P2P connection status of the mobile phone B is represented by 0.
  • the mobile phone A can obtain the current Wi-Fi P2P connection state of the mobile phone B, the MAC address of the Wi-Fi P2P port of the mobile phone B, and the mobile phone B through the first connection with the mobile phone B. Supported channel list, expected connection method of mobile phone B, etc.
  • the communication module in the large-screen device (ie, the GO device) 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.
  • the communication module in the large-screen device manages the P2P link in the large-screen device
  • the module sends a request for multiplexing Wi-Fi P2P capability.
  • the request for multiplexing the Wi-Fi P2P capability may include indication information that a Wi-Fi P2P link already exists between the large-screen device and the mobile phone A.
  • the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request for multiplexing the Wi-Fi P2P capability includes that Wi-Fi already exists between the large-screen device and mobile phone A -Indication information of the Fi P2P link, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the connection information includes: Wi-Fi P2P connection status, role and address information of these devices, P2P group information, etc. with their connected devices (including mobile phone A).
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, so as to determine, according to the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, or determine the large-screen device If there is a Wi-Fi P2P link between the existing and mobile phone A, and the Wi-Fi P2P link supports other services, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • the value of the reference count maintained by the large-screen device is 1, which means that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (the projection of mobile phone A to the large-screen device). business).
  • 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 (the screen casting service of mobile phone A to the large-screen device).
  • the large-screen device will not remove the P2P group, and phone A can share with phone B normally. document. Only when the reference count becomes 0, that is, the screen casting service and the file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device sends a response message indicating that the multiplexing of the P2P capability is successful to the communication module in the large-screen device.
  • the communication module in the large-screen device sends the connection request response information to the communication module in the mobile phone A, where the connection request response information includes: allowing the mobile phone B to join the P2P group Instruction information, information about the P2P group formed by mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone B, and the MAC address of the large-screen device.
  • the connection request response information may include: any one of the indication information that allows mobile phone B to join the P2P group and the information of the P2P group formed by mobile phone A and the large-screen device, and does not necessarily include allowing mobile phone B to join the P2P group at the same time. Indication information of the group, and information of the P2P group formed by mobile phone A and large-screen devices.
  • the connection request response information may further include: indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone A.
  • the communication module in the mobile phone A determines that the mobile phone B can join the P2P group according to the indication information of allowing the 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 jointly maintained by the two devices, and the multiplexing of the Wi-Fi P2P capability is for one device, only one device can apply for Wi-Fi Fi P2P capability multiplexing can only ensure that the device will not actively disconnect the Wi-Fi P2P link during the existence of the service, and the peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect Therefore, the communication module in mobile phone A also needs to send a request for multiplexing Wi-Fi P2P capability to the P2P link management module in mobile phone A.
  • the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone
  • the P2P link management module in the mobile phone A receives the request, as a possible implementation, if the request carries: the indication information that a Wi-Fi P2P connection exists between the large-screen device and the mobile phone A, Then 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 manner, if the request carries: indication information that a Wi-Fi P2P connection exists between the large-screen device and mobile phone A, and the P2P link management module in mobile phone A determines the Wi-Fi P2P connection - If the Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
  • 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 role of mobile phone A.
  • the P2P link management module in mobile phone A can obtain the connection information from the communication module, so as to determine that there is a Wi-Fi P2P link between mobile phone A and the large-screen device according to the connection information (the one between the mobile phone A and the large-screen device). screen-casting Wi-Fi P2P link), or, determine that mobile phone A currently has a Wi-Fi P2P link (the Wi-Fi P2P link for screen-casting between mobile phone A and the large-screen device), and the Wi-Fi P2P link - If the Fi P2P link supports other services, it can be determined that mobile phone A can reuse the Wi-Fi P2P capability.
  • the mobile phone A may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone A.
  • the reference count maintained by mobile phone A is 1, indicating that mobile phone A's own Wi-Fi P2P capability carries one service (mobile phone A's screencasting service to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (the screen casting service of mobile phone A to large-screen devices and the File sharing service from mobile phone A to mobile phone B).
  • the reference count becomes 2 if the screencasting service is disconnected, the reference count becomes 1. Since the reference count is not 0, the mobile phone A will not disconnect the Wi-Fi P2P link, and the mobile phone A can still operate normally. Share the file to phone B. Mobile phone A will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen-casting service and the file-sharing service are disconnected.
  • the P2P link management module in the mobile phone A sends a response message that the multiplexing of the P2P capability is successful to the communication module in the mobile phone A.
  • the communication module in the mobile phone A sends a Wi-Fi P2P connection request to the communication module in the mobile phone B through the first connection, and the Wi-Fi P2P connection request is encrypted with 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 formed by mobile phone A and the large-screen device (for example, the SSID, BSSID, frequency, PASSWORD, etc. of the P2P group), The large-screen device assigns the IP address to mobile phone B, the MAC address of the large-screen device, the IP address and port number information of mobile phone A, and so on.
  • the port number of mobile phone A is obtained by the communication module of mobile phone A by starting monitoring after Wi-Fi P2P is established.
  • the Wi-Fi P2P connection request response information may include: any one of the indication information that allows the mobile phone B to join the P2P group, and the information of the P2P group formed by the mobile phone A and the large-screen device, and it is not necessary to include the permission to join the P2P group.
  • the P2P link management module in the mobile phone B directly initiates a Wi-Fi P2P connection to the large-screen device through the connection interface (for example, the connect interface) according to the P2P group information and the MAC address of the large-screen device, and joins the P2P After the group is formed, the P2P link management module in the mobile phone B sends a response message to the communication module in the mobile phone B, which is used to notify the communication module in the mobile phone B that the mobile phone B has successfully joined the P2P group.
  • the connection interface for example, the connect interface
  • the communication module in the mobile phone B sends the Wi-Fi P2P connection request response information to the communication module in the mobile phone A through the first connection, and the Wi-Fi P2P connection request response information is encrypted with the encryption key , the response information of the Wi-Fi P2P connection request includes: the indication information that the mobile phone B successfully joins the P2P group, the IP address assigned by the large-screen device to the mobile phone B, and the port number generated by the mobile phone B itself.
  • the communication module in the mobile phone A uses the decryption key to decrypt it, and determines that the mobile phone B has successfully joined the P2P group.
  • the communication module in the mobile phone A sends the Wi-Fi P2P connection request response information to the first application on the mobile phone A, which is used to notify the first application on the mobile phone A that the mobile phone B has successfully joined the P2P group, and the Wi-Fi P2P
  • the connection request response information carries: the IP address assigned by the large-screen device to the mobile phone B, the port number generated by the mobile phone B, the IP address and port number information of the mobile phone A, and so on.
  • the first application on mobile phone A utilizes: the IP address and port number information of mobile phone A, combined with the IP address allocated to mobile phone B by the large-screen device and the port number generated by mobile phone B, and the first application on mobile phone B (that is, for file sharing) to establish a socket transmission channel.
  • the first application on the mobile phone A starts file sharing to the first application (ie, the file sharing application) on the mobile phone B based on the socket transmission channel.
  • the 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 the mobile phone B, that is, the data flow of the file sharing service is: mobile phone A ⁇ large screen screen device ⁇ mobile phone B.
  • the data flow of the screen projection service is mobile phone A ⁇ large screen device.
  • the embodiments of the present application may also set their corresponding priorities according to different services, and the services with high priorities are preferentially transmitted or transmitted with a large bandwidth. 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, and the user experience can be further improved.
  • the removal of the P2P group is performed only after the two services of the file sharing service and the screen projection service are completed.
  • the GO device and the P2P group are removed.
  • the reference counts maintained by mobile phone A and the large-screen device are both reduced to 1. Since the reference count is not 0, in this case, GO devices and P2P groups will not be performed. The removal of the group will not disconnect the Wi-Fi P2P link between mobile phone A and the large-screen device.
  • the first electronic device (that is, the GC device) in the P2P group and the third electronic device (that is, the idle device) outside the P2P group can use multiple discovery methods to discover each other, And when the first electronic device in the P2P group and the third electronic device outside the P2P group cannot directly connect to Wi-Fi P2P, the third electronic device will use the first electronic device as an intermediary device to assist itself in joining the first electronic device. In the P2P group where an electronic device is located, or the first electronic device will act as an intermediary device to assist the third electronic device to join the P2P group where the GC device is located.
  • both the first electronic device in the P2P group and the third electronic device outside the P2P group can obtain the IP address and port number of the other party, and establish the first electronic device in the P2P group and the third electronic device outside the P2P group.
  • a socket transmission channel between the three electronic devices so as to realize the data transmission between the two based on the socket transmission channel.
  • multiplex the Wi-Fi P2P capabilities of the first electronic device and the second electronic device (ie the GO device) in the P2P group the first electronic device and the second electronic device can perceive their current Wi-Fi
  • the P2P capability carries multiple services. After multiple services are completed, the P2P group is removed and the Wi-Fi P2P connection is disconnected, thus ensuring that different services can be transmitted and completed.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that the GC equipment in the P2P group and the idle equipment outside the P2P group cannot transmit data in the prior art is solved, and the user experience is improved.
  • FIG. 10 is a schematic diagram of a communication system applicable to an embodiment of the present application.
  • the system architecture includes: a first electronic device, a second electronic device and a third electronic device, and Wi-Fi has been established between the first electronic device and the third electronic device and the second electronic device respectively P2P connection, 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, the first electronic device
  • the equipment and the third electronic equipment are all GC equipment.
  • FIG. 10 the system architecture includes: a first electronic device, a second electronic device and a third electronic device, and Wi-Fi has been established between the first electronic device and the third electronic device and the second electronic device respectively P2P connection, 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, the first electronic device
  • the first electronic device is mobile phone A
  • the third electronic device is mobile phone B
  • the second electronic device is a large-screen device (such as a smart TV). Both mobile phone A and mobile phone B are projecting to the large-screen device, and then mobile phone B (GC device) needs to initiate a file sharing service to mobile phone A (GC device).
  • GC device mobile phone B
  • FIG. 11 is a schematic flowchart of an example of a Wi-Fi P2P connection method provided by the present application in the scenario shown in FIG. 10 .
  • mobile phone A and mobile phone B are casting their screens to large-screen devices through their respective Wi-Fi P2P connections.
  • the method includes: S301 to S329.
  • the user opens the first application (ie the file management application) on the mobile phone B, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • the file management application ie the file management application
  • the first application on the mobile phone B sends a device discovery request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B starts a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • the communication module in the mobile phone B scans the devices, it sends the scanned device list to the first application on the mobile phone B, where the device list contains device identifiers of one or more devices.
  • the displayed device list may be as shown in d in FIG. 8 .
  • the user selects the device identification of the mobile phone A in the device list on the first application on the mobile phone B, and the device identification of the mobile phone A can be the device model, identification code, device name, device ID (device ID) of the mobile phone A, etc. .
  • the device identifier of the mobile phone A is used to uniquely identify the mobile phone A.
  • the first application on the mobile phone B sends a Wi-Fi P2P connection request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B first establishes a first connection with the communication module in the mobile phone A.
  • the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone B and the communication module in the mobile phone A negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone B stores the encryption key and the decryption key.
  • the communication module in the mobile phone A stores the encryption key and the decryption key.
  • the communication module in the mobile phone B will receive the connection state change notification reported by the FRAMEWORK layer, and the notification carries the basic connection information. Therefore, the communication of the mobile phone B
  • the existing connection information has been maintained in the module, and the connection information 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, this information can be used 2 Representation), the role of the connected device (large-screen device) (for GO), and the MAC address and identification of the large-screen device.
  • the communication module in the large-screen device will also receive the connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is the GO role, the connection information In addition to including 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), it also includes the information of the P2P group. In this embodiment of the present application, the P2P group information includes: at least one of SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, according to the connection information, the communication module in hand B determines that mobile phone B is already a GC, and further determines that mobile phone B cannot directly establish a Wi-Fi P2P connection with mobile phone A.
  • the connection information includes: at least one of SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, according to the connection information, the communication module in hand B determines that mobile phone B is already
  • the communication module in the mobile phone B sends a Wi-Fi P2P connection request to the communication module in the mobile phone A through the first connection, the Wi-Fi P2P connection request is encrypted by the encryption key, and the Wi-Fi P2P connection request includes: Device ID of mobile phone B, current Wi-Fi P2P connection status of mobile phone B, MAC address of the Wi-Fi P2P port of mobile phone B, list of channels supported by mobile phone B (for example, to support 36 channels, corresponding to 5180MHz), The frequency of the Wi-Fi hotspot, whether it supports broadband (for example, whether it supports 160MHz, if it is supported, it can be represented by true, if it is not supported, it can be represented by false), the identity of the GO device connected to mobile phone B, and other information.
  • the Wi-Fi P2P connection request includes: Device ID of mobile phone B, current Wi-Fi P2P connection status of mobile phone B, MAC address of the Wi-Fi P2P port of mobile phone B, list of channels supported by mobile phone B (for
  • the current Wi-Fi P2P connection status of mobile phone B includes: mobile phone B does not currently have a Wi-Fi P2P connection with any device, and the connection status can be represented by 0; mobile phone B currently has a Wi-Fi P2P connection with other devices.
  • -Fi P2P connection, and the role of mobile phone B is GO status, the connection status can be represented by 1; there is currently a Wi-Fi P2P connection between mobile phone B and other devices, and the role of mobile phone B is GC status, the connection The state can be represented by 2.
  • the mobile phone B currently has a Wi-Fi P2P connection and the hand role is the GC state, and the current Wi-Fi P2P connection state of the mobile phone B is represented by 2.
  • the communication module in the mobile phone A uses the decryption key to decrypt to obtain the content included in the connection request.
  • the communication module in mobile phone A 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: mobile phone A
  • the current connection status and role 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) (for GO), and the large-screen device MAC address, ID, etc.
  • the communication module in the mobile phone A determines whether the identity of the GO device connected to the mobile phone B is the same as the identity of the GO device connected to itself.
  • the communication module in the mobile phone A can determine that there is Wi-Fi between the mobile phone B and the mobile phone A respectively and the large-screen device P2P connection. Further, the communication module in the mobile phone A sends a request for applying for multiplexing the Wi-Fi P2P capability to the P2P link management module in the mobile phone A.
  • the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the P2P link management module in mobile phone A receives the request, as a possible implementation, if the request carries: mobile phone B and mobile phone A have Wi-Fi P2P connections with the large-screen device respectively Indication information, the P2P link management module in mobile phone A can determine that there is a Wi-Fi P2P connection between mobile phone A and mobile phone B and the large-screen device respectively, then the P2P link management module in mobile phone A can determine that Wi-Fi Fi P2P capability.
  • the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused.
  • 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) (for GO ) and the MAC address of the large-screen device.
  • the P2P link management module in the mobile phone A can obtain the connection information from the communication module, and according to the connection information, combined with the identification of the GO device connected to the mobile phone B, determine the identification of the GO device connected to the mobile phone B and its own connection. If the identifiers of the GO devices are the same, 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, then the P2P link management module in mobile phone A determines that mobile phone A can reuse the Wi-Fi P2P capability .
  • the mobile phone A may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone A.
  • the reference count maintained by mobile phone A is 1, indicating that mobile phone A's own Wi-Fi P2P capability carries one service (mobile phone A's screencasting service to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (the screen casting service of mobile phone A to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 2 if the screencasting 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 chain between mobile phone A and the large-screen device. Road, mobile phone B can also share files with mobile phone A normally. Mobile phone A will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen-casting service and the file-sharing service are disconnected.
  • the P2P link management module in the mobile phone A sends a response message that the multiplexing of the P2P capability is successful to the communication module in the mobile phone A.
  • 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: between mobile phone A and mobile phone B Authorization to transmit first application data over Wi-Fi P2P connection.
  • the Wi-Fi P2P connection request information includes: 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 connected to mobile phone B and other information. at least one.
  • the communication module in the large-screen device checks the mobile phone B. For example, it will check 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.
  • Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be jointly maintained by the two devices, the multiplexing of the Wi-Fi P2P capability is for one device , only apply for Wi-Fi P2P capability multiplexing for a certain device, it can only ensure that this device will not actively disconnect the Wi-Fi P2P link during the service existence, and the peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link. -Fi P2P link will eventually affect service transmission.
  • the communication module in the large-screen device will also send an application reply to the P2P link management module in the large-screen device Request for P2P capability with Wi-Fi.
  • the request for multiplexing 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 B and mobile phone A, respectively.
  • the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request for multiplexing the Wi-Fi P2P capability includes: the large-screen device is connected to the mobile phone B and the mobile phone A respectively. If there is already a Wi-Fi P2P link between them, the P2P link management module in the large-screen device can determine that the large-screen device can reuse the Wi-Fi P2P capability.
  • the connection information includes: Wi-Fi P2P connection status, role and address information of these devices, P2P group with their own connected devices (including mobile phone B and mobile phone A) group information, etc.
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, so as to determine, according to the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, respectively, or, If it is determined that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, and that the two Wi-Fi P2P links support other services, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • 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 two services (mobile phone A and mobile phone B respectively report to the large screen device's screen projection service).
  • 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 (mobile phone A and mobile phone B respectively report to the large-screen device , and the file sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 3 if both screencasting services are disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not remove the P2P group. Phone A shares files. Only when the reference count becomes 0, that is, two screen casting services and one file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be multiplexed, it sends a response message that the multiplexing of the P2P capability is successful to the communication module in the large-screen device.
  • the communication module in the large-screen device sends Wi-Fi P2P connection response information to the communication module in the mobile phone A, where the connection response information includes: P2P group information.
  • the connection response information may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A, respectively, and the large-screen device.
  • the P2P group information includes: at least one of the SSID, BSSID, frequency, and password (PASSWORD) of the P2P group.
  • the communication module in the mobile phone A determines that the data of the first application can be transmitted with the mobile phone B through the Wi-Fi P2P connection according to the P2P group information.
  • the communication module in the mobile phone A sends the Wi-Fi P2P connection response information to the communication module in the mobile phone B through the first connection, and the Wi-Fi P2P connection information is encrypted by the encryption key.
  • the Wi-Fi P2P connection information includes: the IP address and port number information of the mobile phone A, the identification of the GO device connected to the mobile phone A, and other information.
  • the Wi-Fi P2P connection information may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A, respectively, and the large-screen device.
  • the communication module in the mobile phone B decrypts the Wi-Fi P2P connection information by using the decryption key, and obtains the content of the Wi-Fi P2P connection information.
  • the Fi P2P connection information includes 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 indication information of the P2P connection determines that the data of the first application can be transmitted with the mobile phone A through the Wi-Fi P2P connection.
  • the Wi-Fi P2P connection information does not include 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, in the GO connected to mobile phone A
  • 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, so as to determine that mobile phone A can communicate with mobile phone A.
  • the data of the first application is transmitted between them through a Wi-Fi P2P connection.
  • the communication module will also send a request for multiplexing the Wi-Fi P2P capability to the P2P link management module in the mobile phone B.
  • the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the P2P link management module in the mobile phone B receives the request, as a possible implementation, if the request carries: an indication that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A and the large-screen device respectively information, 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, then the P2P link management module in mobile phone B can determine that Wi-Fi can be reused P2P capability.
  • the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused.
  • the request does not carry the indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • 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 connected The role of the device (large-screen device) (for GO) and the MAC address of the large-screen device, etc.
  • the P2P link management module in the mobile phone B can obtain the connection information from the communication module, and determine that the identity of the GO device connected to the mobile phone B is the same as the identity of the GO device connected to itself. If there is a Wi-Fi P2P connection between large-screen devices, the P2P link management module in mobile phone B determines that mobile phone B can reuse the Wi-Fi P2P capability.
  • the mobile phone B may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone B.
  • 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 (the screen casting service of mobile phone B to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (the screen casting service of mobile phone B to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 2 if the screencasting service is disconnected, the reference count becomes 1. Since the reference count is not 0, the mobile phone B will not disconnect the Wi-Fi P2P chain between the mobile phone B and the large-screen device. Road, mobile phone B can also share files with mobile phone A normally. Mobile phone B will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen casting service and the file sharing service are disconnected.
  • the P2P link management module in the mobile phone B sends a response message that the P2P capability is successfully multiplexed to the communication module in the mobile phone B.
  • the communication module in the mobile phone B sends the Wi-Fi P2P connection request response information to the first application on the mobile phone B, where the Wi-Fi P2P connection request response information includes: the relationship between the mobile phone B and the mobile phone A
  • the indication information of the data of the first application, the IP address and port number of mobile phone A, the port number information generated by mobile phone B, etc. can be transmitted between the two devices through the Wi-Fi P2P connection.
  • the first application on the mobile phone B uses the IP address and port number information of the mobile phone A, combined with the IP address of the mobile phone B and the information such as the port number generated by the mobile phone B itself, etc., and the first application on the mobile phone A (for example, a file share) to establish a socket transmission channel.
  • the first application on the mobile phone B starts file sharing to the first application on the mobile phone A based on the socket transmission channel.
  • the 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 the mobile phone A, that is, the data flow of the file sharing service is: mobile phone B ⁇ large screen screen device ⁇ mobile phone A.
  • the data flow of the screen projection service of mobile phone A is mobile phone A ⁇ large-screen device
  • the data flow of the screen projection service of mobile phone B is mobile phone B ⁇ large-screen device.
  • FIG. 12 is a schematic flowchart of another example of a Wi-Fi P2P connection method provided by the present application in the scenario shown in FIG. 10 .
  • mobile phone A and mobile phone B are casting their screens to large-screen devices through their respective Wi-Fi P2P connections.
  • the method includes: S401 to S429.
  • the user opens the first application (ie, the file management application) on the mobile phone B, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • the file management application ie, the file management application
  • the first application on the mobile phone B sends a device discovery request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B After receiving the device discovery request, the communication module in the mobile phone B starts a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • the communication module in the mobile phone B scans the devices, it sends the scanned device list to the first application on the mobile phone B, where the device list contains device identifiers of one or more devices.
  • the displayed device list may be as shown in d in FIG. 8 .
  • the user selects the device identification of the mobile phone A in the device list on the first application on the mobile phone B, and the device identification of the mobile phone A can be the device model, identification code, device name, device ID (device ID) of the mobile phone A, etc. .
  • the device identifier of the mobile phone A is used to uniquely identify the mobile phone A.
  • the first application on the mobile phone B sends a Wi-Fi P2P connection request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B first establishes a first connection with the communication module in the mobile phone A.
  • the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone B and the communication module in the mobile phone A negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone B stores the encryption key and the decryption key.
  • the communication module in the mobile phone A stores the encryption key and the decryption key.
  • the communication module in the mobile phone B will receive the connection state change notification reported by the FRAMEWORK layer, and the notification carries the basic connection information. Therefore, the communication of the mobile phone B
  • the existing connection information has been maintained in the module, and the connection information 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, this information can be used 2 Representation), the role of the connected device (large-screen device) (for GO), and the MAC address and identification of the large-screen device.
  • the communication module in the large-screen device will also receive the connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is the GO role, the connection information In addition to including 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), it also includes the information of the P2P group. In this embodiment of the present application, the P2P group information includes: at least one of SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, according to the connection information, the communication module in hand B determines that mobile phone B is already a GC, and further determines that mobile phone B cannot directly establish a Wi-Fi P2P connection with mobile phone A.
  • the connection information includes: at least one of SSID, BSSID, frequency, and password (PASSWORD) of the P2P group. Therefore, according to the connection information, the communication module in hand B determines that mobile phone B is already
  • the communication module in the mobile phone B sends a connection request to the communication module in the large-screen device, and the connection request includes: the device identification of the mobile phone A, the MAC address of the Wi-Fi P2P port of the mobile phone A, and the IP address information of the mobile phone A. at least one.
  • the connection request is used to request: request to transmit the first application data between mobile phone A and mobile phone B through a Wi-Fi P2P connection. It should be understood that in this embodiment of the present application, the mobile phone B can obtain information such as the MAC address of the Wi-Fi P2P port of the mobile phone A, the IP address of the mobile phone A, and the like through the first connection with the mobile phone A.
  • the communication module in the large-screen device will verify the mobile phone A. For example, it will check whether the mobile phone A is a trusted device, and determine whether the large-screen device has established a connection with the mobile phone A.
  • the communication module in the large-screen device sends an application for multiplexing Wi-Fi to the P2P link management module in the large-screen device - Fi P2P capability request.
  • the request for multiplexing 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 B and mobile phone A, respectively.
  • the capability request 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 Wi-Fi Fi P2P capability.
  • the connection information includes: Wi-Fi P2P connection status, role and address information of these devices, P2P group with their own connected devices (including mobile phone B and mobile phone A) group information, etc.
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, so as to determine, according to the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B and mobile phone A, respectively, or, If it is determined that a Wi-Fi P2P link already exists between the large-screen device and mobile phone A, and that the two Wi-Fi P2P links support other services, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • 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 two services (mobile phone A and mobile phone B respectively report to the large screen device's screen projection service).
  • 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 (mobile phone A and mobile phone B respectively report to the large-screen device , and the file sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 3 if both screencasting services are disconnected, the reference count becomes 1. Since the reference count is not 0, the large-screen device will not remove the P2P group. Phone A shares files. Only when the reference count becomes 0, that is, two screen casting services and one file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device determines that the Wi-Fi P2P capability can be multiplexed, it sends a response message indicating that the multiplexing of the P2P capability is successful to the communication module in the large-screen device.
  • connection request response information includes: allowing mobile phone A and mobile phone B to connect via Wi-Fi P2P
  • the indication information of the data of the first application, the P2P group information and the identifier of the GO device connected to the mobile phone A are transmitted.
  • the connection request response information further includes: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the P2P group information includes: at least one of SSID, BSSID, frequency, and password (PASSWORD) of the P2P group.
  • the communication module in the mobile phone B determines that it can communicate with the mobile phone B according to the instruction information that allows the mobile phone A and the mobile phone B to transmit the data of the first application through the Wi-Fi P2P connection.
  • the Wi-Fi P2P connection transmits the data of the first application. Since the Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be jointly maintained by these two devices, the multiplexing of Wi-Fi P2P capabilities is for one device, only Applying for Wi-Fi P2P capability multiplexing for a certain device can only ensure that the device will not actively disconnect the Wi-Fi P2P link during the service existence, and the peer device cannot guarantee that the Wi-Fi will not be actively disconnected.
  • the communication module in mobile phone B also sends a request for multiplexing the Wi-Fi P2P capability to the P2P link management module in mobile phone B.
  • the request for multiplexing the Wi-Fi P2P capability includes the identity of the GO device to which the mobile phone A is connected.
  • the request for applying for multiplexing the Wi-Fi P2P capability may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the P2P link management module in the mobile phone B receives the request, as a possible implementation, if the request carries: an indication that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A and the large-screen device respectively information, 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, then the P2P link management module in mobile phone B can determine that Wi-Fi can be reused P2P capability.
  • the P2P link management module in mobile phone B determines that the Wi-Fi P2P capability can be reused.
  • the request does not carry the indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the connection information includes: the current connection status and role of the mobile phone B (for example, the mobile phone B already has a Wi-Fi P2P connection and the role is GC), the connected The role of the device (large-screen device) (for GO) and the MAC address of the large-screen device, etc.
  • the P2P link management module in the mobile phone B can obtain the connection information from the communication module, and according to the connection information, determine that the identity of the GO device connected to the mobile phone A is the same as the identity of the GO device connected to itself, and the identity of the GO device connected to the mobile phone B is the same.
  • the communication module 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.
  • the mobile phone B may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone B.
  • 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 (the screen casting service of mobile phone B to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (the screen casting service of mobile phone B to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 2 if the screencasting service is disconnected, the reference count becomes 1. Since the reference count is not 0, the mobile phone B will not disconnect the Wi-Fi P2P chain between the mobile phone B and the large-screen device. Road, mobile phone B can also share files with mobile phone A normally. Mobile phone B will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen casting service and the file sharing service are disconnected.
  • the P2P link management module in the mobile phone B sends a response message that the multiplexing of the P2P capability is successful to the communication module in the mobile phone B.
  • the communication module in the mobile phone B after receiving the response information, sends a Wi-Fi P2P connection request to the communication module in the 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 identity of the GO device connected to mobile phone B.
  • the Wi-Fi P2P connection may further include: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the mobile phone A respectively and the large-screen device.
  • the communication module in the mobile phone A uses the decryption key to decrypt it, obtains the content included in the Wi-Fi P2P connection request, and determines the identity of the GO device connected to the mobile phone B and its own Whether the identities of the connected GO devices are the same.
  • the Wi-Fi P2P connection information includes information indicating that there is a Wi-Fi P2P connection between mobile phone B and mobile phone A, respectively, and the large-screen device
  • the communication module in mobile phone B The indication information of the Wi-Fi P2P connection exists between A and the large-screen device respectively, and it is determined that the data of the first application can be transmitted with the mobile phone A through the Wi-Fi P2P connection.
  • the Wi-Fi P2P connection information does not include 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, in the GO connected to mobile phone A
  • 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, so as to determine that mobile phone A can communicate with mobile phone A.
  • the data of the first application is transmitted between them through a Wi-Fi P2P connection.
  • Wi-Fi P2P link (or Wi-Fi P2P connection) between two devices needs to be jointly maintained by these two devices, only applying for Wi-Fi P2P capability multiplexing for one device can only guarantee this The device will not actively disconnect the Wi-Fi P2P link during the existence of the service, and the peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link, which will eventually affect the service transmission.
  • the communication module will also send a request for multiplexing Wi-Fi P2P capability to the P2P link management module in mobile phone A.
  • the request for multiplexing the Wi-Fi P2P capability may also include: indication information indicating that the identity of the GO device connected to the mobile phone B is the same as the identity of the GO device connected to the mobile phone A, or, the mobile phone B and the mobile phone A are respectively the same as the large-screen device. There is at least one of the indication information of the Wi-Fi P2P connection and the identity of the GO device connected to the mobile phone B.
  • the P2P link management module in the mobile phone A receives the request, as a possible implementation, if the request carries: the identity of the GO device connected to the mobile phone B and the identity of the GO device connected to the mobile phone A.
  • the request carries: the identity of the GO device connected to the mobile phone B and the identity of the GO device connected to the mobile phone A
  • the P2P link management module in mobile phone A can determine that mobile phone A and mobile phone B are connected to the large screen respectively. If there is a Wi-Fi P2P connection between devices, the P2P link management module in mobile phone A determines that the Wi-Fi P2P capability can be reused.
  • the request carries: the identification of the GO device connected to mobile phone B is the same as the identification of the GO device connected to mobile phone A, or, mobile phone B and mobile phone A are respectively associated with If the indication information of Wi-Fi P2P connection exists between the large-screen devices, and the two Wi-Fi P2P connections support other services respectively, the P2P link management module in mobile phone A determines that Wi-Fi P2P can be reused ability. Or, as another possible implementation manner, if the request does not carry the same indication information that the identity of the GO device connected to mobile phone B is the same as the identity of the GO device connected to mobile phone A, or the mobile phone B and mobile phone A are respectively the same as the big one.
  • the indication information that there is a Wi-Fi P2P connection between the screen devices Since the existing connection information has been stored in the communication module of mobile phone A, 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 connected The role of the device (large-screen device) (for GO) and the MAC address of the large-screen device.
  • the P2P link management module in the mobile phone A can obtain the connection information from the communication module, and according to the connection information, it is determined that the identity of the GO device connected to the mobile phone B is the same as the identity of the GO device connected to itself, then the mobile phone can be determined. There are Wi-Fi P2P connections between B and mobile phone A respectively and the large-screen device.
  • the P2P link management module in mobile phone B determines that mobile phone B can reuse the Wi-Fi P2P capability.
  • the mobile phone A may also maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the mobile phone A.
  • the reference count maintained by mobile phone A is 1, indicating that mobile phone A's own Wi-Fi P2P capability carries one service (mobile phone A's screencasting service to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone A itself carries 2 services (the screen casting service of mobile phone A to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 2 services (the screen casting service of mobile phone A to large-screen devices and the File sharing service from mobile phone B to mobile phone A).
  • the reference count becomes 1. Since the reference count is not 0, mobile phone A will not disconnect the Wi-Fi P2P chain between mobile phone A and the large-screen device. Road)
  • Mobile phone B can also share files with mobile phone A normally. Mobile phone A will disconnect the Wi-Fi P2P link only when the reference count becomes 0, that is, when both the screen-casting service and the file-sharing service are disconnected.
  • the P2P link management module in the mobile phone A sends a response message that the multiplexing of the P2P capability is successful to the communication module in the mobile phone A.
  • the communication module in the mobile phone A sends the Wi-Fi P2P connection request response information to the communication module in the 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 that allows mobile phone A and mobile phone B to transmit the data of the first application through the Wi-Fi P2P connection, the IP address and port number information of mobile phone A, and the like.
  • the communication module in the mobile phone B sends the Wi-Fi P2P connection request response information to the first application on the mobile phone B, and the Wi-Fi P2P connection request response information includes: Allows mobile phone A and mobile phone B to transmit the indication information of the data of the first application through the Wi-Fi P2P connection, the IP address and port number information of mobile phone A, and the port number generated by mobile phone B itself.
  • the first application on the mobile phone B uses the IP address and port number information of the mobile phone A, combined with the IP address of the mobile phone B and the port number generated by the mobile phone B itself, and other information to share with the first application on the mobile phone A (for example, file sharing ) to establish a socket transmission channel.
  • the first application on the mobile phone B starts file sharing to the first application on the mobile phone A based on the socket transmission channel.
  • the 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 the mobile phone A, that is, the data flow of the file sharing service is: mobile phone B ⁇ large screen 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.
  • the P2P group and the GO device will be updated. remove.
  • 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, no Carry out the removal of GO devices and P2P groups.
  • the first electronic device (GC device) and the third electronic device (another GC device) in the P2P group can use multiple discovery methods to discover each other, and when P2P
  • 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.
  • the electronic device establishes a socket transmission channel, thus forming the basis for the communication between the two.
  • the first electronic device and the third electronic device in the P2P group can obtain the IP address and port number of the other party, so as to realize the data transmission based on the socket transmission channel between the two.
  • the Wi-Fi P2P capabilities of the first electronic device, the second electronic device, and the third electronic device can perceive the current Wi-Fi P2P of their own.
  • the ability to carry multiple services, P2P group removal and Wi-Fi P2P connection disconnection will be performed only after multiple services are completed, thus ensuring that different services can be transmitted normally, and between different services will not affect each other.
  • the second electronic device in the P2P group is used as a relay. Further, the transmission of services based on the Wi-Fi P2P connection is realized, the problem that data cannot be transmitted between two GC devices in a P2P group in the prior art is solved, and the user experience is improved.
  • FIG. 13 is a schematic diagram of a communication system applicable to an embodiment of the present application.
  • 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,
  • the second electronic device and the first electronic device have formed a P2P group.
  • the P2P group the second electronic device is a GO device or an AP device
  • 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 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,
  • the second electronic device and the first electronic device have formed a P2P group.
  • the second electronic device is a GO device or an AP device
  • the fourth electronic device is a mobile phone C
  • the first electronic device is a mobile phone A
  • the second electronic device is a large-screen device (such as a smart TV).
  • Mobile phone A is projecting to the large-screen device, and then mobile phone C (idle device) needs to initiate file sharing to the large-screen device.
  • the Wi-Fi P2P link is used for screen projection between mobile phone A and the large-screen device.
  • FIG. 14 is a schematic flowchart of an example of a Wi-Fi P2P connection method provided by the present application in the scenario shown in FIG. 13 . As shown in FIG. 14 , the method includes: S501 to S522.
  • the mobile phone A and the large-screen device have already performed the transmission of the service data of the second application (ie, the screen-casting application) based on the established Wi-Fi P2P connection.
  • the service data of the second application ie, the screen-casting application
  • the user opens the first application (that is, the file management application) on the mobile phone C, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • the file management application that is, the file management application
  • the first application on the mobile phone C sends a device discovery request to the communication module in the mobile phone C.
  • the communication module in the mobile phone C After receiving the device discovery request, the communication module in the mobile phone C starts a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • a device discovery method such as BLE scan, BR scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • the communication module in the mobile phone C scans the devices, it sends the scanned device list to the first application on the mobile phone C, where the device list contains device identifiers of one or more devices.
  • the displayed device list may be as shown in d in FIG. 8 .
  • the user selects the device identifier of the large-screen device in the device list on the first application on the mobile phone C, and the device identifier of the large-screen device may be the device model, identification code, device name, device ID (device ID) of the large-screen device. ID), etc.
  • the device identifier of the large-screen device is used to uniquely identify the large-screen device.
  • the first application on the mobile phone C will send a Wi-Fi P2P connection request to the communication module in the mobile phone C.
  • the communication module in the mobile phone C firstly establishes a first connection request with the communication module in the large-screen device.
  • the first connection may be a BLE connection, a BR connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone C and the communication module in the large-screen device negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone C stores the encryption key and the decryption key.
  • the communication module in the large-screen device stores the encryption key and the decryption key.
  • the Wi-Fi P2P connection request includes: the device information of mobile phone C (such as device ID, etc.), the current Wi-Fi P2P connection status of mobile phone C (the current Wi-Fi P2P connection status of mobile phone C includes: mobile phone C is not currently connected to any There is a Wi-Fi P2P connection state between devices, which can be represented by 0; there is a Wi-Fi P2P connection between mobile phone C and other devices currently, and the role of mobile phone C is the GO state, the connection state can be used There is a Wi-Fi P2P connection between mobile phone C and other devices at present, and the role of mobile phone C is the state of GC, and the connection state can be represented by 2.
  • mobile phone C does not currently have Wi-Fi P2P connection
  • 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 list of channels supported by mobile phone C (for example, to support 36 channels, corresponding to 5180MHz)
  • the expected channel of mobile phone C Connection method 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.
  • the frequency of the Wi-Fi hotspot connected to the mobile phone C whether it supports broadband (for example, whether it supports 160MHz, if it is supported, it can be represented by true, if it is not supported, it can be represented by false).
  • the communication module in the large-screen device uses the decryption key for decryption, checks whether the mobile phone C is a trusted device, and determines whether the large-screen device has been established with the mobile phone C Wi-Fi P2P connection is enabled.
  • connection information includes: the Wi-Fi P2P connection with its own connected device (including mobile phone A) Status, role (GC) and address information of these devices, information of P2P groups, etc.
  • the large-screen device After confirming that the large-screen device has not established a Wi-Fi P2P connection with the mobile phone C, the large-screen device is a GO device, and the mobile phone C is a trusted device (for example, the mobile phone C and the large-screen device log in to the same account, or the mobile phone C and the After the large-screen device has been bound to the device in various ways (such as through QR code scanning, etc.), the communication module in the large-screen device sends an application for multiplexing Wi-Fi P2P to the P2P link management module in the large-screen device capacity request.
  • the request for multiplexing Wi-Fi P2P capabilities 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.
  • the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request for multiplexing the Wi-Fi P2P capability includes: there is a Wi-Fi connection between the large-screen device and the mobile phone A -Fi P2P connection, if the large-screen device is a GO device, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability. Or, as another possible implementation, if the request for multiplexing the 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.
  • the communication module in the screen device has maintained the existing connection information, the connection information includes: Wi-Fi P2P connection status, role, address information of these devices, and P2P group information with their own connected devices (including mobile phone A). Wait.
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, and according to the connection information, determine that 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, that is If it is determined that the P2P group exists, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • the value of the reference count maintained by the large-screen device is 1, which means that the Wi-Fi P2P capability of the large-screen device itself carries 1 service (the projection of mobile phone A to the large-screen device). business).
  • 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 (the screen casting service of mobile phone A to the large-screen device).
  • the large-screen device will not remove the P2P group, and the mobile phone C can still send the large-screen device to the large-screen device normally. Share files. Only when the reference count becomes 0, that is, the screen casting service and the file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device sends a response message indicating that the multiplexing of the P2P capability is successful to the communication module in the large-screen device.
  • the communication module in the large-screen device receives the response information, and sends the 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 uses the encryption key to carry out encryption.
  • 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 formed by mobile phone A and the large-screen device, the IP address assigned by the large-screen device to mobile phone C, and the large-screen device IP address and port number, etc.
  • the Wi-Fi P2P connection request response information may include: any one of the indication information that allows the mobile phone C to join the P2P group, and the information of the P2P group formed by the mobile phone A and the large-screen device, and it is not necessary to include the permission to join the P2P group at the same time.
  • the P2P link management module in the mobile phone C directly initiates a Wi-Fi P2P connection to the large-screen device through the connection interface according to the P2P group information and the IP address and port number of the large-screen device.
  • the P2P link management module in the mobile phone C sends response information to the communication module in the mobile phone C to notify the communication module in the mobile phone C that the mobile phone C joins the P2P group successfully.
  • the communication module in the mobile phone C sends the Wi-Fi P2P connection request response information to the first application on the mobile phone C, which is used to notify the first application on the mobile phone C that the mobile phone C joins the P2P group If successful, the Wi-Fi P2P connection request response information carries: the IP address assigned by the large-screen device to the mobile phone C, the port number generated by the mobile phone C itself, the IP address and port number of the large-screen device.
  • the first application on the mobile phone C uses the IP address assigned to the mobile phone C by the large-screen device and the port number generated by the mobile phone C itself, combined with the IP address of the large-screen device and the port number, etc., to establish a socket transmission channel with the first application (file sharing application) on the large-screen device.
  • the first application on the mobile phone C starts file sharing to the first application on the large-screen device based on the socket transmission channel.
  • 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.
  • the removal of the P2P group is performed only after the two services of the file sharing service and the screen projection service are completed. In other words, only when the reference count maintained by the large-screen device is 0, the GO device and the P2P group are removed. After either the file sharing service or the screen casting 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 removed.
  • the Wi-Fi P2P connection method provided by this application, by managing the P2P link of the second electronic device (GO device), between the second electronic device and the first electronic device (GC device) in the P2P group
  • the fourth electronic device (idle device) outside the P2P group initiates a Wi-Fi P2P connection to the second electronic device (GO device) to perform another service
  • 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, and after the multiple services are transmitted.
  • the P2P group and the GO device will be removed, thus ensuring that different services can be transmitted, and different services will not affect each other, improving user experience.
  • FIG. 15 is a schematic diagram of a communication system applicable to an embodiment of the present application.
  • 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 established a Wi-Fi P2P connection.
  • the electronic device and the second electronic device have formed a group, and within the group, the second electronic device is a GO device or an AP device, and the first electronic device is a GC device.
  • the second electronic device is a GO device or an AP device
  • the first electronic device is a GC device.
  • the first electronic device is a mobile phone B as an example
  • the second electronic device is a large-screen device (for example, a smart TV) as an example.
  • Mobile phone B GC device
  • GO device large-screen device
  • mobile phone B needs to initiate file sharing to the large-screen device.
  • FIG. 16 is a schematic flowchart of an example of a Wi-Fi P2P connection method provided by the present application in the scenario shown in FIG. 15 . As shown in FIG. 16 , the method includes: S601 to S625.
  • the mobile phone B and the large-screen device have already performed the transmission of the service data of the second application (ie, the screen-casting application) based on the established Wi-Fi P2P connection.
  • the service data of the second application ie, the screen-casting application
  • the user opens the first application (that is, the file management application) on the mobile phone B, for example, as shown in a in Figure 8, selects the file to be shared (for example, file 1), clicks "Share”, and selects the sharing method is "Wi-Fi Direct", as shown in b and c in Figure 8.
  • the file management application that is, the file management application
  • the first application on the mobile phone B sends a device discovery request to the communication module in the mobile phone B.
  • the communication module in the mobile phone B starts a device discovery method such as classic Bluetooth, BLE scan, WLAN scan, or Wi-Fi P2P scan to discover the device.
  • the classic Bluetooth includes at least one of two types of Bluetooth, BR) and EDR.
  • the communication module in the mobile phone B scans the devices, it sends the scanned device list to the first application on the mobile phone B, where the device list contains device identifiers of one or more devices.
  • the displayed device list may be as shown in d in FIG. 8 .
  • the user selects the device identifier of the large-screen device in the device list on the first application on the mobile phone B, where the device identifier of the large-screen device may be the device model, identification code, device name, device ID (device ID) of the large-screen device. ID), etc.
  • the device identifier of the large-screen device is used to uniquely identify the large-screen device.
  • the first application on the mobile phone B sends a Wi-Fi P2P connection request to the communication module in the mobile phone B.
  • the Wi-Fi P2P connection request includes the device identification of the mobile phone A.
  • the communication module in the mobile phone B after receiving the Wi-Fi P2P connection request, the communication module in the mobile phone B first establishes a request for a first connection with the communication module in the large-screen device.
  • the first connection may be a BLE connection, a Bluetooth connection, a Wi-Fi connection, or the like.
  • the embodiments of the present application are not limited herein.
  • the communication module in the mobile phone B and the communication module in the large-screen device negotiate the secret key based on the first connection to obtain the encryption secret key and the decryption secret key, thereby completing the security authentication based on the first connection.
  • the communication module in the mobile phone B stores the encryption key and the decryption key.
  • the communication module in the large-screen device stores the encryption key and the decryption key.
  • the communication module in the mobile phone B will receive the connection state change notification reported by the FRAMEWORK layer, and the notification carries the basic connection information. Therefore, the communication of the mobile phone B
  • the existing connection information has been maintained in the module, and the connection information 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, this information can be used 2 ), the role of the connected device (large-screen device) (for GO), and the MAC address of the large-screen device, etc.
  • the communication module in the large-screen device will also receive the connection status change notification reported by the FRAMEWORK layer, which carries basic connection information. Since the large-screen device is the GO role, the connection information In addition to including the Wi-Fi P2P connection status, role, and address information of the device (including mobile phone B) connected to itself (large-screen device), it also includes the information of the P2P group.
  • 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. A sort of.
  • the communication module in the mobile phone B determines that the mobile phone B is already a GC, and determines that there is a Wi-Fi P2P connection corresponding to the second application between itself and the large-screen device (the existing Wi-Fi P2P connection).
  • the communication module in the 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: the authorization to allow mobile phone B to transmit the service data of the first application by using the existing Wi-Fi P2P connection.
  • the Wi-Fi P2P connection request is encrypted with 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: mobile phone B does not currently have any Wi-Fi P2P connection with any device).
  • the state of the Fi P2P connection which can be represented by 0; the current Wi-Fi P2P connection between mobile phone B and other devices, and the role of mobile phone B is the GO state, the connection state can be represented by 1; the current state of mobile phone B There is a Wi-Fi P2P connection with other devices, and the role of the mobile phone B is the state of GC, and the connection state can be represented by 2.
  • the mobile phone B currently has a Wi-Fi P2P connection, and the role is GC, 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, and the list of channels supported by mobile phone B (for example, to support 36 channel, corresponding to 5180MHz), the connection method expected by mobile phone B (for example, mobile phone B expects to establish a Wi-Fi P2P connection with the identity of GC, or mobile phone B expects to establish a Wi-Fi P2P connection with the identity of GO, in this embodiment, the 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 it supports broadband (for example, whether it supports 160MHz, if it is supported, it can be represented by true, if it is not supported, it can be represented by false) at least one of the other information.
  • the connection method expected by mobile phone B for example,
  • the communication module in the large-screen device uses the decryption key to decrypt.
  • the large-screen device 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, and the connection information includes: Wi-Fi P2P connection status with its own connected devices (including mobile phone B) , roles, address information of these devices, P2P group information, etc. Therefore, the large-screen device can determine that the large-screen device and mobile phone B are in a P2P group according to the connection information, 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 projected by mobile phone B to the large-screen device.
  • the communication module in the large-screen device sends a request for applying for multiplexing the Wi-Fi P2P capability to the P2P link management module in the large-screen device.
  • the request for applying for multiplexing the Wi-Fi P2P capability includes: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the large-screen device.
  • the P2P link management module in the large-screen device receives the request, as a possible implementation, if the request carries: the indication information that there is a Wi-Fi P2P connection between the mobile phone B and the large-screen device, The P2P link management module in mobile phone B can determine that there is a Wi-Fi P2P connection between mobile phone B and the large-screen device, and the P2P link management module in mobile phone B can determine that the Wi-Fi P2P capability can be reused.
  • the connection information includes: Wi-Fi P2P connection status, roles, address information of these devices, P2P group information, etc. with their connected devices (including mobile phone B).
  • the P2P link management module in the large-screen device can obtain the connection information from the communication module, so as to determine, according to the connection information, that a Wi-Fi P2P link already exists between the large-screen device and mobile phone B, or determine the large-screen device If there is a Wi-Fi P2P link between the existing and mobile phone B, and the Wi-Fi P2P link supports other services, it can be determined that the large-screen device can reuse the Wi-Fi P2P capability.
  • the large-screen device may maintain a reference count, and the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of the large-screen device.
  • 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 (the screen cast of the mobile phone B to the large-screen device). business).
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of the large-screen device itself carries 2 services (the screen casting service of mobile phone B to the large-screen device).
  • the large-screen device will not remove the P2P group, and the mobile phone B can still send the large-screen device normally. Share files. Only when the reference count becomes 0, that is, the screen casting service and the file sharing service are disconnected, the large-screen device will remove the P2P group.
  • the P2P link management module in the large-screen device sends a response message that the Wi-Fi P2P capability is successfully reused to the communication module in the large-screen device.
  • the communication module in the large-screen device sends the Wi-Fi P2P connection request response information to the communication module in the mobile phone B through the first connection.
  • the P2P connection request response message is encrypted with an encryption key.
  • the Wi-Fi P2P connection request response information includes: indication information that allows mobile phone B to use the existing Wi-Fi P2P connection to transmit the service data of the first application, information of the P2P group formed by mobile phone B and the large-screen device, large information such as the IP address and port number of the screen device.
  • the multiplexing of Wi-Fi P2P capabilities is for one device. , only apply for Wi-Fi P2P capability multiplexing for a certain device, it can only ensure that this device will not actively disconnect the Wi-Fi P2P link during the service existence, and the peer device cannot guarantee that it will not actively disconnect the Wi-Fi P2P link. -Fi P2P link will eventually affect service transmission. Therefore, the communication module in mobile phone B will also send a request for multiplexing Wi-Fi P2P capability to the P2P link management module in mobile phone B.
  • the request for applying for multiplexing the Wi-Fi P2P capability includes: indication information that there is a Wi-Fi P2P connection between the mobile phone B and the large-screen device.
  • the P2P link management module in the mobile phone B receives the request, as a possible implementation, if the request for multiplexing the Wi-Fi P2P capability includes: there is Wi-Fi between the mobile phone B and the large-screen device.
  • the indication information of the P2P connection the P2P link management module in the mobile phone B can determine that the mobile phone B can reuse the Wi-Fi P2P capability.
  • the request for multiplexing the Wi-Fi P2P capability does not include the indication information that there is a Wi-Fi P2P connection between the mobile phone B and the large-screen device
  • the communication module in the mobile phone B has already Stores the existing connection information, which 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) (for GO) and the MAC address of the large-screen device.
  • the P2P link management module in the mobile phone B can obtain the connection information from the communication module, so according to the connection information, it can be determined that the mobile phone B can reuse the Wi-Fi P2P capability.
  • mobile phone B may maintain a reference count, where the reference count is used to indicate the number of services (or applications) that simultaneously utilize the Wi-Fi P2P capability of mobile phone B.
  • 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 (the screen casting service of mobile phone B to large-screen devices) .
  • the value of the reference count is incremented by 1 and becomes 2, indicating that the Wi-Fi P2P capability of mobile phone B itself carries 2 services (the screen casting service of mobile phone B to large-screen devices and the File sharing service from mobile phone B to large-screen devices).
  • the reference count becomes 1. Since the reference count is not 0, the mobile phone B will not disconnect the Wi-Fi P2P link with the large-screen device. Mobile phone B can also share files to the large-screen device normally. Only when the reference count becomes 0, that is, when both the screen casting service and the file sharing service are disconnected, mobile phone B will not disconnect the Wi-Fi P2P connection with the large-screen device.
  • the P2P link management module in the mobile phone B sends a response message indicating that the multiplexing of the P2P capability is successful to the communication module in the mobile phone B.
  • the communication module in the mobile phone B receives the response information that the multiplexing of the P2P capability is successful, and sends the Wi-Fi P2P connection request response information to the first application on the mobile phone B, which is used to notify the first application on the mobile phone B that the The existing Wi-Fi P2P connection transmits the service data of the first application.
  • the Wi-Fi P2P connection request response information includes the IP address and port number of the large-screen device, and the port number generated by the mobile phone B itself.
  • the first application on the mobile phone B uses the IP address of the mobile phone B and the port number generated by the mobile phone B, combined with the IP address and port number of the large-screen device, and uses the IP address and port number of the large-screen device.
  • the first application (file sharing application) on the screen device establishes a socket transmission channel.
  • the first application on the mobile phone B starts file sharing to the first application on the large-screen device based on the socket transmission channel.
  • 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.
  • the removal of the P2P group is performed only after the two services of the file sharing service and the screen projection service are completed.
  • the GO device and the P2P group are removed.
  • the reference counts maintained by the mobile phone B and the large-screen device are reduced to 1. Since the reference count is not 0, in this case, the GO device and P2P group will not be performed.
  • the removal of the group means that the Wi-Fi P2P connection between the large-screen device and mobile phone B will not be removed.
  • the method for Wi-Fi P2P connection is by multiplexing 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
  • the 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. After completion, the GO device will be removed and the Wi-Fi P2P connection will be disconnected, thus ensuring that different services can be completely transmitted, and realizing multiple connections between the first electronic device and the second electronic device.
  • Wi-Fi P2P services coexist at the same time, improving user experience. Different services will not affect each other, which improves the user experience.
  • functional modules can be divided into electronic devices (including the above-described first electronic device, second electronic device, third electronic device, and fourth electronic device) according to the foregoing method.
  • each function may be divided into various function modules, or two or more functions may be integrated into one processing module.
  • the above-mentioned 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, and there may be other division manners in actual implementation.
  • the electronic device provided by the embodiments of the present application is used to execute any method for data transmission under Wi-Fi direct connection provided by the above method embodiments, and thus can achieve the same effect as the above implementation method.
  • the electronic device may include a processing module, a memory module and a communication module.
  • the processing module may be used to control and manage the actions of the electronic device. For example, it may be used to support the electronic device to perform the steps performed by the processing unit.
  • the memory 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.
  • the processing module may be a processor or a controller. It may implement or execute the various exemplary logical blocks, modules and circuits described in connection with this disclosure.
  • the processor may 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, and the like.
  • the storage module may be a memory.
  • the communication module may specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, and a Wi-Fi chip.
  • FIG. 17 shows a schematic diagram of the hardware structure of an example of an electronic device 700 provided in this application.
  • the electronic device 700 may be the above-mentioned first terminal device, second terminal device or third terminal device.
  • 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 charge management module 740 , a power management module 741 , and a battery 742 , Antenna 1, Antenna 2, wireless communication module 750, etc.
  • USB universal serial bus
  • the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 700 .
  • the electronic device 700 may include more or less components than shown, or combine some components, or separate some components, or arrange different components.
  • the illustrated components may be implemented in hardware, software or a combination of software and hardware.
  • Processor 710 may include one or more processing units.
  • the processor 710 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video Codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc.
  • AP application processor
  • GPU graphics processing unit
  • ISP image signal processor
  • controller a video Codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural-network processing unit neural-network processing unit
  • NPU neural-network processing unit
  • different processing units may be independent components, or may be integrated in one or more processors.
  • electronic device 700 may also include one or more processors 710 .
  • the controller can generate an operation control signal according to the instruction operation code and the timing signal, and complete the control of fetching and executing instructions.
  • processor 710 may include one or more interfaces.
  • the interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver (universal asynchronous receiver) /transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, SIM card interface, and/or USB interface, etc.
  • the USB interface 730 is an interface that conforms to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, and the like.
  • 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.
  • the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 700 .
  • the electronic device 700 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the wireless communication function of the electronic device 700 can be implemented by the antenna 1, the antenna 2, the wireless communication module 750, and the like.
  • the wireless communication module 750 can provide Wi-Fi (including Wi-Fi perception and Wi-Fi AP), Bluetooth (bluetooth, BT), and wireless data transmission modules (eg, 433MHz, 868MHz, 715MHz) applied on the electronic device 700 . and other wireless communication solutions.
  • the wireless communication module 750 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 750 receives electromagnetic waves via the antenna 1 or the antenna 2 (or, the antenna 1 and the 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 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 1 or the antenna 2 .
  • 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 realize the data storage function. For example to save files like music, video etc in external memory card.
  • Internal memory 721 may be used to store one or more computer programs including instructions.
  • the processor 710 may execute the above-mentioned instructions stored in the internal memory 721, thereby causing the electronic device 700 to execute the Wi-Fi direct connection data transmission method, various applications and data processing provided in some embodiments of the present application.
  • the internal memory 721 may include a code storage area and a data storage area. Among them, the code storage area can store the operating system.
  • the data storage area may store data and the like created during the use of the electronic device 700 .
  • the internal memory 721 may include high-speed random access memory, and may also include non-volatile memory, such as one or more disk storage components, flash memory components, universal flash storage (UFS), and the like.
  • the processor 710 may execute the instructions stored in the internal memory 721 and/or the instructions stored in the memory provided in the processor 710 to cause the electronic device 700 to execute any of the functions provided in the embodiments of the present application.
  • the electronic device 700 includes, but is not limited to, smart TVs, large-screen devices, mobile phones, tablet computers, notebooks, large-screen TVs, smart home items, PDAs, POS, in-vehicle computers, and the like.
  • smart TVs large-screen devices
  • mobile phones tablet computers
  • notebooks large-screen TVs
  • smart home items PDAs
  • POS in-vehicle computers
  • the embodiments of the present application are not limited herein.
  • FIG. 18 shows a schematic block diagram of another example of a communication apparatus 800 provided by an embodiment of the present application.
  • the communication apparatus 800 may correspond to the first electronic device, the second electronic device, and the third electronic device described in each of the above-mentioned various embodiments.
  • the device or the fourth electronic device can also be a chip or component applied to the first electronic device, the second electronic device, the third electronic device or the fourth electronic device, and each module or unit in the communication device 800 uses
  • the communication apparatus 800 may include: processing unit 810 and communication unit 820.
  • the communication apparatus 800 may further include a storage unit 830 .
  • the communication unit 820 may include a receiving unit (module) and a sending unit (module), configured to perform the process of receiving information and sending information by the first terminal device, the second terminal device, or the third terminal device in each of the foregoing method embodiments. step.
  • the storage unit 830 is used to store the 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. .
  • the communication unit 820 may be a transceiver, an input/output interface or an interface circuit, etc., for example, may be implemented by the wireless communication module 750 in the embodiment shown in FIG. 17 .
  • the storage unit may be a memory, for example, may be implemented by the external memory interface 720 or the internal memory 721 in the embodiment shown in FIG. 17 .
  • the processing unit 810 may be implemented by the processor 710 in the embodiment shown in FIG. 17 , or may be implemented by the processor 710 and the internal memory 721 .
  • the communication apparatus 800 shown in FIG. 18 may be the above-mentioned first electronic device, second electronic device, third electronic device or fourth electronic device, or, the first electronic device, the second electronic device, the third electronic device
  • the electronic device or the fourth electronic device may include the communication apparatus 800 shown in FIG. 18 .
  • each unit in the above apparatus can be realized in the form of software calling through the processing element; also can all be realized in the form of hardware; some units can also be realized in the form of software calling through the processing element, and some units can be realized in the form of hardware.
  • each unit can be a separately established processing element, or can be integrated in a certain chip of the device to be implemented, and can also be stored in the memory in the form of a program, which can be called by a certain processing element of the device and execute the unit's processing. Function.
  • the processing element may also be called a processor, which may be an integrated circuit with signal processing capability.
  • each step of the above method or each of the above units may be implemented by an integrated logic circuit of hardware in the processor element or implemented in the form of software being invoked by the processing element.
  • a unit in any of the above apparatuses may be one or more integrated circuits configured to implement the above methods, eg, one or more application specific integrated circuits (ASICs), or, one or more A plurality of digital signal processors (DSPs), or, one or more field programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms.
  • ASICs application specific integrated circuits
  • DSPs digital signal processors
  • FPGAs field programmable gate arrays
  • the processing element can be a general-purpose processor, such as a central processing unit (central processing unit, CPU) or other processors that can invoke programs.
  • CPU central processing unit
  • these units can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • the embodiment of the present application further provides a system for data transmission under Wi-Fi direct connection, the system includes: the first electronic device and the second electronic device provided in the above method embodiment, optionally, the system may further include The third electronic device or the fourth electronic device provided in the above method embodiments.
  • Embodiments of the present application further provide a computer-readable storage medium for storing computer program codes, where the computer program includes a method for executing any of the methods for data transmission under Wi-Fi direct connection provided by the above embodiments of the present application. instruction.
  • the readable medium may be a read-only memory (read-only memory, ROM) or a random access memory (random access memory, RAM), which is not limited in this embodiment of the present application.
  • the present application also provides a computer program product, the computer program product including instructions, when executed, to cause the first electronic device, the second electronic device, the third electronic device or the fourth electronic device to execute the instructions corresponding to the above The corresponding operation in the method.
  • An embodiment of the present application further provides a chip located in a communication device, the chip includes: a processing unit and a communication unit, the processing unit may be, for example, a processor, and the communication unit may be, for example, an input/output interface, a pin or a circuit, etc.
  • the processing unit can execute computer instructions, so that the communication device executes any of the Wi-Fi direct connection data transmission methods provided by the above embodiments of the present application.
  • the computer instructions are stored in a storage unit.
  • the storage unit is a storage unit in the chip, such as a register, a cache, etc.
  • the storage unit can also be a storage unit in the terminal located outside the chip, such as ROM or other storage units that can store static information and instructions. Types of static storage devices, random RAM, etc.
  • the processor mentioned in any one of the above may be a CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the program execution of the above-mentioned transmission method of feedback information.
  • the processing unit and the storage unit can be decoupled, respectively disposed on different physical devices, and connected in a wired or wireless manner to implement the respective functions of the processing unit and the storage unit, so as to support the system chip to implement the above embodiments various functions in .
  • the processing unit and the memory may also be coupled on the same device.
  • the communication device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, for the beneficial effects that can be achieved, reference may be made to the above-provided method. The beneficial effects in the corresponding method will not be repeated here.
  • the memory in this embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory may be ROM, programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically erasable programmable read-only memory (electrically EPROM) , EEPROM) or flash memory.
  • Volatile memory can be RAM, which acts as an external cache.
  • RAM random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • double data rate Synchronous dynamic random access memory double data rate SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • synchronous link dynamic random access memory direct memory bus random access memory Access memory
  • direct rambus RAM direct rambus RAM
  • the methods in the embodiments of the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software When implemented in 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.
  • the computer may be a general purpose computer, special purpose computer, computer network, or other programmable device.
  • the computer program or instructions may be stored in or transmitted over a computer-readable storage medium.
  • the computer-readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server that integrates one or more available media.
  • the disclosed system, apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as independent products, may be stored in a computer-readable storage medium.
  • the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution, and the computer software product is stored in a readable storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned readable storage medium includes: U disk, removable hard disk, ROM, RAM, magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本申请提供了一种Wi-Fi直连下数据传输的方法和电子设备,该方法应用于包括第一电子设备和第二电子设备的***中,第一电子设备为Wi-Fi直连群组内的GC设备,第二电子设备为Wi-Fi直连群组内的GO设备;该方法包括:第一电子设备和第二电子设备通过第一Wi-Fi直连链路传输第一业务的数据;第一电子设备接收用户的第一操作,第一操作用于向该第二电子设备发送第二业务的数据,第二业务与该第一业务不同;第一电子设备通过第一Wi-Fi直连链路向第二电子设备发送第二业务的数据。本申请提供的方法,可复用GC设备之间和GO设备之间Wi-Fi P2P链路,使得该Wi-Fi P2P连接可以同时传输多种不同的业务,提高了用户体验。

Description

Wi-Fi直连下数据传输的方法和电子设备
本申请要求于2020年12月24日提交国家知识产权局、申请号为202011555743.7、申请名称为“Wi-Fi直连下数据传输的方法和电子设备”、以及2021年6月30日提交国家知识产权局、申请号为202110745464.5、申请名称为“Wi-Fi直连下数据传输的方法和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信领域,更为具体的,涉及一种Wi-Fi直连下数据传输的方法和电子设备。
背景技术
Wi-Fi直连(wireless fidelity peer-to-peer,Wi-Fi P2P)技术是无线保真技术(wireless-fidelity,
Figure PCTCN2021137212-appb-000001
)联盟推出的“Wi-Fi DIRECT”标准协议下的一项重要技术,Wi-Fi P2P可以支持两个Wi-Fi设备在没有Wi-Fi热点介入的情况下,直接与对方设备进行连接和通信。
一个完整的Wi-Fi P2P业务包括了Wi-Fi P2P设备发现、Wi-Fi P2P设备连接、Wi-Fi P2P设备业务数据传输这三个阶段。在Wi-Fi P2P设备连接建立后形成一个P2P群组,在P2P群组内,设备存在P2P群组管理者(group owner,GO)和P2P群组客户端(group client,GC)两种角色的区分。根据目前的协议规范以及设备硬件上的限制,目前的Wi-Fi P2P技术不支持同一个设备上的多种P2P角色。因此,造成同一个P2P群组内的GC设备之间、以及GC设备与群组外的设备之间无法建立Wi-Fi P2P设备。并且,目前Android以及WINDOWS***上的Wi-Fi P2P应用(或者也可以称为业务)都是独立管理Wi-Fi P2P链路。一个设备上的Wi-Fi P2P链路由各个应用独自管理和协商,由于资源限制Wi-Fi P2P底层链路只会产生一个,一个业务将Wi-Fi P2P资源占用,当该设备上的另外一个Wi-Fi P2P相关业务也需要使用该Wi-Fi P2P链路时,不能保证另外一个Wi-Fi P2P相关业务可以传输完成。例如,对于两个设备之间存在为用户的第一业务建立的Wi-Fi P2P链路,如果这两个设备之间用户的第二应用也需要利用该Wi-Fi P2P链路,无论第二业务利用该Wi-Fi P2P链路是否传输完成,在第一业务传输完成后,就会拆除该Wi-Fi P2P链路,因此,不能保证第二业务可以传输完成。这就会导致多Wi-Fi P2P业务冲突问题,严重影响了用户体验。
发明内容
本申请提供了一种Wi-Fi直连下数据传输的方法和电子设备,可以使得在P2P群组内的GC设备之间,或者P2P群组内的GC与P2P群组外的空闲设备之间可以基于P2P群组内内的Wi-Fi P2P连接建立传输通道并进行业务数据的传输,使得能够加入Wi-Fi P2P群组内的设备之间都可以发起连接和通信。并且,通过对电子设备上使用 Wi-Fi P2P能力的业务的个数进行统计,在使用Wi-Fi P2P能力的业务的个数为0时才拆除Wi-Fi P2P链路以及Wi-Fi P2P群组,解决了多个Wi-Fi P2P业务之间的冲突问题,提高了用户体验。
第一方面,提供了一种Wi-Fi直连下数据传输的方法,该方法应用于包括第一电子设备和第二电子设备的***中,该第一电子设备为Wi-Fi直连群组内的GC设备,该第二电子设备为该Wi-Fi直连群组内的GO设备;该方法包括:该第一电子设备和该第二电子设备通过第一Wi-Fi直连链路传输第一业务的数据;该第一电子设备接收用户的第一操作,该第一操作用于向该第二电子设备发送第二业务的数据,该第二业务与该第一业务不同;第一电子设备通过该第一Wi-Fi直连链路向该第二电子设备发送该第二业务的数据。
第一方面提供的Wi-Fi直连下数据传输的方法,通过对第二电子设备(GO设备)和第一电子设备(GC设备)的Wi-Fi P2P连接进行复用,使得该Wi-Fi P2P连接可以同时传输多种不同的业务,实现了第一电子设备和第二电子设备之间的多个Wi-Fi P2P业务同时共存,提高了用户体验。不同的业务之间不会相互影响,提高了用户体验。
示例性的,第一电子设备为手机B、第二电子设备为大屏设备,第一业务可以为第一电子设备向第二电子设备的投屏业务。第二业务可以为第一电子设备向第二电子设备的文件分享业务。
根据第一方面,在第一方面一种可能的实现方式中,在该第一电子设备接收用户的第一操作之后,该方法还包括:该第一电子设备通过第一连接,向该第二电子设备发送Wi-Fi直连请求,该Wi-Fi直连请求包括:该第一电子设备的信息,该Wi-Fi直连请求用于请求利用该第一Wi-Fi直连链路向该第二电子设备发送该第二业务的数据;该第二电子设备根据该Wi-Fi直连请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向第一电子设备发送Wi-Fi直连请求响应信息,该Wi-Fi直连请求响应信息包括:该Wi-Fi直连群组的群组信息以及该第二电子设备的IP地址;该第一电子设备根据该Wi-Fi直连请求响应信息,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,通过对第二电子设备(GO设备)和第一电子设备(GC设备)的Wi-Fi P2P能力进行复用,这样第一电子设备和第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在该多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成,实现了第一电子设备和第二电子设备之间的多个Wi-Fi P2P业务同时共存,提高了用户体验。不同的业务之间不会相互影响,提高了用户体验。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第一电子设备向该第二电子设备发送Wi-Fi直连请求之前,该方法还包括:该第一电子设备和该第二电子设备建立该第一连接,该第一连接包括:BLE连接、蓝牙连接、Wi-Fi连接中的任意一种。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二电子设备将该 第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该Wi-Fi直连请求,确定该第二电子设备和该第一电子设备之间已经存在该第一Wi-Fi直连链路。在该实现方式中,可以保证第二业务数据利用该第一Wi-Fi直连链路正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第一电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第一电子设备确定该第二电子设备和该第一电子设备之间已经存在该第一Wi-Fi直连链路。在该实现方式中,可以保证第二业务数据利用该第一Wi-Fi直连链路正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二业务的数据传输完成后或者该第一业务的数据传输完成后,该方法还包括:该第一电子设备将该第一电子设备维护的引用计数减一;该第二电子设备将该第二电子设备维护的引用计数减一。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二电子设备维护的引用计数为0时,该第三电子设备拆除该Wi-Fi直连群组;或者,在该第一电子设备维护的引用计数为0时,该第一电子设备断开与该第二电子设备之间的Wi-Fi直连链路。在该实现方式中,通过对第二电子设备(GO设备)和第一电子设备(GC设备)的Wi-Fi P2P能力进行复用,这样第一电子设备和第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在该多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第一方面,或者以上第一方面的任意一种实现方式,该第一电子设备的信息包括:该第一电子设备的标识、该第一电子设备当前的Wi-Fi直连连接状态、该第一电子设备的Wi-Fi直连端口的MAC地址、该第一电子设备支持的信道列表、该第一电子设备连接的Wi-Fi热点的频率、该第一电子设备是否支持宽频中的至少一种。
根据第一方面,或者以上第一方面的任意一种实现方式,该***还包括第三电子设备,该第三电子设备为该Wi-Fi直连群组外的空闲设备,在该第二业务的数据传输完成之后,该方法还包括:该第三电子设备接收用户的第二操作,该第二操作用于向该第一电子设备发送第三业务的数据;该第三电子设备与该第二电子设备建立第二Wi-Fi直连链路;该第三电子设备通过该第二Wi-Fi直连链路向该第二电子设备发送该第三业务的数据;响应于接收该第三业务的数据,该第二电子设备通过该第一Wi-Fi直连链路向该第一电子设备发送该第三业务的数据。在该实现方式中,在P2P群组外的第三电子设备(即空闲设备)向P2P群组内的第一电子设备(即GC设备)传输业务数据时,可以建立起P2P群组内的第一电子设备(即GC设备)和P2P群组外的第三电子设备(即空闲设备)之间的传输通道,从而实现通过第二Wi-Fi直连链路和第一Wi-Fi直连链路向第一电子设备传输业务数据,从而实现二者之间基于传输通道的数据传输。
示例性的,第一电子设备(即GC设备)和P2P群组外的第三电子设备(即空闲设备)之间的传输通道为socket传输通道。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三电子设备与该第二电子设备建立该第二Wi-Fi直连链路之前,该方法还包括:该第一电子设备向该 第二电子设备发送第三连接请求,该第三连接请求用于请求将该第三电子设备加入到该Wi-Fi直连群组中,该第三连接请求包括该第三电子设备的信息;该第二电子设备根据该第三连接请求,将该第二电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第三电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第三连接请求的第三响应信息,该第三响应信息用于指示将该第三电子设备加入到该Wi-Fi直连群组,该第三响应信息包括:该第二电子设备为该第三电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第三电子设备的MAC地址中;该第一电子设备根据该第三响应信息,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第一电子设备向该第二电子设备发送该第三连接请求之前,该方法还包括:该第三电子设备和该第一电子设备建立第二连接,该第二连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第一方面,或者以上第一方面的任意一种实现方式,该方法还包括:该第三电子设备通过该第二连接向该第一电子设备发送第四连接请求,该第四连接请求包括该第三电子设备的信息;该第一电子设备通过该第二连接,向该第三电子设备发送第四连接请求响应信息,该第四连接请求响应信息包括:该第二电子设备为该第三电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址、该第一电子设备的IP地址以及端口号;响应于接收该第四连接请求响应信息,该第三电子设备根据该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址,与该第二电子设备建立该第二Wi-Fi直连链路。在该实现方式中,第三电子设备可以根据该P2P群组信息以及第二电子设备的MAC地址,加入到P2P群组,从而便于和第一电子设备建立socket传输通道。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第三连接请求,确定该第三电子设备为可信设备、以及确定该第二电子设备和该第一电子设备之间存在Wi-Fi直连链路;在该第一电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第一电子设备根据该第三响应信息,确定该第一电子设备和该第二电子设备之间存在Wi-Fi直连链路。在该实现方式中,可以保证第三业务数据的正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三业务的数据传输完成后,该方法还包括:该第一电子设备将该第一电子设备维护的引用计数减一;该第二电子设备将该第二电子设备维护的引用计数减一。
根据第一方面,或者以上第一方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组;或者,在该第一电子设备维护的引用计数为0时,该第一电子设备断开与该第二电子设备之间的Wi-Fi直连链路。在该实现方式中,对P2P群组内的第一电子设备和第二电子设备(即GO设备)设备的Wi-Fi P2P能力进行复用,第一电子设备和第二电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进 行P2P群组的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的GC设备和P2P群组外的空闲设备无法传输数据的问题,提高了用户体验。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三电子设备通过该第二Wi-Fi直连链路向该第二电子设备发送该第三业务的数据之前,该方法还包括:该第三电子设备通过第二连接,向该第一电子设备发送第五连接请求,该第五连接请求包括:该第三电子设备的信息以及该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第一电子设备根据该第五连接请求,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第一电子设备向第二电子设备发送第六连接请求,该第六连接请求包括:该第三电子设备的信息以及该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第二电子设备根据该第六连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第六连接请求的第六响应信息,该第六响应信息包括:该Wi-Fi直连群组的群组信息、该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;该第一电子设备通过该第二连接,向该第三电子设备发送响应于该第五连接的第五响应信息,该第五响应信息:该第一电子设备的IP地址和端口号、该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第三电子设备根据该第五响应信息,将该第三电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第三电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三电子设备通过该第二Wi-Fi直连链路向该第二电子设备发送该第三业务的数据之前,该方法还包括:该第三电子设备向该第二电子设备发送第七连接请求,该第七连接请求包括该第一电子设备的信息;该第二电子设备根据该第七连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第三电子设备发送响应于该第七连接请求的第七响应信息,该第七响应信息包括:该Wi-Fi直连群组的群组信息、该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;该第三电子设备根据该第七响应信息,将该第三电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第三电子设备Wi-Fi P2P 能力的业务个数;该第三电子设备通过第二连接向该第一电子设备发送第八连接请求,该第八连接请求包括:该Wi-Fi直连群组的群组信息、该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第一电子设备根据该第八连接请求,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第一电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第六连接请求,确定该第三电子设备为可信设备、以及确定该第三电子设备和该第一电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接;或者,该第二电子设备根据该第七连接请求,确定该第一电子设备为可信设备、以及确定该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接。在该实现方式中,可以保证第三业务数据的正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三电子设备将该第三电子设备维护的引用计数加一之前,该方法还包括:该第三电子设备根据该第五响应信息,确定该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同;或者,该第三电子设备根据该第七响应信息,确定该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同。在该实现方式中,可以保证第三业务数据的正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,该方法还包括:在该第一电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第一电子设备根据该第六响应信息或者该第八连接请求,确定该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第三业务的数据传输完成后,该方法还包括:该第一电子设备将该第一电子设备维护的引用计数减一;该第二电子设备将该第二电子设备维护的引用计数减一;该第三电子设备将该第三电子设备维护的引用计数减一。
根据第一方面,或者以上第一方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组;或者,在该第一电子设备维护的引用计数为0时,该第一电子设备断开与该第二电子设备之间的该第一Wi-Fi直连链路;或者,在该第三电子设备维护的引用计数为0时,该第三电子设备断开与该第二电子设备之间的该第二Wi-Fi直连链路。在该实现方式中, 对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。
根据第一方面,或者以上第一方面的任意一种实现方式,该第三电子设备的信息包括:该第三电子设备的标识、该第三电子设备当前的Wi-Fi直连连接状态、该第三电子设备的Wi-Fi直连端口的MAC地址、该第三电子设备支持的信道列表、该第三电子设备连接的Wi-Fi热点的频率、该第三电子设备是否支持宽频中的至少一种。
根据第一方面,或者以上第一方面的任意一种实现方式,该***还包括第四电子设备,该第四电子设备为该Wi-Fi直连群组外的空闲设备,该方法还包括:该第四电子设备接收用户的第三操作,该第三操作用于向该第二电子设备发送第四业务的数据;该第四电子设备与该第二电子设备建立第三Wi-Fi直连链路;该第四电子设备通过该第三Wi-Fi直连链路,向该第二电子设备发送该第四业务的数据。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第四电子设备与该第二电子设备建立第三Wi-Fi直连链路之前,该方法还包括:该第四电子设备通过第三连接,向该第二电子设备第九连接请求,该第九连接请求用于请求将该第四电子设备加入到该Wi-Fi直连群组中,该第九连接请求包括该第四电子设备的信息;该第二电子设备根据该第九连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备通过该第三连接,向该第四电子设备发送响应于该第九连接请求的第九响应信息,该第九响应信息用于指示将该第四电子设备加入到该Wi-Fi直连群组,该第九响应信息包括:该第二电子设备为该第四电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址;该第四电子设备根据该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址,与该第二电子设备建立该第三Wi-Fi直连链路。在该实现方式中,第四电子设备可以根据该P2P群组信息以及第二电子设备的MAC地址,加入到P2P群组,与第二电子设备建立Wi-Fi P2P连接。并且,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第四电子设备通过第三连接,向该第二电子设备第九连接请求之前,该方法还包括:该第四电子设备和该第二电子设备建立该第三连接,该第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第九连接请求,确定该第四电子设备为可信设备、以及确定该第二电子设备和该第四电子设备之间不存在Wi-Fi直连链路。在该实现方式中,可以保证第四电子设备顺利的和第二电子设备建立Wi-Fi P2P连接,可以保证第四业务数据的正常传输。
根据第一方面,或者以上第一方面的任意一种实现方式,在该第四业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第一方面,或者以上第一方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组。在该实现方式中,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第一方面,或者以上第一方面的任意一种实现方式,其特征在于,该第四电子设备的信息包括:该第四电子设备的标识、该第四电子设备当前的Wi-Fi直连连接状态、该第四电子设备的Wi-Fi直连端口的MAC地址、该第四电子设备支持的信道列表、该第四电子设备连接的Wi-Fi热点的频率、该第四电子设备是否支持宽频中的至少一种。
第二方面,提供了一种Wi-Fi直连下数据传输的方法,该方法包括:第二电子设备和第二电子设备通过第一Wi-Fi直连链路传输第一业务的数据;该第二电子设备通过该第一Wi-Fi直连链路接收该第一电子设备发送的第二业务的数据,该第一电子设备为Wi-Fi直连群组内的GC设备,该第二电子设备为该Wi-Fi直连群组内的GO设备,该第二业务与该第一业务不同。
第二方面提供的Wi-Fi直连下数据传输的方法,通过对第二电子设备(GO设备)和第一电子设备(GC设备)的Wi-Fi P2P连接进行复用,使得该Wi-Fi P2P连接可以同时传输多种不同的业务,实现了第一电子设备和第二电子设备之间的多个Wi-Fi P2P业务同时共存,提高了用户体验。不同的业务之间不会相互影响,提高了用户体验。
根据第二方面,在第二方面一种可能的实现方式中,在该第二电子设备通过该第一Wi-Fi直连链路接收该第一电子设备发送的第二业务的数据之前,该方法包括:该第二电子设备通过第一连接,接收该第一电子设备发送的送Wi-Fi直连请求,该Wi-Fi直连请求包括:该第一电子设备的信息,该Wi-Fi直连请求用于请求利用该第一Wi-Fi直连链路向该第二电子设备发送第二业务的数据;该第二电子设备根据该Wi-Fi直连请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向第一电子设备发送Wi-Fi直连请求响应信息,该Wi-Fi直连请求响应信息包括:该Wi-Fi直连群组的群组信息以及该第二电子设备的IP地址。在该实现方式中,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在该多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成,实现了第一电子设备和第二电子设备之间的多个Wi-Fi P2P业务同时共存,提高了用户体验。不同的业务之间不会相互影响,提高了用户体验。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备接收该第一电子设备发送的送Wi-Fi直连请求之前,该方法还包括:该第二电子设备和该 第一电子设备建立该第一连接,该第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该Wi-Fi直连请求,确定该第二电子设备和该第一电子设备之间已经存在该第一Wi-Fi直连链路。在该实现方式中,可以保证第二业务数据利用该第一Wi-Fi直连链路正常传输。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二业务的数据传输完成后或者该第一业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第二方面,或者以上第二方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第三电子设备拆除该Wi-Fi直连群组。在该实现方式中,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,这样第一电子设备和第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在该多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第二方面,或者以上第二方面的任意一种实现方式,该第一电子设备的信息包括:该第一电子设备的标识、该第一电子设备当前的Wi-Fi直连连接状态、该第一电子设备的Wi-Fi直连端口的MAC地址、该第一电子设备支持的信道列表、该第一电子设备连接的Wi-Fi热点的频率、该第一电子设备是否支持宽频中的至少一种。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二业务的数据传输完成之后,该方法还包括:该第二电子设备与第三电子设备与建立第二Wi-Fi直连链路,该第三电子设备为该Wi-Fi直连群组外的空闲设备;该第二电子通过该第二Wi-Fi直连链路,接收该第三电子设备发送的第三业务的数据;该第二电子设备通过该第一Wi-Fi直连链路,向该第一电子设备发送该第三业务的数据。在该实现方式中,在P2P群组外的第三电子设备(即空闲设备)向P2P群组内的第一电子设备(即GC设备)传输业务数据时,第二电子可以协助建立起P2P群组内的第一电子设备(即GC设备)和P2P群组外的第三电子设备(即空闲设备)之间的传输通道,从而实现通过第二Wi-Fi直连链路和第一Wi-Fi直连链路向第一电子设备传输业务数据,实现二者之间基于传输通道的数据传输。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备与第三电子设备与建立第二Wi-Fi直连链路之前,该方法还包括:该第二电子设备接收该第一电子设备发送第三连接请求,该第三连接请求用于请求将该第三电子设备加入到该Wi-Fi直连群组中,该第三连接请求包括该第三电子设备的信息;该第二电子设备根据该第三连接请求,将该第二电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第三电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第三连接请求的第三响应信息,该第三响应信息用于指示将该第三电子设备加入到该Wi-Fi直连群组,该第三响应信息包括:该第二电子设备为该第三电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第三 电子设备的MAC地址中。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备将该第三电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第三连接请求,确定该第三电子设备为可信设备、以及确定该第二电子设备和该第一电子设备之间存在Wi-Fi直连链路。在该实现方式中,可以保证第三业务数据的正常传输。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第三业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第二方面,或者以上第二方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组。在该实现方式中,对P2P群组内的第二电子设备(即GO设备)设备的Wi-Fi P2P能力进行复用,第二电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的GC设备和P2P群组外的空闲设备无法传输数据的问题,提高了用户体验。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子通过该第二Wi-Fi直连链路,接收该第三电子设备发送的第三业务的数据之前,该方法还包括:该第一电子设备向第二电子设备发送第六连接请求,该第六连接请求包括:该第三电子设备的信息以及该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第二电子设备根据该第六连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第六连接请求的第六响应信息,该第六响应信息包括:该Wi-Fi直连群组的群组信息、该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个。在该实现方式中,对第二电子设备的Wi-Fi P2P能力进行复用,第二电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转,进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子通过该第二Wi-Fi直连链路,接收该第三电子设备发送的第三业务的数据之前,该方法还包括:该第二电子设备接收该第三电子设备发送的第七连接请求,该第七连接请求包括该第一电子设备的信息;该第二电子设备根据该第七连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第三电子设备发送响应于该第七连接请求的第七响应信息,该第七响应信息包括:该Wi-Fi直连群组的群组信息、该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信 息中的至少一个。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第六连接请求,确定该第三电子设备为可信设备、以及确定该第三电子设备和该第一电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接;或者,该第二电子设备根据该第七连接请求,确定该第一电子设备为可信设备、以及确定该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第三业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组。在该实现方式中,保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。
根据第二方面,或者以上第二方面的任意一种实现方式,该第三电子设备的信息包括:该第三电子设备的标识、该第三电子设备当前的Wi-Fi直连连接状态、该第三电子设备的Wi-Fi直连端口的MAC地址、该第三电子设备支持的信道列表、该第三电子设备连接的Wi-Fi热点的频率、该第三电子设备是否支持宽频中的至少一种。
根据第二方面,或者以上第二方面的任意一种实现方式,该方法还包括:该第二电子设备与该第四电子设备建立第三Wi-Fi直连链路,该第四电子设备为该Wi-Fi直连群组外的空闲设备;该第二电子设备通过该第三Wi-Fi直连链路,接收该第四电子设备发送的第四业务的数据。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备与该第四电子设备建立第三Wi-Fi直连链路之前,该方法还包括:该第二电子设备通过第三连接,接收该第四电子设备发送的第九连接请求,该第九连接请求用于请求将该第四电子设备加入到该Wi-Fi直连群组中,该第九连接请求包括该第四电子设备的信息;该第二电子设备根据该第九连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备通过该第三连接,向该第四电子设备发送响应于该第九连接请求的第九响应信息,该第九响应信息用于指示将该第四电子设备加入到该Wi-Fi直连群组,该第九响应信息包括:该第二电子设备为该第四电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址。在该实现方式中,第四电子设备可以根据该P2P群组信息以及第二电子设备的MAC地址,加入到P2P群组,与第二电子设备建立Wi-Fi P2P连接。并且,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备通过第三连接,接收该第四电子设备发送的第九连接请求之前,该方法还包括:该第二电子设备和该第四电子设备建立该第三连接,该第三连接包括:蓝牙连接、Wi-Fi连接 中的任意一种。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第九连接请求,确定该第四电子设备为可信设备、以及确定该第二电子设备和该第四电子设备之间不存在Wi-Fi直连链路。
根据第二方面,或者以上第二方面的任意一种实现方式,在该第四业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第二方面,或者以上第二方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组。在该实现方式中,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第二方面,或者以上第二方面的任意一种实现方式,该第四电子设备的信息包括:该第四电子设备的标识、该第四电子设备当前的Wi-Fi直连连接状态、该第四电子设备的Wi-Fi直连端口的MAC地址、该第四电子设备支持的信道列表、该第四电子设备连接的Wi-Fi热点的频率、该第四电子设备是否支持宽频中的至少一种。
第三方面,提供了一种提供了一种Wi-Fi直连下数据传输的方法,该方法应用于包括第一电子设备、第二电子设备和第三电子设备的***中,该第一电子设备为Wi-Fi直连群组内的第一GC设备,该第三电子设备为该Wi-Fi直连群组内的第二GC设备,该第二电子设备为该Wi-Fi直连群组内的GO设备,该方法包括:该第三电子设备接收用户的第二操作,该第二操作用于向该第一电子设备发送第一业务的数据;该第三电子设备通过第二Wi-Fi直连链路向该第二电子设备发送该第一业务的数据;响应于接收该第一业务的数据,该第二电子设备通过第一Wi-Fi直连链路向该第一电子设备发送该第一业务的数据,该第一Wi-Fi直连链路为该第二电子设备和该第一电子设备之间的Wi-Fi直连链路。该第二Wi-Fi直连链路为该第二电子设备和该第三电子设备之间的Wi-Fi直连链路。
第三方面提供的方法,在该实现方式中,在P2P群组内的第三电子设备(GC设备)向P2P群组内的第一电子设备(另一个GC设备)传输业务数据时,可以建立起P2P群组内的第一电子设备和第三电子设备)之间的传输通道,在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
根据第三方面,在第三方面一种可能的实现方式中,在该第三电子设备通过该第二Wi-Fi直连链路向该第二电子设备发送该第三业务的数据之前,该方法还包括:该第三电子设备通过第一连接,向该第一电子设备发送第一Wi-Fi直连请求,该第一Wi-Fi直连请求包括:该第三电子设备的信息以及该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第一电子设备根据该第一Wi-Fi直连请求,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第 一电子设备Wi-Fi P2P能力的业务个数;该第一电子设备向第二电子设备发送第一连接请求,该第一连接请求包括:该第三电子设备的信息以及该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第二电子设备根据该第一连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第一连接请求的第一响应信息,该第一响应信息包括:该Wi-Fi直连群组的群组信息、该第三电子设备和该第一电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;该第一电子设备通过该第一连接,向该第三电子设备发送响应于该第一Wi-Fi直连请求的第一Wi-Fi直连响应信息,该第一Wi-Fi直连响应信息:该第一电子设备的IP地址、该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第三电子设备根据该第一Wi-Fi直连响应信息,将该第三电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第一电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
根据第三方面,或者以上第三方面的任意一种实现方式,该方法还包括:该第三电子设备向该第二电子设备发送第二连接请求,该第二连接请求包括该第一电子设备的信息;该第二电子设备根据该第二连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第三电子设备发送响应于该第二连接请求的第二响应信息,该第二响应信息包括:该Wi-Fi直连群组的群组信息、该第三电子设备和该第一电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;该第三电子设备根据该第二响应信息,将该第三电子设备维护的引用计数加一,该第三电子设备维护的引用计数用于表示同时利用该第三电子设备Wi-Fi P2P能力的业务个数;该第三电子设备通过第一连接向该第一电子设备发送第二Wi-Fi直连请求,该第二Wi-Fi直连请求包括:该Wi-Fi直连群组的群组信息、该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识;该第一电子设备根据该第二Wi-Fi直连请求,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第一电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了 用户体验。
根据第三方面,或者以上第三方面的任意一种实现方式,该方法还包括:在该第一电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第一电子设备根据该第一Wi-Fi直连请求或者该第二响应信息,确定该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同。
根据第三方面,或者以上第三方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第一连接请求,确定该第三电子设备为可信设备、以及确定该第三电子设备和该第一电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接;或者,该第二电子设备根据该第二连接请求,确定该第一电子设备为可信设备、以及确定该第一电子设备和该第三电子设备分别与该第二电子设备之间存在Wi-Fi P2P连接。
根据第三方面,或者以上第三方面的任意一种实现方式,在该第三电子设备将该第三电子设备维护的引用计数加一之前,该方法还包括:该第三电子设备根据该第一Wi-Fi直连响应信息,确定该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同;或者,该第三电子设备根据该第二响应信息,确定该第三电子设备在该Wi-Fi直连群组内连接的GO设备的标识和该第一电子设备在该Wi-Fi直连群组内连接的GO设备的标识相同。
根据第三方面,或者以上第三方面的任意一种实现方式,该方法还包括:该第三电子设备和该第一电子设备建立第一连接,该第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第三方面,或者以上第三方面的任意一种实现方式,在该第一业务的数据传输完成后,该方法还包括:该第三电子设备将该第三电子设备维护的引用计数减一;该第一电子设备将该第一电子设备维护的引用计数减一;该第二电子设备将该第二电子设备维护的引用计数减一。
根据第三方面,或者以上第三方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组;或者,在该第一电子设备维护的引用计数为0时,该第一电子设备断开与该第二电子设备之间的该第二Wi-Fi直连链路;或者,在该第三电子设备维护的引用计数为0时,该第三电子设备断开与该第二电子设备之间的该第一Wi-Fi直连链路。在该实现方式中,对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。
根据第三方面,或者以上第三方面的任意一种实现方式,该第三电子设备的信息包括:该第三电子设备的标识、该第三电子设备当前的Wi-Fi直连连接状态、该第三电子设备的Wi-Fi直连端口的MAC地址、该第三电子设备支持的信道列表、该第三电子设备连接的Wi-Fi热点的频率、该第三电子设备是否支持宽频中的至少一种;或者,
该第一电子设备的信息包括:该第一电子设备的标识、该第一电子设备当前的Wi-Fi直连连接状态、该第一电子设备的Wi-Fi直连端口的MAC地址、该第一电子设备支持的信道列表、该第一电子设备连接的Wi-Fi热点的频率、该第一电子设备是否支持宽频中的至少一种。
第四方面,提供了一种Wi-Fi直连下数据传输的方法,该方法应用于包括第一电子设备、第二电子设备和第三电子设备的***,该第三电子设备为Wi-Fi直连群组外的空闲设备,该第一电子设备为该Wi-Fi直连群组内的GC设备,该第二电子设备为该Wi-Fi直连群组内的GO设备,该方法包括:该第三电子设备接收用户的第一操作,该第一操作用于向该第一电子设备发送第一业务的数据;响应于该第一操作,该第三电子设备与该第二电子设备建立第一Wi-Fi直连链路;该第三电子设备通过第二Wi-Fi直连链路向该第二电子设备发送该第一业务的数据;响应于接收该第一业务的数据,该第二电子设备通过第一Wi-Fi直连链路向该第一电子设备发送该第一业务的数据,该第一Wi-Fi直连链路为该第二电子设备和该第一电子设备之间的Wi-Fi直连链路。该第二Wi-Fi直连链路为该第二电子设备和该第三电子设备之间的Wi-Fi直连链路。
第四方面提供的方法,在该实现方式中,在P2P群组外的第三电子设备(即空闲设备)向P2P群组内的第一电子设备(即GC设备)传输业务数据时,第二电子可以协助建立起P2P群组内的第一电子设备(即GC设备)和P2P群组外的第三电子设备(即空闲设备)之间的传输通道,从而实现通过第二Wi-Fi直连链路和第一Wi-Fi直连链路向第一电子设备传输业务数据,实现二者之间基于传输通道的数据传输。
根据第四方面,在第三方面一种可能的实现方式中,在该第三电子设备与该第二电子设备建立第一Wi-Fi直连链路之前,该方法还包括:该第一电子设备向该第二电子设备发送第一连接请求,该第一连接请求用于请求将该第三电子设备加入到该Wi-Fi直连群组中,该第一连接请求包括该第三电子设备的信息;该第二电子设备根据该第一连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备向该第一电子设备发送响应于该第一连接请求的第一响应信息,该第一响应信息用于指示将该第三电子设备加入到该Wi-Fi直连群组,该第一响应信息包括:该第二电子设备为该第三电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址中;该第一电子设备根据该第一响应信息,将该第一电子设备维护的引用计数加一,该第一电子设备维护的引用计数用于表示同时利用该第一电子设备Wi-Fi P2P能力的业务个数。在该实现方式中,对P2P群组内的第一电子设备和第二电子设备(即GO设备)设备的Wi-Fi P2P能力进行复用,第一电子设备和第二电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的GC设备和P2P群组外的空闲设备无法传输数据的问题,提高了用户体验。
根据第四方面,或者以上第四方面的任意一种实现方式,在该第三电子设备与该第二电子设备建立第一Wi-Fi直连链路之前,该方法还包括:该第三电子设备和该第 一电子设备建立第一连接,该第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第四方面,或者以上第四方面的任意一种实现方式,该方法还包括:该第一电子设备通过该第一连接,向该第三电子设备发送第二连接请求,该第二连接请求包括:该第二电子设备为该第三电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址、该第一电子设备的IP地址以及端口号;该第三电子设备根据该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址,与该第二电子设备建立该第一Wi-Fi直连链路。
根据第四方面,或者以上第四方面的任意一种实现方式,该方法还包括:在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第一连接请求,确定该第三电子设备为可信设备、以及确定该第二电子设备和该第一电子设备之间存在Wi-Fi直连链路。
根据第四方面,或者以上第四方面的任意一种实现方式,在该第一电子设备将该第一电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第一响应信息,确定该第二电子设备和该第一电子设备之间存在Wi-Fi直连链路。
根据第四方面,或者以上第四方面的任意一种实现方式,在该第一业务的数据传输完成后,该方法还包括:该第一电子设备将该第一电子设备维护的引用计数减一;该第二电子设备将该第二电子设备维护的引用计数减一。
根据第四方面,或者以上第四方面的任意一种实现方式,该方法还包括:在该第二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组;或者,在该第一电子设备维护的引用计数为0时,该第一电子设备断开与该第二电子设备之间的Wi-Fi直连链路。
根据第四方面,或者以上第四方面的任意一种实现方式,该第三电子设备的信息包括:该第三电子设备的标识、该第三电子设备当前的Wi-Fi直连连接状态、该第三电子设备的Wi-Fi直连端口的MAC地址、该第三电子设备支持的信道列表、该第三电子设备连接的Wi-Fi热点的频率、该第三电子设备是否支持宽频中的至少一种。
第五方面,提供了一种Wi-Fi直连下数据传输的方法,该方法应用于包括第一电子设备、第二电子设备和第四电子设备的***,该第四电子设备为Wi-Fi直连群组外的空闲设备,该第一电子设备为该Wi-Fi直连群组内的GC设备,该第二电子设备为该Wi-Fi直连群组内的GO设备,该方法包括:该第四电子设备接收用户的第一操作,该第一操作用于向该第二电子设备发送第一业务的数据;响应于该第一操作,该第四电子设备与该第二电子设备建立第一Wi-Fi直连链路;该第四电子设备通过该第一Wi-Fi直连链路,向该第二电子设备发送第一业务的数据。
第五方面提供的Wi-Fi直连下数据传输的方法,通过对第二电子设备(GO设备)的P2P链路进行管理,在第二电子设备与P2P群组内的第一电子设备(GC设备)之间已经存在基于Wi-Fi P2P业务(或者应用)的情况下,P2P群组外的第四电子设备(空闲设备)发起到第二电子设备(GO设备)的Wi-Fi P2P连接以进行另外的业务数据传输时,第四电子设备可以加入到该P2P群组内,实现了第四电子设备(空闲设备)向第二电子设备(GO设备)的业务数据的传输。
根据第五方面,在第五方面一种可能的实现方式中,该方法还包括:该第四电子 设备通过第一连接,向该第二电子设备第一连接请求,该第一连接请求用于请求将该第四电子设备加入到该Wi-Fi直连群组中,该第一连接请求包括该第四电子设备的信息;该第二电子设备根据该第一连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备通过该第一连接,向该第四电子设备发送响应于该第一连接请求的第一响应信息,该第一响应信息用于指示将该第四电子设备加入到该Wi-Fi直连群组,该第一响应信息包括:该第二电子设备为该第四电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址;该第四电子设备根据该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址,与该第二电子设备建立该第一Wi-Fi直连链路。在该实现方式中,第二电子设备会对第二电子设备的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,在该多个业务都传输完成后,才会进行P2P群组以及GO设备的移除,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响,提高了用户体验。
根据第五方面,或者以上第五方面的任意一种实现方式,该第四电子设备通过第一连接,向该第二电子设备第一连接请求,该第一连接请求用于请求将该第四电子设备加入到该Wi-Fi直连群组中,该第一连接请求包括该第四电子设备的信息;该第二电子设备根据该第一连接请求,将该第二电子设备维护的引用计数加一,该第二电子设备维护的引用计数用于表示同时利用该第二电子设备Wi-Fi P2P能力的业务个数;该第二电子设备通过该第一连接,向该第四电子设备发送响应于该第一连接请求的第一响应信息,该第一响应信息用于指示将该第四电子设备加入到该Wi-Fi直连群组,该第一响应信息包括:该第二电子设备为该第四电子设备分配的IP地址、该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址;该第四电子设备根据该Wi-Fi直连群组的群组信息、该第二电子设备的MAC地址,与该第二电子设备建立该第一Wi-Fi直连链路。
根据第五方面,或者以上第五方面的任意一种实现方式,该方法还包括:该第四电子设备根据该第二电子设备为该第四电子设备分配的IP地址,以及该第二电子设备的MAC地址,与该第二电子设备建立基于该第一Wi-Fi直连链路的传输通道。
根据第五方面,或者以上第五方面的任意一种实现方式,该方法还包括:该第四电子设备和该第二电子设备建立该第一连接,该第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
根据第五方面,或者以上第五方面的任意一种实现方式,在该第二电子设备将该第二电子设备维护的引用计数加一之前,该方法还包括:该第二电子设备根据该第一连接请求,确定该第四电子设备为可信设备、以及确定该第二电子设备和该第四电子设备之间不存在Wi-Fi直连链路。
根据第五方面,或者以上第五方面的任意一种实现方式,该第二电子设备和该第二电子设备通过第二Wi-Fi直连链路传输第二业务的数据,在该第一业务的数据传输完成或者该第二业务的数据传输完成后,该方法还包括:该第二电子设备将该第二电子设备维护的引用计数减一。
根据第五方面,或者以上第五方面的任意一种实现方式,该方法还包括:在该第 二电子设备维护的引用计数为0时,该第二电子设备拆除该Wi-Fi直连群组。在该实现方式中,在该实现方式中,通过对第二电子设备(GO设备)的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成。
根据第五方面,或者以上第五方面的任意一种实现方式,该第四电子设备的信息包括:该第四电子设备的标识、该第四电子设备当前的Wi-Fi直连连接状态、该第四电子设备的Wi-Fi直连端口的MAC地址、该第四电子设备支持的信道列表、该第四电子设备连接的Wi-Fi热点的频率、该第四电子设备是否支持宽频中的至少一种。
第六方面,提供了一种电子设备,该电子设备包括用于执行以上第二方面或者第二方面的任意一方面可能的实现方式中的各个步骤的单元。
第七方面,提供了一种电子设备,该电子设备包括至少一个处理器和存储器,该至少一个处理器用于执行以上第二方面或者第二方面的任意一方面可能的实现方式中的方法。
第八方面,提供了一种电子设备,该电子设备包括至少一个处理器和接口电路,该至少一个处理器用于执行以上第二方面或者第二方面中的任意二方面可能的实现方式中的方法。
第九方面,提供了一种Wi-Fi直连下数据传输的***,该***包括用于执行以上第一方面或者第一方面的任意一方面可能的实现方式中的多个电子设备。
第十方面,提供了一种Wi-Fi直连下数据传输的***,该***包括用于执行以上第三方面或者第三方面的任意一方面可能的实现方式中的多个电子设备。
第十一方面,提供了一种Wi-Fi直连下数据传输的***,该***包括用于执行以上第四方面或者第四方面的任意一方面可能的实现方式中的多个电子设备。
第十二方面,提供了一种Wi-Fi直连下数据传输的***,该***包括用于执行以上第五方面或者第五方面的任意一方面可能的实现方式中的多个电子设备。
第十三方面,提供了一种计算机程序产品,该计算机程序产品包括计算机程序,该计算机程序在被处理器执行时,用于执行第一方面至第五方面中任意一方面中的方法,或者,用于执行第一方面至第五方面中任意一方面中的任意可能的实现方式中的方法。
第十四方面,提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当该计算机程序被执行时,用于执行第一方面至第五方面中任意一方面中的方法,或者,用于执行第一方面至第五方面中任意一方面中的任意可能的实现方式中的方法。
第十五方面,提供了一种芯片,该芯片包括:处理器,用于从存储器中调用并运行计算机程序,使得安装有该芯片的通信设备执行第一方面至第五方面中任意一方面中的方法,或者,用于执行第一方面至第五方面中任意一方面中的任意可能的实现方式中的方法。
本申请提供的Wi-Fi直连下数据传输的方法和电子设备,在P2P群组内的GC设 备之间,或者P2P群组内的GC与P2P群组外的空闲设备之间需要进行数据传输时,通过GO设备的介入,协助建立两个设备之间建立传输通道并进行业务数据的传输,使得当前Wi-Fi P2P群组内的设备之间都可以发起连接和通信,从而在业务层将星型组网变为网格(mesh)组网。并且,通过对设备上使用Wi-Fi P2P能力的业务的个数进行统计,在使用Wi-Fi P2P能力的业务的个数为0时才拆除Wi-Fi P2P链路,解决了多个Wi-Fi P2P业务之间的冲突问题,提高了用户体验。
附图说明
图1是现有技术中电子设备上的Wi-Fi P2P业务***架构的示意图。
图2是Wi-Fi P2P设备连接与组网的形式的示意性。
图3是本申请实施例提供的一例Wi-Fi P2P连接的场景架构的示意图。
图4是本申请实施例提供的一例用户触发设备上的Wi-Fi P2P发现操作的示意性界面图。
图5是本申请实施例提供的一例电子设备上Wi-Fi P2P业务***架构的示意图。
图6是本申请实施例提供一例适用于本申请实施例的通信***的示意图。
图7是本申请实施例提供的一例Wi-Fi直连下数据传输的方法的示意性流程图。
图8是本申请实施例提供的一例用户进行操作进行文件分享的示意性界面图。
图9是本申请实施例提供的另一例Wi-Fi直连下数据传输的方法的示意性流程图。
图10是本申请实施例提供另一例适用于本申请实施例的通信***的示意图。
图11是本申请实施例提供的又一例Wi-Fi直连下数据传输的方法的示意性流程图。
图12是本申请实施例提供的又一例Wi-Fi直连下数据传输的方法的示意性流程图。
图13是本申请实施例提供又一例适用于本申请实施例的通信***的示意图。
图14是本申请实施例提供的一例Wi-Fi直连下数据传输的方法的示意性流程图。
图15是本申请实施例提供又一例适用于本申请实施例的通信***的示意图。
图16是本申请实施例提供的又一例Wi-Fi直连下数据传输的方法的示意性流程图。
图17是本申请实施例提供的一例电子设备结构的示意性框图。
图18是本申请实施例提供的一例通信装置结构的示意性框图。
具体实施方式
下面将结合附图,对本申请中的技术方案进行描述。
在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
另外,本申请的各个方面或特征可以实现成方法、装置或使用标准编程和/或工程 技术的制品。本申请中使用的术语“制品”涵盖可从任何计算机可读器件、载体或介质访问的计算机程序。例如,计算机可读介质可以包括,但不限于:磁存储器件(例如,硬盘、软盘或磁带等),光盘(例如,压缩盘(compact disc,CD)、数字通用盘(digital versatile disc,DVD)等),智能卡和闪存器件(例如,可擦写可编程只读存储器(erasable programmable read-only memory,EPROM)、卡、棒或钥匙驱动器等)。另外,本文描述的各种存储介质可代表用于存储信息的一个或多个设备和/或其它机器可读介质。术语“机器可读介质”可包括但不限于,无线信道和能够存储、包含和/或承载指令和/或数据的各种其它介质。
本申请实施例的技术方案可以应用于各种通信***,例如:全球移动通讯(Global System of Mobile communication,GSM)***、码分多址(Code Division Multiple Access,CDMA)***、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)***、通用分组无线业务(General Packet Radio Service,GPRS)、长期演进(Long Term Evolution,LTE)***、LTE频分双工(Frequency Division Duplex,FDD)***、LTE时分双工(Time Division Duplex,TDD)、通用移动通信***(Universal Mobile Telecommunication System,UMTS)、全球互联微波接入(Worldwide Interoperability for Microwave Access,WiMAX)通信***、第五代(5th Generation,5G)***或新无线(New Radio,NR)等。
另外,本申请的各个方面或特征可以实现成方法、装置或使用标准编程和/或工程技术的制品。本申请中使用的术语“制品”涵盖可从任何计算机可读器件、载体或介质访问的计算机程序。例如,计算机可读介质可以包括,但不限于:磁存储器件(例如,硬盘、软盘或磁带等),光盘(例如,压缩盘(compact disc,CD)、数字通用盘(digital versatile disc,DVD)等),智能卡和闪存器件(例如,可擦写可编程只读存储器(erasable programmable read-only memory,EPROM)、卡、棒或钥匙驱动器等)。另外,本文描述的各种存储介质可代表用于存储信息的一个或多个设备和/或其它机器可读介质。术语“机器可读介质”可包括但不限于,无线信道和能够存储、包含和/或承载指令和/或数据的各种其它介质。
Wi-Fi P2P技术是Wi-Fi联盟推出的“Wi-Fi DIRECT”标准协议下的一项重要技术,Wi-Fi P2P可以支持两个Wi-Fi设备在没有Wi-Fi热点介入的情况下,直接与对方设备进行连接和通信。
图1所示的为Wi-Fi P2P业务***架构图,如图1所示的,该***架构主要包括:Wi-Fi芯片(Chipset)、Wi-Fi驱动(Wi-Fi Driver)、中间件、应用程序框架层(FRAMEWORK)、以及上层应用(application,APP)。其中,Wi-Fi驱动负责将Wi-Fi芯片与终端设备的操作***对接起来,而中间件用于终端设备运行中所有消息在内核态与用户态之间的中转,目前应用最为广泛的中间件之一是wpa_supplicant。wpa_supplicant是一个开源项目,后来被谷歌(Google)修改后引入了安卓(Android)平台,是一个独立运行在设备内的守护进程,用于消息的中转。
FRAMEWORK是运行在终端设备操作***之上的一些***能力,以安卓开放源代码项目(android open source project,AOSP)为例,AOSP提供了一些用于操作Wi-Fi P2P的相关接口和服务,例如Wi-Fi P2P相关的服务可以包括Wi-Fi P2P Service,Wi-Fi  P2P Service对应的接口类型为Wi-Fi P2P管理(Manager)类型,Wi-Fi P2P Manager类型的接口包括:提供诸如发现设备(discoverPeers)、连接(connect)等接口,这些接口可以由用户直接对Wi-Fi P2P进行控制。
上层应用是使用FRAMEWORK接口的一些用户可直接接触的应用,它们运行在终端设备上,是用户与终端设备交互的窗口。
Wi-Fi P2P的连接协议一般在Wi-Fi芯片内实现,终端设备内的FRAMEWORK层通过驱动与芯片进行交互。例如,以AOSP为例,FRAMEWORK层通过wpa_supplicant用来与驱动交互以及支持加密认证,通过应用层提供了若干可供开发者/业务直接调用的接口函数,调用后可以通过驱动使芯片执行对应的Wi-Fi P2P相关操作,FRAMEWORK层自身负责上层应用与下层硬件(包括wpa_supplicant、Wi-Fi Driver、Chipset)的消息中转和协调、连接管理等内容。目前,用户对于Wi-Fi P2P的操作都是应用层通过调用FRAMEWORK中的Wi-Fi P2P相关接口和服务来实现的。
一个完整的Wi-Fi P2P业务包括了Wi-Fi P2P设备发现、Wi-Fi P2P设备连接、Wi-Fi P2P设备业务数据传输这三个阶段。在Wi-Fi P2P设备连接建立后形成一个P2P群组(或者也可以称为Wi-Fi P2P群组)。在P2P群组内,设备存在P2P群组管理者(group owner,GO)和P2P群组客户端(group client,GC)两种角色的区分,同时协议规范里对Wi-Fi P2P连接的方式进行了说明和限制,主要存在以下三点:
(1)GO设备仅能与GC相连接,无法与其他GO设备建立连接;
(2)GC设备仅能与GO设备相连接,无法与其他设备GO或GC设备建立连接;
(3)GO设备连接GC设备的数量存在上限;
除了Wi-Fi DIRECT协议本身的限制之外,不同芯片厂商、不同操作***(例如Android、windows等)还存在一些其他对Wi-Fi P2P连接的限制,例如海思等芯片平台不支持同一个设备上的多种P2P角色。不支持同一个设备上的多种P2P角色可以理解为:同一个设备不能同时作为GO和GC;或者,在一个设备作为GO的期间内,该设备不能作为另外一个P2P群组内的GO;或者,在一个设备作为GC的期间内,该设备不能作为另外一个P2P群组内的GC。并且,AOSP也不支持同一个设备多种P2P角色共存。因此,如图2所示的,当前Wi-Fi P2P设备连接与组网的形式局限于以GO设备为中心的星型网络。
当前Android***上的Wi-Fi P2P应用(或者也可以称为业务)都是独立管理Wi-Fi P2P链路。具体的,在应用(例如为投屏应用、文件分享应用或者办公协同应用等)启动时通过调用FRAMEWORK的扫描接口启动Wi-Fi P2P服务,利用下层硬件(wpa_supplicant、Wi-Fi Driver、Chipset)开始Wi-Fi P2P设备发现,在Wi-Fi P2P设备发现后,应用通过调用FRAMEWORK的连接接口启动Wi-Fi P2P服务进行Wi-Fi P2P设备连接以及Wi-Fi P2P链路的建立。业务结束时,应用调用FRAMEWORK的连接接口启动Wi-Fi P2P服务进行Wi-Fi P2P链路的删除。
然而,AOSP对Wi-Fi P2P设备连接的管理做的并不完善,其对业务提供的接口对所有业务开放,但底层设备间的物理连接只有一条,当多个应用(或者业务)同时操作或使用设备的Wi-Fi P2P能力时,就会出现业务冲突问题。换句话说,设备上的Wi-Fi P2P链路由各个应用独自管理和协商,由于资源限制Wi-Fi P2P底层链路只会产生一个, 一个业务将Wi-Fi P2P资源占用,该设备上的另外一个Wi-Fi P2P相关业务就不能保证完整的传输。这就会导致多Wi-Fi P2P业务冲突问题。例如,两个设备间存在业务1和业务2,如果这两个设备均为GC设备,业务1建立了这两个设备之间的Wi-Fi P2P连接后,业务2也要使用该Wi-Fi P2P连接(或者使用该Wi-Fi P2P能力),此时业务2调用Wi-Fi P2P连接接口就会直接失败。如果这两个设备一个为GO设备,另一个为GC设备,业务2可以直接使用业务1建立的Wi-Fi P2P连接,虽然可以实现这两个设备间的通信,但一旦业务1结束后断开Wi-Fi P2P连接,这两个设备间的Wi-Fi P2P连接也随即断开,业务2也会被中断。又例如,多个设备之间的多业务Wi-Fi P2P业务冲突问题,假设:手机A和电脑正在办公协同,手机A和电脑建立了Wi-Fi P2P连接,此时电脑为GO设备或接入点(access point,AP)设备,手机A为GC设备,在这种情况下,手机A不能同时向另外一个手机B分享文件,并且,手机A也不能接收手机B分享的文件。
当前一种建立Wi-Fi P2P连接的方式是使用AOSP原生接口,按照Wi-Fi DIRECT标准协议,从Wi-Fi P2P设备发现开始,进行Wi-Fi P2P连接,连接完成后建立基于Wi-Fi P2P的传输通路。在进行设备间的Wi-Fi P2P连接时,必须双端设备一同发起P2P设备发现,发现设备后在调用Wi-Fi P2P连接接口进行连接。在这个过程中,如果其中一方设备是永久组(persistent group),则建立连接后此永久组设备会作为GO设备,对端设备作为GC设备,否则,则会根据双端设备的协商结果确定GO设备和GC设备的角色。图3所示的为本申请提供的一例Wi-Fi P2P连接的场景架构的示意图。如图3所示的,GO设备、GC1设备、GC2设备、GC3设备组成一个P2P群组,GO设备分别与GC1设备、GC2设备、GC3设备之间已经建立了Wi-Fi P2P连接。空闲设备1和空闲设备2为该P2P群组外的两个空闲设备,空闲设备1和空闲设备2与其他设备之间没有建立Wi-Fi P2P连接。该P2P群组内的GO设备分别与GC1设备、GC2设备、GC3设备之间进行Wi-Fi P2P业务的传输。在图3所示的架构中,存在四个场景:
场景1:P2P群组外的两个空闲设备之间进行Wi-Fi P2P连接,在场景1中,发起连接方是空闲设备1或者空闲设备2均是等价的,以空闲设备1发起Wi-Fi P2P连接为例进行说明。在发起Wi-Fi P2P连接前,空闲设备1与空闲设备2需要同时触发Wi-Fi P2P的发现操作,当空闲设备1通过空闲设备2广播的报文,发现了空闲设备2之后,空闲设备1可以调用连接命令,建立两个与空闲设备2之间的Wi-Fi P2P连接。
场景2:空闲设备与P2P群组内的GO设备之间建立Wi-Fi P2P连接。以空闲设备1和GO设备之间建立Wi-Fi P2P连接为例进行说明,当空闲设备1发起到GO设备的连接时,由于GO设备建立P2P群组后会持续发送广播,因此无需再GO设备上触发Wi-Fi P2P发现。在空闲设备1上需要触发Wi-Fi P2P发现,当空闲设备1通过GO设备广播的报文,发现了GO设备之后,空闲设备1通过连接操作可以建立到GO设备的Wi-Fi P2P连接。
当GO设备发起到空闲设备1的Wi-Fi P2P连接时,类似的,需要GO设备与空闲设备1同时触发Wi-Fi P2P发现,在GO设备发现空闲设备1后,GO设备可以通过连接操作建立与空闲设备1的Wi-Fi P2P连接。
例如,图4所示的为用户触发空闲设备或者GO设备上的Wi-Fi P2P发现操作的 示意性界面图。如图4中的a所示的,用户可以点击空闲设备或者GO设备上的“设置”图标,显示的界面如图4中的b所示的,用户单击“WLAN直连”菜单,便可以触发Wi-Fi P2P发现。用户点击“WLAN直连”后,显示的界面如图4中的c所示的,用户点击“停止”菜单,便可以停止Wi-Fi P2P发现。在发现的众多可用的设备中,用户可以点击其中的任意一个设备,在用户点击该设备后,用户使用的设备便可以和该设备进行Wi-Fi P2P连接。
对于上述的场景1和场景2,利用上述的建立Wi-Fi P2P连接的方法可以建立Wi-Fi P2P连接,在Wi-Fi P2P连接建立完成后,还需要建立能够传输数据的通路,由于当前AOSP的接口只能获取GO设备的互联网协议(internet protocol,IP)地址,因此在不依赖其他通信手段来协助交换端口号的情况下,只能由GO设备侧在固定端口上进行监听,由GC设备以GO设备IP地址和端口号的信息来建立套接字(socket)连接,从而进行后续的数据传输。
场景3:P2P群组内的GC设备之间建立Wi-Fi P2P连接。例如,P2P群组内的GC1与GC2之间建立Wi-Fi P2P连接。利用上述的建立Wi-Fi P2P连接的方式,对于场景3而言,两台设备已经成为GC设备,两台GC设备双端触发设备发现后,能够互相发现对端,但是发起设备连接后,两台GC设备之间的Wi-Fi P2P连接会失败,也无法进行后续的数据传输。
场景4:P2P群组内的GC设备与P2P群组外的空闲设备之间Wi-Fi P2P连接。例如,P2P群组内的GC1设备与空闲设备1之间建立Wi-Fi P2P连接。利用上述的建立Wi-Fi P2P连接的方式,对于场景4而言,GC1设备可以通过邀请模式将空闲设备1连接至GO设备上,但连接完成后,无论是原来的GC1设备,还是该空闲设备1,如果不借助其他通信方式协助传递信息,就无法获取对方的IP地址,从而无法建立传输通道。
因此,利用上述的建立Wi-Fi P2P连接的方式,对于上述的场景3和场景4,即两个GC设备之间,或者GC设备与群组外的设备之间,均无法建立Wi-Fi P2P连接。
有鉴于此,本申请提供了一种Wi-Fi P2P连接的方法,在P2P群组内的GC设备之间,或者P2P群组内的GC与P2P群组外的空闲设备之间需要进行数据传输时,通过GO设备的介入,协助建立两个设备之间建立传输通道并进行业务数据的传输,使得当前Wi-Fi P2P群组内的设备之间都可以发起连接和通信,从而在业务层将星型组网变为网格(mesh)组网。并且,通过对设备上使用Wi-Fi P2P能力的业务的个数进行统计,在使用Wi-Fi P2P能力的业务的个数为0时才拆除Wi-Fi P2P链路,解决了多个Wi-Fi P2P业务之间的冲突问题,提高了用户体验。
下面结合具体的例子来说明本申请提供的Wi-Fi P2P连接的方法。
应理解,本申请提供的方法主要是针对Wi-Fi DIRECT标准协议中的Wi-Fi P2P连接和组网的场景中,可以适用于使用Wi-Fi DIRECT标准协议的Wi-Fi P2P技术的Android操作***和WINDOWS操作***的设备中,还可以适用于使用IOS操作***和鸿蒙操作***的设备中等。本申请实施例在此不作限制。
图5所示的为本申请提供的一例Wi-Fi P2P业务***架构图,如图5所示的,该***架构主要包括:Wi-Fi芯片(Chipset)、Wi-Fi驱动(Wi-Fi Driver)、中间件、 应用程序框架层(FRAMEWORK)、通信模块以及上层应用(application,APP)。其中,在FRAMEWORK层的Wi-Fi P2P服务中还包括P2P链路管理模块。P2P链路管理模块用于对设备的Wi-Fi P2P能力(或者Wi-Fi P2P链路)进行管理。通信模块用于应用层和FRAMEWORK层之间进行通信。应该理解,在本申请实施例中,通信模块还可以位于FRAMEWORK层之中。
图6所示的一例适用于本申请实施例的通信***的示意图。如图6所示的,该***包括:第一电子设备、第二电子设备以及第三电子设备,其中,第二电子设备和第一电子设备之间已经建立了Wi-Fi P2P连接,换句话说,第二电子设备和第一电子设备已经组成一个P2P群组,在该P2P群组内,第二电子设备为GO设备或者为AP设备,第一电子设备为GC设备。第三电子设备为该P2P群组外的一个空闲设备,第三电子设备和其他设备之间没有Wi-Fi P2P连接。在图6所示的例子中,第三电子设备为手机B为例、第一电子设备为手机A为例,第二电子设备为大屏设备(例如为智能电视、智慧屏等)为例。手机A正在投屏到大屏设备,然后手机B(空闲设备)需要发起到手机A的文件分享。手机A与大屏设备投屏是使用的Wi-Fi P2P链路。
图7所示的为在图6所示的场景中,本申请提供的一例Wi-Fi P2P连接的方法的示意性流程图。其中,手机A正在投屏到大屏设备,手机A与大屏设备投屏是使用的Wi-Fi P2P链路,如图7所示的,该方法包括:S101至S127。
S101,用户在手机B上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。图8所示的为用于在手机B上执行的操作。
S102,在用户点击“Wi-Fi直连”后,手机B上的第一应用向手机B中的通信模块发送发现设备请求。
S103,手机B中的通信模块接收到该发现设备请求后,启动低功耗蓝牙(bluetooth low energy,BLE)扫描、经典蓝牙扫描、无线局域网(wireless local area networks,WLAN)扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。在本申请实施例中,经典蓝牙包括蓝牙基础速率(bluetooth basic rate,BR)和蓝牙增强速率(bluetooth enhanced data rate,EDR)两种类型的蓝牙中的至少一种。
S104,手机B中的通信模块扫描到设备后,将扫描到的设备列表发送给手机B上的第一应用,该设备列表中包含有一个或多个设备的设备标识。例如,显示的设备列表可以如图8中的d所示的。
S105,用户在手机B上的第一应用上选择设备列表中的手机A的设备标识,该手机A的设备标识可以为手机A的设备型号、标识码、设备名称、设备ID(device ID)等。手机A的设备标识用于唯一标识该手机A。
S106,用户在设备列表中点击手机A的设备标识后,手机B上的第一应用会向手机B中的通信模块发送Wi-Fi P2P连接请求。该Wi-Fi P2P连接请求包括手机A的设备标识。
S107,手机B中的通信模块接收到该Wi-Fi P2P连接请求后,首先和手机A中的通信模块建立第一连接。例如,该第一连接可以为BLE连接、BR连接、Wi-Fi连接等。本申请实施例在此不作限制。
S108,手机B中的通信模块和手机A中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S109,手机B中的通信模块存储该加密秘钥和解密秘钥。
S110,手机A中的通信模块存储该加密秘钥和解密秘钥。
S111,手机B中的通信模块通过第一连接向手机A中的通信模块发送Wi-Fi P2P连接请求,该Wi-Fi P2P连接请求利用加密秘钥进行加密。该Wi-Fi P2P连接请求包括:手机B的设备标识、手机B当前的Wi-Fi P2P连接状态(手机B当前的Wi-Fi P2P连接状态包括:手机B当前没有与任何设备之间存在Wi-Fi P2P连接的状态,该连接状态可以用0表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GO的状态,该连接状态可以用1表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GC的状态,该连接状态可以用2表示。在本实施例中,手机B当前无Wi-Fi P2P连接,手机B当前的Wi-Fi P2P连接状态用0表示)、手机B的Wi-Fi P2P端口的媒体接入控制(media access control,MAC)地址、手机B支持的信道列表(例如为支持36信道,对应5180MHz)、手机B预期的连接方式(例如手机B期望以GC的身份建立Wi-Fi P2P连接,或者手机B期望以GO的身份建立Wi-Fi P2P连接,在本实施例中,手机B期望是以GC的身份建立Wi-Fi P2P连接)、手机B连接的Wi-Fi热点的频率、是否支持宽频(例如是否支持160MHz,如果支持可以用true表示,如果不支持可以用false表示)等信息中的至少一个。
S112,手机A中的通信模块接收到该Wi-Fi P2P连接请求后,利用该解密秘钥进行解密。手机A中的通信模块根据已经存储的连接信息,确定手机A已经为GC,因此不能与手机B之间直接建立Wi-Fi P2P连接。
具体的,由于手机A在与大屏设备建立Wi-Fi P2P连接后,手机A中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,因此手机A的通信模块里已经维护了既有的连接信息,该连接信息包括:手机A当前的Wi-Fi P2P连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。而对于大屏设备而言,大屏设备中的通信模块也会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,由于大屏设备为GO角色,因此,该连接信息除了包括与自己(大屏设备)连接的设备(包括手机A)的Wi-Fi P2P连接状态、角色以及设备的地址信息外,还包括该P2P群组的信息。在本申请实施例中,该P2P群组信息包括:该P2P群组的服务集标识(service set identifier,SSID)、基本服务集标识(basicservice set identifier,BSSID)、频率、密码(PASSWORD)中至少一种。
S113,手机A中的通信模块向大屏设备中的通信模块发送连接请求,该连接请求用于请求将手机B加入手机A和大屏设备组成的P2P群组中。该连接请求包括:手机B的设备标识、手机B当前的Wi-Fi P2P连接状态、手机B的Wi-Fi P2P端口的MAC地址、手机B支持的信道列表、手机B预期的连接方式、手机B连接的Wi-Fi热点的频率、手机B是否支持宽频等信息中的至少一个。
S114,大屏设备中的通信模块接收到该连接请求后,会校验手机B是否为可信设 备,以及判断大屏设备是否已经与手机B建立了Wi-Fi P2P连接。
S115,在确定大屏设备没有与手机B建立了Wi-Fi P2P连接,大屏设备是GO设备,并且手机B是可信设备(例如,手机B和大屏设备登录的是同一个账号,或者手机B与大屏设备通过各种方式(例如通过二维码扫描等)进行过设备绑定)后,大屏设备中的通信模块向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求可以包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息。
S116,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息,则可以确定大屏设备可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求不包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息,由于大屏设备中的通信模块已经维护了既有的连接信息,该连接信息包括:与自己连接设备(包括手机A)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备与手机A之间已经存在Wi-Fi P2P链路,或者,确定大屏设备已经存与手机A之间已经存在Wi-Fi P2P链路,并且,该Wi-Fi P2P链路支持其他业务使用,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为1,表示大屏设备自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,大屏设备才会拆除P2P群组。
S117,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用P2P能力成功的响应信息。
S118,大屏设备中的通信模块接收到该复用P2P能力成功的响应信息后,向手机A中的通信模块发送连接请求响应信息,该连接请求响应信息包括:允许手机B加入P2P群组的指示信息、手机A和大屏设备组成的P2P群组的信息、大屏设备为手机B分配的IP地址、大屏设备的MAC地址等信息。应理解,该连接请求响应信息中可以包括:允许手机B加入P2P群组的指示信息和手机A和大屏设备组成的P2P群组的信息中任意一个,而不必同时包括允许手机B加入P2P群组的指示信息、以及手机A和大屏设备组成的P2P群组的信息。可选的,该连接请求响应信息还可以包括:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息。
S119,手机A中的通信模块接收到该连接请求响应信息后,根据允许手机B加入P2P群组的指示信息,或者,P2P群组信息,确定手机B可以加入P2P群组。由于两 个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,而对Wi-Fi P2P能力的复用是针对一个设备而言的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输,因此,手机A中的通信模块也需要向手机A中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求还可以包括:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息。
S120,手机A中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该请求中携带:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,则手机A中的P2P链路管理模块可以确定手机A可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,并且,手机A中的P2P链路管理模块确定该Wi-Fi P2P链路支持其他业务使用,则可以确定手机A可以复用Wi-Fi P2P能力。或者,作为又一种可能的实现方式,如果该请求中没有携带大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,由于手机A中的通信模块已经维护了既有的连接信息,该连接信息包括:手机A当前的连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机A中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定手机A与大屏设备之间已经存在Wi-Fi P2P链路(手机A和大屏设备之间投屏的Wi-Fi P2P链路),或者,确定手机A当前已经存在Wi-Fi P2P链路(手机A和大屏设备之间投屏的Wi-Fi P2P链路),并且,该Wi-Fi P2P链路支持其他业务使用,则可以确定手机A可以复用Wi-Fi P2P能力。
进一步的,手机A也可以维护一个引用计数,该引用计数用于指示同时利用手机A Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机A维护的引用计数的值为1,表示手机A自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机A自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机A不会断开该Wi-Fi P2P链路,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机A才会断开该Wi-Fi P2P链路。
S121,手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机A中的通信模块发送复用P2P能力成功的响应信息。
S122,手机A中的通信模块接收到该响应信息后,通过第一连接向手机B中的通信模块发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息利用加密秘钥进行加密。该Wi-Fi P2P连接请求响应信息包括:允许手机B加入P2P群组的指示信息、手机A和大屏设备组成的P2P群组的信息(例如,P2P群组的SSID、BSSID、频率、PASSWORD等)、大屏设备为手机B分配的IP地址、大屏设备的MAC地址、手机A的IP地址以及端口号信息等,其中,手机A的端口号是手机A的通信模块在 Wi-Fi P2P建立后通过启动监听来获取的。应理解,该Wi-Fi P2P连接请求响应信息中可以包括:允许手机B加入P2P群组的指示信息、以及手机A和大屏设备组成的P2P群组的信息中任意一个,而不必同时包括允许手机B加入P2P群组的指示信息和手机A和大屏设备组成的P2P群组的信息。
S123,手机B中的通信模块接收到该Wi-Fi P2P连接请求响应信息并利用解密秘钥进行解密后,根据允许手机B加入P2P群组的指示信息,或者手机A和大屏设备组成的P2P群组的信息,确定可以加入P2P群组,则向手机B中的P2P链路管理模块发送加入P2P群组的请求,该请求中携带P2P群组信息以及大屏设备的MAC地址。
S124,手机B中的P2P链路管理模块根据该P2P群组信息以及大屏设备的MAC地址,通过连接接口(例如为connect接口),直接发起到大屏设备的Wi-Fi P2P连接,加入P2P群组后,手机B中的P2P链路管理模块向手机B中的通信模块发送响应信息,用于向手机B中的通信模块通知手机B加入P2P群组成功。
S125,手机B中的通信模块接收到该响应信息后,向手机B上的第一应用发送Wi-Fi P2P连接请求响应信息,用于向手机B上的第一应用通知手机B加入P2P群组成功,该Wi-Fi P2P连接请求响应信息携带:大屏设备为手机B分配的IP地址、手机B自己生成的端口号、手机A的IP地址以及端口号。
S126,手机B加入P2P群组后,手机B已经成为GC设备,手机B上的第一应用利用大屏设备为手机B分配的IP地址以及手机B自己生成的端口号,结合手机A的IP地址以及端口号信息等,与手机A上的第一应用建立socket传输通道。
S127,手机B上的第一应用基于socket传输通道,向手机A上的第一应用开始文件分享。其中,文件分享业务开始后,手机B先将分享文件的数据传输至大屏设备,大屏设备再将该分享文件的数据传输给手机A,即文件分享业务的数据流为:手机B→大屏设备→手机A。投屏业务的数据流为手机A→大屏设备。
图7所示方法为手机B(空闲设备)需要发起到手机A(GC设备)的文件分享的流程。图9所示的为在图6所示的场景中,手机A(GC设备)需要发起向手机B(空闲设备)的文件分享的方法的示意性流程图,其中,手机A正在投屏到大屏设备,手机A与大屏设备投屏是使用的Wi-Fi P2P链路。如图9所示的,该方法包括:S201至S228。
S201,用户在手机A上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。
S202,在用户点击“Wi-Fi直连”后,手机A上的第一应用向手机B中的通信模块发送发现设备请求。
S203,手机A中的通信模块接收到该发现设备请求后,启动BLE扫描、BR扫描、WLAN扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。
S204,手机A中的通信模块扫描到设备后,将扫描到的设备列表发给手机A上的第一应用。该设备列表中包含有一个或多个设备的设备标识。
S205,用户在手机A上的第一应用上选择设备列表中的手机B的设备标识,该手机B的设备标识可以为手机B的设备型号、标识码、设备名称、设备ID(device ID)等。手机B的设备标识用于唯一标识该手机B。
S206,用户在设备列表中点击手机B的设备标识后,手机A上的第一应用向手机A中的通信模块发送Wi-Fi P2P连接请求。
S207,手机A中的通信模块接收到该Wi-Fi P2P连接请求后,首先和手机B中的通信模块建立第一连接。例如,该第一连接可以为BLE连接、BR连接、Wi-Fi连接等。本申请实施例在此不作限制。
S208,手机A中的通信模块和手机B中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S209,手机A中的通信模块存储该加密秘钥和解密秘钥。
S210,手机B中的通信模块存储该加密秘钥和解密秘钥。
S211,由于手机A在与大屏设备建立Wi-Fi P2P连接后,手机A中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,因此手机A的通信模块里已经维护了既有的连接信息,该连接信息包括:手机A的设备标识、手机A当前的Wi-Fi P2P连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。而对于大屏设备而言,大屏设备中的通信模块也会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,由于大屏设备为GO角色,因此,该连接信息除了包括与自己(大屏设备)连接的设备(包括手机A)的Wi-Fi P2P连接状态、角色以及设备的地址信息外,还存储了该P2P群组的信息中的至少一个。在本申请实施例中,该P2P群组的信息可以是SSID、BSSID、频率、密码(PASSWORD)中至少一种。因此,手机A中的通信模块根据连接信息,确定手机A已经为GC,进而确定手机A不能与手机B之间直接建立Wi-Fi P2P连接。
S212,手机A中的通信模块向大屏设备(即GO设备)中的通信模块发送连接请求,该连接请求用于请求将手机B加入手机A和大屏设备组成的P2P群组中。该连接请求包括手机B的身份信息,在本申请实施例中,手机B的身份信息包括:手机B的设备标识、手机B当前的Wi-Fi P2P连接状态、手机B的Wi-Fi P2P端口的MAC地址、手机B支持的信道列表(例如为支持36信道,对应5180MHz)、手机B预期的连接方式(例如手机B期望以GC的身份建立Wi-Fi P2P连接,或者手机B期望以GO的身份建立Wi-Fi P2P连接,在本实施例中,手机B期望是以GC的身份建立Wi-Fi P2P连接)、手机B连接的Wi-Fi热点的频率、是否支持宽频(例如是否支持160MHz,如果支持可以用true表示,如果不支持可以用false表示)等信息中的至少一个。例如,手机B当前的Wi-Fi P2P连接状态包括:手机B当前没有与任何设备之间存在Wi-Fi P2P连接的状态,该连接状态可以用0表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GO的状态,该连接状态可以用1表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GC的状态,该连接状态可以用2表示。在本实施例中,手机B当前无Wi-Fi P2P连接,手机B当前的Wi-Fi P2P连接状态用0表示。应理解,在本申请实施例中,手机A可以通过与手机B之间的第一连接,获取手机B当前的Wi-Fi P2P连接状态、手机B的Wi-Fi P2P端口的MAC地址、手机B支持的信道列表、手机B预期的连接方式等信息。
S213,大屏设备(即GO设备)中的通信模块接收到该连接请求后,会校验手机B 是否为可信设备,以及判断大屏设备是否已经与手机B建立了Wi-Fi P2P连接。
S214,在确定大屏设备没有与手机B建立Wi-Fi P2P连接,大屏设备为GO设备,并且手机B是可信设备,大屏设备中的通信模块向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求可以包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息。
S215,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息,则可以确定大屏设备可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求不包括大屏设备与手机A之间已经存在Wi-Fi P2P链路的指示信息,由于大屏设备中的通信模块已经维护了既有的连接信息,该连接信息包括:与自己连接设备(包括手机A)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备与手机A之间已经存在Wi-Fi P2P链路,或者,确定大屏设备已经存与手机A之间已经存在Wi-Fi P2P链路,并且,该Wi-Fi P2P链路支持其他业务使用,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为1,表示大屏设备自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机A向手机B的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机A还可以正常的向手机B分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,大屏设备才会拆除P2P群组。
S216,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用P2P能力成功的响应信息。
S217,大屏设备中的通信模块接收到该复用P2P能力成功的响应信息后,向手机A中的通信模块发送连接请求响应信息,该连接请求响应信息包括:允许手机B加入P2P群组的指示信息、手机A和大屏设备组成的P2P群组的信息、大屏设备为手机B分配的IP地址、大屏设备的MAC地址等信息。应理解,该连接请求响应信息中可以包括:允许手机B加入P2P群组的指示信息和手机A和大屏设备组成的P2P群组的信息中任意一个,而不必同时包括允许手机B加入P2P群组的指示信息、以及手机A和大屏设备组成的P2P群组的信息。可选的,该连接请求响应信息还可以包括:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息。
S218,手机A中的通信模块接收到该连接请求响应信息后,根据允许手机B加入P2P群组的指示信息,或者,P2P群组信息,确定手机B可以加入P2P群组。由于两个设备之间的Wi-Fi P2P链路是需要这两个设备共同维护的,而对Wi-Fi P2P能力的复用是针对一个设备而言的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这 台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输,因此,手机A中的通信模块也需要向手机A中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求还可以包括:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息。
S219,手机A中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该请求中携带:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,则手机A中的P2P链路管理模块可以确定手机A可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,并且,手机A中的P2P链路管理模块确定该Wi-Fi P2P链路支持其他业务使用,则可以确定手机A可以复用Wi-Fi P2P能力。或者,作为又一种可能的实现方式,如果该请求中没有携带大屏设备已经与手机A之间存在Wi-Fi P2P连接的指示信息,由于手机A中的通信模块已经维护了既有的连接信息,该连接信息包括:手机A当前的连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机A中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定手机A与大屏设备之间已经存在Wi-Fi P2P链路(手机A和大屏设备之间投屏的Wi-Fi P2P链路),或者,确定手机A当前已经存在Wi-Fi P2P链路(手机A和大屏设备之间投屏的Wi-Fi P2P链路),并且,该Wi-Fi P2P链路支持其他业务使用,则可以确定手机A可以复用Wi-Fi P2P能力。
进一步的,手机A也可以维护一个引用计数,该引用计数用于指示同时利用手机A Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机A维护的引用计数的值为1,表示手机A自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机A自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机A向手机B的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机A不会断开该Wi-Fi P2P链路,手机A还可以正常的向手机B分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机A才会断开该Wi-Fi P2P链路。
S220,手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机A中的通信模块发送复用P2P能力成功的响应信息。
S221,手机A中的通信模块接收到该响应信息后,通过第一连接向手机B中的通信模块发送Wi-Fi P2P连接请求,该Wi-Fi P2P连接请求利用加密秘钥进行加密。该Wi-Fi P2P连接请求包括:允许手机B加入P2P群组的指示信息、手机A和大屏设备组成的P2P群组的信息(例如,P2P群组的SSID、BSSID、频率、PASSWORD等)、大屏设备为手机B分配的IP地址、大屏设备的MAC地址、手机A的IP地址以及端口号信息等。其中,手机A的端口号是手机A的通信模块在Wi-Fi P2P建立后通过启动监听来获取的。应理解,该Wi-Fi P2P连接请求响应信息中可以包括:允许手机B加入P2P群组的指示信息、以及手机A和大屏设备组成的P2P群组的信息中任意一个, 而不必同时包括允许手机B加入P2P群组的指示信息和手机A和大屏设备组成的P2P群组的信息。
S222,手机B中的通信模块接收到该Wi-Fi P2P连接请求响应信息并利用解密秘钥进行解密后,根据允许手机B加入P2P群组的指示信息,或者手机A和大屏设备组成的P2P群组的信息,确定可以加入P2P群组,则向手机B中的P2P链路管理模块发送加入P2P群组的请求,该请求中携带P2P群组信息以及大屏设备的MAC地址。
S223,手机B中的P2P链路管理模块根据该P2P群组信息以及大屏设备的MAC地址,通过连接接口(例如为connect接口),直接发起到大屏设备的Wi-Fi P2P连接,加入P2P群组后,手机B中的P2P链路管理模块向手机B中的通信模块发送响应信息,用于向手机B中的通信模块通知手机B加入P2P群组成功。
S224,手机B中的通信模块接收到该响应信息后,通过第一连向手机A中的通信模块发送Wi-Fi P2P连接请求响应信息,Wi-Fi P2P连接请求响应信息利用加密秘钥进行加密,该Wi-Fi P2P连接请求响应信息包括:手机B加入P2P群组成功的指示信息、大屏设备为手机B分配的IP地址以及手机B自己生成的端口号。
S225,手机A中的通信模块接收到该Wi-Fi P2P连接请求响应信息后,利用解密秘钥进行解密,确定手机B已经加入P2P群组成功。
S226,手机A中的通信模块向手机A上的第一应用发送Wi-Fi P2P连接请求响应信息,用于向手机A上的第一应用通知手机B加入P2P群组成功,该Wi-Fi P2P连接请求响应信息携带:大屏设备为手机B分配的IP地址以及手机B自己生成的端口号、手机A的IP地址以及端口号信息等。
S227,手机A上的第一应用利用:手机A的IP地址以及端口号信息,结合大屏设备为手机B分配的IP地址、以及手机B自己生成的端口号,与手机B上的第一应用(即为文件分享)建立socket传输通道。
S228,手机A上的第一应用基于socket传输通道,向手机B上的第一应用(即文件分享应用)开始文件分享。其中,文件分享业务开始后,手机A先将分享文件的数据传输至大屏设备,大屏设备再将该分享文件的数据传输给手机B,即文件分享业务的数据流为:手机A→大屏设备→手机B。投屏业务的数据流为手机A→大屏设备。
可选的,在图7和图9所示的方法中。对于手机A和大屏设备之间存在着较大的数据流量的情况,本申请实施例还可以根据不同的业务设置其对应的优先级,优先级高的业务优先传输或者占用较大的带宽传输等,进行流量限制和均衡,从而使得投屏业务和文件分享业务可以保持均衡,使得优先高的业务快速传输,进一步的提高用户体验。
在本申请实施例中,在文件分享业务和投屏业务这两个业务都完成后,才会进行P2P群组的移除,即进行GO设备以及P2P群组的拆除。换句话说,在手机A和大屏设备维护的引用计数都为0时,才进行GO设备以及P2P群组的拆除。在文件分享业务和投屏业务中任意一个完成后,手机A和大屏设备维护的引用计数均减为1,由于引用计数不为0,在这种情况下,不会进行GO设备以及P2P群组的拆除,即不会将手机A和大屏设备之间的Wi-Fi P2P链路断开。
本申请提供的Wi-Fi P2P连接的方法,P2P群组内的第一电子设备(即GC设备) 和P2P群组外的第三电子设备(即空闲设备)可以使用多种发现方式相互发现,并且当P2P群组内的第一电子设备和P2P群组外的第三电子设备无法直接进行Wi-Fi P2P连接时,第三电子设备会将第一电子设备作为中介设备,协助自己加入到第一电子设备所在的P2P群组内,或者,第一电子设备将作为中介设备,协助第三电子设备加入到GC设备所在的P2P群组内。同时,P2P群组内的第一电子设备和P2P群组外的第三电子设备都可以获取对方的IP地址和端口号,建立起P2P群组内的第一电子设备和P2P群组外的第三电子设备之间的socket传输通道,从而实现二者之间基于socket传输通道的数据传输。并且对P2P群组内的第一电子设备和第二电子设备(即GO设备)设备的Wi-Fi P2P能力进行复用,第一电子设备和第二电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的GC设备和P2P群组外的空闲设备无法传输数据的问题,提高了用户体验。
图10所示的另一例适用于本申请实施例的通信***的示意图。如图10所示的,该***架构包括:第一电子设备、第二电子设备以及第三电子设备,第一电子设备和第三电子设备分别与第二电子设备之间已经建立了Wi-Fi P2P连接,换句话说,第一电子设备、第二电子设备和第三电子设备已经组成一个P2P群组,在该P2P群组内,第二电子设备为GO设备或者为AP设备,第一电子设备、第三电子设备均为GC设备。在图10所示的例子中,第一电子设备为手机A为例、第三电子设备为手机B为例,第二电子设备为大屏设备(例如为智能电视)为例。手机A和手机B均正在投屏到大屏设备,然后手机B(GC设备)需要发起到手机A(GC设备)的文件分享业务。
图11所示的为在图10示的场景中,本申请提供的一例Wi-Fi P2P连接的方法的示意性流程图。其中,手机A和手机B分别通过各自Wi-Fi P2P连接正在投屏到大屏设备。如图11示的,该方法包括:S301至S329。
S301,用户在手机B上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。
S302,在用户点击“Wi-Fi直连”后,手机B上的第一应用向手机B中的通信模块发送发现设备请求。
S303,手机B中的通信模块接收到该发现设备请求后,启动BLE扫描、BR扫描、WLAN扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。
S304,手机B中的通信模块扫描到设备后,将扫描到的设备列表发送给手机B上的第一应用,该设备列表中包含有一个或多个设备的设备标识。例如,显示的设备列表可以如图8中的d所示的。
S305,用户在手机B上的第一应用上选择设备列表中的手机A的设备标识,该手机A的设备标识可以为手机A的设备型号、标识码、设备名称、设备ID(device ID)等。手机A的设备标识用于唯一标识该手机A。
S306,手机B上的第一应用向手机B中的通信模块发送Wi-Fi P2P连接请求。
S307,手机B中的通信模块接收到该Wi-Fi P2P连接请求后,首先和手机A中的通信模块建立第一连接。例如,该第一连接可以为BLE连接、蓝牙连接、Wi-Fi连接等。本申请实施例在此不作限制。
S308,手机B中的通信模块和手机A中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S309,手机B中的通信模块存储该加密秘钥和解密秘钥。
S310,手机A中的通信模块存储该加密秘钥和解密秘钥。
S311,由于手机B在与大屏设备建立Wi-Fi P2P连接后,手机B中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,因此手机B的通信模块里已经维护了既有的连接信息,该连接信息包括:手机B当前的Wi-Fi P2P连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址、标识等。而对于大屏设备而言,大屏设备中的通信模块也会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,由于大屏设备为GO角色,因此,该连接信息除了包括与自己(大屏设备)连接的设备(包括手机A和手机B)的Wi-Fi P2P连接状态、角色以及设备的地址信息外,还包括该P2P群组的信息。在本申请实施例中,该P2P群组信息包括:该P2P群组的SSID、BSSID、频率、密码(PASSWORD)中至少一种。因此,手B中的通信模块根据连接信息,确定手机B已经为GC,进而确定手机B不能与手机A之间直接建立Wi-Fi P2P连接。
S312,手机B中的通信模块通过第一连接向手机A中的通信模块发送Wi-Fi P2P连接请求,该Wi-Fi P2P连接请求通过加密秘钥进行加密,该Wi-Fi P2P连接请求包括:手机B的设备标识、手机B当前的Wi-Fi P2P连接状态、手机B的Wi-Fi P2P端口的MAC地址、手机B支持的信道列表(例如为支持36信道,对应5180MHz)、手机B连接的Wi-Fi热点的频率、是否支持宽频(例如是否支持160MHz,如果支持可以用true表示,如果不支持可以用false表示)、手机B所连接的GO设备的标识等信息。例如,手机B当前的Wi-Fi P2P连接状态包括:手机B当前没有与任何设备之间存在Wi-Fi P2P连接的状态,该连接状态可以用0表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GO的状态,该连接状态可以用1表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GC的状态,该连接状态可以用2表示。在本实施例中,手机B当前存在Wi-Fi P2P连接且手角色为GC的状态,手机B当前的Wi-Fi P2P连接状态用2表示。
S313,手机A中的通信模块接收到该连接请求后,利用解密秘钥进行解密,获取连接请求包括的内容。由于手机A在与大屏设备建立Wi-Fi P2P连接后,手机A中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,该连接信息包括:手机A当前的连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址、标识等。进一步的,手机A中的通信模块确定手机B所连接的GO设备的标识与自己所连接的GO设备的标识是否相同。
S314,在手机B所连接的GO设备的标识与自己所连接的GO设备的标识相同的情况下,手机A中的通信模块可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接。进一步的,手机A中的通信模块向手机A中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。
S315,手机A中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,手机A中的P2P链路管理模块便可以确定手机A和手机B分别与大屏设备之间存在Wi-Fi P2P连接,则手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,并且,这两个Wi-Fi P2P连接分别均支持其他业务使用,则手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为再一种可能的实现方式,如果该请求中没有携带手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,由于手机A中的通信模块已经存储了既有的连接信息,该连接信息包括:手机A当前的连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机A中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,结合手机B所连接的GO设备的标识,确定手机B所连接的GO设备的标识与自己所连接的GO设备的标识相同,则可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,则手机A中的P2P链路管理模块确定手机A可以复用Wi-Fi P2P能力。
进一步的,手机A也可以维护一个引用计数,该引用计数用于指示同时利用手机A Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机A维护的引用计数的值为1,表示手机A自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机A自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机A不会断开手机A和大屏设备之间的Wi-Fi P2P链路,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机A才会断开该Wi-Fi P2P链路。
S316,手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机A中的通信模块发送复用P2P能力成功的响应信息。
S317,手机A中的通信模块接收到该响应信息后,向大屏设备中的通信模块发送Wi-Fi P2P连接请求,该Wi-Fi P2P连接请求信息用于请求:手机A与手机B之间通过Wi-Fi P2P连接传输第一应用数据的授权。该Wi-Fi P2P连接请求信息包括:手机B的设备标识、手机B的Wi-Fi P2P端口的MAC地址、手机B的IP地址以及端口号、手机B所连接的GO设备的标识等信息中的至少一个。
S318,大屏设备中的通信模块接收到该Wi-Fi连接请求后,会对手机B进行校验。例如,会校验手机B是否为可信设备,以及判断大屏设备是否已经与手机B建立了 Wi-Fi P2P连接。
S319,由于两个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,而对Wi-Fi P2P能力的复用是针对一个设备而言的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输。因此,在确定大屏设备是GO设备、手机B是可信设备(例如,手机B和大屏设备登录的是同一个账号,或者手机B与大屏设备通过各种方式(例如通过二维码扫描等)进行过设备绑定),以及大屏设备已经与手机B建立了Wi-Fi P2P连接后,大屏设备中的通信模块也会向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该复用Wi-Fi P2P能力的请求可以包括:大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息。
S320,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求包括:大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息,则大屏设备中的P2P链路管理模块可以确定大屏设备可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求不包括大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息,由于大屏设备中的通信模块已经存储了既有的连接信息,该连接信息包括:与自己连接设备(包括手机B和手机A)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路,或者,确定大屏设备分别与手机A之间已经存在Wi-Fi P2P链路,并且,这两个Wi-Fi P2P链路支持其他业务使用,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机A和手机B分别向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为3,表示大屏设备自身的Wi-Fi P2P能力承载了3个业务(手机A和手机B分别向大屏设备的投屏业务、以及手机B向手机A的文件分享业务)。引用计数的值变为3后,若两个投屏业务均断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即两个投屏业务和一个文件分享业务均断开时,大屏设备才会拆除P2P群组。
S321,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用P2P能力成功的响应信息。
S322,大屏设备中的通信模块接收到该响应信息后,向手机A中的通信模块发送Wi-Fi P2P连接响应信息,该连接响应信息包括:P2P群组信息。可选的,该连接响应信息还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。在本申请实施例中,该P2P群组信息包括:P2P群组的SSID、BSSID、频率、密 码(PASSWORD)中至少一种。
S323,手机A中的通信模块接收到该Wi-Fi P2P连接响应信息后,根据P2P群组信息,确定可以与手机B之间通过Wi-Fi P2P连接传输第一应用的数据。手机A中的通信模块通过第一连接向手机B中的通信模块发送Wi-Fi P2P连接响应信息,该Wi-Fi P2P连接信息通过加密秘钥进行加密。该Wi-Fi P2P连接信息包括:手机A的IP地址以及端口号信息、手机A所连接的GO设备的标识等信息。可选的,该Wi-Fi P2P连接信息还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。
S324,手机B中的通信模块接收到该Wi-Fi P2P连接信息后,利用解密秘钥进行解密,获取该Wi-Fi P2P连接信息的内容后,作为一种可能的实现方式,如果该Wi-Fi P2P连接信息包括手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,手机B中的通信模块根据手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,确定可以与手机A之间通过Wi-Fi P2P连接传输第一应用的数据。或者,作为另一种可能的实现方式,如果该Wi-Fi P2P连接信息不包括手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,在手机A所连接的GO设备的标识与自己所连接的GO设备的标识相同的情况下,手机B中的通信模块可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,从而确定可以与手机A之间通过Wi-Fi P2P连接传输第一应用的数据。
由于两个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输,因此,手机B中的通信模块也会向手机B中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。
S325,手机B中的P2P链路管理模块接收到该请求后,作为一种可能实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,手机B中的P2P链路管理模块便可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,则手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,并且,这两个Wi-Fi P2P连接分别均支持其他业务使用,则手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为再一种可能的实现方式,如果该请求中没有携带手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。由于手机B中通信模块中已经存储了既有的连接信息,该连接信息包括:手机B当前的连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机B中的P2P链路管理模块可以从通信模块处获取该连接信息,确定手机B所连接的GO设备的标识与自己所连接的GO设备的标识相同,即可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,则手机B中的 P2P链路管理模块确定手机B可以复用Wi-Fi P2P能力。
进一步的,手机B也可以维护一个引用计数,该引用计数用于指示同时利用手机BWi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机B维护的引用计数的值为1,表示手机B自身的Wi-Fi P2P能力承载了1个业务(手机B向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机B自身的Wi-Fi P2P能力承载了2个业务(手机B向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机B不会断开手机B和大屏设备之间的Wi-Fi P2P链路,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机B才会断开该Wi-Fi P2P链路。
S326,手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机B中的通信模块发送复用P2P能力成功的响应信息。
S327,手机B中的通信模块接收到该响应信息后,向手机B上的第一应用发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息包括:手机B与手机A之间可以通过Wi-Fi P2P连接传输第一应用的数据的指示信息、手机A的IP地址以及端口号、手机B自己生成的端口号信息等。
S328,手机B上的第一应用利用手机A的IP地址以及端口号信息,结合手机B的IP地址以及手机B自己生成的端口号等信息等,与手机A上的第一应用(例如为文件分享)建立socket传输通道。
S329,手机B上的第一应用基于socket传输通道,向手机A上的第一应用开始文件分享。其中,文件分享业务开始后,手机B先将分享文件的数据传输至大屏设备,大屏设备再将该分享文件的数据传输给手机A,即文件分享业务的数据流为:手机B→大屏设备→手机A。手机A的投屏业务的数据流为手机A→大屏设备,手机B投屏业务的数据流为手机B→大屏设备。
可选的,作为另外一种可能实现方式,图12所示的为在图10所示的场景中,本申请提供的另一例Wi-Fi P2P连接的方法的示意性流程图。其中,手机A和手机B分别通过各自Wi-Fi P2P连接正在投屏到大屏设备。如图12所示的,该方法包括:S401至S429。
S401,用户在手机B上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。
S402,在用户点击“Wi-Fi直连”后,手机B上的第一应用向手机B中的通信模块发送发现设备请求。
S403,手机B中的通信模块接收到该发现设备请求后,启动BLE扫描、BR扫描、WLAN扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。
S404,手机B中的通信模块扫描到设备后,将扫描到的设备列表发送给手机B上的第一应用,该设备列表中包含有一个或多个设备的设备标识。例如,显示的设备列表可以如图8中的d所示的。
S405,用户在手机B上的第一应用上选择设备列表中的手机A的设备标识,该手 机A的设备标识可以为手机A的设备型号、标识码、设备名称、设备ID(device ID)等。手机A的设备标识用于唯一标识该手机A。
S406,手机B上的第一应用向手机B中的通信模块发送Wi-Fi P2P连接请求。
S407,手机B中的通信模块接收到该Wi-Fi P2P连接请求后,首先和手机A中的通信模块建立第一连接。例如,该第一连接可以为BLE连接、蓝牙连接、Wi-Fi连接等。本申请实施例在此不作限制。
S408,手机B中的通信模块和手机A中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S409,手机B中的通信模块存储该加密秘钥和解密秘钥。
S410,手机A中的通信模块存储该加密秘钥和解密秘钥。
S411,由于手机B在与大屏设备建立Wi-Fi P2P连接后,手机B中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,因此手机B的通信模块里已经维护了既有的连接信息,该连接信息包括:手机B当前的Wi-Fi P2P连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址、标识等。而对于大屏设备而言,大屏设备中的通信模块也会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,由于大屏设备为GO角色,因此,该连接信息除了包括与自己(大屏设备)连接的设备(包括手机A和手机B)的Wi-Fi P2P连接状态、角色以及设备的地址信息外,还包括该P2P群组的信息。在本申请实施例中,该P2P群组信息包括:该P2P群组的SSID、BSSID、频率、密码(PASSWORD)中至少一种。因此,手B中的通信模块根据连接信息,确定手机B已经为GC,进而确定手机B不能与手机A之间直接建立Wi-Fi P2P连接。
S412,手机B中的通信模块向大屏设备中的通信模块发送连接请求,该连接请求包括:手机A的设备标识、手机A的Wi-Fi P2P端口的MAC地址、手机A的IP地址信息的至少一种。该连接请求用于请求:请求手机A与手机B之间通过Wi-Fi P2P连接传输第一应用数据。应理解,在本申请实施例中,手机B可以通过与手机A之间的第一连接,获取手机A的Wi-Fi P2P端口的MAC地址、手机A的IP地址等信息。
S413,大屏设备中的通信模块接收到该连接请求后,会对手机A进行校验。例如,会校验手机A是否为可信设备,以及判断大屏设备是否已经与手机A建立了连接。
S414,在确定大屏设备是GO设备、手机A是可信设备(例如,手机A和大屏设备登录的是同一个账号,或者手机A与大屏设备通过各种方式(例如通过二维码扫描等)进行过设备绑定),以及大屏设备已经与手机A建立了Wi-Fi P2P连接后,大屏设备中的通信模块向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该复用Wi-Fi P2P能力的请求可以包括:大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息。
S415,大屏设备中的P2P链路管理模块接收到该请求后,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求包括:大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息, 则大屏设备中的P2P链路管理模块可以确定大屏设备可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求不包括大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路的指示信息,由于大屏设备中的通信模块已经存储了既有的连接信息,该连接信息包括:与自己连接设备(包括手机B和手机A)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备分别与手机B和手机A之间已经存在Wi-Fi P2P链路,或者,确定大屏设备分别与手机A之间已经存在Wi-Fi P2P链路,并且,这两个Wi-Fi P2P链路支持其他业务使用,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机A和手机B分别向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为3,表示大屏设备自身的Wi-Fi P2P能力承载了3个业务(手机A和手机B分别向大屏设备的投屏业务、以及手机B向手机A的文件分享业务)。引用计数的值变为3后,若两个投屏业务均断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即两个投屏业务和一个文件分享业务均断开时,大屏设备才会拆除P2P群组。
S416,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用P2P能力成功的响应信息。
S417,大屏设备中的通信模块接收到该响应信息后,向手机B中的通信模块发送连接请求响应信息,该连接请求响应信息包括:允许手机A与手机B之间通过Wi-Fi P2P连接传输第一应用的数据的指示信息以及P2P群组信息以及手机A所连接的GO设备的标识。可选的,该连接请求响应信息还包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。在本申请实施例中,该P2P群组信息包括:P2P群组的SSID、BSSID、频率、密码(PASSWORD)中至少一种。
S418,手机B中的通信模块接收到该连接请求响应信息后,根据允许手机A与手机B之间通过Wi-Fi P2P连接传输第一应用的数据的指示信息,确定可以与手机B之间通过Wi-Fi P2P连接传输第一应用的数据。由于两个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,而对Wi-Fi P2P能力的复用是针对一个设备而言的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输。因此,手机B中的通信模块也会向手机B中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。复用Wi-Fi P2P能力的请求包括手机A所连接的GO设备的标识。可选的,该申请复用Wi-Fi P2P能力的请求还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。
S419,手机B中的P2P链路管理模块接收到该请求后,作为一种可能实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示 信息,手机B中的P2P链路管理模块便可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,则手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,并且,这两个Wi-Fi P2P连接分别均支持其他业务使用,则手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为再一种可能的实现方式,如果该请求中没有携带手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。由于手机B中的通信模块已经存储了既有的连接信息,该连接信息包括:手机B当前的连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机B中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定手机A所连接的GO设备的标识与自己所连接的GO设备的标识相同,手机B中的通信模块可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,则手机B中的P2P链路管理模块确定手机B可以复用Wi-Fi P2P能力。
进一步的,手机B也可以维护一个引用计数,该引用计数用于指示同时利用手机BWi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机B维护的引用计数的值为1,表示手机B自身的Wi-Fi P2P能力承载了1个业务(手机B向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机B自身的Wi-Fi P2P能力承载了2个业务(手机B向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机B不会断开手机B和大屏设备之间的Wi-Fi P2P链路,手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机B才会断开该Wi-Fi P2P链路。
S420,手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机B中的通信模块发送复用P2P能力成功的响应信息。
S421,手机B中的通信模块接收到该响应信息后,通过第一连接向手机A中的通信模块发送Wi-Fi P2P连接请求,该Wi-Fi P2P连接请求响应信息通过加密秘钥进行加密。该Wi-Fi P2P连接请求:P2P群组信息、手机B所连接的GO设备的标识。可选的,该Wi-Fi P2P连接还可以包括:手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。
S422,手机A中的通信模块接收到该Wi-Fi P2P连接请求后,利用解密秘钥进行解密,获取Wi-Fi P2P连接请求包括的内容,并确定手机B所连接的GO设备的标识与自己所连接的GO设备的标识是否相同。作为一种可能的实现方式,如果该Wi-Fi P2P连接信息包括手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,手机B中的通信模块根据手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,确定可以与手机A之间通过Wi-Fi P2P连接传输第一应用的数据。或者,作为另一种可能的实现方式,如果该Wi-Fi P2P连接信息不包括手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,在手机A所连接的GO设备的标识与自己所连接的GO设备的标识相同的情况下,手机B中的通信模块可以确定手机B 和手机A分别与大屏设备之间存在Wi-Fi P2P连接,从而确定可以与手机A之间通过Wi-Fi P2P连接传输第一应用的数据。
S423,在确定手机B可以与手机A之间通过Wi-Fi P2P连接传输第一应用的数据后。由于两个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输,因此,手机A中的通信模块也会向手机A中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。该复用Wi-Fi P2P能力的请求还可以包括:手机B所连接的GO设备的标识和手机A所连接的GO设备的标识相同的指示信息、或者,手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息、手机B所连接的GO设备的标识中的至少一个。
S424,手机A中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该请求中携带:手机B所连接的GO设备的标识与手机A所连接的GO设备的标识相同的指示信息,或者,手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,手机A中的P2P链路管理模块便可以确定手机A和手机B分别与大屏设备之间存在Wi-Fi P2P连接,则手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求中携带:手机B所连接的GO设备的标识与手机A所连接的GO设备的标识相同的指示信息,或者,手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息,并且,这两个Wi-Fi P2P连接分别均支持其他业务使用,则手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为再一种可能的实现方式,如果该请求中没有携带手机B所连接的GO设备的标识与手机A所连接的GO设备的标识相同的指示信息,或者手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接的指示信息。由于手机A中的通信模块中已经存储了既有的连接信息,该连接信息包括:手机A当前的连接状态和角色(例如:手机A已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机A中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定手机B所连接的GO设备的标识与自己所连接的GO设备的标识相同,则可以确定手机B和手机A分别与大屏设备之间存在Wi-Fi P2P连接,手机B中的P2P链路管理模块确定手机B可以复用Wi-Fi P2P能力。
进一步的,手机A也可以维护一个引用计数,该引用计数用于指示同时利用手机A Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机A维护的引用计数的值为1,表示手机A自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机A自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务以及手机B向手机A的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机A不会断开手机A和大屏设备之间的Wi-Fi P2P链路)手机B还可以正常的向手机A分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机A才会断开该Wi-Fi P2P链路。
S425,手机A中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机A中的通信模块发送复用P2P能力成功的响应信息。
S426,手机A中的通信模块接收到该响应信息后,向手机B中的通信模块发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息通过加密秘钥进行加密。该Wi-Fi P2P连接请求响应信息包括:允许手机A与手机B之间通过Wi-Fi P2P连接传输第一应用的数据的指示信息、手机A的IP地址以及端口号信息等。
S427,手机B中的通信模块收到该Wi-Fi P2P连接请求响应信息后,向手机B上的第一应用发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息包括:允许手机A与手机B之间通过Wi-Fi P2P连接传输第一应用的数据的指示信息、手机A的IP地址以及端口号信息、手机B自己生成的端口号等。
S428,手机B上的第一应用利用手机A的IP地址以及端口号信息、结合手机B的IP地址以及手机B自己生成的端口号等信息,与手机A上的第一应用(例如为文件分享)建立socket传输通道。
S429,手机B上的第一应用基于socket传输通道,向手机A上的第一应用开始文件分享。其中,文件分享业务开始后,手机B先将分享文件的数据传输至大屏设备,大屏设备再将该分享文件的数据传输给手机A,即文件分享业务的数据流为:手机B→大屏设备→手机A。投屏业务的数据流为手机A→大屏设备以及手机B→大屏设备。
在本申请实施例中,在一个文件分享业务和两个投屏业务这三个业务都完成后,即大屏设备维护的引用计数为0的情况下,才会进行P2P群组以及GO设备的移除。在一个文件分享业务和两个投屏业务中任意一个完成后,手机A、手机B以及大屏设备维护的引用计数均减为1,由于引用计数不为0,在这种情况下,不会进行GO设备以及P2P群组的拆除。
本申请提供的Wi-Fi P2P连接的方法,P2P群组内的第一电子设备(GC设备)和第三电子设备(另一个GC设备)之间可以使用多种发现方式相互发现,并且当P2P群组内的第一电子设备和第三电子设备无法直接进行Wi-Fi P2P连接时,第一电子设备将P2P群组内的第二电子设备(GO设备)作为中介设备,协助自己和第三电子设备建立socket传输通道,从而形成二者互通的基础。同时P2P群组内的第一电子设备和第三电子设备之间可以获取对方的IP地址和端口号,从而实现二者之间基于socket传输通道的数据传输。并且对第一电子设备、第二电子设备以及第三电子设备的Wi-Fi P2P能力进行复用,第一电子设备、第二电子设备以及第三电子设备可以感知到当前自身的Wi-Fi P2P能力承载了多个业务,在多个业务都完成后,才会进行P2P群组移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以正常的传输,不同的业务之间不会相互影响。在进行数据传输时,通过P2P群组内的第二电子设备作为中转。进而实现基于Wi-Fi P2P连接的业务的传输,解决了现有技术中P2P群组内的两个GC设备之间无法传输数据的问题,提高了用户体验。
图13所示的另一例适用于本申请实施例的通信***的示意图。如图13所示的,该***架构包括:第一电子设备、第二电子设备以及第四电子设备,其中,第二电子设备和第一电子设备之间已经建立了Wi-Fi P2P连接,换句话说,第二电子设备和第一电子设备已经组成一个P2P群组,在该P2P群组内,第二电子设备为GO设备或者 为AP设备,第一电子设备为GC设备。第四电子设备为该P2P群组外的一个空闲设备,第四电子设备和其他设备之间没有Wi-Fi P2P连接。在图13所示的例子中,第四电子设备为手机C为例、第一电子设备为手机A为例,第二电子设备为大屏设备(例如为智能电视)为例。手机A正在投屏到大屏设备,然后手机C(空闲设备)需要发起到大屏设备的文件分享。手机A与大屏设备投屏是使用的Wi-Fi P2P链路。
图14所示的为在图13所示的场景中,本申请提供的一例Wi-Fi P2P连接的方法的示意性流程图。如图14所示的,该方法包括:S501至S522。
S501,手机A与大屏设备已经基于建立的Wi-Fi P2P连接进行第二应用(即投屏应用)业务数据的传输。
S502,用户在手机C上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。
S503,在用户点击“Wi-Fi直连”后,手机C上的第一应用向手机C中的通信模块发送发现设备请求。
S504,手机C中的通信模块接收到该发现设备请求后,启动BLE扫描、BR扫描、WLAN扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。
S505,手机C中的通信模块扫描到设备后,将扫描到的设备列表发送给手机C上的第一应用,该设备列表中包含有一个或多个设备的设备标识。例如,显示的设备列表可以如图8中的d所示的。
S506,用户在手机C上的第一应用上选择设备列表中的大屏设备的设备标识,该大屏设备的设备标识可以为大屏设备的设备型号、标识码、设备名称、设备ID(device ID)等。大屏设备的设备标识用于唯一标识该大屏设备。
S507,用户在设备列表中点击大屏设备的设备标识后,手机C上的第一应用会向手机C中的通信模块发送Wi-Fi P2P连接请求。
S508,手机C中的通信模块接收到该Wi-Fi P2P连接请求后,首先和大屏设备中的通信模块建立第一连接的请求。例如,该第一连接可以为BLE连接、BR连接、Wi-Fi连接等。本申请实施例在此不作限制。
S509,手机C中的通信模块和大屏设备中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S510,手机C中的通信模块存储该加密秘钥和解密秘钥。
S511,大屏设备中的通信模块存储该加密秘钥和解密秘钥。
S512,手机C中的通信模块通过第一连接向大屏设备中的通信模块发送Wi-Fi P2P连接请求。该Wi-Fi P2P连接请求利用加密秘钥进行加密。该Wi-Fi P2P连接请求包括:手机C的设备信息(例如设备ID等)、手机C当前的Wi-Fi P2P连接状态(手机C当前的Wi-Fi P2P连接状态包括:手机C当前没有与任何设备之间存在Wi-Fi P2P连接的状态,该连接状态可以用0表示;手机C当前与其他设备之间存在Wi-Fi P2P连接,且手机C的角色为GO的状态,该连接状态可以用1表示;手机C当前与其他设备之间存在Wi-Fi P2P连接,且手机C的角色为GC的状态,该连接状态可以用2表示。在本实施例中,手机C当前无Wi-Fi P2P连接,手机C当前的Wi-Fi P2P连接状态用0 表示)、手机C的Wi-Fi P2P端口的MAC地址、手机C支持的信道列表(例如为支持36信道,对应5180MHz)、手机C预期的连接方式(例如手机C期望以GC的身份建立Wi-Fi P2P连接,或者手机C期望以GO的身份建立Wi-Fi P2P连接,在本实施例中,手机C期望是以GC的身份建立Wi-Fi P2P连接)、手机C连接的Wi-Fi热点的频率、是否支持宽频(例如是否支持160MHz,如果支持可以用true表示,如果不支持可以用false表示)等信息。
S513,大屏设备中的通信模块接收到该Wi-Fi P2P连接请求后,利用该解密秘钥进行解密,会校验手机C是否为可信设备,以及判断大屏设备是否已经与手机C建立了Wi-Fi P2P连接。
S514,在手机A在与大屏设备建立Wi-Fi P2P连接后,大屏设备已经维护了既有的连接信息,该连接信息包括:与自己连接设备(包括手机A)的Wi-Fi P2P连接状态、角色(GC)以及这些设备的地址信息、P2P群组的信息等。在确定大屏设备没有与手机C建立Wi-Fi P2P连接,大屏设备是GO设备,并且手机C是可信设备(例如,手机C和大屏设备登录的是同一个账号,或者手机C与大屏设备通过各种方式(例如通过二维码扫描等)进行过设备绑定)后,大屏设备中的通信模块向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的。该申请复用Wi-Fi P2P能力的请求包括:大屏设备与手机A之间存在Wi-Fi P2P连接,大屏设备是GO设备。
S515,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求包括:大屏设备与手机A之间存在Wi-Fi P2P连接,大屏设备是GO设备,则可以确定大屏设备可以复用Wi-Fi P2P能力。或者,作为另外一种可能的实现方式,如果该申请复用Wi-Fi P2P能力的请求不包括:大屏设备与手机A之间存在Wi-Fi P2P连接,大屏设备是GO设备,由于大屏设备中的通信模块已经维护了既有的连接信息,该连接信息包括:与自己连接设备(包括手机A)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备与手机A之间存在Wi-Fi P2P连接,大屏设备是GO设备,即确定P2P群组是存在的,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为1,表示大屏设备自身的Wi-Fi P2P能力承载了1个业务(手机A向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机A向大屏设备的投屏业务、以及手机C向大屏设备的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机C还可以正常的向大屏设备分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,大屏设备才会拆除P2P群组。
S516,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用P2P能力成功的响应信息。
S517,大屏设备中的通信模块接收到该响应信息,通过第一连接向手机C中的通 信模块发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息利用加密秘钥进行加密。该Wi-Fi P2P连接请求响应信息包括:允许手机C加入P2P群组的指示信息、手机A和大屏设备组成的P2P群组的信息、大屏设备为手机C分配的IP地址、大屏设备的IP地址以及端口号等。应理解,该Wi-Fi P2P连接请求响应信息中可以包括:允许手机C加入P2P群组的指示信息、以及手机A和大屏设备组成的P2P群组的信息中任意一个,而不必同时包括允许手机C加入P2P群组的指示信息和手机A和大屏设备组成的P2P群组的信息。
S518,手机C中的通信模块接收到该连接请求响应信息并利用解密秘钥进行解密后,确定可以加入P2P群组,则向手机C中的P2P链路管理模块发送加入P2P群组的请求,该请求中携带P2P群组信息以及大屏设备的IP地址以及端口号。
S519,手机C中的P2P链路管理模块根据该P2P群组信息以及大屏设备的IP地址以及端口号,通过连接接口,直接发起到大屏设备的Wi-Fi P2P连接,加入P2P群组后,手机C中的P2P链路管理模块向手机C中的通信模块发送响应信息,用于向手机C中的通信模块通知手机C加入P2P群组成功。
S520,手机C中的通信模块接收到该响应信息后,向手机C上的第一应用发送Wi-Fi P2P连接请求响应信息,用于向手机C上的第一应用通知手机C加入P2P群组成功,该Wi-Fi P2P连接请求响应信息携带:大屏设备为手机C分配的IP地址、手机C自己生成的端口号、大屏设备的IP地址以及端口号。
S521,手机C加入P2P群组后,手机C上的第一应用(即文件分享应用)利用大屏设备为手机C分配的IP地址以及手机C自己生成的端口号,结合大屏设备的IP地址以及端口号等,与大屏设备上的第一应用(文件分享应用)建立socket传输通道。
S522,手机C上的第一应用基于socket传输通道,向大屏设备上的第一应用开始文件分享。其中,文件分享业务开始后,文件分享业务的数据流为:手机C→大屏设备。投屏业务的数据流为手机A→大屏设备。
在本申请实施例中,在文件分享业务和投屏业务这两个业务都完成后,才会进行P2P群组的移除,即进行GO设备以及P2P群组的拆除。换句话说,当大屏设备维护的引用计数为0时,才进行GO设备以及P2P群组的拆除。在文件分享业务和投屏业务中任意一个完成后,大屏设备维护的引用计数减为1,由于引用计数不为0,在这种情况下,不会进行GO设备以及P2P群组的拆除。
本申请提供的Wi-Fi P2P连接的方法,通过对第二电子设备(GO设备)的P2P链路进行管理,在第二电子设备与P2P群组内的第一电子设备(GC设备)之间已经存在基于Wi-Fi P2P业务(或者应用)的情况下,P2P群组外的第四电子设备(空闲设备)发起到第二电子设备(GO设备)的Wi-Fi P2P连接以进行另外的业务数据传输时,第二电子设备会对第二电子设备的Wi-Fi P2P能力进行复用,这样第二电子设备就可以感知到当前自身承载了多个业务,在该多个业务都传输完成后,才会进行P2P群组以及GO设备的移除,从而保证了不同的业务均可以传输完成,不同的业务之间不会相互影响,提高了用户体验。
图15所示的另一例适用于本申请实施例的通信***的示意图。如图15所示的,该***架构包括:第一电子设备和第二电子设备,其中,第一电子设备和第二电子设 备之间已经建立了Wi-Fi P2P连接,换句话说,第一电子设备和第二电子设备已经组成一个群组,在该群组内,第二电子设备为GO设备或者为AP设备,第一电子设备为GC设备。在图15所示的例子中,第一电子设备为手机B为例、第二电子设备为大屏设备(例如为智能电视)为例。手机B(GC设备)正在投屏到大屏设备(GO设备),然后手机B需要发起到大屏设备的文件分享。
图16所示的为在图15所示的场景中,本申请提供的一例Wi-Fi P2P连接的方法的示意性流程图。如图16所示的,该方法包括:S601至S625。
S601,手机B与大屏设备已经基于建立的Wi-Fi P2P连接进行第二应用(即投屏应用)业务数据的传输。
S602,用户在手机B上打开第一应用(即文件管理应用),例如,如图8中的a所示的,选择需要分享的文件(例如为文件1),点击“分享”,选择分享方式为“Wi-Fi直连”,如图8中的b和c所示的。
S603,在用户点击“Wi-Fi直连”后,手机B上的第一应用向手机B中的通信模块发送发现设备请求。
S604,手机B中的通信模块接收到该发现设备请求后,启动经典蓝牙、BLE扫描、WLAN扫描或者Wi-Fi P2P扫描等发现设备的方式来发现设备。在本申请实施例中,经典蓝牙包括BR)和EDR两种类型的蓝牙中的至少一种。
S605,手机B中的通信模块扫描到设备后,将扫描到的设备列表发送给手机B上的第一应用,该设备列表中包含有一个或多个设备的设备标识。例如,显示的设备列表可以如图8中的d所示的。
S606,用户在手机B上的第一应用上选择设备列表中的大屏设备的设备标识,该大屏设备的设备标识可以为大屏设备的设备型号、标识码、设备名称、设备ID(device ID)等。大屏设备的设备标识用于唯一标识该大屏设备。
S607,用户在设备列表中点击大屏设备的设备标识后,手机B上的第一应用会向手机B中的通信模块发送Wi-Fi P2P连接请求。该Wi-Fi P2P连接请求包括手机A的设备标识。
S608,手机B中的通信模块接收到该Wi-Fi P2P连接请求后,首先和大屏设备中的通信模块建立第一连接的请求。例如,该第一连接可以为BLE连接、蓝牙连接、Wi-Fi连接等。本申请实施例在此不作限制。
S609,手机B中的通信模块和大屏设备中的通信模块基于第一连接进行秘钥的协商,得到加密秘钥和解密秘钥,从而完成基于第一连接的安全认证。
S610,手机B中的通信模块存储该加密秘钥和解密秘钥。
S611,大屏设备中的通信模块存储该加密秘钥和解密秘钥。
S612,由于手机B在与大屏设备建立Wi-Fi P2P连接后,手机B中的通信模块会收到FRAMEWORK层上报的连接状态变化通知,该通知携带着基本的连接信息,因此手机B的通信模块里已经维护了既有的连接信息,该连接信息包括:手机B当前的Wi-Fi P2P连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC,该信息可以用2表示)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。而对于大屏设备而言,大屏设备中的通信模块也会收到FRAMEWORK 层上报的连接状态变化通知,该通知携带着基本的连接信息,由于大屏设备为GO角色,因此,该连接信息除了包括与自己(大屏设备)连接的设备(包括手机B)的Wi-Fi P2P连接状态、角色以及设备的地址信息外,还包括该P2P群组的信息。在本申请实施例中,该P2P群组信息包括:该P2P群组的服务集标识(service set identifier,SSID)、基本服务集标识(basicservice set identifier,BSSID)、频率、密码(PASSWORD)中至少一种。因此,手机B中的通信模块根据已经存储的连接信息,确定手机B已经为GC,确定自己已经与大屏设备之间存在对应于第二应用的Wi-Fi P2P连接(已有的Wi-Fi P2P连接)。
S613,手机B中的通信模块通过第一连接向大屏设备中的通信模块发送Wi-Fi P2P连接请求。该Wi-Fi P2P连接请求用于请求:允许手机B利用该已有的Wi-Fi P2P连接传输第一应用的业务数据的授权。该Wi-Fi P2P连接请求利用加密秘钥进行加密。该Wi-Fi P2P连接请求包括:手机B的设备标识、手机B当前的Wi-Fi P2P连接状态(手机B当前的Wi-Fi P2P连接状态包括:手机B当前没有与任何设备之间存在Wi-Fi P2P连接的状态,该连接状态可以用0表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GO的状态,该连接状态可以用1表示;手机B当前与其他设备之间存在Wi-Fi P2P连接,且手机B的角色为GC的状态,该连接状态可以用2表示。在本实施例中,手机B当前已经存在Wi-Fi P2P连接,并且角色为GC,手机B当前的Wi-Fi P2P连接状态用2表示)、手机B的Wi-Fi P2P端口的媒体接入控制(media access control,MAC)地址、手机B支持的信道列表(例如为支持36信道,对应5180MHz)、手机B预期的连接方式(例如手机B期望以GC的身份建立Wi-Fi P2P连接,或者手机B期望以GO的身份建立Wi-Fi P2P连接,在本实施例中,手机B期望是以GC的身份建立Wi-Fi P2P连接)、手机B连接的Wi-Fi热点的频率、是否支持宽频(例如是否支持160MHz,如果支持可以用true表示,如果不支持可以用false表示)等信息中的至少一个。
S614,大屏设备中的通信模块接收到该Wi-Fi P2P连接请求后,利用该解密秘钥进行解密。在手机B在与大屏设备建立Wi-Fi P2P连接后,大屏设备也已经维护了既有的连接信息,该连接信息包括:与自己连接设备(包括手机B)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。因此,大屏设备可以根据该连接信息,确定大屏设备和手机B处于一个P2P群组内,并且,自己已经与手机B之间已经存在Wi-Fi P2P连接。该Wi-Fi P2P连接用于传输手机B向大屏设备投屏的数据流。
S615,大屏设备中的通信模块向大屏设备中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求包括:手机B和大屏设备之间存在Wi-Fi P2P连接的指示信息。
S616,大屏设备中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该请求中携带:手机B和大屏设备之间存在Wi-Fi P2P连接的指示信息,手机B中的P2P链路管理模块便可以确定手机B与大屏设备之间存在Wi-Fi P2P连接,则手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该请求没有携带:手机B和大屏设备之间存在Wi-Fi P2P连接的 指示信息,由于大屏设备中的通信模块已经存储了既有的连接信息,该连接信息包括:与自己连接设备(包括手机B)的Wi-Fi P2P连接状态、角色以及这些设备的地址信息、P2P群组的信息等。大屏设备中的P2P链路管理模块可以从通信模块处获取该连接信息,从而根据该连接信息,确定大屏设备与手机B之间已经存在Wi-Fi P2P链路,或者,确定大屏设备已经存与手机B之间已经存在Wi-Fi P2P链路,并且,该Wi-Fi P2P链路支持其他业务使用,则可以确定大屏设备可以复用Wi-Fi P2P能力。
进一步的,大屏设备可以维护一个引用计数,该引用计数用于指示同时利用大屏设备Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,大屏设备维护的引用计数的值为1,表示大屏设备自身的Wi-Fi P2P能力承载了1个业务(手机B向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示大屏设备自身的Wi-Fi P2P能力承载了2个业务(手机B向大屏设备的投屏业务以及手机B向大屏设备的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此大屏设备不会拆除P2P群组,手机B还可以正常的向大屏设备分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,大屏设备才会拆除P2P群组。
S617,大屏设备中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向大屏设备中的通信模块发送复用Wi-Fi P2P能力成功的响应信息。
S618,大屏设备中的通信模块接收到该复用Wi-Fi P2P能力成功的响应信息后,通过第一连接向手机B中的通信模块发送Wi-Fi P2P连接请求响应信息,该Wi-Fi P2P连接请求响应信息利用加密秘钥进行加密。该Wi-Fi P2P连接请求响应信息包括:允许手机B利用该已有的Wi-Fi P2P连接传输第一应用的业务数据的指示信息、手机B和大屏设备组成的P2P群组的信息、大屏设备的IP地址以及端口号等信息。
S619,手机B中的通信模块接收到该连接请求响应信息并利用解密秘钥进行解密后,确定手机B可以利用该已有的Wi-Fi P2P连接传输第一应用的业务数据。
S620,由于两个设备之间的Wi-Fi P2P链路(或者Wi-Fi P2P连接)是需要这两个设备共同维护的,而对Wi-Fi P2P能力的复用是针对一个设备而言的,只对某一台设备申请Wi-Fi P2P能力复用,只可以保证这台设备在业务存续期间不会主动断开Wi-Fi P2P链路,对端设备无法保证不会主动断开该Wi-Fi P2P链路,最终还是会影响到业务传输,因此,手机B中的通信模块也会向手机B中的P2P链路管理模块发送申请复用Wi-Fi P2P能力的请求。可选的,该申请复用Wi-Fi P2P能力的请求包括:手机B和大屏设备之间存在Wi-Fi P2P连接的指示信息。
S621,手机B中的P2P链路管理模块接收到该请求后,作为一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求包括:手机B和大屏设备之间存在Wi-Fi P2P连接的指示信息,则手机B中的P2P链路管理模块可以确定手机B可以复用Wi-Fi P2P能力。或者,作为另一种可能的实现方式,如果该复用Wi-Fi P2P能力的请求不包括手机B和大屏设备之间存在Wi-Fi P2P连接的指示信息,由于手机B中的通信模块已经存储了既有的连接信息,该连接信息包括:手机B当前的连接状态和角色(例如:手机B已经存在Wi-Fi P2P连接且角色为GC)、所连接的设备(大屏设备)的角色(为GO)以及大屏设备的MAC地址等。手机B中的P2P链路管理模块可以从通信模块处 获取该连接信息,从而根据该连接信息,则可以确定手机B可以复用Wi-Fi P2P能力。
进一步的,手机B可以维护一个引用计数,该引用计数用于指示同时利用手机B Wi-Fi P2P能力的业务(或者应用)的个数。在确定可以复用Wi-Fi P2P能力前,手机B维护的引用计数的值为1,表示手机B自身的Wi-Fi P2P能力承载了1个业务(手机B向大屏设备的投屏业务)。在确定可以复用Wi-Fi P2P能力后,引用计数的值加1,变为2,表示手机B自身的Wi-Fi P2P能力承载了2个业务(手机B向大屏设备的投屏业务以及手机B向大屏设备的文件分享业务)。引用计数的值变为2后,若投屏业务断开,引用计数变为1,由于引用计数不为0,因此手机B不会断开与大屏设备之间的Wi-Fi P2P链路,手机B还可以正常的向大屏设备分享文件。只有在引用计数变为0,即投屏业务和文件分享业务均断开时,手机B不会断开与大屏设备之间的Wi-Fi P2P连接。
S622,手机B中的P2P链路管理模块确定可以复用Wi-Fi P2P能力后,向手机B中的通信模块发送复用P2P能力成功的响应信息。
S623,手机B中的通信模块接收到复用P2P能力成功的响应信息,向手机B上的第一应用发送Wi-Fi P2P连接请求响应信息,用于向手机B上的第一应用通知可以利用已有的Wi-Fi P2P连接传输第一应用的业务数据。该Wi-Fi P2P连接请求响应信息包括大屏设备的IP地址以及端口号、以及手机B自己生成的端口号等信息。
S624,手机B上的第一应用接收到该Wi-Fi P2P连接请求响应信息后,利用手机B的IP地址以及手机B自己生成的端口号,结合大屏设备的IP地址以及端口号,与大屏设备上的第一应用(文件分享应用)建立socket传输通道。
S625,手机B上的第一应用基于socket传输通道,向大屏设备上的第一应用开始文件分享。其中,文件分享业务开始后,文件分享业务的数据流为:手机B→大屏设备。投屏业务的数据流为手机B→大屏设备。
在本申请实施例中,在文件分享业务和投屏业务这两个业务都完成后,才会进行P2P群组的移除,即进行GO设备以及P2P群组的拆除。换句话说,在大屏设备和手机B维护的引用计数为0时,才进行GO设备以及P2P群组的拆除。在文件分享业务和投屏业务中任意一个完成后,手机B以及大屏设备维护的引用计数均减为1,由于引用计数不为0,在这种情况下,不会进行GO设备以及P2P群组的拆除,即不会拆除大屏设备和手机B之间的Wi-Fi P2P连接。
本申请提供的Wi-Fi P2P连接的方法,通过对第一电子设备(GO设备)和第二电子设备(GC设备)的Wi-Fi P2P能力进行复用,这样第一电子设备和第二电子设备就可以感知到当前自身承载了多个业务,其中的任意一个业务断开时,都不会真正地造成P2P群组的移除以及Wi-Fi P2P连接的断开,在该多个业务都完成后,才会进行GO设备的移除以及Wi-Fi P2P连接的断开,从而保证了不同的业务均可以完整的传输完成,实现了第一电子设备和第二电子设备之间的多个Wi-Fi P2P业务同时共存,提高了用户体验。不同的业务之间不会相互影响,提高了用户体验。
应理解,上述只是为了帮助本领域技术人员更好地理解本申请实施例,而非要限制本申请实施例的范围。本领域技术人员根据所给出的上述示例,显然可以进行各种等价的修改或变化,例如,上述各个方法某些步骤可以不必须的,或者可以新加入某 些步骤等。或者上述任意两种或者任意多种实施例的组合。这样的修改、变化或者组合后的方案也落入本申请实施例的范围内。
还应理解,本申请实施例中的方式、情况、类别以及实施例的划分仅是为了描述的方便,不应构成特别的限定,各种方式、类别、情况以及实施例中的特征在不矛盾的情况下可以相结合。
还应理解,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
还应理解,上文对本申请实施例的描述着重于强调各个实施例之间的不同之处,未提到的相同或相似之处可以互相参考,为了简洁,这里不再赘述。
上述结合图1-图16描述了本申请实施例提供的Wi-Fi直连下数据传输的方法的实施例,下面描述本申请实施例提供的电子设备。
本实施例可以根据上述方法,对电子设备(包括上述的第一电子设备、第二电子设备、第三电子设备以及第四电子设备)进行功能模块的划分。例如,可以对应各个功能,划分为各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
需要说明的是,上述方法实施例涉及的各步骤的相关内容,均可以援引到对应功能模块的功能描述,此处不再赘述。
本申请实施例提供的电子设备,用于执行上述方法实施例提供任一种Wi-Fi直连下数据传输的方法,因此可以达到与上述实现方法相同的效果。在采用集成的单元的情况下,电子设备可以包括处理模块、存储模块和通信模块。其中,处理模块可以用于对电子设备的动作进行控制管理。例如,可以用于支持电子设备执行处理单元执行的步骤。存储模块可以用于支持存储程序代码和数据等。通信模块,可以用于支持电子设备与其他设备的通信。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他电子设备交互的设备。
示例性地,图17示出了本申请提供的一例电子设备700的硬件结构示意图。该电子设备700可以为上述的第一终端设备、第二终端设备或者第三终端设备。如图14所示,电子设备700可包括处理器710,外部存储器接口720,内部存储器721,通用串行总线(universal serial bus,USB)接口730,充电管理模块740,电源管理模块741,电池742,天线1,天线2,无线通信模块750等。
可以理解的是,本申请实施例示意的结构并不构成对电子设备700的具体限定。在本申请另一些实施例中,电子设备700可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬 件的组合实现。
处理器710可以包括一个或多个处理单元。例如:处理器710可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的部件,也可以集成在一个或多个处理器中。在一些实施例中,电子设备700也可以包括一个或多个处理器710。其中,控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
在一些实施例中,处理器710可以包括一个或多个接口。接口可以包括集成电路间(inter-integrated circuit,I2C)接口,集成电路间音频(integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,SIM卡接口,和/或USB接口等。其中,USB接口730是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口2530可以用于连接充电器为电子设备700充电,也可以用于电子设备700与***设备之间传输数据。
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备700的结构限定。在本申请另一些实施例中,电子设备700也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
电子设备700的无线通信功能可以通过天线1,天线2以及无线通信模块750等实现。
无线通信模块750可以提供应用在电子设备700上的包括Wi-Fi(包括Wi-Fi感知和Wi-Fi AP),蓝牙(bluetooth,BT),无线数传模块(例如,433MHz,868MHz,715MHz)等无线通信的解决方案。无线通信模块750可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块750经由天线1或者天线2(或者,天线1和天线2)接收电磁波,将电磁波信号滤波以及调频处理,将处理后的信号发送到处理器710。无线通信模块750还可以从处理器710接收待发送的信号,对其进行调频,放大,经天线1或者天线2转为电磁波辐射出去。
外部存储器接口720可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备700的存储能力。外部存储卡通过外部存储器接口720与处理器710通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器721可以用于存储一个或多个计算机程序,该一个或多个计算机程序包括指令。处理器710可以通过运行存储在内部存储器721的上述指令,从而使得电子设备700执行本申请一些实施例中所提供的Wi-Fi直连下数据传输的方法,以及各种应用以及数据处理等。内部存储器721可以包括代码存储区和数据存储区。其中,代码存储区可存储操作***。数据存储区可存储电子设备700使用过程中所创建的数据等。此外,内部存储器721可以包括高速随机存取存储器,还可以包括非易失性存储器,例如一个或多个磁盘存储部件,闪存部件,通用闪存存储器(universal flash storage,UFS)等。在一些实施例中,处理器710可以通过运行存储在内部存储器721的指令,和/或存储在设置于处理器710中 的存储器的指令,来使得电子设备700执行本申请实施例中所提供任一种的Wi-Fi直连下数据传输的方法,以及其他应用及数据处理。
电子设备700包括但不限于智能电视、大屏设备、手机、平板电脑、笔记本、大屏电视、智能家居单品、PDA、POS、车载电脑等。本申请实施例在此不作限制。
应理解,电子设备700执行上述相应步骤的具体过程请参照前文中结合图7、图9、图11、图12、图14、图16各个实施例中描述的第一电子设备、第二电子设备、第三电子设备或者第四电子设备执行步骤的相关描述,为了简洁,这里不加赘述。
图18示出了本申请实施例的提供的另一例通信装置800的示意性框图,该通信装置800可以对应上述各个方法中各个实施例中描述第一电子设备、第二电子设备、第三电子设备或者第四电子设备,也可以是应用于第一电子设备、第二电子设备、第三电子设备或者第四电子设备的芯片或组件,并且,该通信装置800中的各模块或单元分别用于执行上述各个方法中描述的第一电子设备、第二电子设备、第三电子设备或者第四电子设备所执行的各动作或处理过程,如图18所示,该通信装置800可以包括:处理单元810和通信单元820。可选的,该通信装置800还可以包括存储单元830。
应理解,通信装置800中各单元执行上述相应步骤的具体过程请参照前文中结合图7、图9、图11、图12、图14和图16中各个实施例中描述的第一电子设备、第二电子设备、第三电子设备或者第四电子设备执行步骤的相关描述,为了简洁,这里不加赘述。
可选的,通信单元820可以包括接收单元(模块)和发送单元(模块),用于执行前述各个方法实施例中第一终端设备、第二终端设备或者第三终端设备接收信息和发送信息的步骤。存储单元830用于存储处理单元810和通信单元820执行的指令。处理单元810、通信单元820和存储单元830通信连接,存储单元830存储指令,处理单元810用于执行存储单元830存储的指令,通信单元820用于在处理单元810的驱动下执行具体的信号收发。
应理解,通信单元820可以是收发器、输入/输出接口或接口电路等,例如可以由图17所示实施例中的无线通信模块750实现。存储单元可以是存储器,例如,可以由图17所示实施例中的外部存储器接口720或者内部存储器721实现。处理单元810可以由图17所示实施例中处理器710,或者可以由处理器710及内部存储器721实现。
还应理解,图18所示的通信装置800可以为上述的第一电子设备、第二电子设备、第三电子设备或者第四电子设备,或者,第一电子设备、第二电子设备、第三电子设备或者第四电子设备可以包括图18所示的通信装置800。
还应理解,以上装置中单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且装置中的单元可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分单元以软件通过处理元件调用的形式实现,部分单元以硬件的形式实现。例如,各个单元可以为单独设立的处理元件,也可以集成在装置的某一个芯片中实现,此外,也可以以程序的形式存储于存储器中,由装置的某一个处理元件调用并执行该单元的功能。这里该处理元件又可以称为处理器,可以是一种具有信号处理能力的集成电路。在实现过程中,上述方法的各步骤或以上各个单元可以通过处理器元件中的硬件的集成逻 辑电路实现或者以软件通过处理元件调用的形式实现。在一个例子中,以上任一装置中的单元可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个专用集成电路(application specific integrated circuit,ASIC),或,一个或多个数字信号处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA),或这些集成电路形式中至少两种的组合。再如,当装置中的单元可以通过处理元件调度程序的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序的处理器。再如,这些单元可以集成在一起,以片上***(system-on-a-chip,SOC)的形式实现。
本申请实施例还提供了一种Wi-Fi直连下数据传输的***,该***包括:上述方法实施例中提供的第一电子设备、第二电子设备,可选的,该***还可以包括上述方法实施例中提供的第三电子设备或者第四电子设备。
本申请实施例还提供了一种计算机可读存储介质,用于存储计算机程序代码,该计算机程序包括用于执行上述本申请实施例提供的任意一种Wi-Fi直连下数据传输的方法的指令。该可读介质可以是只读存储器(read-only memory,ROM)或随机存取存储器(random access memory,RAM),本申请实施例对此不做限制。
本申请还提供了一种计算机程序产品,该计算机程序产品包括指令,当该指令被执行时,以使得第一电子设备、第二电子设备、第三电子设备或者第四电子设备执行对应于上述方法中的对应的操作。
本申请实施例还提供了一种位于通信装置中的芯片,该芯片包括:处理单元和通信单元,该处理单元,例如可以是处理器,该通信单元例如可以是输入/输出接口、管脚或电路等。该处理单元可执行计算机指令,以使所述通信装置执行上述本申请实施例提供的任一种Wi-Fi直连下数据传输的方法。
可选地,该计算机指令被存储在存储单元中。
可选地,该存储单元为该芯片内的存储单元,如寄存器、缓存等,该存储单元还可以是该终端内的位于该芯片外部的存储单元,如ROM或可存储静态信息和指令的其他类型的静态存储设备,随机RAM等。其中,上述任一处提到的处理器,可以是一个CPU,微处理器,ASIC,或一个或多个用于控制上述的反馈信息的传输方法的程序执行的集成电路。该处理单元和该存储单元可以解耦,分别设置在不同的物理设备上,通过有线或者无线的方式连接来实现该处理单元和该存储单元的各自的功能,以支持该***芯片实现上述实施例中的各种功能。或者,该处理单元和该存储器也可以耦合在同一个设备上。
其中,本实施例提供的通信装置、计算机可读存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
可以理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是ROM、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是RAM,其用作外部高速缓存。RAM有多种不同的类型,例如静态 随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synch link DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
在本申请中可能出现的对各种消息/信息/设备/网元/***/装置/动作/操作/流程/概念等各类客体进行了赋名,可以理解的是,这些具体的名称并不构成对相关客体的限定,所赋名称可随着场景,语境或者使用习惯等因素而变更,对本申请中技术术语的技术含义的理解,应主要从其在技术方案中所体现/执行的功能和技术效果来确定。
在本申请的各个实施例中,如果没有特殊说明以及逻辑冲突,不同的实施例之间的术语和/或描述具有一致性、且可以相互引用,不同的实施例中的技术特征根据其内在的逻辑关系可以组合形成新的实施例。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请的实施例中的方法可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机程序或指令。在计算机上加载和执行所述计算机程序或指令时,全部或部分地执行本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机程序或指令可以存储在计算机可读存储介质中,或者通过所述计算机可读存储介质进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是集成一个或多个可用介质的服务器等数据存储设备。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的***、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的***、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个可读存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的可读存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (60)

  1. 一种Wi-Fi直连下数据传输的方法,其特征在于,所述方法应用于包括第一电子设备和第二电子设备的***中,所述第一电子设备为Wi-Fi直连群组内的GC设备,所述第二电子设备为所述Wi-Fi直连群组内的GO设备;所述方法包括:
    所述第一电子设备和所述第二电子设备通过第一Wi-Fi直连链路传输第一业务的数据;
    所述第一电子设备接收用户的第一操作,所述第一操作用于向所述第二电子设备发送第二业务的数据,所述第二业务与所述第一业务不同;
    第一电子设备通过所述第一Wi-Fi直连链路向所述第二电子设备发送所述第二业务的数据。
  2. 根据权利要求1所述的方法,其特征在于,在所述第一电子设备接收用户的第一操作之后,所述方法还包括:
    所述第一电子设备通过第一连接,向所述第二电子设备发送Wi-Fi直连请求,所述Wi-Fi直连请求包括:所述第一电子设备的信息,所述Wi-Fi直连请求用于请求利用所述第一Wi-Fi直连链路向所述第二电子设备发送所述第二业务的数据;
    所述第二电子设备根据所述Wi-Fi直连请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向第一电子设备发送Wi-Fi直连请求响应信息,所述Wi-Fi直连请求响应信息包括:所述Wi-Fi直连群组的群组信息以及所述第二电子设备的IP地址;
    所述第一电子设备根据所述Wi-Fi直连请求响应信息,将所述第一电子设备维护的引用计数加一,所述第一电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数。
  3. 根据权利要求2所述的方法,其特征在于,在所述第一电子设备向所述第二电子设备发送Wi-Fi直连请求之前,所述方法还包括:
    所述第一电子设备和所述第二电子设备建立所述第一连接,所述第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
  4. 根据权利要求2或3所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述Wi-Fi直连请求,确定所述第二电子设备和所述第一电子设备之间已经存在所述第一Wi-Fi直连链路。
  5. 根据权利要求2至4中任一项所述的方法,其特征在于,在所述第一电子设备将所述第一电子设备维护的引用计数加一之前,所述方法还包括:
    所述第一电子设备确定所述第二电子设备和所述第一电子设备之间已经存在所述第一Wi-Fi直连链路。
  6. 根据权利要求2至5中任一项所述的方法,其特征在于,在所述第二业务的数据传输完成后或者所述第一业务的数据传输完成后,所述方法还包括:
    所述第一电子设备将所述第一电子设备维护的引用计数减一;
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组;或者,
    在所述第一电子设备维护的引用计数为0时,所述第一电子设备断开与所述第二电子设备之间的Wi-Fi直连链路。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,所述第一电子设备的信息包括:所述第一电子设备的标识、所述第一电子设备当前的Wi-Fi直连连接状态、所述第一电子设备的Wi-Fi直连端口的MAC地址、所述第一电子设备支持的信道列表、所述第一电子设备连接的Wi-Fi热点的频率、所述第一电子设备是否支持宽频中的至少一种。
  9. 根据权利要求1至8中任一项所述的方法,其特征在于,所述***还包括第三电子设备,所述第三电子设备为所述Wi-Fi直连群组外的空闲设备,在所述第二业务的数据传输完成之后,所述方法还包括:
    所述第三电子设备接收用户的第二操作,所述第二操作用于向所述第一电子设备发送第三业务的数据;
    所述第三电子设备与所述第二电子设备建立第二Wi-Fi直连链路;
    所述第三电子设备通过所述第二Wi-Fi直连链路向所述第二电子设备发送所述第三业务的数据;
    响应于接收所述第三业务的数据,所述第二电子设备通过所述第一Wi-Fi直连链路向所述第一电子设备发送所述第三业务的数据。
  10. 根据权利要求9所述的方法,其特征在于,在所述第三电子设备与所述第二电子设备建立所述第二Wi-Fi直连链路之前,所述方法还包括:
    所述第一电子设备向所述第二电子设备发送第三连接请求,所述第三连接请求用于请求将所述第三电子设备加入到所述Wi-Fi直连群组中,所述第三连接请求包括所述第三电子设备的信息;
    所述第二电子设备根据所述第三连接请求,将所述第二电子设备维护的引用计数加一,所述第三电子设备维护的引用计数用于表示同时利用所述第三电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第一电子设备发送响应于所述第三连接请求的第三响应信息,所述第三响应信息用于指示将所述第三电子设备加入到所述Wi-Fi直连群组,所述第三响应信息包括:所述第二电子设备为所述第三电子设备分配的IP地址、所述Wi-Fi直连群组的群组信息、所述第三电子设备的MAC地址中;
    所述第一电子设备根据所述第三响应信息,将所述第一电子设备维护的引用计数加一,所述第一电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数。
  11. 根据权利要求10所述的方法,其特征在于,在所述第一电子设备向所述第二电子设备发送所述第三连接请求之前,所述方法还包括:
    所述第三电子设备和所述第一电子设备建立第二连接,所述第二连接包括:蓝牙 连接、Wi-Fi连接中的任意一种。
  12. 根据权利要求11所述的方法,其特征在于,所述方法还包括:
    所述第三电子设备通过所述第二连接向所述第一电子设备发送第四连接请求,所述第四连接请求包括所述第三电子设备的信息;
    所述第一电子设备通过所述第二连接,向所述第三电子设备发送第四连接请求响应信息,所述第四连接请求响应信息包括:所述第二电子设备为所述第三电子设备分配的IP地址、所述Wi-Fi直连群组的群组信息、所述第二电子设备的MAC地址、所述第一电子设备的IP地址以及端口号;
    响应于接收所述第四连接请求响应信息,所述第三电子设备根据所述Wi-Fi直连群组的群组信息、所述第二电子设备的MAC地址,与所述第二电子设备建立所述第二Wi-Fi直连链路。
  13. 根据权利要求10至12中任一项所述的方法,其特征在于,在所述第二电子设备将所述第一电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第三连接请求,确定所述第三电子设备为可信设备、以及确定所述第二电子设备和所述第一电子设备之间存在Wi-Fi直连链路;
    在所述第一电子设备将所述第一电子设备维护的引用计数加一之前,所述方法还包括:
    所述第一电子设备根据所述第三响应信息,确定所述第一电子设备和所述第二电子设备之间存在Wi-Fi直连链路。
  14. 根据权利要求10至13中任一项所述的方法,其特征在于,在所述第三业务的数据传输完成后,所述方法还包括:
    所述第一电子设备将所述第一电子设备维护的引用计数减一;
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  15. 根据权利要求14所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组;或者,
    在所述第一电子设备维护的引用计数为0时,所述第一电子设备断开与所述第二电子设备之间的Wi-Fi直连链路。
  16. 根据权利要求9所述的方法,其特征在于,在所述第三电子设备通过所述第二Wi-Fi直连链路向所述第二电子设备发送所述第三业务的数据之前,所述方法还包括:
    所述第三电子设备通过第二连接,向所述第一电子设备发送第五连接请求,所述第五连接请求包括:所述第三电子设备的信息以及所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识;
    所述第一电子设备根据所述第五连接请求,将所述第一电子设备维护的引用计数加一,所述第一电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第一电子设备向第二电子设备发送第六连接请求,所述第六连接请求包括:所述第三电子设备的信息以及所述第三电子设备在所述Wi-Fi直连群组内连接的GO 设备的标识;
    所述第二电子设备根据所述第六连接请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第一电子设备发送响应于所述第六连接请求的第六响应信息,所述第六响应信息包括:所述Wi-Fi直连群组的群组信息、所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;
    所述第一电子设备通过所述第二连接,向所述第三电子设备发送响应于所述第五连接的第五响应信息,所述第五响应信息:所述第一电子设备的IP地址和端口号、所述第一电子设备在所述Wi-Fi直连群组内连接的GO设备的标识;
    所述第三电子设备根据所述第五响应信息,将所述第三电子设备维护的引用计数加一,所述第三电子设备维护的引用计数用于表示同时利用所述第三电子设备Wi-Fi P2P能力的业务个数。
  17. 根据权利要求9所述的方法,其特征在于,在所述第三电子设备通过所述第二Wi-Fi直连链路向所述第二电子设备发送所述第三业务的数据之前,所述方法还包括:
    所述第三电子设备向所述第二电子设备发送第七连接请求,所述第七连接请求包括所述第一电子设备的信息;
    所述第二电子设备根据所述第七连接请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第三电子设备发送响应于所述第七连接请求的第七响应信息,所述第七响应信息包括:所述Wi-Fi直连群组的群组信息、所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个;
    所述第三电子设备根据所述第七响应信息,将所述第三电子设备维护的引用计数加一,所述第三电子设备维护的引用计数用于表示同时利用所述第三电子设备Wi-Fi P2P能力的业务个数;
    所述第三电子设备通过第二连接向所述第一电子设备发送第八连接请求,所述第八连接请求包括:所述Wi-Fi直连群组的群组信息、所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识;
    所述第一电子设备根据所述第八连接请求,将所述第一电子设备维护的引用计数加一,所述第一电子设备维护的引用计数用于表示同时利用所述第一电子设备Wi-Fi P2P能力的业务个数。
  18. 根据权利要求16或17所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第六连接请求,确定所述第三电子设备为可信设备、以及确定所述第三电子设备和所述第一电子设备分别与所述第二电子设备之间存在 Wi-Fi P2P连接;或者,
    所述第二电子设备根据所述第七连接请求,确定所述第一电子设备为可信设备、以及确定所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接。
  19. 根据权利要求16至18中任一项所述的方法,其特征在于,在所述第三电子设备将所述第三电子设备维护的引用计数加一之前,所述方法还包括:
    所述第三电子设备根据所述第五响应信息,确定所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识和所述第一电子设备在所述Wi-Fi直连群组内连接的GO设备的标识相同;或者,
    所述第三电子设备根据所述第七响应信息,确定所述第一电子设备在所述Wi-Fi直连群组内连接的GO设备的标识和所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识相同。
  20. 根据权利要求16至19中任一项所述的方法,其特征在于,所述方法还包括:在所述第一电子设备将所述第一电子设备维护的引用计数加一之前,所述方法还包括:
    所述第一电子设备根据所述第六响应信息或者所述第八连接请求,确定所述第一电子设备在所述Wi-Fi直连群组内连接的GO设备的标识和所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识相同。
  21. 根据权利要求16至20中任一项所述的方法,其特征在于,在所述第三业务的数据传输完成后,所述方法还包括:
    所述第一电子设备将所述第一电子设备维护的引用计数减一;
    所述第二电子设备将所述第二电子设备维护的引用计数减一;
    所述第三电子设备将所述第三电子设备维护的引用计数减一。
  22. 根据权利要求21所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组;或者,
    在所述第一电子设备维护的引用计数为0时,所述第一电子设备断开与所述第二电子设备之间的所述第一Wi-Fi直连链路;或者,
    在所述第三电子设备维护的引用计数为0时,所述第三电子设备断开与所述第二电子设备之间的所述第二Wi-Fi直连链路。
  23. 根据权利要求10至22中任一项所述的方法,其特征在于,所述第三电子设备的信息包括:所述第三电子设备的标识、所述第三电子设备当前的Wi-Fi直连连接状态、所述第三电子设备的Wi-Fi直连端口的MAC地址、所述第三电子设备支持的信道列表、所述第三电子设备连接的Wi-Fi热点的频率、所述第三电子设备是否支持宽频中的至少一种。
  24. 根据权利要求1至23中任一项所述的方法,其特征在于,所述***还包括第四电子设备,所述第四电子设备为所述Wi-Fi直连群组外的空闲设备,所述方法还包括:
    所述第四电子设备接收用户的第三操作,所述第三操作用于向所述第二电子设备发送第四业务的数据;
    所述第四电子设备与所述第二电子设备建立第三Wi-Fi直连链路;
    所述第四电子设备通过所述第三Wi-Fi直连链路,向所述第二电子设备发送所述第四业务的数据。
  25. 根据权利要求24所述的方法,其特征在于,在所述第四电子设备与所述第二电子设备建立第三Wi-Fi直连链路之前,所述方法还包括:
    所述第四电子设备通过第三连接,向所述第二电子设备第九连接请求,所述第九连接请求用于请求将所述第四电子设备加入到所述Wi-Fi直连群组中,所述第九连接请求包括所述第四电子设备的信息;
    所述第二电子设备根据所述第九连接请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备通过所述第三连接,向所述第四电子设备发送响应于所述第九连接请求的第九响应信息,所述第九响应信息用于指示将所述第四电子设备加入到所述Wi-Fi直连群组,所述第九响应信息包括:所述第二电子设备为所述第四电子设备分配的IP地址、所述Wi-Fi直连群组的群组信息、所述第二电子设备的MAC地址;
    所述第四电子设备根据所述Wi-Fi直连群组的群组信息、所述第二电子设备的MAC地址,与所述第二电子设备建立所述第三Wi-Fi直连链路。
  26. 根据权利要求25所述的方法,其特征在于,在所述第四电子设备通过第三连接,向所述第二电子设备第九连接请求之前,所述方法还包括:
    所述第四电子设备和所述第二电子设备建立所述第三连接,所述第三连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
  27. 根据权利要求25或26所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第九连接请求,确定所述第四电子设备为可信设备、以及确定所述第二电子设备和所述第四电子设备之间不存在Wi-Fi直连链路。
  28. 根据权利要求25至27中任一项所述的方法,其特征在于,在所述第四业务的数据传输完成后,所述方法还包括:
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  29. 根据权利要求28所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组。
  30. 根据权利要求25至29中任一项所述的方法,其特征在于,所述第四电子设备的信息包括:所述第四电子设备的标识、所述第四电子设备当前的Wi-Fi直连连接状态、所述第四电子设备的Wi-Fi直连端口的MAC地址、所述第四电子设备支持的信道列表、所述第四电子设备连接的Wi-Fi热点的频率、所述第四电子设备是否支持宽频中的至少一种。
  31. 一种Wi-Fi直连下数据传输的方法,其特征在于,所述方法包括:
    第二电子设备和第二电子设备通过第一Wi-Fi直连链路传输第一业务的数据;
    所述第二电子设备通过所述第一Wi-Fi直连链路接收所述第一电子设备发送的第 二业务的数据,所述第一电子设备为Wi-Fi直连群组内的GC设备,所述第二电子设备为所述Wi-Fi直连群组内的GO设备,所述第二业务与所述第一业务不同。
  32. 根据权利要求31所述的方法,其特征在于,在所述第二电子设备通过所述第一Wi-Fi直连链路接收所述第一电子设备发送的第二业务的数据之前,所述方法包括:
    所述第二电子设备通过第一连接,接收所述第一电子设备发送的送Wi-Fi直连请求,所述Wi-Fi直连请求包括:所述第一电子设备的信息,所述Wi-Fi直连请求用于请求利用所述第一Wi-Fi直连链路向所述第二电子设备发送第二业务的数据;
    所述第二电子设备根据所述Wi-Fi直连请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向第一电子设备发送Wi-Fi直连请求响应信息,所述Wi-Fi直连请求响应信息包括:所述Wi-Fi直连群组的群组信息以及所述第二电子设备的IP地址。
  33. 根据权利要求32所述的方法,其特征在于,在所述第二电子设备接收所述第一电子设备发送的送Wi-Fi直连请求之前,所述方法还包括:
    所述第二电子设备和所述第一电子设备建立所述第一连接,所述第一连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
  34. 根据权利要求32或33所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述Wi-Fi直连请求,确定所述第二电子设备和所述第一电子设备之间已经存在所述第一Wi-Fi直连链路。
  35. 根据权利要求32至34中任一项所述的方法,其特征在于,在所述第二业务的数据传输完成后或者所述第一业务的数据传输完成后,所述方法还包括:
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  36. 根据权利要求35所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组。
  37. 根据权利要求31至36中任一项所述的方法,其特征在于,所述第一电子设备的信息包括:所述第一电子设备的标识、所述第一电子设备当前的Wi-Fi直连连接状态、所述第一电子设备的Wi-Fi直连端口的MAC地址、所述第一电子设备支持的信道列表、所述第一电子设备连接的Wi-Fi热点的频率、所述第一电子设备是否支持宽频中的至少一种。
  38. 根据权利要求31至37中任一项所述的方法,其特征在于,在所述第二业务的数据传输完成之后,所述方法还包括:
    所述第二电子设备与第三电子设备与建立第二Wi-Fi直连链路,所述第三电子设备为所述Wi-Fi直连群组外的空闲设备;
    所述第二电子通过所述第二Wi-Fi直连链路,接收所述第三电子设备发送的第三业务的数据;
    所述第二电子设备通过所述第一Wi-Fi直连链路,向所述第一电子设备发送所述 第三业务的数据。
  39. 根据权利要求38所述的方法,其特征在于,在所述第二电子设备与第三电子设备与建立第二Wi-Fi直连链路之前,所述方法还包括:
    所述第二电子设备接收所述第一电子设备发送第三连接请求,所述第三连接请求用于请求将所述第三电子设备加入到所述Wi-Fi直连群组中,所述第三连接请求包括所述第三电子设备的信息;
    所述第二电子设备根据所述第三连接请求,将所述第二电子设备维护的引用计数加一,所述第三电子设备维护的引用计数用于表示同时利用所述第三电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第一电子设备发送响应于所述第三连接请求的第三响应信息,所述第三响应信息用于指示将所述第三电子设备加入到所述Wi-Fi直连群组,所述第三响应信息包括:所述第二电子设备为所述第三电子设备分配的IP地址、所述Wi-Fi直连群组的群组信息、所述第三电子设备的MAC地址中。
  40. 根据权利要求39所述的方法,其特征在于,在所述第二电子设备将所述第三电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第三连接请求,确定所述第三电子设备为可信设备、以及确定所述第二电子设备和所述第一电子设备之间存在Wi-Fi直连链路。
  41. 根据权利要求39或40所述的方法,其特征在于,在所述第三业务的数据传输完成后,所述方法还包括:
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  42. 根据权利要求39所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组。
  43. 根据权利要求38所述的方法,其特征在于,在所述第二电子通过所述第二Wi-Fi直连链路,接收所述第三电子设备发送的第三业务的数据之前,所述方法还包括:
    所述第一电子设备向第二电子设备发送第六连接请求,所述第六连接请求包括:所述第三电子设备的信息以及所述第三电子设备在所述Wi-Fi直连群组内连接的GO设备的标识;
    所述第二电子设备根据所述第六连接请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第一电子设备发送响应于所述第六连接请求的第六响应信息,所述第六响应信息包括:所述Wi-Fi直连群组的群组信息、所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个。
  44. 根据权利要求38所述的方法,其特征在于,在所述第二电子通过所述第二Wi-Fi直连链路,接收所述第三电子设备发送的第三业务的数据之前,所述方法还包括:
    所述第二电子设备接收所述第三电子设备发送的第七连接请求,所述第七连接请求包括所述第一电子设备的信息;
    所述第二电子设备根据所述第七连接请求,将所述第二电子设备维护的引用计数加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备向所述第三电子设备发送响应于所述第七连接请求的第七响应信息,所述第七响应信息包括:所述Wi-Fi直连群组的群组信息、所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接的指示信息中的至少一个。
  45. 根据权利要求43或44所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第六连接请求,确定所述第三电子设备为可信设备、以及确定所述第三电子设备和所述第一电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接;或者,
    所述第二电子设备根据所述第七连接请求,确定所述第一电子设备为可信设备、以及确定所述第一电子设备和所述第三电子设备分别与所述第二电子设备之间存在Wi-Fi P2P连接。
  46. 根据权利要求43至45中任一项所述的方法,其特征在于,在所述第三业务的数据传输完成后,所述方法还包括:
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  47. 根据权利要求46所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组。
  48. 根据权利要求39至47中任一项所述的方法,其特征在于,所述第三电子设备的信息包括:所述第三电子设备的标识、所述第三电子设备当前的Wi-Fi直连连接状态、所述第三电子设备的Wi-Fi直连端口的MAC地址、所述第三电子设备支持的信道列表、所述第三电子设备连接的Wi-Fi热点的频率、所述第三电子设备是否支持宽频中的至少一种。
  49. 根据权利要求31至48中任一项所述的方法,其特征在于,所述方法还包括:
    所述第二电子设备与所述第四电子设备建立第三Wi-Fi直连链路,所述第四电子设备为所述Wi-Fi直连群组外的空闲设备;
    所述第二电子设备通过所述第三Wi-Fi直连链路,接收所述第四电子设备发送的第四业务的数据。
  50. 根据权利要求49所述的方法,其特征在于,在所述第二电子设备与所述第四电子设备建立第三Wi-Fi直连链路之前,所述方法还包括:
    所述第二电子设备通过第三连接,接收所述第四电子设备发送的第九连接请求,所述第九连接请求用于请求将所述第四电子设备加入到所述Wi-Fi直连群组中,所述第九连接请求包括所述第四电子设备的信息;
    所述第二电子设备根据所述第九连接请求,将所述第二电子设备维护的引用计数 加一,所述第二电子设备维护的引用计数用于表示同时利用所述第二电子设备Wi-Fi P2P能力的业务个数;
    所述第二电子设备通过所述第三连接,向所述第四电子设备发送响应于所述第九连接请求的第九响应信息,所述第九响应信息用于指示将所述第四电子设备加入到所述Wi-Fi直连群组,所述第九响应信息包括:所述第二电子设备为所述第四电子设备分配的IP地址、所述Wi-Fi直连群组的群组信息、所述第二电子设备的MAC地址。
  51. 根据权利要求50所述的方法,其特征在于,在所述第二电子设备通过第三连接,接收所述第四电子设备发送的第九连接请求之前,所述方法还包括:
    所述第二电子设备和所述第四电子设备建立所述第三连接,所述第三连接包括:蓝牙连接、Wi-Fi连接中的任意一种。
  52. 根据权利要求50或51所述的方法,其特征在于,在所述第二电子设备将所述第二电子设备维护的引用计数加一之前,所述方法还包括:
    所述第二电子设备根据所述第九连接请求,确定所述第四电子设备为可信设备、以及确定所述第二电子设备和所述第四电子设备之间不存在Wi-Fi直连链路。
  53. 根据权利要求50至52中任一项所述的方法,其特征在于,在所述第四业务的数据传输完成后,所述方法还包括:
    所述第二电子设备将所述第二电子设备维护的引用计数减一。
  54. 根据权利要求53所述的方法,其特征在于,所述方法还包括:
    在所述第二电子设备维护的引用计数为0时,所述第二电子设备拆除所述Wi-Fi直连群组。
  55. 根据权利要求50至54中任一项所述的方法,其特征在于,所述第四电子设备的信息包括:所述第四电子设备的标识、所述第四电子设备当前的Wi-Fi直连连接状态、所述第四电子设备的Wi-Fi直连端口的MAC地址、所述第四电子设备支持的信道列表、所述第四电子设备连接的Wi-Fi热点的频率、所述第四电子设备是否支持宽频中的至少一种。
  56. 一种电子设备,其特征在于,包括:处理器及存储器;所述处理器和存储器耦合,所述存储器存储有程序指令,当所述存储器存储的程序指令被所述处理器执行时执行如权利要求31至55中任一项所述的方法。
  57. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储了计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1至30中任一项所述的方法。
  58. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储了计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求31至55中任一项所述的方法。
  59. 一种芯片,其特征在于,包括:处理器,用于从存储器中调用并运行计算机程序,使得安装有所述芯片的通信设备执行如权利要求1至30中任一项所述的方法。
  60. 一种芯片,其特征在于,包括:处理器,用于从存储器中调用并运行计算机程序,使得安装有所述芯片的通信设备执行如权利要求31至55中任一项所述的方法。
PCT/CN2021/137212 2020-12-24 2021-12-10 Wi-Fi直连下数据传输的方法和电子设备 WO2022135187A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP21909184.0A EP4247041A4 (en) 2020-12-24 2021-12-10 DATA TRANSMISSION METHOD UNDER WI-FI PEER-TO-PEER AND ELECTRONIC DEVICE
US18/340,689 US20230337303A1 (en) 2020-12-24 2023-06-23 Method for transmitting data under wi-fi direct and electronic device

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202011555743 2020-12-24
CN202011555743.7 2020-12-24
CN202110745464.5A CN114679732A (zh) 2020-12-24 2021-06-30 Wi-Fi直连下数据传输的方法和电子设备
CN202110745464.5 2021-06-30

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/340,689 Continuation US20230337303A1 (en) 2020-12-24 2023-06-23 Method for transmitting data under wi-fi direct and electronic device

Publications (1)

Publication Number Publication Date
WO2022135187A1 true WO2022135187A1 (zh) 2022-06-30

Family

ID=82070453

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/137212 WO2022135187A1 (zh) 2020-12-24 2021-12-10 Wi-Fi直连下数据传输的方法和电子设备

Country Status (4)

Country Link
US (1) US20230337303A1 (zh)
EP (1) EP4247041A4 (zh)
CN (1) CN114679732A (zh)
WO (1) WO2022135187A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117135767A (zh) * 2023-10-24 2023-11-28 荣耀终端有限公司 一种设备间的连接方法及电子设备

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114928899B (zh) * 2022-07-18 2022-10-28 荣耀终端有限公司 物理链路的建立方法和电子设备
CN115002939B (zh) * 2022-07-18 2022-10-04 荣耀终端有限公司 加入WiFi群组的方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103702291A (zh) * 2012-09-27 2014-04-02 中兴通讯股份有限公司 一种基于Wi-Fi建立群组的方法和WiFi直连设备
CN104541569A (zh) * 2012-08-08 2015-04-22 三星电子株式会社 生成用于Wi-Fi直连服务的P2P群组的方法和装置
US20180014341A1 (en) * 2016-07-06 2018-01-11 Samsung Electronics Co., Ltd. Method and apparatus for communicating using multiple frequency bands
CN108693969A (zh) * 2017-04-06 2018-10-23 三星电子株式会社 用于连接外部设备和更新数据的设备
CN111372325A (zh) * 2020-02-21 2020-07-03 华为技术有限公司 建立Wi-Fi点对点连接的方法和装置

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7552355B2 (en) * 2005-02-24 2009-06-23 Lsi Logic Corporation System for providing an alternative communication path in a SAS cluster
AU2013338811B2 (en) * 2012-11-05 2016-12-01 Lg Electronics Inc. Method for searching for or advertising service in direct communication system and device for same
US9924552B2 (en) * 2013-01-03 2018-03-20 Lg Electronics Inc. Method and apparatus for changing in wireless communication system
KR102133846B1 (ko) * 2013-03-12 2020-07-14 엘지전자 주식회사 직접 통신 시스템에서 피투피 그룹 형성 방법 및 이를 위한 장치
CN111010744B (zh) * 2018-10-08 2022-05-13 华为技术有限公司 建立会话的方法和装置以及发送报文的方法和装置
CN109587667B (zh) * 2018-11-23 2021-06-18 Oppo广东移动通信有限公司 一种连接建立方法及装置、设备、存储介质
CN113382397B (zh) * 2019-04-18 2023-12-08 华为技术有限公司 一种蓝牙连接方法、设备及***

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104541569A (zh) * 2012-08-08 2015-04-22 三星电子株式会社 生成用于Wi-Fi直连服务的P2P群组的方法和装置
CN103702291A (zh) * 2012-09-27 2014-04-02 中兴通讯股份有限公司 一种基于Wi-Fi建立群组的方法和WiFi直连设备
US20180014341A1 (en) * 2016-07-06 2018-01-11 Samsung Electronics Co., Ltd. Method and apparatus for communicating using multiple frequency bands
CN108693969A (zh) * 2017-04-06 2018-10-23 三星电子株式会社 用于连接外部设备和更新数据的设备
CN111372325A (zh) * 2020-02-21 2020-07-03 华为技术有限公司 建立Wi-Fi点对点连接的方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4247041A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117135767A (zh) * 2023-10-24 2023-11-28 荣耀终端有限公司 一种设备间的连接方法及电子设备
CN117135767B (zh) * 2023-10-24 2024-04-12 荣耀终端有限公司 一种设备间的连接方法及电子设备

Also Published As

Publication number Publication date
EP4247041A4 (en) 2024-04-24
US20230337303A1 (en) 2023-10-19
CN114679732A (zh) 2022-06-28
EP4247041A1 (en) 2023-09-20

Similar Documents

Publication Publication Date Title
WO2022135187A1 (zh) Wi-Fi直连下数据传输的方法和电子设备
EP3550888B1 (en) Wireless connection switching method and terminal
JP6110507B2 (ja) ワイファイダイレクトサービスシステムにおいて通信設定方法及びそのための装置
EP2555490B1 (en) Method for creating Wi-Fi P2P group
CN113014483B (zh) 一种多路径传输的方法及设备
EP3547732A1 (en) Communication device and computer programs for communication device
CN111050415B (zh) 一种操作便捷的无线数据传输方法
WO2014069868A1 (ko) 엔에프씨를 이용한 와이파이 다이렉트 서비스 방법 및 이를 위한 장치
WO2022143071A1 (zh) 连接建立方法及电子设备
JP6421673B2 (ja) 通信機器
KR20130097357A (ko) 무선 통신 네트워크에서 디바이스 탐색 방법 및 장치
WO2022228083A1 (zh) 一种多设备建立连接的方法及设备
EP2918140A1 (en) Proxy connection method and apparatus
CN114390491A (zh) 一种组网方法、装置和***
EP2713672B1 (en) Wireless slave devices configuration and communication therewith
CN116963054B (zh) Wlan多链路tdls密钥导出
KR20160007259A (ko) 무선 통신 시스템에서 채널을 선택하기 위한 방법 및 장치
EP3291630A1 (en) Method for paging between neighbor awareness networks, and neighbor awareness network device
EP4287711A1 (en) Method for discovering and connecting electronic device, and electronic device
JP6515804B2 (ja) 通信端末
WO2022143157A1 (zh) 一种密钥协商的方法及其相关设备
CN113114798B (zh) 一种互联网协议ip地址的获取方法及电子设备
JP2015176536A (ja) 通信装置、通信方法、通信プログラムおよび記憶媒体
WO2022228207A1 (zh) 建立Wi-Fi P2P连接的方法和电子设备
WO2024120069A1 (zh) P2p业务数据传输的方法和电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21909184

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021909184

Country of ref document: EP

Effective date: 20230615

NENP Non-entry into the national phase

Ref country code: DE