HOWTO connect an HTC desire to an ad-hoc network
THERE IS NOW AN ANDROID APPLICATION THAT RUNS THESE COMMANDS FOR YOU: desire-adhoc
This is a short guide on how to connect your HTC desire phone to an ad-hoc wireless network. Currently the process is highly unautomated but easily scriptable – maybe at some point somebody will implement an easier solution.
Root your phone
In order to have full access to your phone’s OS you’ll have to ‘root’ it. Follow this guide.
Install additional software
Now all that’s missing is a little tool called iwconfig that will be used to set your network device’s communication parameters. Since it’s not included in the default installation, I got mine from the wifi-tether application (eg. download this package, unzip it and put the iwconfig binary on your phone using `adb push`).
Restart the network interface
Any modifications you do to your network device will be changed back by (AFAICT) wpa_supplicant, thus we will be doing things manually. First, disable the phone’s wifi using the normal GUI tools. Once you have done that, the wifi interface will be gone and the kernel module unloaded, so we need to reload it. Open a shell on your phone:
adb shell
and load the module:
insmod /system/lib/modules/bcm4329.ko
Now you have a nice, clean wifi interface that’s completely under your control!
Connect to the ad-hoc network
Finally, you can connect to your ad-hoc network. In my case I use static IP addresses:
iwconfig eth0 mode ad-hoc iwconfig eth0 essid mynetwork ifconfig eth0 192.168.0.150
That’s it.
Notes
- It seems the phone dislikes the idea of joining existing adhoc networks. If you see that iwconfig just doesn’t switch the interface to adhoc mode, try a different ESSID.
Is there any way to put the interface in monitor mode ?
Not as far as I can tell – “iwconfig eth0 mode monitor” fails.
How would I go about activating DHCP on this?
Android doesn’t have dhclient or similar as far as I can see.
I figured that one out myself, “netcfg eth0 dhcp”.
Now i’m having trouble with properly setting up DNS servers, ping and browsing to a IP adress works. Any help?
I feel like a spammer but it just started working on its own. Strange.
@Poodlemastah: good to hear
Hey. Could someone please tell me, where I’ve to adb push the iwconfig? (path?) I’ve been trying for some time now but doesn’t matter where I put it, I always get the answer iwconfig: not found. I read that it’s possible to directly modify wpa_supplicant.conf, so that you can see adhoc-networks directly over the UI. But I couldn’t manage this neither…
Someone can help? Thanks
@baesae: the path doesn’t really matter, you can put it somewhere in /data and then call it using the full path (eg. /data/mypath/foo/iwconfig eth0 …). or you can figure out the system’s PATH (echo $PATH) and put it in one of those dirs.
great hint. thanks.
Hey. Could someone please tell me, where I’ve to adb push the iwconfig? (path?) I’ve been trying for some time now but doesn’t matter where I put it, I always get the answer iwconfig: not found. I read that it’s possible to directly modify wpa_supplicant.conf, so that you can see adhoc-networks directly over the UI. But I couldn’t manage this neither…Someone can help? Thanks
+1
i can’t get the iwconfig to work:
1. if i push it to the system it says \read only ..\ (it’s normal)
2. i copyed it to the sdcard and seems the root has no right —-rwx— and doesn’t let me use it
please help
my bad , the owner has no rights
I copied the file using the adb push command. Cannot execute the binary because I keep getting the permission denied error. Any suggestions? Thanks
@stefan: which file? if you’re talking about iwconfig, try chmod +x /path/to/iwconfig. or you could just install the app from http://desire-adhoc.googlecode.com/
For everyone having trouble with dns-configuration: you can manually set the dns-server with e.g
setprop net.dns1 192.168.0.1
This guide and app seems don’t works with froyo based rom.
I have a rom based on official htc rom and don’t works for me…