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 modmygphone.com'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 192.168.0.0 net, ICS will not work. Try create a network bridge between the wireless connection and LAN connection instead.

Have fun with your Android! ;-)

44 comments:

Anonymous said...

it's working only on rooted phones

Anonymous said...

Thank you man, you made my day, it worked like a charm, once again, thank you

Tomáš Velecký said...

Perfect, it's working on HTC Hero, too. I faced only two problems.

First I needed to run chmod 666 tiwlan.ini before I was able to pull it on computer.

Second problem was with wpa_supplicant.conf file. I chmoded it too, but still not able to pull it. So I run adb shell and then su. I copied file on sdcard and then adb-pulled from sdcard to computer. After I updated file and pushed it back to sdcard, it had to be copied back to proper location.

Don't forget to chmod it back to original values. You can see original access rights if you run ls -l command, before you chmod it for the first time.

北落师门 said...

Hi, I have tried the method and the ad hoc network worked perfectly. Thanks lots for that! But my problem now is that even when the ad hoc network is connected and Internet Sharing is enabled in Vista, the browser in my android is still refusing to connect to internet. Any suggestion as to what could have gone wrong? I have an HTC Magic and a laptop running Windows Vista

bitslice said...

北落师门: I'm not sure how Vista net sharing works. But it should be similar to that of XP. Can you try a traceroute from your Android to see whether the connection really works?

Tomáš Velecký said...

@北落师门: if I were you, I would check firewall settings, it helped me with other connection problem.

Anonymous said...

Can't get it to work because:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mount: Operation not permitted

Probably this instructions valid for rooted phones

Rafa said...

Hi there,
I'm trying to use ADB to edit these files in order to get an ad-hoc connection, but I'm stuck because I can not install the drivers for my phone.

I have a HTC MyTouch 3G rooted phone (Cyanogen 4.2.6) and I've already downloaded the drivers from the SDK official page, but I just can't work it out. Did you have a trouble like this? I'm thinking maybe I don't need to install drivers at all, or maybe it's not possible to install those driver in my case, any clue?

Thanks in advance

bitslice said...

Racheado,

You can follow the instructions at http://modmygphone.com/forums/showthread.php?t=22681

Anonymous said...

Между прочим, лучший способ обезопасить кого-нибудь от назойливых телефонных звонков - включить Подавители связи

Anonymous said...

tiwlan.ini is missing in Samsung Galaxy Spica, can i use any other tiwlan.ini or should be device specific, if not please upload the file.

thanks and God Bless!

Anonymous said...

This is useful information. Thanks for this

Unknown said...

There is no tiwlan.ini on the Spica. TI stands for Texas Instruments and the Spica uses a Broadcom solution.

A workaround for phones with these chipsets would be much appreciated too!

David said...

I was so happy reading through your post but got sad after reading the last comment.I have Galaxy Spica and it seems i won't be able to let this work on my phone.Hardluck.
If someone know a way around for spica please let me know.

Greg said...

I tried this on a Rooted 2.1 Hero, but can't get the ad hoc network to show up on the phone. Any advice???

Tomáš Velecký said...

Original link to editing wifi files doesn't exist any more. New link is
http://modmymobile.com/forums/491-jailbreak-root-access/544146-connect-g1-ad-hoc-network-solved.html

Tomáš Velecký said...

@Gregory: I just did it on my HTC Hero 2.1 (VillainROM) and it worked. Where did you end up?

For htc hero you need to do following:
> adb remount
> adb pull /system/etc/wifi/tiwlan.ini tiwlan.ini
> adb pull /data/misc/wifi/wpa_supplicant.conf wpa_supplicant.conf

(backup those two files and then edit them according to link I posted before)

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

That's it. It should work now.

If you get an error that wifi can't be started, then just chmod both files in phone to 666.

Let me know, if it is still not working.

Greg said...

Tomas,

Nope, same problem. Hero just doesn't see my computer. I left encryption off, and nothing works.

Greg

Tomáš Velecký said...

make sure, that you have same SSID set on your computer and hero.

