Omega2+ // Wifi shut down ? Apcli link down.
After some problems for configuring my wifi, I run into a new problem.
My Omega2+ disconnect wifi after some times :
For example :
[ 39.743241] !!! APCLI LINK UP - IF(apcli0) AuthMode(7)=WPA2PSK, WepStatus(6)=AES! [ ...] [ 583.277377] !!! APCLI LINK DOWN - IF(apcli0)!!!
[ 2025.448630] !!! APCLI LINK UP - IF(apcli0) AuthMode(7)=WPA2PSK, WepStatus(6)=AES! [ 4183.494187] !!! APCLI LINK DOWN - IF(apcli0)!!!
So if I don't have a serial connection to the omega, I can't restart wifi...
Is there a reason for this disconnection ? Is there a way to change that ?
Or perhaps I can setup a cron that check if there is connectivity and if not, restart network ?
Thanks for your help !
In addition, for my proposition to setup a cron which restart network when wifi is down :
Is there a log file where I can see this output :
[ 583.277377] !!! APCLI LINK DOWN - IF(apcli0)!!!
I see this output on the serial console, but can't find it in log files...
My goal is to search for this "words" to detect if wifi restart is needed or not...
/# ls -alh /var/log/ drwxr-xr-x 2 root root 80 Jan 10 16:24 . drwxrwxrwt 18 root root 500 Jan 12 12:42 .. -rw-r--r-- 1 root root 0 Jan 10 16:24 lastlog -rw-r--r-- 1 root root 0 Jan 10 16:24 wtmp
Is this a normal behavior ? Nothing is logged in Omega ?
Ok I reply to myself, I found this : https://wiki.openwrt.org/doc/howto/log.essentials
Give me my logs !
EDIT : correct the script (the test wasn't working) !
Here is my try :
#!/bin/sh # Get last log line containing "APCLI" LASTAPCLILOG=$(logread -e "APCLI" | tail -1) # If this line contain the "DOWN" word # then we have to restart wifi. case "$LASTAPCLILOG" in *DOWN*) logger -t mwi "WiFi is down, try to restart WiFi"; wifimanager ;; esac
(the "else" part is not necessary but it was for debugging)
And the crontab line :
* * * * * /root/wifi-restart.sh
now I'm waiting for disconnection to see if it works :)
I correct my script, to handle some problems at omega startup.
Sometimes, the wifi won't connect. So my script now restart wifi if the last "APCLI status" is not "UP".
So it work with no status too.
#!/bin/sh # Get last log line containing "APCLI" LASTAPCLILOG=$(logread -e "APCLI LINK" | tail -1) # If this line doesn't contain the "APCLI LINK UP" words # then we have to restart wifi. case "$LASTAPCLILOG" in *"APCLI LINK UP"*) ;; *) logger -t mwi "WiFi is down, try to restart WiFi"; wifimanager ;; esac
I changed your script so it can be used as watchdog-like service (once started will wait for LINK DOWN):
#!/bin/sh logread -f -e "APCLI" | while read -r line do case "$line" in *" APCLI LINK DOWN "*) logger -t mwi "WiFi is down, try to restart WiFi"; ifconfig apcli0 up wifimanager ;; esac done
Just start it as a service (as described in procd documentation).
Still, sometimes wifimanager fails to init wifi and restarting (calling wifimanager) will not help. It should be started again if needed. I will write complete solution if find some free time ;-)