maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   An app to automatically grab open wifi? (https://talk.maemo.org/showthread.php?t=23248)

arover 2008-08-29 15:28

An app to automatically grab open wifi?
 
Does such an app exist with the N8x0? Or some sort of script I can use? I'm basically looking for a way to have my N810 grab the next open wifi connection wherever it goes when I'm using it at times, or at least a way to make it automatically grab by SSID, or even grab all open connections with some sort of exception list. Any ideas, anyone?

arover 2008-08-29 16:03

Re: An app to automatically grab open wifi?
 
Nevermind..I found something: Devicescape. Work well?

timsamoff 2008-08-29 16:11

Re: An app to automatically grab open wifi?
 
Quote:

Originally Posted by arover (Post 218962)
Nevermind..I found something: Devicescape. Work well?

It's cool (closed source, though). It doesn't automatically pick open wifi spots unless they are stored in their database (user-driven). It will, though, automatically connect to any of the spots you have stored on your tablet.

-T.

arover 2008-08-29 16:25

Re: An app to automatically grab open wifi?
 
Are there any tools out there that grab any and all unsecured wireless connections? If my experience with linux were a bit more in-depth, I'd look into writing a script myself to run a connection to "x" if there is no security.

Saturn 2008-08-29 18:36

Re: An app to automatically grab open wifi?
 
Hi,

not exactly what you're asking, but you might find it useful..

I connect to my access points using:
dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:$IAP uint32:0

replacing $IAP with the name of my access point.

I got it from here:
http://www.gossamer-threads.com/lists/maemo/users/13694

tz1 2008-08-29 19:55

Re: An app to automatically grab open wifi?
 
when not (or poorly connected), doing "iwlist wlan0 scan" will return a list of access points (and AdHoc networks) including if they are encrypted. Then the above dbus command could connect to them.

One problem might be some places that are semi-public and use a bounce "By using this service you agree to these TOS:..., Click I Agree".

But in general, if I do any network activity it seems to try to reconnect to anything it has seen - including the default netgear, linksys, etc. I have in my list - when it loses a connection (like when I'm driving from my hotel, it gets the next one, the one at the fastfood place, then the office store, and the coffee shop in order, since I hear the "disconnected" tone several times).

arover 2008-08-29 22:25

Re: An app to automatically grab open wifi?
 
ok then I guess my question is this: Is it possible to make a script that can do the following :
- Check every x minutes for a lack of connection OR run upon disconnection
- run the dbus command where the variable access point is defined by the scanned point with no security and the greatest signal strength according to iwlist..

stangri 2008-08-30 13:02

Re: An app to automatically grab open wifi?
 
Uhm, not sure if it will be of great help, but I guess it wouldn't hurt. Some folks over at dd-wrt (it's a third-party linux-based firmware for home routers) wrote a script which does exactly this -- it picks up the open wifi AP with the strongest signal, checks if it connects to internet (some open AP require the login/pass to get the actual internet) and it cycles to the nest strongest signal on failure.
Given that that script works on linux, I'm guessing it could be of help. I'd post a link to the forum thread, but not sure if it's welcomed on this forum.

arover 2008-08-30 14:58

Re: An app to automatically grab open wifi?
 
If you don't wish to post it here, I'd be grateful if you could message me the link. I mean, I really don't see any problem in posting it here, but maybe there are some rules I don't know of :confused:

Edit: I found the script you were talking about, but I think it uses commands that are mainly only used on the DD-WRT firmware. I DID however find a bash script someone wrote on the other linux forums. I'm going to try it out and I'll report back the results.

arover 2008-08-30 16:48

Re: An app to automatically grab open wifi?
 
Here's the script I found, credits to a linux forum, though I can't get it to work...seems to be pulling up an error on line 31, and I have no idea what it means. If anyone else wishes to try it, and possibly get it to work, I'd be forever grateful. Keep in mind you must have bash installed, as it is a bash script: (I wish it were more clean but I can't figure out how to keep the formatting)

Quote:

