Active Topics

 


Reply
Thread Tools
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#1
I have the exact opposite problem of this fellow: http://talk.maemo.org/showthread.php?t=62736


I have wifi networks configured on my N900 for my house, girlfriend's house, and work. I scan every 5 min and auto-connect to wifi when avail. When I go home or to girlfriend's house the wifi automatically connects. When I go to work it sees the wifi network, and it can connect to the wifi network, but it doesn't.

The main difference is that the wifi at work is WPA2/PEAP/MSCHAPv2. Is there some reason that security would prevent auto-connect from working? I am using the power kernel.

Last edited by Flynx; 2011-03-15 at 03:45. Reason: solved
 
Posts: 112 | Thanked: 26 times | Joined on Sep 2009
#2
I've heard from my reading that WPA2 Enterprise (as opposed to PSK) doesn't allow for auto connection. Is this the case with your network?
 
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#3
I don't think so. Both my work-provided laptop (windows) and my personal laptop (ubuntu) will auto-connect to the enterprise network at work.
 
pusak gaoq's Avatar
Posts: 723 | Thanked: 519 times | Joined on Nov 2010 @ Kuching:Malaysia
#4
delete the AP from your n900 the try to add/connect to your wifi network at your work again....
 
Posts: 112 | Thanked: 26 times | Joined on Sep 2009
#5
I think this post mentions the bug, which I was describing to prevent auto-association with WPA enterprise.

http://talk.maemo.org/showpost.php?p=206365&postcount=3
 

The Following User Says Thank You to Dead1nside For This Useful Post:
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#6
ahh, so its a "feature". yeah, i've used that trick before too.

seems like a script could be written and then scheduled to auto-run during hours i might be at work.

i'll look into this tomorrow.
 
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#7
Ok, here's what I figured out so far....

I used 'alarmed' to run a script. The script is scheduled to run every 5 min between 8am and 6pm on weekdays (when I would typically be at work).

The script uses dbus commands to disconnect from the network, wait five seconds (required for disconnect to complete), then attempt to connect to the WPA Enterprise network.

This, unfortunately, is only a start. The script doesn't check to see if it is already connected to the Enterprise network, so it will perpetually disconnect and re-connect.

The script also doesn't check to see if the Enterprise network is available before attempting to switch to it.
 
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#8
OK, I wrote a bash script that should do the following:

1) check if i'm already connected to the enterprise network. if not...

2) look for the SSID of the enterprise network. if found...

3) disconnect from current connection and connect to enterprise network.

then I will use alarmed to auto-run the script every 10 min or so during business hours.

I haven't fully tested the script yet, but it seems to be working. I'm not really good with bash and never used awk so don't laugh!


Code:
#!/bin/bash

#get current ssid
LIST=$(iwconfig wlan0 | awk -F":" '/ESSID/{print $2}')

#if already connected then quit
if [ $LIST = '"nasa"' ]; then 
    exit 1;
fi

#clear previous ssid scans
rm /home/user/MyDocs/scripts/scans

#if not connected, bring up wlan (if not already) and scan ssids
ifconfig wlan0 up
SCANS=$(iwlist wlan0 scan | awk -F":" '/ESSID/{print $2}')
echo "$SCANS" > /home/user/MyDocs/scripts/scans
GOAL=$(more scans | awk '/"nasa"/{print "1"}' /home/user/MyDocs/scans)

#if network not found, exit
[ "$GOAL" ] || exit

#if network found, disconnect current network and connect to network using dbus
if [ "$GOAL" ]; then
	dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
	sleep 5
	dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:5f027850-3445-4eef-ac3f-76b423515990 uint32:0
	fi
I would like to modify this code so I don't have to be writing variables out to files, but the fact that its working is enough for now.
 

The Following 4 Users Say Thank You to Flynx For This Useful Post:
Posts: 37 | Thanked: 18 times | Joined on Apr 2010
#9
Here's my current bash at it:
Code:
#!/bin/sh

#get current SSID
LIST=`iwconfig wlan0 | awk -F":" '/ESSID/{print $2}'`
echo Current connection: $LIST

