[IMPROVED FIX] ADHOC Mode with scripts to switch between ADHOC and Infrastructure

Search This thread

johnopsec

Senior Member
Dec 7, 2010
155
42
This -> View attachment adhoc-switcher.zip <- archive includes the modified wpa_supplicant file that supports ADHOC mode, along with scripts to switch back and forth between the ADHOC mode wpa_supplicant and the stock (Infrastructure only) wpa_supplicant on your NC.

The included file adhoc-switcher.sh is will do all of the work for you.

From the included README file:

Unzip the archive View attachment adhoc-switcher.zip into the same directory as your adb binary.

Execute ./adhoc-switcher.sh in your adb binary directory.

# md5sum adhoc-switcher.zip
e682e1578df1a253f1e4c42fd89f37d5 adhoc-switcher.zip


When you run adhoc-switcher.sh, you will see the following output telling you what it is doing:

Code:
$ ./adhoc-switcher.sh 

(1) Remounting /system as read-write...

(2) Making backup of original wpa_supplicant at:
/system/bin/wpa_supplicant.original...

(3) Making local backup of /system/bin/wpa_supplicant.original...

2070 KB/s (226036 bytes in 0.106s)

(4) Pushing up new files to /system/bin/...

wpa_supplicant.adhoc: 1662 KB/s (226028 bytes in 0.132s)
wpa_supplicant.infrastructure: 1711 KB/s (226036 bytes in 0.128s)
ap: 6 KB/s (271 bytes in 0.042s)
adhoc: 6 KB/s (253 bytes in 0.040s)

(5) Setting permissions on new files in /system/bin/...

(6) Setting Wifi mode to Infrastructure (ap)...

(7) Remounting /system as read-only...

All done!
To switch between Access Point (AP) [Infrastructure] mode and ADHOC mode,
execute the following commands on your NC:

# su
# ap

To switch to Access Point [Infrastructure] mode, execute the following
commands on your NC:

# su
# adhoc

You should turn off wifi before executing these commands.



Hope you find this useful.

John - your friendly neighborhood e-thug. :eek:
 
Last edited by a moderator:

rxr

Senior Member
Feb 19, 2006
60
0
Thank you. Will give this a try.
Any chance of anyone creating a toggle widget that can toggle between both with a simple tap.

Sent from my SGH-T959 using XDA App
 

monsterpt

Member
Dec 30, 2008
40
4
Very nice John. Good quick fix for the adhoc switching. Appreciate the effort.

Sent from the totally awesome Rooted Nook Color
 

johnopsec

Senior Member
Dec 7, 2010
155
42
Thank you. Will give this a try.
Any chance of anyone creating a toggle widget that can toggle between both with a simple tap.

Sent from my SGH-T959 using XDA App

I'd love to do that but, my netbook just isn't up to the task of running a full-on android dev environment. Over Christmas, I'll try to remember to bring the "big" laptop back with me.

If someone else beats me to it, that would be great too. :D
 

edison

Senior Member
Jul 21, 2007
85
11
This -> View attachment 464007 <- archive includes the modified wpa_supplicant file that supports ADHOC mode, along with scripts to switch back and forth between the ADHOC mode wpa_supplicant and the stock (Infrastructure only) wpa_supplicant on your NC.

Hey there, Mr. eThug. Thanks for the update. But I didn't it was necessary. After installing the original fixed wpa_supplicant, I can connect to adhoc and infrastructure networks. Or is there something else I'm missing?
 

johnopsec

Senior Member
Dec 7, 2010
155
42
Hey there, Mr. eThug. Thanks for the update. But I didn't it was necessary. After installing the original fixed wpa_supplicant, I can connect to adhoc and infrastructure networks. Or is there something else I'm missing?

The ADHOC capable wpa_supplicant has a bug that requires you restart wifi any time the NC sleeps. The original does not. Since my personal use is with standard Infrastructure (AP) connections primarily and ADHOC only on occasion, I decided that it would be handy to be able to switch between them easily.
 

johnopsec

Senior Member
Dec 7, 2010
155
42
You have a typo in the script, line 28 I think, should be "adb shell" and you have "db" shell.

