and I would like to configure the WAN light behaviour exactly like the stock firmware whereby if there is no WAN connection the WAN light is a solid amber, else the WAN light goes to white with blinking when packets of data are moving.
It is possible to do via LuCI or is there another way? I have read another post on this forum regarding making a script but I wouldn't know where to start. All I know is the first line would be to check the WAN connection and set the light to amber if the connection isn't active. If it is active set WAN light to white.
config led 'led_wan'
option name 'WAN_OFF'
option sysfs 'pca963x:shelby:amber:wan'
option trigger 'netdev'
option dev 'eth1.2'
option default '0'
config led 'led_usb1'
option name 'USB 1'
option sysfs 'pca963x:shelby:white:usb2'
option trigger 'usbport'
option default '0'
list port 'usb1-port1'
config led 'led_usb2'
option name 'USB 2'
option sysfs 'pca963x:shelby:white:usb3_1'
option trigger 'usbport'
list port 'usb2-port1'
list port 'usb3-port1'
option default '0'
config led 'led_usb2_ss'
option name 'USB 2 SS'
option sysfs 'pca963x:shelby:white:usb3_2'
option trigger 'usbport'
option default '0'
list port 'usb3-port1'
config led
option name 'WAN_ON'
option sysfs 'pca963x:shelby:white:wan'
option default '0'
option trigger 'netdev'
option mode 'link'
option dev 'eth1.2'
I made a WAN_OFF and set the LED for WAN to amber using the WAN connect eth1.2 (WAN interface).
The stock firmware uses a script to probe for an actual connection to the Internet (e.g.by pinging the manufacturer's site.) That functionality is not included in OpenWRT by default but you could look at modifying something like watchcat to turn LEDs on and off based on ping success or failure.
/etc/rc.local
I have modified the '/etc/rc.local' to suit my router
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
#Check WAN Connection
while :
do
Status=$(ping -q -c 20 -W 1 208.67.222.222 > /dev/null 2>&1 && echo "ok" || echo "FAIL")
if [ "$Status" = "ok" ]; then
echo 255 > /sys/class/leds/pca963x:shelby:amber:wan/brightness
echo 0 > /sys/class/leds/pca963x:shelby:white:wan/brightness
else
echo 255 > /sys/class/leds/pca963x:shelby:white:wan/brightness
echo 0 > /sys/class/leds/pca963x:shelby:amber:wan/brightness
fi
sleep 10
done
exit 0
I have also added in both lights to they function as normal. The script above simply controls the brightness of each lights so once is only one is on at one time.
/etc/config/system
config led
option default '0'
option sysfs 'pca963x:shelby:white:wan'
option trigger 'netdev'
option dev 'eth1.2'
option mode 'link tx rx'
option name 'WAN_ON'
config led
option default '0'
option name 'WAN_OFF'
option sysfs 'pca963x:shelby:amber:wan'
option trigger 'netdev'
option dev 'eth1.2'
However, I would like to know how to put a loop on this code if the WAN connection does go down. Any ideas?
but it gave me permission denied. I have even tried rebooting the router but I have a feeling the script isn't running. I'll check logs and post update on here when I'm back home.
I think the script run with the same permission as you when you ssh.
So if you can't change the attribute the script should also not change the attribute.
Maybe the device only allow 1 time a change.
May you add a line before sleep
date >> /tmp/testfile
Then the current time will be added to testfile on each loop