Reachability test and digital output activation on RUT200

We often use RUT200. Sometimes we provide the router to the customer and he inserts the SIM independently. Sometimes the customer does not have the SIM with active data traffic. Is there the possibility in the router to activate a timed PING or when the INPUT signal changes to check the reachability of 8.8.8.8? We would like that in case of success, the OUTPUT output of the router is switched. Does this possibility exist?

Regards

Hello,

Can you clarify what you wanted to achieve?
If 8.8.8.8 is pingable or the digital input signal is changed, then you want to change the state of the Output pin.

I wrote a simple script where it will check either the digital input is 1 (triggered) or the 8.8.8.8 is pingable, it will change the state of the Output pin, then change it back after couple seconds.

#!/bin/ash

while true

do
        input_value=`ubus call ioman.gpio.din1 status | jsonfilter -e '@.value'`

        # Try to ping 8.8.8.8
        ping -c 4 8.8.8.8
        if [ $? -eq 0 ]; then
                pingable=0  # Set pingable to 0 if 8.8.8.8 is reachable

        fi

        if [ $input_value -eq 1 ] || [ $pingable -eq 0 ];
        then
                ubus call ioman.gpio.dout1 update '{"value": "1"}'
        fi

        # Change the sleep value based on how often you wanted to check the reachability
        sleep 10

        # change to value to low
        ubus call ioman.gpio.dout1 update '{"value": "0"}'
done

However, if you just wanted to change the Output state if the input state changes, then that would be possible through I/O Juggler.

Hi.

Thank you so much for your example. It was exactly what I wanted to do. If I run the script from shell, I see the output switch.

Greetings
Fabrizio

I would like to ask for one final confirmation. If I wanted to run it, should I put it in “Startup Script”? because if I launch it from the CLI (Command Line) it works correctly and I see the output switch, but it seems to me that it doesn’t work from the autostart script. Maybe I need to restart the router?

The way I would approach this is that I am going to save the script somewhere in the /bin directory.

Then I will run it using the custom scripts in the WebUI by typing its directory (e.g. /bin/script.sh)
Just make sure you add an executable rights on the script itself using chmod +x /directory/script command.

Hope that helps.

This topic was automatically closed after 16 days. New replies are no longer allowed.