Commit b008c424 authored by rubo77's avatar rubo77
Browse files

tq settings from ffac-version implemented

parent 5e548c87
......@@ -22,7 +22,6 @@ ssid_changer = {
tq_limit_enabled = 0, -- if false, the offline SSID will only be set if there is no gateway reacheable
-- upper and lower limit to turn the offline_ssid on and off
-- in-between these two values the SSID will never be changed to prevent it from toggeling every minute.
-- TODO: enabled=1 still has to be implemented
tq_limit_max = '55', -- upper limit, above that the online SSID will be used
tq_limit_min = '45' -- lower limit, below that the offline SSID will be used
},
......
......@@ -10,7 +10,7 @@ FIRST="$(uci -q get ssid-changer.settings.first)"
: ${FIRST:=5}
PREFIX="$(uci -q get ssid-changer.settings.prefix)"
# generate the ssid with either 'nodename', 'mac' or to use only the prefix: 'none'
# the Offline-SSID will start with this prefix
: ${PREFIX:='FF_OFFLINE_'}
if [ "$(uci -q get ssid-changer.settings.enabled)" = '0' ]; then
......@@ -20,6 +20,8 @@ else
fi
SETTINGS_SUFFIX="$(uci -q get ssid-changer.settings.suffix)"
# generate the ssid with either 'nodename', 'mac' or to use only the prefix set to 'none'
: ${SETTINGS_SUFFIX:='nodename'}
if [ $SETTINGS_SUFFIX = 'nodename' ]; then
SUFFIX="$(uname -n)"
......@@ -41,13 +43,48 @@ fi
OFFLINE_SSID="$PREFIX$SUFFIX"
# TODO: ffac tq limits has to be implemented here if enabled
ONLINE_SSID="$(uci -q get wireless.client_radio0.ssid)"
# if for whatever reason ONLINE_SSID is NULL
: ${ONLINE_SSID:="FREIFUNK"}
CHECK="$(batctl gwl -H|grep -v "gateways in range"|wc -l)"
TQ_LIMIT_ENABLED="$(uci -q get ssid-changer.settings.tq_limit_enabled)"
# if true, the offline ssid will only be set if there is no gateway reacheable
# upper and lower limit to turn the offline_ssid on and off
# in-between these two values the SSID will never be changed to preven it from toggeling every Minute.
: ${TQ_LIMIT_ENABLED:='0'}
if [ $TQ_LIMIT_ENABLED = 1 ]; then
TQ_LIMIT_MAX="$(uci -q get ssid-changer.settings.tq_limit_max)"
# upper limit, above that the online SSID will be used
: ${TQ_LIMIT_MAX:='55'}
TQ_LIMIT_MIN="$(uci -q get ssid-changer.settings.tq_limit_min)"
# lower limit, below that the offline SSID will be used
: ${TQ_LIMIT_MIN:='45'}
# grep the connection quality of the currently used gateway
GATEWAY_TQ=$(batctl gwl | grep -e "^=>" -e "^\*" | awk -F '[('')]' '{print $2}' | tr -d " ")
if [ ! $GATEWAY_TQ ]; then
# there is no gateway
GATEWAY_TQ=0
fi
MSG="TQ is $GATEWAY_TQ, "
if [ $GATEWAY_TQ -gt $TQ_LIMIT_MAX ]; then
CHECK=1
elif [ $GATEWAY_TQ -lt $TQ_LIMIT_MIN ]; then
CHECK=0
else
# this is just get a clean run if we are in-between the grace periode
echo "TQ is $GATEWAY_TQ, do nothing"
exit
fi
else
MSG=""
CHECK="$(batctl gwl -H|grep -v "gateways in range"|wc -l)"
fi
HUP_NEEDED=0
if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
echo "node is online"
......@@ -60,7 +97,7 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
fi
CURRENT_SSID="$(grep "^ssid=$OFFLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
if [ "$CURRENT_SSID" = "$OFFLINE_SSID" ]; then
logger -s -t "gluon-ssid-changer" -p 5 "SSID is $CURRENT_SSID, change to $ONLINE_SSID"
logger -s -t "gluon-ssid-changer" -p 5 $MSG"SSID is $CURRENT_SSID, change to $ONLINE_SSID"
sed -i "s~^ssid=$CURRENT_SSID~ssid=$ONLINE_SSID~" $HOSTAPD
# HUP here would be to early for dualband devices
HUP_NEEDED=1
......@@ -80,7 +117,7 @@ elif [ "$CHECK" -eq 0 ]; then
fi
CURRENT_SSID="$(grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
if [ "$CURRENT_SSID" = "$ONLINE_SSID" ]; then
logger -s -t "gluon-ssid-changer" -p 5 "SSID is $CURRENT_SSID, change to $OFFLINE_SSID"
logger -s -t "gluon-ssid-changer" -p 5 $MSG"SSID is $CURRENT_SSID, change to $OFFLINE_SSID"
sed -i "s~^ssid=$ONLINE_SSID~ssid=$OFFLINE_SSID~" $HOSTAPD
HUP_NEEDED=1
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment