# [solution]A workaround for one of the CM9 wifi issues



## dharani1234 (Aug 20, 2011)

CM9 folks ...here's the most stupid workaround(that works) for one of the WIFI problems on CM9.

Users who just have one WiFi network at their home; try to change your router's channel to 6 or 1 and the wifi "should" work.If you have multiple SSID's you can also probably try this. The process looks big , but it will hardly take 5 minutes .

This workaround is for the users who are not able to connect to the corporate Wifi routers. The problem seems to be that there are multiple networks with the same SSID in a corporate wireless-LAN and the touchpad is not able to "roam" from one router to the other. Hence when you connect initially, it registers itself with a certain "BSSID" and when that is no more in range ... it's unable to reconnect.


```
<br />
NOTE:  I am not a network professional...all the info stated in this post is from a couple of experiments I have been conducting for the past 1 week.<br />
I have tested it on a WPA2 network , and I guess this should work with EAP as well.<br />
	  <br />
That being said ... I am not responsible if it doesn't work as stated or I am not able to answer all your questions or you feel this method is cumbersome.
```
People who have the time/interest/patience to test something just for fun can continue reading...

1) The concept of this is simple ... get the BSSID's of the individual networks and add them manually to the wpa_supplicant.conf file so that the driver treats each BSSID as an individual AP.
2) To get started ... delete the "wifi" folder from /data/misc . Either use root explorer or "terminal".
3) Reboot and connect to wifi as usual.
4) Download wifi analyzer from the market. --- https://market.andro...W5hbHl6ZXIiXQ..
5) Open wifi analyzer and click on the "view" icon as shown in the image and select "AP List"
6) Every entry in the "AP List" view shows the "SSID NAME" "BSSID number" "Channel#" strength and other characteristics.



7) Now comes the fun part; keep watching the different BSSID's that keep changing on every scan.
8) You will notice that there are some rows(BSSID entries) that are constant and do not disappear from the screen. Keep watching for atleast 3-5 minutes.
9) These are the BSSID's we are interested in. Get those BSSID's for the channel numbers "1" and "6".
10) Other channel#'s might work , but I was not able to get them to work on my TP.
11) Note down those BSSID's in a file on your PC/MAC , then on the touchpad ,open root explorer or any explorer with access to / and navigate to "/data/misc/wifi"
12) modify the wpa_supplicant.conf file as shown below; make sure you edit the file manually in the text editor.
13) You can manually type one network {} entry and then copy/paste the other ones.


```
ctrl_interface=wlan0<br />
	update_config=1<br />
<br />
network={<br />
	ssid="SSID-NAME"<br />
	psk="password"<br />
	key_mgmt=WPA-PSK<br />
   scan_ssid=1<br />
   bssid=xxxxxxxx:a6:bf:49<br />
}<br />
<br />
network={<br />
	ssid="SSID-NAME"<br />
	psk="password"<br />
	key_mgmt=WPA-PSK<br />
   scan_ssid=1<br />
   bssid=xxxxxxxx:a6:f2:c9<br />
}<br />
<br />
network={<br />
	ssid="SSID-NAME"<br />
	psk="password"<br />
	key_mgmt=WPA-PSK<br />
   scan_ssid=1<br />
   bssid=xxxxxxxx:a6:ef:59<br />
}<br />
<br />
network={<br />
	ssid="SSID-NAME"<br />
	psk="password"<br />
	key_mgmt=WPA-PSK<br />
   scan_ssid=1<br />
   priority=1<br />
   bssid=xxxxxxxx:a6:f2:19<br />
}<br />
<br />
network={<br />
	ssid="SSID-NAME"<br />
	psk="password"<br />
	key_mgmt=WPA-PSK<br />
   scan_ssid=1<br />
   bssid=xxxxxxxx:a6:6b:f9<br />
}
```
14) So every time you go to a new place within your company; just stop wifi, edit the wpa_supplicant.conf file and add the dominant "1" or "6" channel BSSID entry from the "wifi analyzer" and start wifi.
15) The next time you visit the same place ; Wifi will autoconnect.
16) Roam around all the common places once, add the dominant BSSID and you should be good . Do not forget to take a backup of the wpa_supplicant.conf file after you have added all your common place's BSSID's.

