I am working on an android based application, which will be used in the emergency or disaster situations to help the user, which path to follow to evacuate safely. Therefore, in this regard I need to establish a mesh network between the users in a particular area. I have to work on ad-hoc mode to make it possible.
The protocol you may be looking for is not conveniently labeled "ad-hoc", it's called "Wifi P2P":
Documentation: developer.android.com/guide/topics/connectivity/wifip2p.html
WifiP2pManager mManager;
Channel mChannel;
BroadcastReceiver mReceiver;
...
@Override
protected void onCreate(Bundle savedInstanceState){
...
mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), null);
mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
...
}
//obtain a peer from the WifiP2pDeviceList
WifiP2pDevice device;
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
mManager.connect(mChannel, config, new ActionListener() {
@Override
public void onSuccess() {
//success logic
}
@Override
public void onFailure(int reason) {
//failure logic
}
});
Hope this helps