Hello,
The following example was made on RUTX11, but the general procedure should apply to RUTX50 as well.
This can be achieved hotplug system, which allows to execute scripts when network interfaces go up or down, in this case that would be WiFi interfaces.
- Log into the router via SSH;
- Execute the following command to create a script file and open it with a text editor:
vi /etc/wifi_mon.sh
- Press letter ‘i’ to enable editing and enter the following content:
#!/bin/sh
while true; do
if iw dev wlan0-1 info > /dev/null 2>&1; then
ubus call ioman.gpio.dout1 update '{"value":"1"}'
logger "WiFi is up, triggered output"
break # Exit the loop once the interface is up
fi
sleep 1 # Check every second
done
-
Once done, press ‘
Esc’, write ‘:wq’ and press ‘Enter’ to quit editing, save the file, and exit the editor.- It will set digital output value to on, when 2.4GHz WiFI interface goes up. For 5GHz WiFI, use wlan0-2.
-
Execute the following command to make the script executable:
chmod +x /etc/wifi_mon.sh
-
Modify
/etc/rc.localfile with the command:sh /etc/wifi_mon.sh &
-
Reboot your router. The output will be triggered once the WiFI comes up.
-
The logs should also generate something similar:
- user.notice root: WiFi is up, triggered output
Best regards,