#!/bin/bash
# Finds the strongest unencrypted AP and tries to connect to it via dhcp
# Call this script like "wifi.sh wlan0"
TEMP=/tmp/bestap.tmp
LOCK=/var/lock/bestap.lock
if [ `whoami` != "root" ];then
echo "Sorry, you need to be root to run this program"
exit 1
fi

if [[ -z $1 ]];then
echo "USAGE: $0 device"
exit 1
else
interface=$1
fi

# Checking for lock
if [[ -e $LOCK ]];then
exit 1; # Too simply nothing to do here :)
else
touch $TEMP $LOCK
fi


# Proggy
iwlist $interface scan > $TEMP
NumAPs=`cat $TEMP | grep ESSID | wc -l`
BestAP=0
BestQuality=-1
for i in `seq 1 $NumAPs`;
do
# Check if AP is encrypted
Encryption=`cat $TEMP | grep Encryption | head -n$i | tail -n1 | cut -d":" -f2`
if [ $Encryption = "off" ]; then
# Find AP with the highest quality
QUALITY=`cat $TEMP | grep Quality | head -n$i | tail -n1 | cut -d":" -f2 | cut -d"/" -f1 | sed 's/ //g'`
if [ "$QUALITY" -gt "$BestQuality" ]; then
BestQuality=$QUALITY
BestAP=$i
fi
fi
done
if [ $BestAP -gt 0 ]; then
# Yay, we found an unencrypted AP:
echo Connecting to...
ESSID=`cat $TEMP | grep ESSID | head -n$BestAP | tail -n1 | cut -d""" -f2`
echo ESSID=$ESSID
MODE=`cat $TEMP | grep Mode | head -n$BestAP | tail -n1 | cut -d":" -f2`
echo Mode=$MODE
CHANNEL=`cat $TEMP | grep Channel | head -n$BestAP | tail -n1 | cut -d"(" -f2 | sed 's/Channel //g' | sed 's/)//g'`
echo Channel=$CHANNEL
# Connect
iwconfig $interface essid $ESSID mode $MODE channel $CHANNEL
if [ -e /etc/dhcpc/dhcpcd-${interface}.pid ]; then
rm /etc/dhcpc/dhcpcd-${interface}.pid
fi
dhcpcd $interface
# Cleanup
fi
rm -f $TEMP $LOCK

Laughing Man 2008-08-31 02:14

Re: An app to automatically grab open wifi?
 
Maybe there's an error in the instruction on line 31 of the code? (count how many lines down). Maybe the internet tablets don't support the protocal or something is missing? I see it needs wireless tools.

ajax1 2008-08-31 02:45

Re: An app to automatically grab open wifi?
 
Suggest you look at the DD-WRT script "autoAP". This may give you some ideas.


From the wiki
"AutoAP is a script that continuously scans for open Wi-Fi connections, tests them for validity, and connects to the strongest signal. If the connection is lost, the script scans again and finds the strongest valid signal again, and maintains a continuous connection to the internet in a mobile or portable environment. The script paremeters are highly configurable, including ability to configure secure connections. "

Parameters include:
Filters to avoid logging onto specific SSIDs
Filters giving preferential logging onto specific SSIDs, including encyption key values


Script can also verify that successful wifi connection also allows internet access.

I would love to see something like this adapted to run on the Nokia tablets.

See
http://www.dd-wrt.com/wiki/index.php/Autoap
and
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=6575

arover 2008-08-31 04:48

Re: An app to automatically grab open wifi?
 
See, I looked at AutoAP...It's not the same kind of 'script' in the sense that the code is just there and easy to look at...At least not for me. The script uses the router interface / commands and wouldn't be easy to port to the N810, at least not that specific script. The best thing to use is a bash / sh based script that takes advantage of wireless-tools. I was working with a friend earlier who's more experienced with scripting in bash to work out the bugs in that script I posted- It seems to be our best bet. I wish I had more experience in this sort of stuff. I'm going to resume work on it when I return in a few days. Until then, if anyone wants to take a whack at running/debugging it on the N810, xterm, chmod 777 the file (copy and paste the script in notepad, save it as something.sh, copy it over), and run it in root. Have fun :P

