RUTX50: How can i configure the digital Output to switch on when WIFI is ready?

Hello,
i have a device that needs to connect to the RUTX50 WIFI. Both the RUTX and the device are switched on simultaneously, but the Router takes longer to start its WIFI then the device for startup. When the WIFI is not ready, the device opens its own hotspot and does not try connect to the RUTX anymore.
Now i want to switch on the device with the Output of the RUTX, but i could not find a way to switch on the output when the WIFI is up.
Maybe somebody here can help me?
Thank you and best regards,
Hubert

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.local file with the command:

  • 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,

1 Like