Wednesday 23 January 2013

Getting the Android into Ad-Hoc Mode and creating a Mesh

Hi folks this has been one hell of a week where i had to bend my back alot for this task to make it work because it really creates some hard core issue as android doesn't by default allows adhoc mode.
But to make this happen i went across two free applications on market that does this job fairly well

1. barnacle wifi tether
2. wifi tether for root

To make the scenario i used 3 android devices and 2 PC running Ubuntu 12.04, 
now take any first device and run any of the application this will create our gateway for the adhoc mode and it will start broadcasting itself automatically, but as android doesn't allow adhoc mode connectivity there are 3 ways to make another android phone connect to the adhoc mode.

1. modify the data/misc/wifi/wpa_supplicant.conf

2. modify the system/bin/wpa_supplicant
3. install cyanogenmod 9 as a firmware which allows to connect to adhoc mode by default.

How to do the first one is listed as follows - 
In the conf file enter this,

ctrl_interface=wlan0
update_config=1
device_type=0-00000000-0
ap_scan=2
network={
ssid="your adhoc network name"
scan_ssid=1
key_mgmt=NONE
auth_alg=OPEN SHARED
mode=1
priority=1
}

save and exit, 
then do this in the terminal emulator

#chown system.wifi /data/misc/wifi/wpa_supplicant.conf

Turn on wifi you will see ur adhoc mode listed - make the IP static and it will connect 
but this doesn't work on all devices so chances are 50-50.

To do the second one is more tricky but works 100% - 
Download this file from here ,

http://forum.xda-developers.com/attachment.php?attachmentid=805983&d=1323095437

1. Unzip the file (wpa_supplicant.zip) and send wpa_supplicant to your phone.

2. Using Root Explorer go to the folder were you save it (wpa_supplicant) and copy the file.
3. Using Root Explorer, enter the /system folder and press the Mount W/R button (upper right corner)
4. Now go to /system/bin and backup your current wpa_supplicant, and paste the new one.
5. Set permissions of wpa_supplicant to 755, then go back to /system and press Mount R/O (upper right corner, so you leave everything exactly like it was) and reboot.

Now you can see the ad hoc mode connect to it - sometimes it its stuck on obtaining ip address in that case make the ip static then it will definitely connect.

The third option is a bit more complex , u need to go to cyanogenmod website find your device firmware download and flash it over the phone, but it will enable your device to connect to adhoc network out of the box - no modification of wpa binaries or wpa configuration.

To connect ubuntu is fairly easy all you need to do is see ur wireless networks available, you will see an adhoc netwrok listed - connect to it, if it get stuck on optainig ip address make it static by the network manager help.

This will create a mesh of multiple platform connected together in adhoc mode.

No comments:

Post a Comment