#Quit if already connected
if [ $LIST = "\"$1\"" ]; then
    echo \"$1\" is already connected
    exit 1;
fi

#Bring up wlan and scan for SSIDs
ifconfig wlan0 up
if [ -z `iwlist wlan0 scan | grep -m 1 -o \"$1\"` ]; then
    echo SSID \"$1\" not found;
    exit 1;
fi

#Disconnect current using dbus
dbus-send --system --dest=com.nokia.icd \
/com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true

#Wait for disconnect
sleep 6

#Find IAP_ID from SSID
IAP_ID=`gconftool-2 -R /system/osso/connectivity/IAP | tac | \
awk "/name = $1/,/connectivity\/IAP/" | \
awk -F '/|:' '/connectivity\/IAP/{ print $6}'`
echo IAP ID = $IAP_ID

#Connect to chosen SSID once disconnected
dbus-send --system --type=method_call --dest=com.nokia.icd \
/com/nokia/icd com.nokia.icd.connect string:"$IAP_ID" uint32:0

sleep 20

LIST=`iwconfig wlan0 | awk -F":" '/ESSID/{print $2}'`

echo Connected to $LIST

dbus-send --type=method_call --dest=org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications.SystemNoteDialog \
string:"Connected to $LIST" uint32:0 string:"OK"
  • Takes SSID as single parameter input
  • Uses SH instead of BASH and (I think) should work on an otherwise unmodified N900
  • Notifies user after connect
  • May well not work if you have changed the name of the connection to something other than the SSID
  • Still uses some inelegant string manipulation and downright ugly sleeps

Might try to add check for network status so I can remove the extra sleeps but probably won't get round to it!

EDIT: Doesn't seem to like being run as User. I'm running "sudo /usr/bin/run-standalone.sh /path/script 'SSID'" in alarmd to get round this

Last edited by hutchinsfairy; 2011-10-21 at 07:47. Reason: New info
 

The Following 4 Users Say Thank You to hutchinsfairy For This Useful Post:
Posts: 215 | Thanked: 158 times | Joined on Jan 2010
#10
I saw some people complaining about this bug again in bugzilla and came back to revisit the problem. I have two N900s now and only one sim card so I always want the other to be on wifi.

hutchinsfairy - sorry I am not smart enough to get your script to work for me. Here is what happens when I run it:

Code:
$ sudo /usr/bin/run-standalone.sh ~/MyDocs/scripts/hutchinsfairy 'nasa'
Current connection: wlan0 IEEE 802.11bg ESSID:""
sh: IEEE: unknown operand
SSID "" not found

My old script does seem to still be more-or-less working for me, but I did not include enough information for anyone else to be able to use it too.

1) i don't know if there are any dependencies, except bash obviously

2) You have to manually replace my SSID with yours in two places in the script.

2a) In line 7, my ssid is nasa. Replace that with yours:

Code:
if [ $LIST = '"nasa"' ]; then
note both the single and double quotes around the ssid.

2b) The second-to-last line looks like this:

Code:
dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:5f027850-3445-4eef-ac3f-76b423515990 uint32:0
we are concerned about the part in the middle that says:

Code:
string:5f027850-3445-4eef-ac3f-76b423515990
that somehow identifies the wifi network to connect to. I don't know why, and I haven't figured out a way to replace that with something simple, like the ssid, BUT you can replace that long string with the one for your network. Open a terminal and type:

Code:
gconftool -R /system/osso/connectivity/IAP
That will list a bunch of info about all your networks, search through it and find the IAP string for your wifi network and paste it into the script over mine. Then save.

(I had better luck connecting to the network and then using the gconftool command and near the top there is a line that says "last used network: blahblahblah". I used that string.)

3) you need to have a folder under MyDocs called scripts. put the script there.

4) To run the script, type:

Code:
sudo bash nameofscript
5) if it works, use alarmd to run the scripts routinely during business hours.

6) if you test it, let us know how it went.

Last edited by Flynx; 2011-10-20 at 23:39.
 
Reply

Tags
maemo 5, wpa2-eap


 
Forum Jump


All times are GMT. The time now is 19:52.