How can I send a TCP message to an address via SMS?

I have purchased a RUT200. I was wondering if it would be possible to create some sort of script that I could SMS my unit and get it to send a TCP msg to another LAN card on the same network?
For example send an SMS that would read #qq and the IP address 192.168.1.155 and then the router sends the message to unit at .155

OR even just broadcast the #qq to all connected devices?
Thanks!

Hello,

You can create a custom SMS rule to execute a script with arguments. Then, you can create a script itself that will take those arguments, process and format them the way you need, and then send them to your device.

For example, create the following /etc/yourscript.sh script:

#!/bin/sh
argfromsms=$1
echo "$argfromsms" | nc "192.168.1.10" "6666"

Give it execution rights:

chmod +x /etc/yourscript.sh

Then, use this script in your new SMS rule with an argument:

#!/bin/sh
sh /etc/yourscript.sh $1

You can find a similar example here.

Kind Regards,

1 Like

Fantastic thanks!!!

Hello,
I have made the scripts, as follows:

#!/bin/sh
argfromsms=$@
echo "$argfromsms" | nc "192.168.1.177" "8008"

And I named the script paulcmd.sh and when I run it in your CLI it works fine and my PCB responds just fine as follows:

root@Teltonika-RUT200:/etc# sh paulcmd.sh pp d qq t8 p9                                 
BACK:pp d qq t8 p9                                                                      
root@Teltonika-RUT200:/etc# sh paulcmd.sh pp d qq t8 p9                                 
BACK:pp d qq t8 p9                                                                      
root@Teltonika-RUT200:/etc# sh paulcmd.sh pp d qq t8 u88                                
BACK:pp d qq t8 u88                                                                     
root@Teltonika-RUT200:/etc# sh paulcmd.sh a b c d                                       
BACK:a b c d   

BUT, when I send the SMS it seems like only the 1st SMS sent works. After that the 3 x 3g/4g lights flash on the RUT200 and I have to wait quite a while before they stop blinking and then I can send another SMS command again. Here is my SMS script code:

#!/bin/sh
sh /etc/paulcmd.sh "$@"

Also, when I try to read the list of received SMS’s on the SMS MESSAGES page, the page is blank/inaccessible until those three lights have stopped flashing.

So I have two questions:

  1. Is this normal behaviour? Or am I doing things wrong?
  2. Should I be having some sort of code after the sh /etc/paulcmd.sh “$@” to tell the unit stop executing this script?

Other than this the unit functions fabulously!

Hello,

I’ve tried sending multiple messages with ~1 sec in-between, but they were all received and executed.

Could you execute ‘logread -f’ to view logs in real time, and then try sending SMS. Anything in the logs?

Kind Regards,

1 Like

HI Andzej
I tried looking at logs, and nothing really shows.
But, what I can definitely say, is that if I send the RUT200 a standard SMS, it receives as many as I send without any trouble.
But, the minute I send the SMS with the #cmd abc in it it reeives and acts on only the first sms and then the lights start flashing and one has to wait about two/three minutes where everything is blank on the SMS messages page. A popup occirs which says “Could not retrieve SMS’s” or something like that. Herewith the screen capture of the first SMS cmd sent, followed by a sccreen capture thereafter. As you can see the second image has no message info.

And herewith the logreads:

Firstly, the logread after the 1st sms is sent:

root@Teltonika-RUT200:~# logread -f                                                     
Wed Sep 13 20:30:55 2023 kern.notice kernel: SMS received from: +277xxxxxxxx (internal m
odem)                                                                                   
Wed Sep 13 20:31:00 2023 cron.err crond[6447]: USER root pid 16283 cmd /sbin/rut_fota --
fw_info >/dev/null 2>&1 

then after the second sms is sent:

oot@Teltonika-RUT200:~# logread -f                                                     
Wed Sep 13 20:33:01 2023 daemon.err /usr/sbin/sms_utils: [1-1] Failed to send SMS messag
 Status code: 0' to '+277xxxxxxxx'                                                      
Wed Sep 13 20:33:01 2023 daemon.info /usr/sbin/sms_utils: Removing SMS '3' from memory  
Wed Sep 13 20:33:05 2023 daemon.info gsmd[1859]: [check_req_timeout:104] error: [MODEM_M
ANAGER] Warning: request reached timeout (126s) on `1-1 [05c6:f601]` modem!             
Wed Sep 13 20:33:11 2023 daemon.err /usr/sbin/sms_utils: Failed to Remove SMS '3'       
Wed Sep 13 20:33:21 2023 daemon.err mobifd: [gsm.modem0] Failed to get SMS storage      
Wed Sep 13 20:33:21 2023 daemon.err /usr/sbin/sms_utils: Unable to read sms '5'         
Wed Sep 13 20:34:14 2023 daemon.info hostapd: wlan0: STA 70:32:17:29:fc:0c WPA: group ke
y handshake completed (RSN)   

ps: I have xxxxx out my cell number.

Oh dear me…

I found the problem. I did not have any SMS credit on the sim card! Apologies!

It seems somewhere there is a setting to SMS my number back when any data comes in from my PCB. Right now my PCB/MCU just echoes back whatever the unit sends it for testing purposes and the unit was hanging trying to send me an sms. Once I put credit on the sim card the unit worked fine every time.

Thanks for your help. I am going to try to find out where that rule is.

Hello,

When executing the script via SMS message, the device always responds with an SMS that contains a status code. Currently, there is no way to disable this in the SMS utilities.

Kind Regards,

1 Like

Ah OK, thanks a mil! Noted and I must just make sure the machine has SMS credit then. It works perfectly now.

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