10934 questions

13039 answers

20335 comments

27482 members

0 votes
481 views 8 comments
by
I can get JSON-RPC responses over the RMS WebUI Link.

How can I control digital output to ON while only 5 seconds over JSON-RPC ?

gpio.sh can turn on or off, but it has no wait function.

/cgi-bin/output can turn on-off and wait specified seconds, but it does not restore to off state if it is interrupted with another /cgi-bin/output request.

1 Answer

0 votes
by
Hello,

Could you post your JSON requests here so I could test them myself. Also, I would like to ask about your whole use case. What do you want to achieve and why you need to wait exactly 5 seconds?

Regards.
by

I have no problem for JSON-RPC request messages. It works fine as same as code in TELTONIKA Wiki.

But I cannot find any scripts or commands supports following process.

1. turn on DOUT1
2. wait 1〜 5 seconds
3. turn off DOUT1

The reason of this process is we are required for our customer. The time of waiting may be shorten up to 1 second.
It is very important for out customer to restore the DOUT1 to be OFF.

by

I think the easiest way to achieve your desired process is to utilize the POST/GET feature.

This command exactly does what you need:

http://192.168.1.1/cgi-bin/output?username=user1&password=user1&action=on&pin=oc&time=5

I think you already know how to change 192.168.1.1 to RMS URL.

More about POST /GET: https://wiki.teltonika-networks.com/view/RUT240_Input/Output#Post.2FGet_examples

Best regards.

by

Thank you for your advice. /cgi-bin/output has time= parameter.

But while the /cgi-bin/output is processing while 5 seconds, when another same request is executed, DOUT1 is left as ON.

/www/cgi-bin/output depends on the current status of GPIO.
It is not acceptable for us.

And because of I was recommended from TELTONIKA people, I want to try JSON-RPC via RMS WebUI at first.

Can I place a script file as "/sbin/dout-on-5sec.sh" such as following ? And can I call this script via JSON-RPC via RMS API ?

#!/bin/sh

/sbin/gpio.sh set DOUT1
sleep 5
/sbin/gpio.sh clear DOUT1

by

I can control digital output with WebUI Link + JSON-RPC with executing command "dout-on-5sec.sh".

{"jsonrpc":"2.0", "id":1, "method":"call", "params":["3ef14e02...(omit)", "file", "exec", {"command":"dout-on-5sec.sh"}]}

Thank you. 

But it is slow from Japan. After requesting WebUI Link + JSON-RPC, it takes 3 〜 5 seconds to control digital output of RUT240. It is out for our requirement "2 second maximum delay".
 

by
I suppose you are using the RMS link for your JSON request? If that is the case then it is understandable, because RMS servers are far from you. By any chance, do you have the possibility to have a SIM card with public static IP?
by

Yes, I am using RMS WebUI Link for JSON-RPC request.  (JSON-RPC over RMS WebUI Link)

Currently, Public static IP (global IP) address is costly for us. Also I can't find such service in our favorite SORACOM SIM service.

Do you mean static IP and HTTP CGI POST/GET must be shorten the RTT of RT240 remote API ?
by
Well, it would reduce some waiting time because you will directly access the router via public IP. Basically right now your command travel path is:

JSON-RPC application > RMS > Router

It would reduce to:

JSON-RPC application > Router.
by
Thank you for your advice.

I will keep the direct method you suggested as one of the other candidates.

JSON-RPC requires TCP initialize sequences for HTTP. It is disadvantage over the LTE link.

I will back to MQTT which does not require TCP session establishment in each API requests.