Titan – AN3: How to use ALIAS to execute SMS commands

¿Buscas alguna otra cosa?

Scenario Details

The Titan routers include all the typical features of a 2G/3G/4G router. However, they also include a series of additional features that help make it one of the leading market routers based on the number of features it includes.

One of these additional features is the ability to execute AT commands via SMS. By uaing AT commands, we can read parameters such as the network coverage, carry out a reset of the device, change the configuration, switch a relay, edit a Modbus register on an external device connected to the router, etc.

From time to time, it may be difficult to execute AT commands directly via SMS given they can be lengthy and uncomfortable to write on a cell phone. In the following examples we will see the advantages of using ALIAS which solve this problem.

Description of the Example

In this example, we will configure the SMS commands for a Titan router. Let’s imagine we have the following setup:

(Image: sending SMS messages; Modbus TCP/RTU device with an Ethernet/RS232/485 port)

We will configure 5 SMS messages. Message 1 will retrieve the router’s network coverage remotely. Message 2 will write the value “1” in the Modbus RTU’s register #5 with the address @1. Message 3 will write the value “0” in the Modbus RTU’s register #5 with the address @1. Message 4 will write the value “1” in the Modbus TCP device’s register #5 with the IP address 192.168.1.95 and TCP port 502. Message 5 will write the value “0” in the Modbus TCP device’s register #5 with the IP address 192.168.1.95 and TCP port 502.

How must SMS commands be sent without ALIAS?

If we do not use ALIAS and therefore have to send AT commands directly, we would have to send the following code for each of the previously detailed messages:

SMS nº1: mtx at+csq
SMS nº2: mtx at^mtxtunnel=setmodbus,1;5;1
SMS nº3: mtx at^mtxtunnel=setmodbus,1;5;0
SMS nº4: mtx at^mtxtunnel=setmodbus,192.168.1.95:502;5;1
SMS nº5: mtx at^mtxtunnel=setmodbus,192.168.1.95:502;5;0

As we can see, these are not easy messages to write, especially on a cell phone. To avoid this, we can use ALIAS, whereby the code above is substituted with a specific text that can be written and executes the corresponding code.

How must SMS commands be sent using ALIAS?

First we must establish the text that each of the previous SMS messages will have associated to it. For example, we can choose the following: “gsm”, “rtu on”, “rtu off”, “ip on”, “ip off”

gsm at+csq
rtu on at^mtxtunnel=setmodbus,1;5;1
rtu off at^mtxtunnel=setmodbus,1;5;0
ip on at^mtxtunnel=setmodbus,192.168.1.95:502;5;1
ip off at^mtxtunnel=setmodbus,192.168.1.95:502;5;0

In other words, each time we send an SMS with the text “rtu on”, the router will execute the AT command associated with this code, i.e. at^mtxtunnel=setmodbus,1;5;1. Then it will return the result of the execution via SMS.

The configuration screen of the Titan router can be seen below:

What are the possible return messages of an SMS message being sent using ALIAS?

This depends on the configuration. There are two boxes: “Alias Result OK” and “Alias Result ERROR”, as can be seen in the following screen:

If no text is introduced in these boxes, the Titan router will return the result of the AT command execution. This may or may not be appropriate, depending on the type of AT command. For example, if we send an SMS with the ALIAS “gsm”, the router may return via SMS a text like the following:

at+csq
+CSQ: 20,99
OK

This is correct since we want to know the GSM network status (in this case, we can see “20”). However, if we use the ALIAS “rtu on” the response would be:

at^mtxtunnel=setmodbus,1;5;1
OK

Therefore, depending on the user profile used, this may or may not be correct. The Titan routers allow for a personalized response for each ALIAS. Continuing with the same example, we can create the following responses:

gsm the reply from the AT command
rtu on rtu on OK (if the execution was successful)
rtu on ERROR (if the execution failed)
rtu off rtu off OK (if the execution was successful)
rtu off ERROR (if the execution failed)
ip on ip on OK (if the execution was successful)
ip on ERROR (if the execution failed)
ip off ip off OK (if the execution was successful)
ip off ERROR (if the execution failed)

To implement this, we must enter in the “Alias Result OK” box the text we wish to appear for each ALIAS that is correctly executed:

<a1></a1><a2>rtu on OK</a2><a3>rtu off OK</a3><a4>ip on OK</a4><a5>ip off OK</a5>

Likewise, in the “Alias Result ERROR” box, we must enter the text we wish to appear for each ALIAS that is executed with errors:

<a1></a1><a2>rtu on ERROR</a2><a3>rtu off ERROR</a3><a4>ip on ERROR</a4><a5>ip off ERROR</a5>

Note that the response for ALIAS nº 1 es <a1></a1>. If no text is specified, the reply from the AT command is returned. In the case of the example, this is interesting as we wish to know the status of the network coverage, yet this is not returned.

Description of the Example

Remember that to execute SMS commands, regardless of whether we use ALIAS or not, we must activate the option to execute AT commands via SMS in the configuration (shown below), as well as specify the cell phone numbers authorized to carry out this action (either all numbers or a restricted list of authorized numbers).