*PS: *It does take some time (approx 1 min ) to re-connect when you "roam" from one place to another after the BSSID's have been added.

For those who are not afraid of using the terminal; there's an easy way.

1) start terminal emulator ( make sure wifi is on ) and enter the commands shown below ..
2) su - ("allow" root access)
3) cd /system/bin
4) wpa_cli scan_results | egrep -i '2412|2437' | grep -i "your ssid name" | awk '{print $1}'
5) The above command gives you the necessary BSSID's in that area.


----------



## mercado79 (Dec 13, 2011)

Just to be clear... BSSID is the same thing as saying MAC address. So if you have access to the actual routers, you should be able to simply read the numbers off of them. I was running into this issue at home. Thanks so much for the fix! I'm trying it out now.

EDIT: 
Wifi analyzer gave me slightly different IDs. For both my routers, the last character was different. Weird. I used the values Wifi analyzer gave me though and everything is looking good. Thanks again!


----------



## dharani1234 (Aug 20, 2011)

mercado79 said:


> Just to be clear... BSSID is the same thing as saying MAC address. So if you have access to the actual routers, you should be able to simply read the numbers off of them. I was running into this issue at home. Thanks so much for the fix! I'm trying it out now.
> 
> EDIT:
> Wifi analyzer gave me slightly different IDs. For both my routers, the last character was different. Weird. I used the values Wifi analyzer gave me though and everything is looking good. Thanks again!


Glad to hear it's working for you .... I do not have access to the physical routers , so I am using wifii analyzer.
If more ppl test this and it works ... we can figure out a way to script this ...


----------



## mercado79 (Dec 13, 2011)

dharani1234 said:


> Glad to hear it's working for you .... I do not have access to the physical routers , so I am using wifii analyzer.
> If more ppl test this and it works ... we can figure out a way to script this ...


well it worked for me for a little while and then i started getting system lockups followed by reboots. sometimes would reset even before fully loading. i reverted to a nandroid backup. i haven't had time to go back to this until tonight.

this time i made sure i was not messing with any other mods, new apps, etc. within a minute or two, the same thing has started happening again. so, i'm hoping you can tell me how you modified the wpa_supplicant.conf file. no apps i use were able to open it and so i was doing an adb pull to my desktop (tried both in windows 7 and ubuntu) and editing in the text editor. no major changes. just added the bssid's for two wireless signals.

any tips/pointers?

EDIT:
what's the "scan_ssid" part? does that mean the channel the signal is being broadcast on? if so, that may be my issue. i simply copied your "1", but my routers are running on 6.

EDIT2:
Found more info here:
http://www.daemon-systems.org/man/wpa_supplicant.conf.5.html
*scan_ssid*

SSID scan technique; 0 (default) or 1. Technique 0 scans for the
SSID using a broadcast Probe Request frame while 1 uses a
directed Probe Request frame. Access points that cloak them-
selves by not broadcasting their SSID require technique 1, but
beware that this scheme can cause scanning to take longer to com-
plete.


----------



## mercado79 (Dec 13, 2011)

i tried changing the ssid_scan value to 0. no luck. worked initially, but once i rebooted, it just kept boot looping. below is my modified wpa_supplicant.conf file. maybe someone will see something i don't:


```
<br />
ctrl_interface=wlan0<br />
update_config=1<br />
<br />
network={<br />
ssid="NAME"<br />
psk="PASSWORD"<br />
key_mgmt=WPA-PSK<br />
scan_ssid=1<br />
bssid=00:25:9c:XX:XX:XX<br />
}<br />
<br />
network={<br />
ssid="NAME"<br />
psk="PASSWORD"<br />
key_mgmt=WPA-PSK<br />
scan_ssid=1<br />
bssid=00:0f:66:XX:XX:XX<br />
}<br />
```
i also tried leaving in the priority numbers. no luck there either.


----------



## dharani1234 (Aug 20, 2011)

mercado79 said:


> i tried changing the ssid_scan value to 0. no luck. worked initially, but once i rebooted, it just kept boot looping. below is my modified wpa_supplicant.conf file. maybe someone will see something i don't:
> ......
> .......
> 
> i also tried leaving in the priority numbers. no luck there either.


