Saturday, July 18, 2009

Connecting Android Phone Through Adhoc Wifi Network

An Android phone works perfectly when you have a wireless connection, either through wifi wireless AP or mobile network GPRS. However, when it comes to places where only wired connectivity is available, for instance an Ethernet connection or a dial-up connection, or when you're roaming and using mobile network's data roaming might cost you a fortune, some workaround must be done.

My HTC Magic works fine back at home. I got both unlimited wifi and GPRS connectivities. But when I roam elsewhere, which I do a lot, the data roaming cost would be too high and most hotels I stay have no wifi but only wired Ethernet in-room.

One thing which I know will work is to carry with you a wireless AP, plug the LAN cable in, and you're all set. But I don't want to add any more weight to my bags. So I think about turning the laptop into an access point instead.

So I did some searches and found a very useful information at's forum. The thread mentioned configuring your G1 Android phone to connect to a laptop's ad-hoc wireless network. That's exactly what I need!

I didn't modify the files directly on the phone, but instead I used adb pull the 2 files onto my laptop, then edited the files, then adb push them back. So the steps were:

> adb pull /system/etc/wifi/tiwlan.ini tiwlan.ini
> adb pull /data/misc/wifi/wpa_supplicant.conf wpa_supplicant.conf

[.edit tiwlan.ini and wpa_supplicant.conf according to the guide]

> adb shell
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

# exit

> adb push tiwlan.ini /system/etc/wifi/tiwlan.ini

> adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.conf
> adb shell
# mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
# exit


You will see your ad-hoc wifi network name in networks list (Settings -> Wireless controls -> Wi-Fi settings). Phone modification part is complete.

Now back to the laptop. An ad-hoc wireless connection has to be created and Internet Connection Sharing enabled. There are many guides available on the Internet. (for example here.) When it's created, in "Choose a wireless network" window, select your ad-hoc network and click "Connect." Your phone and laptop should try to connect to each other and you're all done!

In case you're unlucky and your hotel network assigns IP address in net, ICS will not work. Try create a network bridge between the wireless connection and LAN connection instead.

Have fun with your Android! ;-)