If you don't have DHCP server on your computer then you have to setup manual IP address on your hero and also gateway should be set to computer's IP.

You can try to update radio on your hero.
http://www.villainrom.co.uk/wiki/index.php?title=Installing_Custom_ROMs#Step_Three:_Updating_your_Radio

The problem can be also in WiFi channel. If your computer's wifi is set to use for example ad-hoc channel 13, your Hero might not see the computer.

Greg said...

I set the SSID correctly, but that's the only thing that is obvious. There's no apparent way to set the IP address or anything else on the Hero if I wanted to.

I hope they intentionally meant to make this difficult, because if not, they are just idiots. All we know is they put in a line called "Adhocwifi = 0", so some bonehead deliberately spent the time to ensure that this capability wouldn't be accessible.

Brilliant.

Tomáš Velecký said...

Go to wifi settings and there press menu button. Menu will pop-up and select "advanced". There you'll be able to set IP address. Hope this solves your problem.

Greg said...

Thanks, but I'm not sure how that's supposed to help. I set the IP address, but I can't tell what difference that makes. I can't force my computer to connect to that IP address, can I? I can only set the IP info on each device, not direct it to look for particular info on the OTHER device.

Tomáš Velecký said...

Let's get back little bit. What do you mean by "Hero just doesn't see my computer"?

You don't have ad-hoc wifi listed in available networks? Once you perform action specified in article, you should have the ad-hoc wifi listed all the time.

Unknown said...

i can't find the file /system/etc/wifi/tiwlan.ini tiwlan.ini on my windows vista and how do you edit it? Thanks.

Elektricni_coban said...

can't find tiwlan.ini anywhere on my desire...Where could it be :)?

Anonymous said...

damn it i just dont unerstand how the hell to do this? how do i find this ini file? wish it was easy like iphone. i am on htc mt 1.6.
i need more explaination...

Cristhian said...

Sei que to atrasado com a resposta, mas pra quem ainda estiver enfrentando esse problema... uma boa alma jah resolveu ele pra gente...
Connectify! Um programa que simula um AP usando a wireless do pc... o android acessa a rede do pc como se fosse um ap... sem alterações... sem complicaçoes!

Betty at Purse Party said...

I have a Blackberry and it is frustrating me that the Facebook app does not work on it's wifi. How come it works on other smart phones? Perhaps, it is not so smart at all.

Unknown said...

hi... im using Xperia X10, i read your post and open up my root explorer... i find there are no tiwlan.ini in my wifi folder. does that mean i cant use this method?

Anonymous said...

Try to download www.bzeek.com to your laptop, and most probably the laptop will become a wifi hotspot, to which yo'll easily connect your device.

Unknown said...

Hi all ,
I followed the instructions and now i have a network listed in wifi networws, but is always in status "Not in Range, remembered".
The wifi network is alive and i can connect to it using a pc or notebook.
I'm using a motorola milstone rooted, with android 2.1.
Any suggestion about what I can try to fix it?

Anonymous said...

hi ...
friends i have android 007 and its not connecting with adhoc wifi so please suggest me what i do i m waiting for ur reply

Anonymous said...

Fine information. Thanks so much, have a good day!
Systems Phone

Free Antivirus Download said...

what is lucrative thing behind it. free antivirus download

Unknown said...

What an informative collection.vodafone deals

Anonymous said...

Hey to everyone, it’s my first visit of the blog site; this blog includes awesome and actually best info for the visitors.

Unknown said...

Your articles are very well written and unique.
which payday on line loans operate in minnesota

Unknown said...

It’s really such nice information to get advantage from.
shotblast equipment

Unknown said...

I would be supportive on all your articles and blogs as a result of they are simply up to the mark.
concrete vacuum

Unknown said...

Hey nice post man! Thanks for incredible info.
spindle cap

Anonymous said...

It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. http://www.actionlinkwireless.com/

SEO KILLER said...

The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface. iOS 11.4 Jailbreak

lindi said...

Emus4u

Nancy said...

It will also provide several additional benefits and enable you to make inexpensive international calls. No matter where you go, you can always call the same number. Static IP SIM Card