4411 kBps = chilobaits not kb chilobits per second.
It's actually not that bad! more than 30Mbps
It's overwrited at the next check. Anyway add
rm /tmp/tmpdwn
after downSpeed=$(expr $downSize / $downTime) #speed in kB/s
if you want to erase it to free space
It's impressive how scarce is the documentation on this point. I found a couple of forums but nothing official.
Sorry, I used the first openwrt device I found to test the script and it was very old. I'll go on with the new functions.
You argue that the host router throttle the band and that the lower bitrate is a consequence whereas I was guessing the opposite (i.e. that the router was lowering the band to decrease the available speed). In the first case I'll be useless to increase the bitrate since the speed is managed from the QoS of the host fastweb router and we can only hope to reset the connection. Maybe someone more expert might help us!
Let's move to the other solution. I can't verify by myself that the code is working since I don't have a recent openwrt device. Anyway you should check if all these commands extract the bit rate from the iwinfo and iw commands.
iwinfo wlan0 info | grep "Bit Rate" | cut -d$':' -f2 | cut -d$'M' -f1
iw dev wlan0 link | grep "rx bitrate" | cut -d$':' -f2 | cut -d$'M' -f1
iw dev wlan0 link | grep "tx bitrate" | cut -d$':' -f2 | cut -d$'M' -f1
I don't even know the difference between them...I'll use the first one.
I rewrote the entire script removing the useless stuffs
#!/bin/sh
################ settings ###############
minSpeed=8 #Mbps
debouncerMax=3 #how many times check before resetting
waitBetweenChecks=10 #second between checks
########################################
syncCheck() {
if command -v iwinfo &> /dev/null
then
actSpeed=$(iwinfo wlan0 info | grep "Bit Rate" | cut -d$':' -f2 | cut -d$'M' -f1)
else
actSpeed=$(iwconfig ath0 | grep Bit | cut -d$':' -f2 | cut -d$' ' -f1)
fi
[ $actSpeed -lt $minSpeed ] && touch /root/wifiRebootsCounter.log && return 1
return 0
}
act() {
echo $(date) >> /root/wifiRebootsCounter.log
# what to do when the connection is not working?
ifup WOWFI
}
debouncer=0
while [ 1 ]; do
syncCheck && debouncer=0 || debouncer=$(expr $debouncer + 1 )
sleep $waitBetweenChecks
[ $debouncer -gt $debouncerMax ] && act
done
I used ifup in this case. Wifi disconnect and reconnect all the wifi devices.
In the upper part you can change the wait time (between checks) and a couple of other stuffs...take care of not adding spaces before and after the =!
If you prefer you can schedule a systematic reboot (E.g. at 4.00 am?).
Let me know if it works!