Search code examples
androidwifirootadhoccyanogenmod

How to set up an ad hoc network by using the shell on a rooted Android device?


In the moment I am working with some ad hoc routing protocols (namely OLSR and B.A.T.M.A.N.) on rooted Android devices running Cyanogenmod. My tests are working pretty well. However, there is one thing which really is annoying: I can only connect to an existing ad hoc network, but not create one manually using only the phones. Right now I am using my laptop to set up an ad hoc network and to run a small DHCP server.

Do you know how to create an ad hoc network manually by using the shell on Android? I have found some methods how this should work, but none did work for me. I tried using ifconfig, iwconfig, netcfg and even wpa_cli (which seemed to be the best choice for this). But after any try the system fell back into "no wifi connected" state - even if the phone stayed in ad hoc mode for a couple of seconds while searching for an IP.

I will be so gladful if I can finally get around this problem because then I might actually use my laptop for Internet access (and therefore searching for online help during the tests) instead of using it to set up an ad hoc network. :-)


Solution

  • I'm not really clear on the technical details, but android-wifi-tether requires you to have a custom kernel with NETFILTER support, which I don't know if Cyanogenmod has. You might try using another open source project as an example: Barnacle Tether. It doesn't require a custom kernel.

    I've started looking at the source for Barnacle for my own project. It's pretty easy to compile, but I've only just begun playing with it so I don't know the exact answer to your question.