Author: hummen Date: Wed Mar 21 23:27:08 2012 New Revision: 2940 Log: new handover script for n900 based on tablet version Modified: trunk/tools/auto-handover-n900.sh Modified: trunk/tools/auto-handover-n900.sh ============================================================================== --- trunk/tools/auto-handover-n900.sh Wed Mar 21 23:17:49 2012 (r2939) +++ trunk/tools/auto-handover-n900.sh Wed Mar 21 23:27:08 2012 (r2940) @@ -2,7 +2,6 @@ #your parameters WIFI_IF="wlan0" -ETH_IF="eth0" PATTERN="pisa-testbed" AP_IP="192.168.8.1" IP="192.168.8.141" @@ -15,10 +14,12 @@ activate_wifi() { echo "Stopping network-manager" - /etc/init.d/wlancond stop + killall wlancond echo "Bringing up $WIFI_IF" ifconfig $WIFI_IF up - #iwconfig $WIFI_IF essid $PATTERN + echo "Connecting to $PATTERN" + iwconfig $WIFI_IF essid $PATTERN + echo "Setting up addresses and routes" ifconfig $WIFI_IF $IP netmask 255.255.255.0 route del -net $DEST_NET netmask 255.255.255.0 route add -net $DEST_NET netmask 255.255.255.0 gw $AP_IP @@ -32,61 +33,57 @@ fail_counter=0 while true; do - result=$(iwlist $WIFI_IF scanning | ./iwlist_parser -s $PATTERN | cut -d' ' -f1) + result=$(./iwlist_parser.py -p $PATTERN) - sleep 1 - - if [ "$result" = "NONE" ]; then + if [ "$result" = "None" ]; then echo "No PISA access points nearby" fail_counter=$(($fail_counter+1)) - echo "Increasing module fail counter $fail_counter" + echo "Increasing module fail counter to $fail_counter" last_result=$result sleep_time=3 - else if [ "$result" != "$last_result" ]; then + elif [ "$last_result" != "$result" ]; then update_counter=0 - echo "Changing to $result" - echo iwconfig $WIFI_IF ap $result + echo "Changing to new access point ($result)" iwconfig $WIFI_IF essid $PATTERN ap $result - # needed for driver to switch association iwconfig $WIFI_IF essid $PATTERN ap $result - #arp -d $AP_IP 2> /dev/null - while [ $update_counter -lt 5 ]; do - sleep 1 + sleep 1 + while [ true ]; do + ping -c 1 $AP_IP > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Triggering HIP update" + hipconf daemon manual-update > /dev/null 2>&1 + update_counter=0 + fail_counter=0 + last_result=$result + sleep_time=10 + break + fi - checkap=$(iwconfig | grep "Access Point:" | cut -d' ' -f18) - if [ "$checkap" = "$result" ]; then - if [ "$last_result" = "NONE" ]; then - ifconfig $WIFI_IF $IP netmask 255.255.255.0 - fi - - # trigger hip update as soon as we are associated - hipconf manual-update - - fail_counter=0 - last_result=$result - sleep_time=5 - break - else if [ $update_counter -eq 4 ]; then - fail_counter=$(($fail_counter + 1)) + if [ $update_counter -eq 4 ]; then + echo "Check for new AP" + fail_counter=$(($fail_counter+1)) last_result="NONE" - sleep_time=3 + sleep_time=2 + break fi + update_counter=$(($update_counter+1)) + sleep 1 done else echo "Access Point is still best ($result)" - sleep_time=8 + sleep_time=10 fi if [ "$fail_counter" = "5" ]; then - echo "Restarting kernel modules" + echo "Re-activating Wi-Fi interface" rmmod wl12xx modprobe wl12xx - sleep 1 fail_counter=0 activate_wifi sleep_time=3 fi + echo "Sleeping for $sleep_time seconds" sleep $sleep_time done -- This is the pisa developer mailing list. Please also subscribe to the main pisa list at: //www.freelists.org/list/pisa