androidnetwork-programmingwifiadhochotspot

Is it possible to connect more hotspots?


I'm working on a wireless ad hoc network for Android devices. Until now I thought to use a phone as a hotspot, so nearby devices could connect each other, but what if two hotspots have to speak to each other?

Can two or more hotspots connect and communicate each other?


Solution

  • Yes, you need to use WiFi Direct for this. When using WiFi direct in concurrent mode, and device can act as both a client and an AP the same time. This is what you need. Whether it will work for you as is, depends on your specific device and driver, but there is support for WiFi Direct in Android since v4.0. Sometimes WiFi Direct is also called WiFi Peer-To-Peer or WiFi P2P and this is what the Android API calls it.

    see Android WiFi P2P

    With the Android API you can discover other peers and services you define and connect to them.

    The WiFi p2p utilities are under very active development, so I am not sure if the Android is currently supporting the concurrent mode. You can try. However, you can also setup your connections directly by using the wpa_supplicant utility which is actually what Android is using internally. I have been able to use this directly from my applications for other purposes. If the version that Android is using is not working, or if you find it a bit unstable, you can get the latest version from the hostap and wpa_supplicant projects. Installing those may require root access though.