Messes with permissions.

I just verified from my local copy and also downloaded the archive I uploaded to the site. They're identical and in every instance, it is "./adb shell" just as it should be.

Any possibility you opened adhoc-switcher.sh in an editor and accidently deleted a character? ;) Other than that, the MD5SUM of the original archive is:

# md5sum adhoc-switcher.zip
e682e1578df1a253f1e4c42fd89f37d5 adhoc-switcher.zip

Make sure that the MD5SUM matches for what you downloaded.
 

KitF

Senior Member
Dec 14, 2010
413
79
Philadelphia
kit.im
Oh that's right, I must have messed it up somehow converting it into a windows Batch file.

Any way we can get some sort of GUI app or a widget toggle for this? Seems like it would be handy for when I need to tether to my phone when there's no wifi around.
 

johnopsec

Senior Member
Dec 7, 2010
155
42
Oh that's right, I must have messed it up somehow converting it into a windows Batch file.

Any way we can get some sort of GUI app or a widget toggle for this? Seems like it would be handy for when I need to tether to my phone when there's no wifi around.

Cool. Glad we tracked that down! :D

I'd love a widget or app to switch between them. Two things though... This is a temporary "fix" for an issue. Once they get the bugs worked out of wpa_supplicant so it can support Infrastructure and ADHOC and not have the sleep issue, we won't need to switch back and forth between them. Second: I don't have a full-blown android dev platform to do an app or widget myself so, someone else would need to do it.
 

nikescar

Member
Jan 9, 2008
44
14
Indiana
I tried to modify the scripts to run through gscript and I thought it worked initially. Then when I went to switch it waste my wifi. Had to restore from the backup.

Gscripts would be nice I'm just not smart enough to do it.
 

KitF

Senior Member
Dec 14, 2010
413
79
Philadelphia
kit.im
Did you switch Wifi off before switching?

Also here's my converted .bat that I used:

Code:
echo
echo "(1) Remounting /system as read-write..."
adb shell "mount -o remount rw /system"
echo
echo "(2) Making backup of original wpa_supplicant at:"
echo "/system/bin/wpa_supplicant.original..."
adb shell "mv /system/bin/wpa_supplicant /system/bin/wpa_supplicant.original"
echo
echo "(3) Making local backup of /system/bin/wpa_supplicant.original..."
echo
adb pull /system/bin/wpa_supplicant.original
echo 
echo "(4) Pushing up new files to /system/bin/..."
echo
echo -n "wpa_supplicant.adhoc: "
adb push wpa_supplicant.adhoc /system/bin/
echo -n "wpa_supplicant.infrastructure: "
adb push wpa_supplicant.infrastructure /system/bin/
echo -n "ap: "
adb push ap /system/bin/
echo -n "adhoc: "
adb push adhoc /system/bin/
echo
echo "(5) Setting permissions on new files in /system/bin/..."
adb shell "chmod 755 /system/bin/wpa_supplicant.*"
adb shell "chmod 755 /system/bin/ap"
adb shell "chmod 755 /system/bin/adhoc"
echo
echo "(6) Setting Wifi mode to Infrastructure (ap)..."
adb shell "ln -s /system/bin/wpa_supplicant.infrastructure /system/bin/wpa_supplicant"
echo
echo "(7) Remounting /system as read-only..."
adb shell "mount -o remount,ro /dev/block/mmcblk0p5 /system"
echo
echo "All done!"
echo

A bit messy but it works.
 

donballz

Senior Member
Aug 26, 2010
70
7
I can see the ad-hoc network created by my phone and I connect. But none of the web-based apps are working. Says I am connected but no data comes through. Any ideas?
 

greenmky

Senior Member
Aug 4, 2010
129
7
Midland, MI
The .bat file is a good idea.

I factory reset my Nook again (tried to return it for one that flickers less). I had to go through this again. I was distracted when going through the commands and had mucked something up - Wifi wouldn't start back up at all after I tried to switch back and forth. But I knew it worked because I had it working yesterday.

Poked my head in and checked security (ls -l /system/bin) , I could tell the security of the files didn't match. Looks like I missed one or two of the chmod commands (kids were probably distracting me). Fixed 'em up and it's working fine now.

