Wednesday, August 5, 2009

enable wifi ad hoc on Andrid

Android comes with wifi ad hoc disable by default.  I have always wanted to use my Android the cheap way.  I do not have data plan.  Typically I am either at home or work.  My android is configured to connect to my home router via wifi.  We can not have a wifi router at work.  So a peer to peer connection would let my pc tether for my Android phone's internet connection.  And today I found it amazingly easy to do.

1.  edit /system/etc/wifi/tiwlan.ini

adb pull /system/etc/wifi/tiwlan.ini .
vi tiwlan.ini
find line "WiFiAdhoc = 0" and make the 0 1.  This would probably already be ok.  But somewhere I copied and pasted 2 more lines below, so now that block looks like

WiFiAdhoc = 1
dot11DesiredSSID = YOUR_SSID
dot11DesiredBSSType = 0
....

2  edit /data/misc/wifi/wpa_supplicant.conf 
This is for security.  Of course if you want to use it every day.
adb pull /data/misc/wifi/wpa_supplicant.conf .
vi wpa_supplicant.conf
if it is and empty file, paste in below and modify your ssid and wep_key0
update_config=0
ctrl_interface=tiwlan0
eapol_version=2
ap_scan=2
fast_reauth=1
network={
    ssid="YOUR_SSID"
    scan_ssid=0
    mode=1
    key_mgmt=NONE
    group=WEP104
    auth_alg=SHARED
    wep_key0="13alphanumeri"
}

if it not an empty, you must already have a ap connection configuration.  Just paste in the network clause.  Then it seems one or both of the below 2 lines is a must have to have security turned on.  
eapol_version=2
ap_scan=2

Then your pc or linux will be able to find the ssid specifed in the network clause as soon as wifi is turned on on Android.  Connect and enter the preset wep_key.  Make sure the pc or linux is configured to share internet connection.

Pretty sweet.