Difference between revisions of "Domnev"

From Teltonika Networks Wiki
 
(70 intermediate revisions by the same user not shown)
Line 1: Line 1:
<span style="color: red;">The information in this page is shown in accordance with firmware versions {{{fw_version}}}.</span>
+
<p style="color:red">The information on this page is updated in accordance with the [https://wiki.teltonika-networks.com/view/FW_%26_SDK_Downloads'''00.07.4'''] firmware version .</p>
 +
__TOC__
 +
==Summary==
 +
In this guide, the MQTT Serial Gateway function will be configured using third-party MQTT Broker services (in this example, ''Flespi.io'').
  
==Introduction==
+
==Configuration overview & prerequisites==
 +
*Two devices with serials ports - one acts as Modbus RTU Master, another as Modbus RTU Slave;
 +
*Flespi.io account to act as an MQTT Broker/Publisher/Subscriber (for first configuration example);
  
'''''gsmctl''''' is an SSH command used to communicate with a {{{name}}} router's modem. In other words, ''gsmctl'' relays '''AT''' commands (a set of instructions used to control a modem) to the router's modem; thus, providing the user with a way to control and obtain information from the modem via SSH. This can be used to either obtain certain modem related variables (signal strength, operator, connection state, etc.) or to execute certain actions (sending SMS messages, changing the frequency band, etc.).  
+
[[File:MQTT Serial gateway topology v2.png|border|center|class=tlt-border|847x279px]]
  
This article provides a complete overview on ''gsmctl'' commands available in {{{name}}} routers.  
+
RUT2 will act as a Modbus RTU slave and RUT1 as a Modbus RTU Master. On RUT1, MQTT Serial Gateway will be configured to transfer Modbus data over MQTT. Flespi.io platform will serve as an MQTT Broker
  
==Prerequisites==
+
==RUT2 configuration==
 
+
===Configuring Modbus RTU Slave===
''gsmctl'' commands can be used on all {{{name}}} routers via any type of command line interface (CLI) supported by the router. So all you need is:
 
 
 
*a {{{name}}} router
 
*knowledge on how to login via a '''[[Command line interfaces|command line interface]]'''
 
 
 
==gsmctl options==
 
 
 
''gsmctl'' commands are used in tandem with various options that specify what type of action should be executed.
 
----
 
'''Example structure'''
 
 
 
Individual options are described in separate subsections of this article. To find the information you are looking for faster, refer to the table of contents at the top of the page or use your browser's "Find in page" feature ('''Control + F''').
 
 
 
Each option is presented with its usage syntax and an example command. For easier differentiation of the different elements that make up the examples, different colors are used:
 
 
 
*<span style="color:blue;">options</span> are highlighted in blue
 
*<span style="color:red;">responses</span> are highlighted in red
 
*<span style="color:purple;">additional parameters</span> are highlighted in purple
 
 
 
----
 
'''Two execution methods'''
 
 
 
Each option can be executed in two distinct ways. One is shorter, the other is longer and more descriptive. For example, to obtain the modem's IMEI you can either use:
 
 
 
*short version: '''''gsmctl -i'''''
 
*long version: '''''gsmctl --imei'''''
 
 
 
In both cases, you just type the desired command and press the "Enter" key on your keyboard to execute that command. The response will be printed out as a '''standard output''' ('''stdout''') string in your terminal window.
 
----
 
'''Combined options'''
 
 
 
Multiple options can be combined together to obtain more than one parameter at a time. For example, to obtain the name of the operator used, signal strength and connection type with one command you can use one of the following:
 
 
 
*short version: '''''gsmctl -oqt'''''
 
*long version: '''''gsmctl --operator --signal --conntype'''''
 
 
 
Note that in the shorter version multiple options can be used together with one hyphen (-) symbol with no spacing, while in the longer version different options must be separated by spaces and before each option a double hyphen (--) is required.
 
 
 
==Basic options==
 
 
 
This section overviews basic ''gsmctl'' options, usually related to obtaining certain modem related information.
 
 
 
===Get number of bytes sent===
 
 
----
 
----
To obtain the number of bytes sent (TX bytes) by a network interface, use '''''-e''''' or '''''--bsent''''' options.
+
Go to Services → Modbus → Modbus RTU Slave and create a new instance.
 
+
# Enter the '''desired instance name''';
'''Usage syntax''':
+
# Select the '''desired serial interface'''.
 
 
gsmctl <span style="color:blue;">-e</span>, <span style="color:blue;">--bsent</span> <span style="color:purple;"><INTERFACE></span>
 
 
 
Where ''<INTERFACE>'' is the name of a network interface.
 
 
 
'''Example''': obtaining the number of bytes sent (TX bytes) by the mobile connection interface:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-e</span> <span style="color:purple;">{{#ifeq:{{{series}}}|RUTOS|mob1s1a1|wwan0}}</span>
 
<span style="color:red;">36335</span>
 
 
 
Where '''''wwan0''''' is the name of the mobile interface when the connection type is set to QMI (default). You can use the '''''ifconfig''''' command to check the names of existing network interfaces.
 
 
 
'''Possible responses''':
 
 
 
*An integer number representing '''bytes''' (not bits) sent
 
  
 +
[[File:Modbus RTU Slave.png|border|center|class=tlt-border|855 × 308px]]
  
===Get number of bytes received===
+
==RUT1 configuration==
 +
===Configuring MQTT Gateway===
 
----
 
----
To obtain the number of bytes received (RX bytes) by a network interface, use '''''-r''''' or '''''--brecv''''' options.
+
Go to '''Services → Modbus → MQTT Gateway''' and there:
  
'''Usage syntax''':
+
# '''Enable''' the '''instance''';
 +
# '''Enter Host''' (copied from flespi connection settings without 'wss://' and port);
 +
# '''Enter Username''' (Copied from flespi Connection settings generated '''token''');
 +
# '''Enter Password'''.
  
gsmctl <span style="color:blue;">-r</span>, <span style="color:blue;">--brecv</span> <span style="color:purple;"><INTERFACE></span>
+
[[File:MQTT Gateway config.png|border|center|class=tlt-border|862 × 412px]]
  
Where ''<INTERFACE>'' is the name of a network interface.
+
'''Note''': ''Everything else can be left as default or changed according to your needs.''
  
'''Example''': obtaining the number of bytes received (RX bytes) by the mobile connection interface:
+
===Configuring Serial Gateway===
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-r</span> <span style="color:purple;">{{#ifeq:{{{series}}}|RUTOS|mob1s1a1|wwan0}}</span>
 
<span style="color:red;">92551</span>
 
 
 
Where '''''wwan0''''' is the name of the mobile interface when the connection type is set to QMI (default). You can use the '''''ifconfig''''' command to check the names of existing network interfaces.
 
 
 
'''Possible responses''':
 
 
 
*An integer number representing '''bytes''' (not bits) received
 
 
 
 
 
===Get network connection state===
 
 
----
 
----
To obtain the network connection state, use '''''-j''''' or '''''--connstate''''' options.
+
Under the MQTT Gateway configuration, create the Serial Gateway:
 
+
# Enter the '''desired device ID''';
'''Usage syntax''':
+
# Select the '''desired serial interface'''.
 
 
gsmctl <span style="color:blue;">-j</span>, <span style="color:blue;">--connstate</span>
 
 
 
'''Example''': obtaining the current network connection state:
 
  
root@Teltonika:~# gsmctl <span style="color:blue;">-j</span>
+
[[File:Serial gateway config.png|border|center|class=tlt-border|868×308px]]
<span style="color:red;">connected</span>
 
  
'''Possible responses''':
+
===Configuring Flespi.io MQTT Broker===
 
 
*connected
 
*disconnected
 
===-P===
 
 
----
 
----
 +
'''Log in''' or '''create an account''' on '''https://flespi.io''';
  
===Get network link state===
+
#Navigate to '''MQTT Board''' on the '''left side''' menu;                                       
----
+
#On the right-hand panel, top right corner, next to the name of the MQTT board, '''press the cogwheel-looking icon''' to open ''Connection Settings'';
To obtain the registration state of the mobile network, use '''''-g''''' or '''''--netstate''''' options.
+
#In the opened window, press '''"Get flespi token"''' to generate a username;
 +
#Enter the '''Client name''';
 +
#Copy the Host address;
 +
#Copy '''Username''';
 +
#Create a '''password'''.
  
'''Usage syntax''':
+
Once done, save all the changes.
 +
[[File:Flespi board.png|border|center|class=tlt-border|1102x729px]]
  
gsmctl <span style="color:blue;">-g</span>, <span style="color:blue;">--netstate</span>
+
===Message format for MQTT publisher===
 
 
'''Example''': obtaining the registration state of the mobile network:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-g</span>
 
<span style="color:red;">registered (home)</span>
 
 
 
'''Possible responses''':
 
 
 
*registered (home)
 
*registered (roaming)
 
*unregistered
 
*searching
 
*unknown
 
 
 
===Get cell ID parameter===
 
 
----
 
----
To obtain the ID of the cell that the SIM card is connected to, use '''''-C''''' or '''''--cellid''''' options.
+
Modbus request data sent in the MQTT payload should be generated in accordance with the following format:
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-C</span>, <span style="color:blue;">--cellid</span>
 
  
'''Example''': obtaining the cell ID:
+
<pre>1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT> </pre>
  
root@Teltonika:~# gsmctl <span style="color:blue;">-C</span>
+
The table below explains what each option means:
<span style="color:red;">1037089</span>
 
  
'''Possible responses''':
+
{| class="wikitable"
 
+
|1.  Format version
*a 7 digit sequence of decimal numbers indicating the cell ID
+
|'''1'''
*N/A - returned when the SIM card is not inserted or unregistered
+
|-
 
+
|2. Cookie
 
+
|from '''0''' to '''2<sup>64</sup> -1'''
===Get name of operator used===
+
|-
 +
|3. Serial device ID
 +
|a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section
 +
|-
 +
|4. Timeout
 +
|timeout for Modbus connection, in seconds. Range [1..999].
 +
|-
 +
|5. Slave ID
 +
|Indicates to which slave request is sent
 +
|-
 +
|6. Modbus function
 +
|Modbus task type that will be executed. Possible values are:
 +
        <ul>
 +
            <li><b>1</b> - read coils;</li>
 +
            <li><b>2</b> - read input coils;</li>
 +
            <li><b>3</b> - read holding registers;</li>
 +
            <li><b>4</b> - read input registers;</li>
 +
            <li><b>5</b> - set single coil;</li>
 +
            <li><b>6</b> - write to a single holding register;</li>
 +
            <li><b>15</b> - set multiple coils;</li>
 +
            <li><b>16</b> - write to multiple holding registers.</li>
 +
        </ul>
 +
|-
 +
|7. First register
 +
|number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.
 +
|-
 +
|8. Registry count
 +
| <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li>
 +
            <li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li>
 +
            <li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li>
 +
            <li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li>
 +
            <li><b>5</b> - <u>coil value</u> (in range [0..1]);</li>
 +
            <li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li>
 +
            <li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].
 +
|}
 +