DO NOT edit the file outside ....

NOTE: Before you try any of the following steps, delete the "wifi" dir from /data/misc, reboot touchpad and then continue.

1)Do you have root explorer ? use it
2)If you know how to use "vi editor" then download hacker's keyboard and edit the supplicant.conf file in terminal editor.
3) If not ... use terminal emulator to copy the file to a different directory and then edit it using a text editor .


```
<br />
su -<br />
cd /data/misc/wifi<br />
cp wpa_supplicant.conf /sdcard/download/wpa_supplicant.conf<br />
edit the file in "/sdcard/download" with a text editor of your choice and save it.<br />
cp /sdcard/download/wpa_supplicant.conf /data/misc/wifi<br />
chmod 600 /data/misc/wifi/wpa_supplicant.conf<br />
```
scan_ssid=1 is preferable for networks which do not broadcast SSID's such as the case of my network's routers.If your networks do not have hidden SSID's , do not create that entry. ( Do not put scan_ssid=0 )

I have been using the setup for the past 4 days and it works flawlessly ....hope it works for you as well...


----------



## mercado79 (Dec 13, 2011)

dharani1234 said:


> DO NOT edit the file outside .... NOTE: Before you try any of the following steps, delete the "wifi" dir from /data/misc, reboot touchpad and then continue. 1)Do you have root explorer ? use it 2)If you know how to use "vi editor" then download hacker's keyboard and edit the supplicant.conf file in terminal editor. 3) If not ... use terminal emulator to copy the file to a different directory and then edit it using a text editor .
> 
> ```
> su - cd /data/misc/wifi cp wpa_supplicant.conf /sdcard/download/wpa_supplicant.conf edit the file in "/sdcard/download" with a text editor of your choice and save it. cp /sdcard/download/wpa_supplicant.conf /data/misc/wifi chmod 600 /data/misc/wifi/wpa_supplicant.conf
> ...


thanks man. i'll give this another shot later today. i swear i read over your instructions several times and somehow skipped the whole "delete wifi folder" part. that might be it. that and changing the file permissions. i hope that's it. i'll report back later.

(oh and my vi skills are laughable...they were once barely good enough to get me by, but... i've slacked on it. maybe i should brush up)


----------



## fakedrake (Jan 24, 2012)

mercado79 said:


> thanks man. i'll give this another shot later today. i swear i read over your instructions several times and somehow skipped the whole "delete wifi folder" part. that might be it. that and changing the file permissions. i hope that's it. i'll report back later.
> 
> (oh and my vi skills are laughable...they were once barely good enough to get me by, but... i've slacked on it. maybe i should brush up)


Let us know how it goes. I will try it out if works for a few of you. This wifi issue is making my touhcpad unusable at work.


----------



## mercado79 (Dec 13, 2011)

well, looks like it's working for me now. it's been extremely frustrating to get it done, though i think the main problems for me had to do with using the wrong apps for a) copying the wpa_supplicant.conf file and b) editing the text. without going into too much detail, i had been using file expert for copy/pasting the file and didn't have or at least didn't know what app to use for editing the file. editing the file on my personal pc seemed to lead to errors. similarly, editing the file with FE Text Editor (bundled w/ File Expert) or ES Note Editor (Estrongs File Explorer) always resulted in a bootloop.

steps that worked for me:
use estrongs file explorer (with root and read write permissions enabled in settings) to delete the /data/misc/wifi directory
reboot and turn on wifi so that a fresh wpa_supplicant file is created for you. i didn't connect to anything. just toggled it on, then off.
copy that file using estrongs to your sdcard (file is not editable while in the original folder)
edit the file using DB Text Editor (comes up as an option if you have dropbox installed and choose "Open as..." from within Estrongs). note that this part was kind of a pain since there's A LOT of commented text in there initially...mainly notes on proper usage. all of it can be deleted. the amount of text in the file makes the text editor very sluggish. so, long press on a word. once the menu icon pops up, choose "select all" and then delete. the menu might be hidden by the keyboard when in landscape, so rotate the touchpad to portrait mode (tall).
enter in your new settings. mine are exactly as i posted previously, minus the scan_ssid line.
save and exit.
copy the file back to the /data/misc/wifi directory.
toggle on wifi (no reboot necessary) and see if the touchpad connects to the wireless signal automatically.
troubleshooting:
i recommend you do a nandroid backup before you make any changes to system files. this is probably one of the safer mods though. if your tablet starts to bootloop, just boot into clockworkmod recovery, mount /data, connect the touchpad to your computer, then remove the wpa_supplicant.conf file using adb commands then reboot and start over.


```
<br />
c:\adb shell<br />
# cd /data/misc/wifi<br />
# rm wpa_supplicant.conf<br />
# exit<br />
```
i imagine that root explorer would have done all this far easier. dharani, is that what you used or did you use vi? any suggestions for a good standalone text editor to use? either way, i think this is a go. if it can be scripted for people somehow, that'd be even better.


----------



## dharani1234 (Aug 20, 2011)

Actually it's a pretty easy way ....  ... i use root explorer to do it.

1) Get the BSSID's
2) Stop WIiFI
2 Add them to wpa_supplicant.conf via root explorer
4) start wifi
5) Enjoy wifi


----------



## Nazgul07 (Sep 22, 2011)

Just wanted to throw this out to everyone. I had wifi issues back in GB... (said connected but couldn't do anything on the net). I fixed it by setting my router channel to 3 (something lower than 6). However, the issue came back immediately when i updated to cm9 and was persistent after a reboot.

I read around and decided to update my webos to 3.0.5 (was on 3.0.4) and after I did that I haven't had a single issue. I know that webos shouldn't affect android, but I wonder if it could be a file or setting on the very low level boot that affects something in the android kernel/wifi driver. Anyway, it worked for me, so maybe it will for others.


----------



## nevertells (Oct 29, 2011)

Nazgul07 said:


> Just wanted to throw this out to everyone. I had wifi issues back in GB... (said connected but couldn't do anything on the net). I fixed it by setting my router channel to 3 (something lower than 6). However, the issue came back immediately when i updated to cm9 and was persistent after a reboot.
> 
> I read around and decided to update my webos to 3.0.5 (was on 3.0.4) and after I did that I haven't had a single issue. I know that webos shouldn't affect android, but I wonder if it could be a file or setting on the very low level boot that affects something in the android kernel/wifi driver. Anyway, it worked for me, so maybe it will for others.


Glad that helped. Just for the record, after installing alpha .0, no wifi problems at all. Here is a tip about setting channels on your router. Router guru's state that one should use a channel that is well seperated from the other primary channels, ie. 1,6 or 11. Using anything in between means you are sharing bandwidth with with two of the primary channels, 1,6,or 11. Try using Wifi analyzer to look at the wifi spectrum in your area. Pick either 1 or 6 depending where there is the least usage. Don't use 11, as Touchpads running Android don't like 11.


----------



## fakedrake (Jan 24, 2012)

dharani1234 said:


> Actually it's a pretty easy way ....  ... i use root explorer to do it.
> 
> 1) Get the BSSID's
> 2) Stop WIiFI
> ...


Looks to be easy enough for me to try it out. I'll let you know how it went. Thanks dharani!!


----------



## craigmarc82 (Sep 6, 2011)

I haven't had any issues with wifi on any cm alpha builds gingerbread or ics until cm9 alpha .6. 
On alpha .6 my wifi would connect then just drop out and not reconnect unless I switched airplane mode on and off.
To try and resolve this issue I installed wifi fixer from the market and now the connection seems to be rock solid. 
The app is free. Hope this helps.
Sent from my cm_tenderloin using RootzWiki


----------



## fakedrake (Jan 24, 2012)

fakedrake said:


> Looks to be easy enough for me to try it out. I'll let you know how it went. Thanks dharani!!


I tried everything from this post, but I am not lucky I guess. I don't think there is a big affected user base with this specific issue in order for the CM team to get their attention! It happens only at work places or universities where there are multiple routers (at different channels) with the same hostname, but works perfectly fine at home.

If anyone has any update, or got it working on their CM9 touchpad, please post a reply here.


----------

