Difference between Wifi aware and Wifi P2P on Android?
WiFi Aware is significantly faster at establishing a connection.
The discovery stage is much more flexible: you can add your own information (255 bytes) to your service announcements and exchange short messages (255 bytes) with other peers without needing to establish a connection.
However, all the connections in WiFi Aware are one-to-one. A device can only have a very limited number of simultaneous connections (two, in the case of the Pixel 2).
For comparison, WiFi P2P works more similarly to an automatic Hotspot: the devices negotiate among themselves which of them will create a WiFi network, and afterwards other devices can join in. If you manage to get the WiFi SSID/password, it is possible to join the network manually.
My understanding is that WiFi P2P has worse performance in terms of battery (at least in the case of the central node).
Based on the Android docs, with Wi-Fi Aware, you can send data (lightweight only! max of 255 bytes) between the devices during service discovery phase and when needed, you may open a connection between the devices to send larger data. With Wi-Fi peer-to-peer, you have to perform some kind of authentication first and then open a socket before you can send data between the devices.
Here are the portions of the Wi-Fi aware overview where I got these information:
The Wi-Fi Aware APIs let apps perform the following operations:
- Discover other devices: [...] After the subscriber discovers a publisher, the subscriber can either send a short message or establish a network connection with the discovered device.
- Create a network connection: After two devices have discovered each other [...] they can create a bi-directional Wi-Fi Aware network connection without an access point.
Note: Messages are generally used for lightweight messaging, as they might not be delivered (or be delivered out-of-order or more than once) and are limited to about 255 bytes in length.
Additionally, with Wi-Fi Aware, developers have a choice between the methods createNetworkSpecifierOpen()
and createNetworkSpecifierPassphrase()
of the DiscoverySession
class to open unencrypted or encrypted connections, respectively, between the devices.
With Wi-Fi peer to peer, developers have no other choices other than the WifiP2PManager.connect()
method. Calling it will trigger a dialog box (Push Button Configuration) on the device being connected to and that dialog box will only appear when two devices connects to each other for the first time.
By the way... modifying the WpsInfo
of a WifiP2pConfig
is useless; it will always use the Push Button Configuration option. I tested it on the devices I have (Asus ZC520TL-Nougat, Asus ZE551ML-Marshmallow, Huawei Y5-Marshmallow, and Huawei T1-KitKat). The PBC dialog appeared even if the wifip2pconfig.wps.setup
is not equal to WpsInfo.PBC
. Feel free correct me if this isn't true for all devices because it might just be an OEM thing.
For more information visit Wi-Fi peer-to-peer overview.