====Examples====
 
----
 
----
To obtain the name of the operator used, use '''''-o''''' or '''''--operator''''' options.
+
{| class="wikitable"
 
+
|Setting relay (on) (Relay address is 202, which means 'Number of first register will be 203)
'''Usage syntax''':
+
|'''1 1 1 1 1 6 203 1'''
 
+
|-
gsmctl <span style="color:blue;">-o</span>, <span style="color:blue;">--operator</span>
+
|Getting temperature
 
+
|'''1 1 1 1 1 3 6 2'''
'''Example''': obtaining the operator name:
+
|}
 
+
Modbus parameters are held within registers. The register numbers and corresponding system values can be found [[RUT955_Monitoring_via_Modbus#Get_Parameters|'''in this article''']].
root@Teltonika:~# gsmctl <span style="color:blue;">-o</span>
 
<span style="color:red;">LT BITE GSMC</span>
 
 
 
'''Possible responses''':
 
 
 
*a string of text representing the network operator's name
 
*N/A - returned when the SIM card is not connected to any operator
 
  
===Get operator number===
+
==Testing MQTT Publisher and Subscriber on flespi.io==
 +
====Adding Flespi Subscriber====
 
----
 
----
To obtain the network operator's number, use '''''-f''''' or '''''--opernum''''' options.
+
To test the Modbus Serial Gateway functionality, '''log into''' your '''Flespi account''' '''MQTT Board''' and '''add a Subscriber''':
  
'''Usage syntax''':
+
#Press '''''<nowiki/>'+'''''' button on the top right corner
 +
#Select '''''<nowiki/>'Subscriber''''''
 +
# In the topic field enter '''''<nowiki/>'response''''''
 +
#Press '''''<nowiki/>'Subscribe'''''' button
  
gsmctl <span style="color:blue;">-f</span>, <span style="color:blue;">--opernum</span>
+
[[File:Flespi subscriber.png|border|class=tlt-border|496x204px]]          [[File:Flespi subscriber setup.png|border|class=tlt-border|496x205px]]
 
+
====Adding Flespi Subscriber====
'''Example''': obtaining the network operator's number:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-f</span>
 
<span style="color:red;">24602</span>
 
 
 
'''Possible responses''':
 
 
 
*a 6 digit sequence of decimal numbers
 
*N/A - returned when the SIM card is not connected to any operator
 
 
 
 
 
===Get data carrier type===
 
 
----
 
----
To obtain the connection type, use '''''-t''''' or '''''--conntype''''' options.
 
 
'''Usage syntax''':
 
 
gsmctl <span style="color:blue;">-t</span>, <span style="color:blue;">--conntype</span>
 
 
'''Example''': obtaining the connection type:
 
  
root@Teltonika:~# gsmctl <span style="color:blue;">-t</span>
+
Also, you will need to '''add a Publisher''':
<span style="color:red;">LTE</span>
 
  
'''Possible responses''':
+
#Press '''''<nowiki/>'+'''''' button on the top right corner
 +
#Select '''''<nowiki/>'Publisher''''''
 +
#In the topic field enter '''''<nowiki/>'request''''''
 +
#In the message field enter message, for this example '''''<nowiki/>'Getting temperature'''''' is used
 +
#Press '''''<nowiki/>'Publish'''''' button
  
*NOSERVICE - NOSERVICE mode
+
[[File:Flespi publisher.png|border|class=tlt-border|495x238px]]  [[File:Flespi publisher setup.png|border|class=tlt-border|494x239px]]
*GSM - GSM/GPRS/EDGE mode
+
====Flespi Subscriber output====
*WCDMA - WCDMA/HSDPA/HSPA mode
 
*TDSCDMA - TDSCDMA mode
 
*LTE - LTE mode
 
*CDMA - CDMA mode
 
*EVDO - EV-DO/eHRPD mode
 
*CDMA-EVDO - CDMA/EV-DO(eHRPD) mode
 
 
 
===Get network information===
 
 
----
 
----
To obtain information related to the mobile network information, use '''''-F''''' or '''''--network''''' options.
+
Check the response in the '''''<nowiki/>'Subscriber'''''' tab, you should receive a message similar to the one below.
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-F</span>, <span style="color:blue;">--network</span>
 
 
 
'''Example''': obtaining mobile network information:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-F</span>
 
<span style="color:red;">+QNWINFO: "FDD LTE",46001,"LTE BAND 3",1650</span>
 
 
 
'''Possible responses''':
 
 
 
*response syntax: ''+QNWINFO: <Act>,<oper>,<band>,<channel>'' <br> Where:
 
**'''''<Act>''''' - service mode
 
**'''''<oper>''''' - operator number
 
**'''''<band>''''' - frequency band used
 
**'''''<channel>''''' - channel ID
 
 
 
<b>Note</b>: From FW version <i>R_00.07.03</i> the values are returned in a different format. Example:
 
 
 
root@Teltonika:~# gsmctl -F
 
LTE | LTE_B3 | 24602
 
 
 
===Get serving cell information===
 
----
 
To obtain the serving cell information, use '''''-K''''' or '''''--serving''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-K</span>, <span style="color:blue;">--serving</span>
 
 
 
'''Example''': obtaining the serving cell information
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-K</span>
 
<span style="color:red;">+QENG: "servingcell","NOCONN","LTE","FDD",246,02,FD317,109,1850,3,5,5,92,-108,-12,-76,14,-</span>
 
MEIG modem output:
 
<span style="color:red;">+SGCELLINFOEX:LTE,FDD LTE,246,02,1037079,109,4051,23,146,3,100,1850,19850,-63,-99,-13,199,19,4,255,-,-,4,-,0,-,0,0,0</span>
 
 
 
<b>Note</b>: From FW version <i>R_00.07.03</i> the values are returned in a different format. Example:
 
 
 
root@Teltonika:~# gsmctl -K
 
Access tech: LTE | TDD mode: FDD | MCC: 246 | MNC: 2 | UE state: 3
 
 
 
===Get neighbour cell information===
 
----
 
To obtain the neighbor cell information, use '''''-I''''' or '''''--neighbour''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-I</span>, <span style="color:blue;">--neighbour</span>
 
 
 
'''Example''': obtaining the neighbour cell information
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-I</span>
 
<span style="color:red;">+QENG: "neighbourcell intra","LTE",522,269,-9,-87,-58,0,-,-,-,-,-</span>
 
 
 
===Get VoLTE state status===
 
----
 
To obtain the VoLTE state, use '''''-v''''' or '''''--volte_state''''' options.
 
 
 
<b>Note</b>: This argument is supported from FW version <i>R_00.07.03</i>.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-v</span>, <span style="color:blue;">--volte_state</span>
 
 
 
'''Example''': obtaining the VoLTE state.
 
 
 
root@Teltonika:~# gsmctl -v
 
Active
 
===-b===
 
----
 
==Modem commands==
 
===Send AT command to device===
 
----
 
 
 
To send AT command to device, use '''''-A''''' or '''''--at''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-A, --at</span> <span style="color:purple;">'AT+command'</span>
 
 
 
'''Example''':
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-A</span> <span style="color:purple;">'AT+CLCK="SC",2'</span>
 
<span style="color:red;"></span>
 
 
 
'''Possible responses''':
 
 
 
*This example will return SIM card pin lock state ("+CLCK: 0" - pin lock disabled).
 
 
 
===Get device IMEI===
 
----
 
To obtain the modem's International Mobile Equipment Identity (IMEI), use '''''-i''''' or '''''--imei''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-i</span>, <span style="color:blue;">--imei</span>
 
 
 
'''Example''': obtaining the modem's IMEI:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-i</span>
 
<span style="color:red;">990000862471854</span>
 
 
 
'''Possible responses''':
 
 
 
*a 15 digit sequence of decimal numbers
 
 
 
===Get SIM ICCID===
 
----
 
To obtain the Integrated Circuit Card Identifier (ICCID) of the SIM card that is currently in use, use '''''-J''''' or '''''--iccid''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-J</span>, <span style="color:blue;">--iccid</span>
 
 
 
'''Example''': obtaining the ICCID of the SIM card in use:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-J</span>
 
<span style="color:red;">89310410106543789301</span>
 
 
 
'''Possible responses''':
 
 
 
*a 19 or 20 digit sequence of decimal numbers
 
 
 
===Get device model===
 
----
 
To obtain the modem's model name, use '''''-m''''' or '''''--model''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-m</span>, <span style="color:blue;">--model</span>
 
 
 
'''Example''': obtaining the modem's model name
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-m</span>
 
<span style="color:red;">model_name</span>
 
 
 
'''Possible responses''':
 
 
 
*a string of letters and digits representing the model name
 
 
 
 
 
===Get device manufacturer===
 
----
 
To obtain the modem's manufacturer's name, use '''''-w''''' or '''''--manuf''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-w</span>, <span style="color:blue;">--manuf</span>
 
 
 
'''Example''': obtaining the modem's manufacturer's name:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-w</span>
 
<span style="color:red;">manufacturers_name</span>
 
 
 
'''Possible responses''':
 
 
 
*a string of letters and digits representing the manufacturer's name
 
 
 
===Get device revision number===
 
----
 
To obtain the modem's revision number (firmware version), use '''''-y''''' or '''''--revision''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-y</span>, <span style="color:blue;">--revision</span>
 
 
 
'''Example''': obtaining the modem's revision number:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-y</span>
 
<span style="color:red;">EC25EFAR02A08M4G</span>
 
 
 
'''Possible responses''':
 
 
 
*a string of letters and digits representing the revision number (firmware version)
 
 
 
 
 
===Get IMSI===
 
----
 
To obtain the International Mobile Subscriber Identity (IMSI), use '''''-x''''' or '''''--imsi''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-x</span>, <span style="color:blue;">--imsi</span>
 
 
 
'''Example''': obtaining IMSI:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-x</span>
 
<span style="color:red;">246029999999999</span>
 
 
 
'''Possible responses''':
 
 
 
*a 15 digit (or less) sequence of decimal numbers
 
 
 
 
 
===Get SIM card state===
 
----
 
To obtain the state of the SIM card currently in use, use '''''-z''''' or '''''--simstate''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-z</span>, <span style="color:blue;">--simstate</span>
 
 
 
'''Example''': obtaining the current SIM state:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-z</span>
 
<span style="color:red;">inserted</span>
 
 
 
'''Possible responses''':
 
 
 
*inserted
 
*not inserted
 
 
 
===-u===
 
----
 
 
 
===Get operator station time===
 
----
 
To obtain the operator station, use '''''-H''''' or '''''--modemtime''''' options with time argument (1 - GMT, 2 - local).
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-H</span>, <span style="color:blue;">--modemtime</span> <span style="color:purple;"><1/2></span>
 
 
 
'''Example''': obtaining the operator time
 
 
 
root@Teltonika:~# gsmctl -H 1
 
22/12/01,12:27:14
 
 
 
===Get module temperature===
 
----
 
To obtain the module's temperature, use '''''-c''''' or '''''--temp''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-c</span>, <span style="color:blue;">--temp</span>
 
 
 
'''Example''': obtaining the module's temperature:
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-c</span>
 
<span style="color:red;">360</span>
 
 
 
'''Possible responses''':
 
 
 
*an integer number representing the module's current temperature (in 0.1 degrees Celsius (°C))
 
 
 
 
 
===Get PIN/PUK count===
 
----
 
To obtain the PIN/PUK count, use '''''-B''''' or '''''--pincount''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-B</span>, <span style="color:blue;">--pincount</span>
 
 
 
'''Example''': obtaining the
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-B</span>
 
<span style="color:red;">3</span>
 
 
 
'''Possible responses''':
 
 
 
*an integer number representing the amount of PIN/PUK attempts left
 
*N/A - returned when the SIM card is not inserted
 
 
 
===Get modem info in json format===
 
----
 
To obtain the full modem information in JSON format, use '''''-E''''' or '''''--info''''' options.
 
 
 
<b>Note</b>: This argument is supported from FW version <i>R_00.07.03</i>.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-E</span>, <span style="color:blue;">--info</span>
 
 
 
'''Example''': obtaining the modem information
 
 
 
root@Teltonika:~# gsmctl -E
 
{
 
"name": "Quectel EG06-E",
 
"model": "EG06-E",
 
"manuf": "Quectel",
 
"driver": "Quectel EG06 AT",
 
"usb_id": "3-1",
 
...
 
 
 
===-U===
 
----
 
 
 
===-Y===
 
----
 
 
 
===Reboot the modem===
 
----
 
To reboot the modem, use '''''-Q''''' or '''''--reboot''''' options. After the command is executed, the modem will start rebooting.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-Q</span>, <span style="color:blue;">--reboot</span>
 
 
 
'''Example''': rebooting the modem
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-Q</span>
 
<span style="color:red;">Modem was reset</span>
 
 
 
'''Possible responses''':
 
 
 
*Modem was reset
 
 
 
 
 
==SMS management options==
 
 
 
This section overviews ''gsmctl'' options related to SMS management. Every SMS related command uses the '''''"-S"''''' or '''''"--sms"''''' along with another option.
 
 
 
===Read SMS by index===
 
----
 
 
 
To read a single SMS message, use '''''-S -r''''' or '''''--sms --read''''' options. Additionally you have to specify the '''''<INDEX>''''' of the message that you wish to read. The ''<INDEX>'' is an integer number that defines the position of a message in the SMS message list. It can range from 1 to however many messages your SMS memory can store.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -r</span>, <span style="color:blue;">--sms --read</span> <span style="color:purple;"><INDEX></span>
 
 
 
'''Example''': reading the first message in the SMS list
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -r</span> <span style="color:purple;">1</span>
 
<span style="color:red;">Index: 1
 
Date: 2018-08-02 10:33:20
 
Sender: +37061111111
 
Status: read
 
Text: Hello
 
 
 
'''Possible responses''':
 
 
 
*five lines of string type output indicating the following information related to the SMS message:
 
**Index - an integer number indicating the position of the message in the SMS message list
 
**Date - the date the message was received
 
**Sender - sender's phone number
 
**Status - indicates whether the message has been previously read. (Possible values: ''read'' or ''new'')
 
**Text - the body of the message
 
*no message - indicates that an SMS message with the specified ''<INDEX>'' does not exist
 
*out of range - indicates that the specified ''<INDEX>'' is out of range of the SMS message list
 
 
 
 
 
===List SMS by type===
 
----
 
 
 
To print a list of SMS messages, use '''''-S -l''''' or '''''--sms --list''''' options. Additionally you have to specify the '''''<TYPE>''''' of the list. ''<TYPE>'' can either '''''read''''', '''''new''''' or '''''all'''''
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -l</span>, <span style="color:blue;">--sms --list</span> <span style="color:purple;"><TYPE></span>
 
 
 
'''Example''': printing the list of all new (unread) SMS messages
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -l</span> <span style="color:purple;">new</span>
 
<span style="color:red;">Index: 19
 
Date: 2018-08-03 08:26:36
 
Sender: +37061111111
 
Text: status
 
Status: new</span>
 
 
 
'''Possible responses''':
 
 
 
*multiple entries comprised of five lines of string type output indicating the following information related to an SMS message:
 
**Index - an integer number indicating the position of the message in the SMS message list
 
**Date - the date the message was received
 
**Sender - sender's phone number
 
**Text - the body of the message
 
**Status - indicates whether the message has been previously read. (Possible values: ''read'' or ''new'')
 
 
 
 
 
===Print SMS memory usage===
 
----
 
 
 
To check the SMS memory usage, use '''''-S -t''''' or '''''--sms --total''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -t</span>, <span style="color:blue;">--sms --total</span>
 
 
 
'''Example''': checking the SMS memory usage
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -t</span>
 
<span style="color:red;">Used: 28
 
Total: 50 </span>
 
 
 
'''Possible responses''':
 
 
 
*two lines of string type output
 
**Used - used memory space (integer)
 
**Total - total memory space (integer)
 
 
 
 
 
===Delete SMS by index===
 
----
 
 
 
To delete an SMS message, use '''''-S -d''''' or '''''--sms --delete''''' options. Additionally you have to specify the '''''<INDEX>''''' of the message that you wish to delete. The ''<INDEX>'' is an integer number that defines the position of a message in the SMS message list. It can range from 1 to however many messages your SMS memory can store.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -d</span>, <span style="color:blue;">--sms --delete</span> <span style="color:purple;"><INDEX></span>
 
 
 
'''Example''': deleting the first SMS message
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -d</span> <span style="color:purple;">1</span>
 
<span style="color:red;">OK</span>
 
 
 
'''Possible responses''':
 
 
 
*OK - indicates that the message with specified <INDEX> has been deleted successfully
 
*out of range - indicates that the specified <INDEX> is out of range of the SMS message list
 
 
 
 
 
===Send SMS===
 
----
 
 
 
To send an SMS message, use '''''-S -s''''' or '''''--sms --send''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -s</span>, <span style="color:blue;">--sms --send</span> <span style="color:purple;">"<NUMBER> <TEXT>"</span>
 
 
 
'''Example''': sending a "Hello" message to the number +37011111111
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -s</span> <span style="color:purple;">"0037011111111 Hello"</span>
 
<span style="color:red;"></span>
 
 
 
'''Possible responses''':
 
 
 
*If response in terminal "OK", SMS was sent successfully.
 
 
 
 
 
===Send SMS encoded in base64===
 
----
 
 
 
First you need to create a /tmp/.smstext file and append some text you want to send
 
 
 
<b>Note</b>: From FW version <i>R_00.07.03</i> this argument has been removed.
 
 
 
To send a base64 SMS message, use '''''-S -b''''' or '''''--sms --send-b64''''' options
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-S -b,</span><span style="color:blue;">--sms --send-b64</span> <span style="color:purple;"><NUMBER></span>
 
 
 
'''Example''':
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-S -b</span> <span style="color:purple;">+37061234567</span>
 
<span style="color:red;"></span>
 
 
 
'''Possible responses''':
 
 
 
*If response in terminal "OK", SMS was sent successfully.
 
 
 
 
 
===List available options===
 
----
 
Using '''''-h''''' or '''''--help''''' options prints of all available ''gsmctl'' options with descriptions and usage syntax examples.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-h</span>, <span style="color:blue;">--help</span>
 
 
 
'''Example''': printing a list of available ''gsmctl'' options
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-h</span>
 
<span style="color:red;">usage: gsmctl OPTIONS
 
  -p, --ip <INTERFACE>          Get IP of logical interface
 
  -e, --bsent <INTERFACE>      Get number of bytes sent
 
  -r, --brecv <INTERFACE>      Get number of bytes recieved</span>
 
  ...
 
'''Possible responses''':
 
 
 
*a list of options that can be used with ''gsmctl''
 
 
 
 
 
===Print gsmctl version===
 
----
 
To find out the current ''gsmctl'' version, use '''''-v''''' or '''''--version''''' options.
 
 
 
'''Usage syntax''':
 
 
 
gsmctl <span style="color:blue;">-v</span>, <span style="color:blue;">--version</span>
 
 
 
'''Example''': obtaining the ''gsmctl'' version
 
 
 
root@Teltonika:~# gsmctl <span style="color:blue;">-v</span>
 
<span style="color:red;">GSMCTL version: 0.2b</span>
 
  
'''Possible responses''':
 
  
*a string type output indicating the ''gsmctl'' version
+
[[File:Flespi response.png|border|center|class=tlt-border|500x305px]]
  
==Auxiliary options==
 
  
==See also==
+
In the output, we can see that router's '''temperature''' is '''44 degrees Celsius'''.
  
*[[AT Commands]]
+
==See Also==
 +
*[[RUT955 Monitoring via Modbus#Get Parameters]]
 +
*[[RUT955_Modbus#MQTT_Gateway|MQTT Gateway and Modbus]]
 +
==External links==
 +
[https://flespi.io/#/ Flespi.io]

Latest revision as of 08:14, 13 September 2023

The information on this page is updated in accordance with the 00.07.4 firmware version .

Summary

In this guide, the MQTT Serial Gateway function will be configured using third-party MQTT Broker services (in this example, Flespi.io).

Configuration overview & prerequisites

  • Two devices with serials ports - one acts as Modbus RTU Master, another as Modbus RTU Slave;
  • Flespi.io account to act as an MQTT Broker/Publisher/Subscriber (for first configuration example);
MQTT Serial gateway topology v2.png

RUT2 will act as a Modbus RTU slave and RUT1 as a Modbus RTU Master. On RUT1, MQTT Serial Gateway will be configured to transfer Modbus data over MQTT. Flespi.io platform will serve as an MQTT Broker

RUT2 configuration

Configuring Modbus RTU Slave


Go to Services → Modbus → Modbus RTU Slave and create a new instance.

  1. Enter the desired instance name;
  2. Select the desired serial interface.
855 × 308px

RUT1 configuration

Configuring MQTT Gateway


Go to Services → Modbus → MQTT Gateway and there:

  1. Enable the instance;
  2. Enter Host (copied from flespi connection settings without 'wss://' and port);
  3. Enter Username (Copied from flespi Connection settings generated token);
  4. Enter Password.
862 × 412px

Note: Everything else can be left as default or changed according to your needs.

Configuring Serial Gateway


Under the MQTT Gateway configuration, create the Serial Gateway:

  1. Enter the desired device ID;
  2. Select the desired serial interface.
868×308px

Configuring Flespi.io MQTT Broker


Log in or create an account on https://flespi.io;

  1. Navigate to MQTT Board on the left side menu;
  2. On the right-hand panel, top right corner, next to the name of the MQTT board, press the cogwheel-looking icon to open Connection Settings;
  3. In the opened window, press "Get flespi token" to generate a username;
  4. Enter the Client name;
  5. Copy the Host address;
  6. Copy Username;
  7. Create a password.

Once done, save all the changes.

Flespi board.png

Message format for MQTT publisher


Modbus request data sent in the MQTT payload should be generated in accordance with the following format:

1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT> 

The table below explains what each option means:

1. Format version 1
2. Cookie from 0 to 264 -1
3. Serial device ID a string used to identify a serial device. Must match with Device ID field in MQTT Gateway page Serial gateway configuration section
4. Timeout timeout for Modbus connection, in seconds. Range [1..999].
5. Slave ID Indicates to which slave request is sent
6. Modbus function Modbus task type that will be executed. Possible values are:
  • 1 - read coils;
  • 2 - read input coils;
  • 3 - read holding registers;
  • 4 - read input registers;
  • 5 - set single coil;
  • 6 - write to a single holding register;
  • 15 - set multiple coils;
  • 16 - write to multiple holding registers.
7. First register number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.
8. Registry count
  • 1 - coil count (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);
  • 2 - input count (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);
  • 3 - holding register count (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);
  • 4 - input register count (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);
  • 5 - coil value (in range [0..1]);
  • 6 - holding register value (in range [0..65535]);
  • 15 - coil count (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and coil values separated with commas, without spaces (e.g., 1,2,3,654,21,789); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].
  • Examples


    Setting relay (on) (Relay address is 202, which means 'Number of first register will be 203) 1 1 1 1 1 6 203 1
    Getting temperature 1 1 1 1 1 3 6 2

    Modbus parameters are held within registers. The register numbers and corresponding system values can be found in this article.

    Testing MQTT Publisher and Subscriber on flespi.io

    Adding Flespi Subscriber


    To test the Modbus Serial Gateway functionality, log into your Flespi accountMQTT Board and add a Subscriber:

    1. Press '+' button on the top right corner
    2. Select 'Subscriber'
    3. In the topic field enter 'response'
    4. Press 'Subscribe' button

    Flespi subscriber.png Flespi subscriber setup.png

    Adding Flespi Subscriber


    Also, you will need to add a Publisher:

    1. Press '+' button on the top right corner
    2. Select 'Publisher'
    3. In the topic field enter 'request'
    4. In the message field enter message, for this example 'Getting temperature' is used
    5. Press 'Publish' button

    Flespi publisher.png Flespi publisher setup.png

    Flespi Subscriber output


    Check the response in the 'Subscriber' tab, you should receive a message similar to the one below.


    Flespi response.png


    In the output, we can see that router's temperature is 44 degrees Celsius.

    See Also

    External links

    Flespi.io