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.

Compiling and executing OLSR for Android on Ubuntu 12.04

Hi all,

This is another start to yet another problem that i have faced during my thesis and this time is making OLSR run over an android Phone,
To achieve the said task i want you to follow the following steps carefully and in the end you will be running the OLSR protocol over an android phone.
The OS of android doesnt matter wether it be GB or ICS or JB.
This method is compatible for all ( Cross Checked )
The pre-requistes are listed as follows,
1. bison
2. flex
3. libc6
4. Android SDK
5. Android NDK
6. git-core

Download the SDK and NDK, untar them to /opt folder in the base directory otherwise you are gonna go thru lot of errors.

ok lets get down to business,

open terminal and start like this,

$sudo su
# apt-get install bison flex libc6 git-core
#git clone git://olsr.org/olsrd.git
#cd olsrd
#cd make
# gedit makefile.android

Edit it from these places -

NDK_BASE ?= /opt/android-ndk

Place the location of NDK here on this line - make it match your untarred location other wise u r gonna go thru lot of issues.

save it close it and go back to terminal

#make OS=android DEBUG=0 NDK_BASE=/opt/android-ndk
#sudo make OS=android DEBUG=0 install_all

Once this is done, the hunting for created files start -

Im listing down the location and files u need to place them in a separate folder of whatever name you like -

/bin/sgw_policy_routing_setup.sh
/bin/olsrd
/etc/olsrd.conf
/lib/ ( there are altogether 18 files that get created - sort them according to date modified, they shud cluster together because of the same time and same date creation and copy them to whatever desired folder you want )
/usr/share/doc/olsrd
/usr/share/man/man5
/usr/share/man/man8

now thats done put them together in some place more easily findable,

now push these files into the android phone

you will need a root explorer to do that with root privileges

put the contents of the bin folder to the /system/bin of the phone
put the contents of the etc folder to the /system/etc of the phone
like wise for the next two as well where lib contents goes to /system/libs and contents of /user/share goes to /system/usr/share

that's it - now u need to modify ur olsrd.conf file to suit the phone

open terminal emulator - its a small application available freely on the market

and start doing this,

$su
#netcfg

This will list down your interface which is responsible for wifi connectivity

i used this on three devices separately , im listing there names and the interface found and modified the olsrd.conf accordingly to adjust to your situation

1. Samsung Galaxy S2 - eth0 ( running Gingerbread 2.3.5 )
2. Samsung Galaxy Y - eth0 ( running Gingerbread 2.3.6 )
3. Ainol Tab Aurora II - wlan0 ( running IceCreamSandwich 4.0.3 )

Once the olsrd.conf is properly edited according to ur device just go back to terminal emulator and enter

#olsrd

Thats it - the olsrd will be up and running.