computerfreek 2008-09-01 02:30

Re: An app to automatically grab open wifi?
 
To bad it's not like the old dlink/linksys and windows where you can just put in ssid "ANY" all CAPS and it will auto connect to any open access point .
Maybe it works the same way i did not test it on linux or n810 ..

Computerfreek274

n810_itt 2008-09-02 20:51

Re: An app to automatically grab open wifi?
 
Hello,

I'm new around here and also in need of a script of this kind. I took the previously posted script and adapted it a bit to my needs. This sort of works for me on an n810. It chooses the strongest AP and connects to it. Sadly, even if the connection can be established, I can't get the tablet to switch to a "connected" state, so for now one has to manually reconnect with the statusbar applet if the connection via this script worked.

I'd be very grateful if anybody adds improvements. Especially the parsing code is quite slow.
Lateron I also want to add the possibility to manually choose the AP to connect to. But the biggest problem for now is the unability to get the tablet connected and "online" on the commandline.

Code:

#!/bin/bash
# Finds the strongest unencrypted AP and tries to connect to it via dhcp
# Call this script like "wifi.sh wlan0"
echo hi

if [ `whoami` != "root" ];then
echo "Sorry, you need to be root to run this program"
exit 1
fi

interface=wlan0
ifconfig $interface up

# Proggy
while true
do
iwlist $interface scan > $TEMP
NumAPs=`cat $TEMP | grep ESSID | wc -l`
BestAP=0
BestQuality=-1
BestESSID=""
echo APs: $NumAPs
for i in `seq 1 $NumAPs`;
do
# Check if AP is encrypted
Encryption=`cat $TEMP | grep Encryption | head -n$i | tail -n1 | cut -d":" -f2`
if [ $Encryption = "off" ]; then
# Find AP with the highest quality
ESSID=`cat $TEMP | grep ESSID | head -n$i | tail -n1 | cut -d"\"" -f2` 
MODE=`cat $TEMP | grep Mode | head -n$BestAP | tail -n1 | cut -d":" -f2`
QUALITY=`cat $TEMP | grep Quality | head -n$i | tail -n1 | cut -d":" -f2 | cut -d"/" -f1 | sed 's/ //g'`
echo ESSID=$ESSID Mode=$MODE Quality=$QUALITY
if [ "$QUALITY" -gt "$BestQuality" ]; then
BestQuality=$QUALITY
BestAP=$i
BestESSID=$ESSID
fi
fi
done
if [ $BestAP -gt 0 ]; then
timeout 2 mplayer /usr/share/sounds/ui-new_email.wav > /dev/null 2>&1 &
# Yay, we found an unencrypted AP:
echo
#ESSID=`cat $TEMP | grep ESSID | head -n$BestAP | tail -n1 | cut -d"\"" -f2`
CHANNEL=`cat $TEMP | grep Channel | head -n$BestAP | tail -n1 | cut -d":" -f2 | sed 's/Channel //g' | sed 's/)//g'`
echo Connecting to \"$BestESSID\"  Channel $CHANNEL
echo
# Connect
iwconfig $interface essid "$BestESSID" channel $CHANNEL mode managed #$MODE
sleep 3
iwconfig #2>&1 | grep ESSID
echo
if ping -c2 `udhcpc -i $interface -n -q 2>&1 | grep dns | cut -d" " -f3`
then
echo
ping -c 1 www.google.com
echo
echo very well
echo
read a
ifconfig $interface down
ifconfig $interface up
else
echo
echo bad
echo
ifconfig $interface down
ifconfig $interface up
fi
fi
done
# Cleanup


n810_itt 2008-09-03 05:00

Re: An app to automatically grab open wifi?
 
Forgot to add, this runs with sh:

sh /path/toscript

bash is not needed.

Bye


All times are GMT. The time now is 22:57.

vBulletin® Version 3.8.8