Determination of wifi p2p owner

The original text is quoted from: http://www.bubuko.com/infodetail-958689.html The

P2P architecture defines three components, one device and two roles. The three components are:

    P2P Device: It is the entity of the role in the P2P architecture, and readers can regard it as a Wi-Fi device.
    P2P Group Owner (GO): A Group will be generated when a P2P network is established.
    P2P Group Client (GC):

    Before the establishment of P2P Group (ie P2P Network), intelligent terminals are all P2P Devices.
    When the P2P negotiation is completed between these P2P Device devices, one and only one of them will play the role of GO, and the other Devices will play the role of GC.

The final organization structure of the P2P Group is shown in the figure: Schematic diagram of the

technology sharing

P2P Group The

figure shows the composition of a typical P2P Group, in which:

a P2P Group can only have one GO. A GO can support 1 or more (ie 1:n in the figure) GC connections.

    Since the function of the GO is similar to that of the AP, the surrounding WIFI STAs that do not support the P2P function can also discover and associate with the GO. These WIFI STAs are called Legacy Clients.

Note: A more accurate definition of "does not support P2P function" means that it cannot handle the P2P protocol. In a P2P network, GO is equivalent to AP, so Legacy Clients can also search for GO and associate it. However, since Legacy Clients cannot handle the P2P protocol, some P2P-specific functions cannot be implemented in these Legacy Clients.




The approximate pairing process of Wifi_Direct is as follows:
        a. WifiP2pManager.discoverPeers() starts scanning devices
        b. Obtain the scanned devices, select one of the devices to connect and pair WifiP2pManager.connect
        c. After successful pairing, proceed according to WifiP2pInfo.isGroupOwner and WifiP2pInfo.groupOwnerAddress connect.

        The flow chart is as follows:
Technology sharing




FAQ
Question 1: How to determine who is GO and who is GC when WifiP2pManger.connect() is

used. Answer: When calling WifiP2pManger.connect() to connect, the identity of GO and GC is random. The developer cannot decide which device the GroupOwner is, but it can be suggested via the WifiP2pConfig.groupOwnerIntent parameter.


Question 2: What should I do if I have to determine who is the GO and who is the GC?

Answer : Step 1: The GO side first calls

WifiP2pManger.createGroup

. connect


Question 3: How to disconnect

A : WifiP2pManger.removeGroup

Note: WifiP2pManger.removeGroup is to remove the Group and disconnect. WifiP2pManger.cancelConnect() disconnects a connecting connection, that is, disconnects the connection whose current status is Invited.


Question 4: We know that the prerequisite for successful pairing is that both devices being paired must be able to scan each other. So how to ensure that the machine is always in the search state?

A: After testing, it is known that, under normal circumstances, the machine can stay online for 3 minutes after Scan once, that is, the time it takes to search for other devices / to be searched by other devices is generally 3 minutes. But this 3 minutes is not very accurate, which has a lot to do with the performance of the mobile phone or the WIFI chip. So the solution we can do is to restart the search if the search ends.

For general Peer Discovery, if the search is over, the broadcast WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION will be received, so that you can search again after receiving the broadcast.

For Service Discovery (which is actually the most widely used), after the search is over, the system will not send out a broadcast notification, which brings a problem to developers: you can't know whether you are currently in the search (visible) state.

At present, it is more feasible to restart the search every 3 minutes (or less), which basically ensures that the machine is always in the search state. However, this can only cover most cases. It is recommended to add manual search on this basis (you can search manually if you cannot find it) to ensure the current visible state.

At present, wifip2p is still not very stable. From the test results, the performance of Wifi_Direct is greatly affected by the specific device, and the pairing speed is also quite different, from 10 seconds to 2 minutes or even longer. likely to appear

aA machine is in the search (visible) state, but the B machine is still not searchable;

b. It is also possible that the A machine is in the search (visible) state, and the B machine is also searched, but the connection fails (the main reason for this situation is that A After the machine search is over, the system will not send a notification, and the machine A currently searched by machine B is the state of machine A before)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326098905&siteId=291194637