At least with a .bat file or the like, there's less chance for a typo.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 11
    This -> View attachment adhoc-switcher.zip <- archive includes the modified wpa_supplicant file that supports ADHOC mode, along with scripts to switch back and forth between the ADHOC mode wpa_supplicant and the stock (Infrastructure only) wpa_supplicant on your NC.

    The included file adhoc-switcher.sh is will do all of the work for you.

    From the included README file:

    Unzip the archive View attachment adhoc-switcher.zip into the same directory as your adb binary.

    Execute ./adhoc-switcher.sh in your adb binary directory.

    # md5sum adhoc-switcher.zip
    e682e1578df1a253f1e4c42fd89f37d5 adhoc-switcher.zip


    When you run adhoc-switcher.sh, you will see the following output telling you what it is doing:

    Code:
    $ ./adhoc-switcher.sh 
    
    (1) Remounting /system as read-write...
    
    (2) Making backup of original wpa_supplicant at:
    /system/bin/wpa_supplicant.original...
    
    (3) Making local backup of /system/bin/wpa_supplicant.original...
    
    2070 KB/s (226036 bytes in 0.106s)
    
    (4) Pushing up new files to /system/bin/...
    
    wpa_supplicant.adhoc: 1662 KB/s (226028 bytes in 0.132s)
    wpa_supplicant.infrastructure: 1711 KB/s (226036 bytes in 0.128s)
    ap: 6 KB/s (271 bytes in 0.042s)
    adhoc: 6 KB/s (253 bytes in 0.040s)
    
    (5) Setting permissions on new files in /system/bin/...
    
    (6) Setting Wifi mode to Infrastructure (ap)...
    
    (7) Remounting /system as read-only...
    
    All done!
    To switch between Access Point (AP) [Infrastructure] mode and ADHOC mode,
    execute the following commands on your NC:

    # su
    # ap

    To switch to Access Point [Infrastructure] mode, execute the following
    commands on your NC:

    # su
    # adhoc

    You should turn off wifi before executing these commands.



    Hope you find this useful.

    John - your friendly neighborhood e-thug. :eek:
    3
    Did you switch Wifi off before switching?

    Also here's my converted .bat that I used:

    Code:
    echo
    echo "(1) Remounting /system as read-write..."
    adb shell "mount -o remount rw /system"
    echo
    echo "(2) Making backup of original wpa_supplicant at:"
    echo "/system/bin/wpa_supplicant.original..."
    adb shell "mv /system/bin/wpa_supplicant /system/bin/wpa_supplicant.original"
    echo
    echo "(3) Making local backup of /system/bin/wpa_supplicant.original..."
    echo
    adb pull /system/bin/wpa_supplicant.original
    echo 
    echo "(4) Pushing up new files to /system/bin/..."
    echo
    echo -n "wpa_supplicant.adhoc: "
    adb push wpa_supplicant.adhoc /system/bin/
    echo -n "wpa_supplicant.infrastructure: "
    adb push wpa_supplicant.infrastructure /system/bin/
    echo -n "ap: "
    adb push ap /system/bin/
    echo -n "adhoc: "
    adb push adhoc /system/bin/
    echo
    echo "(5) Setting permissions on new files in /system/bin/..."
    adb shell "chmod 755 /system/bin/wpa_supplicant.*"
    adb shell "chmod 755 /system/bin/ap"
    adb shell "chmod 755 /system/bin/adhoc"
    echo
    echo "(6) Setting Wifi mode to Infrastructure (ap)..."
    adb shell "ln -s /system/bin/wpa_supplicant.infrastructure /system/bin/wpa_supplicant"
    echo
    echo "(7) Remounting /system as read-only..."
    adb shell "mount -o remount,ro /dev/block/mmcblk0p5 /system"
    echo
    echo "All done!"
    echo

    A bit messy but it works.
    1
    The adhoc and infrastructure don't show up in the folder in gscepits (only the switch.sh). Do you have to rename them with a .sh at the end?

    Sent rom my NC using XDA App

    Yes you will need to put a .sh at the end of the scripts.