Developing lightweight computation at the DSG edge

Commit f1d40048 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system]: reset wifi when configured and operating channels differ



This script checks that, for every wireless device configured by qMp (in
/etc/config/qmp), the channel configured in /etc/config/wireless and the one
reported by the "iw" command match. If they differ, it resets the wifi system.

First part of #470
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent c6590c4a
#!/bin/sh
# This script checks if the wireless devices configured in /etc/config/qmp are
# operating in the channel they are configured to. It is useful to go back to
# the configured channel if DFS switches the device to another one.
# Make sure there is at least one wireless device configured
lastdev=$(uci -q get qmp.@wireless[-1].device)
if [ $lastdev ]; then
# Iterate through all the configured devices
i=0
while [ $i -ge 0 ]; do
# Get qMp device configuration parameters
qmpdev=$(uci -q get qmp.@wireless[${i}].device)
qmpmode=$(uci -q get qmp.@wireless[${i}].mode)
qmpchannel=$(uci -q get qmp.@wireless[${i}].channel)
# Check the device is not disabled in qMp, skip it otherwise
if [ "$qmpmode" != "none" ]; then
wifiradio=$(uci -q get wireless.$qmpdev.device)
if [ $wifiradio ]; then
wifichannel=$(uci get wireless.${wifiradio}.channel)
if [ $wifichannel ]; then
iwchannel=$(iw dev $qmpdev info | grep channel | sed -e 's/^[ \t]*//' | cut -d ' ' -f 2)
# Trim the HT40 upper/lower channel extension info (i.e., the + or - symbols)
qmpchannelnum=$(echo ${qmpchannel} | sed -e 's/[-+]*//g')
wifichannelnum=$(echo ${wifichannel} | sed -e 's/[-+]*//g')
# Check that channel configurations in /etc/config/qmp and /etc/config/wireless match
if [ "$qmpchannelnum" == "$wifichannelnum" ]; then
# If the channel configured in /etc/config/wireless and the one reported by iw differ, reset the wifi
if [ $wifichannelnum -ne $iwchannel ]; then
wifi
exit 0
fi
fi
fi
fi
fi
if [ "$(uci -q get qmp.@wireless[${i}].device)" == "$(uci -q get qmp.@wireless[-1].device)" ]; then
i=-1
else
let i=$i+1
fi
done
fi
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