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.
  1. Adrien
    May 31st, 2010 at 19:10 | #1

    Is there any way to put the interface in monitor mode ?

  2. May 31st, 2010 at 19:17 | #2

    Not as far as I can tell – “iwconfig eth0 mode monitor” fails.

  3. Poodlemastah
    May 31st, 2010 at 20:50 | #3

    How would I go about activating DHCP on this?
    Android doesn’t have dhclient or similar as far as I can see.

  4. Poodlemastah
    May 31st, 2010 at 21:18 | #4

    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?

  5. Poodlemastah
    May 31st, 2010 at 21:25 | #5

    I feel like a spammer but it just started working on its own. Strange.

  6. May 31st, 2010 at 23:13 | #6

    @Poodlemastah: good to hear :)

  7. baesae
    June 15th, 2010 at 13:23 | #7

    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

  8. June 15th, 2010 at 17:49 | #8

    @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.

  9. June 26th, 2010 at 14:02 | #9

    great hint. thanks.

  10. June 29th, 2010 at 15:43 | #10

    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

  11. Misa
    July 22nd, 2010 at 00:58 | #11

    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 :(

  12. Misca
    July 22nd, 2010 at 10:55 | #12

    Misa :
    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

  13. stefan
    August 3rd, 2010 at 01:44 | #13

    I copied the file using the adb push command. Cannot execute the binary because I keep getting the permission denied error. Any suggestions? Thanks

  14. August 3rd, 2010 at 02:54 | #14

    @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/

  15. froggy
    August 5th, 2010 at 04:19 | #15

    Poodlemastah :
    Now i’m having trouble with properly setting up DNS servers, ping and browsing to a IP adress works. Any help?

    For everyone having trouble with dns-configuration: you can manually set the dns-server with e.g
    setprop net.dns1 192.168.0.1

  16. Mattia
    August 13th, 2010 at 20:18 | #16

    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…

  1. June 3rd, 2010 at 16:06 | #1
  2. July 15th, 2010 at 20:35 | #2