FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
+1 vote
1,016 views 3 comments
by anonymous
Hi,

How could I program the RUT240 to provide a signal (for external single LED) into the output pin to indicate an active/existing mobile data connection?

Wbr,

-t

1 Answer

+2 votes
by anonymous

Hello,

RUT240 does not have a functionality which would activate router's output based on mobile data connection status. Therefore you cannot configure such router's behavior just from router's WebUI.

Nonetheless, there is a solution: You could use simple SSH script, which allow you to monitor if router has mobile data connectivity (actually, in this example, script would monitor internet connectivity all together, and not just "mobile data connection status"). To achieve this:

  1. Connect to router via SSH (e.g. using Putty application):

         - SSH login: root

         - SSH password: <your router's password>

  2. Execute the following SSH command (it would create a new file, in which you will write your script. File name here is "aaa"):

            vi /bin/aaa

  3. Press "a" keyboard button then copy the following text into the file (by clicking "right mouse button", since "ctrl + v" combination would not work in SSH):

#!/bin/ash

while [ 1 ]; do

ping 8.8.8.8 -s 0 -c 3 -q >/dev/null

ret=$?

if [ $ret -ne 0 ]; then

gpio.sh set DOUT1

else

gpio.sh clear DOUT1

fi

sleep 10

done

  4. Then press "esc" keyboard button, press ":x" and press "enter" keyboard button (this would save and close the file)

  5. After that, execute the following SSH command:

       chmod +x /bin/aaa

  6. Finally, connect to router's WebUI, navigate to "System -> User scripts" menu and write "/bin/aaa" line ABOVE "exit 0" line. Save the changes and reboot the router. (This action would make router to start your script each time router is powered on)

That's it.With this script, router would periodically (every 10 seconds) check for internet connectivity. When router will have internet connectivity, its output will be "inactive" and when connectivity will be lost, output will be activated. Feel free to reverse output actions or change the timing of the script.

Hope this helps you to accomplish your unique solution. It would be great if you could let me know if this approach indeed helped you in this situation.

Best answer
by anonymous
Hello everyboby,

I also need to use the mobile data status to inform a local web server that mobile connexion is up to push some data files on remote server once a day ( mobile connexion is only activated by SMS on request to save mobile datas).

So I tried your solution, but output remains low whatever mobile data status. (i'm sure to be internet connected by pinging 8.8.8.8 via the TRB140 link)

I'm trying to fix this issue...cheking the GPIO configuration

via SSH command, ubus call ioman.gpio.dio0 status which respond :

{

        "value": "0",

        "direction": "out",

        "bi_dir": true,

        "invert_input": false

}

What's parameter "bi_dir" for ?

further help on custom SSH script syntax would be appreciated

Thanks.
by anonymous

Hello,

New TRB device firmware requires a slightly different SSH command to control its output. Instead of "gpio.sh set DOUT1" and "gpio.sh clear DOUT1", use the following commands instead (to read status, deactivate or activate the output):

ubus call ioman.gpio.dio0 status

ubus call ioman.gpio.dio0 update '{"value":"0"}'

ubus call ioman.gpio.dio0 update '{"value":"1"}'

Updated script from the initial answer:

#!/bin/ash

while [ 1 ]; do

ping 8.8.8.8 -s 0 -c 3 -q >/dev/null

ret=$?

if [ $ret -ne 0 ]; then

ubus call ioman.gpio.dio0 update '{"value":"1"}'

else

ubus call ioman.gpio.dio0 update '{"value":"0"}'

fi

sleep 10

done

by anonymous
Hello,

thanks for your advice about command update, I made corrections in the script but still not working.

what's the priority between the script and the I/O manual control in Services/Input/output/power socket status setup menu ?

manual control of outputs is working fine through GUI

how to be sure that script is executed ?

thanks for your help.