Changes

m
Changed TRB1 series to correct name from TRB14X
Line 12: Line 12:  
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
 
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
   −
This article provides a guide on how to use Modbus TCP to monitor {{{name}}} routers with a PC using a Linux Operating System. However, the same principles apply to RUTXxx and TRBxx family devices, but the holding register information will differ. You can find this information in the links below:
+
This article provides a guide on how to use Modbus TCP to monitor {{{name}}} routers with a PC using a Linux Operating System.
*'''[[RUTXR1 Monitoring via Modbus]]'''
  −
*'''[[RUTX12 Monitoring via Modbus]]'''
  −
*'''[[RUTX11 Monitoring via Modbus]]'''
  −
*'''[[RUTX10 Monitoring via Modbus]]'''
  −
*'''[[RUTX09 Monitoring via Modbus]]'''
  −
*'''[[RUTX08 Monitoring via Modbus]]'''
  −
*'''[[TRB245 Monitoring via Modbus]]'''
  −
*'''[[TRB255 Monitoring via Modbus]]'''
  −
*'''[[TRB140 Monitoring via Modbus]]'''
  −
*'''[[TRB141 Monitoring via Modbus]]'''
  −
*'''[[TRB142 Monitoring via Modbus]]'''
  −
*'''[[TRB145 Monitoring via Modbus]]'''
   
==Configuring the router==
 
==Configuring the router==
    
In order to start using Modbus TCP, we must first configure the router. Modbus TCP configuration from the router's side is very simple. All you need to do is log in to the router's WebUI, go to '''Services → Modbus''', '''Enable''' the Modbus TCP service, enter a '''Port''' number through which the Modbus TCP communication will take place and '''Allow remote access''' if you wish to connect to the router remotely (from WAN).
 
In order to start using Modbus TCP, we must first configure the router. Modbus TCP configuration from the router's side is very simple. All you need to do is log in to the router's WebUI, go to '''Services → Modbus''', '''Enable''' the Modbus TCP service, enter a '''Port''' number through which the Modbus TCP communication will take place and '''Allow remote access''' if you wish to connect to the router remotely (from WAN).
   −
[[File:Networking_rutos_manual_modbus_modbus_tcp_slave_v2.png]]
+
[[File:Networking_rutos_manual_modbus_modbus_tcp_slave.png|border|class=tlt-border]]
    
==Installing the necessary software==
 
==Installing the necessary software==
Line 42: Line 30:  
Modbus TCP can be used to both '''get''' and '''set''' certain router parameters. First lets do an overview of how to obtain parameters via Modbus TCP. Please keep in mind that in order to get routers parameters when using '''[https://wiki.teltonika-networks.com/view/{{{name}}}_Modbus#Requests_configuration Request Configuration]''' you need to use '''Register Number''' instead of '''Register Address'''.
 
Modbus TCP can be used to both '''get''' and '''set''' certain router parameters. First lets do an overview of how to obtain parameters via Modbus TCP. Please keep in mind that in order to get routers parameters when using '''[https://wiki.teltonika-networks.com/view/{{{name}}}_Modbus#Requests_configuration Request Configuration]''' you need to use '''Register Number''' instead of '''Register Address'''.
   −
===List of parameters===
+
{{Template:Networking_rutos_manual_modbus_modbus_tcp_get_parameters_table
----
+
|mobile = {{{mobile}}}  
Router parameters are held within '''registers'''. Each register contains 2 bytes of information. For simplification the number of registers for storing numerical values is 2, while the number of registers for storing text information is 16. The register addresses and corresponding system values are described in the table below:
+
|series = {{{series}}}
 
+
|name = {{{name}}}
<table class="nd-othertables">
+
|analog = {{{analog}}}
    <tr>
+
|gps = {{{gps}}}
        <th width="546">required value</th>
+
|dualsim = {{{dualsim}}}
      <th width="200">register address</th>
  −
        <th width="200">register number</th>
  −
      <th width="200">number of registers</th>
  −
      <th width="200">representation</th>
  −
    </tr>
  −
    <tr>
  −
      <td>System uptime</td>
  −
      <td>1</td>
  −
        <td>2</td>
  −
      <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
{{#ifeq:{{{mobile}}}| 1 |
  −
    <tr>
  −
      <td>Mobile signal strength ([[RSSI]] in dBm)</td>
  −
      <td>3</td>
  −
        <td>4</td> 
  −
      <td>2</td>
  −
        <td>32 bit integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>System temperature (in 0.1 °C)</td>
  −
      <td>5</td>
  −
        <td>6</td>
  −
      <td>2</td>
  −
        <td>32 bit integer</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
      <td>System hostname</td>
  −
      <td>7</td>
  −
        <td>8</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
{{#ifeq:{{{mobile}}}| 1 |
  −
    <tr>
  −
      <td>GSM operator name</td>
  −
      <td>23</td>
  −
        <td>24</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
      <td>Router serial number</td>
  −
      <td>39</td>
  −
        <td>40</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
{{#switch:{{{name}}}
  −
|TRB141=
  −
|TRB142=
  −
|TRB145=
  −
|
  −
    <tr>
  −
      <td>LAN MAC address</td>
  −
      <td>55</td>
  −
        <td>56</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
      <td>Router name</td>
  −
      <td>71</td>
  −
        <td>72</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
{{#ifeq:{{{mobile}}}| 1 |
  −
    <tr>
  −
      <td>Currently active SIM card slot</td>
  −
      <td>87</td>
  −
        <td>88</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Network registration info</td>
  −
      <td>103</td>
  −
        <td>104</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Network type</td>
  −
      <td>119</td>
  −
        <td>120</td>
  −
      <td>16</td>
  −
        <td>Text</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
      <td>Current WAN IP address</td>
  −
      <td>139</td>
  −
        <td>140</td>
  −
      <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
{{#ifeq:{{{analog}}}| 1|
  −
    <tr>
  −
      <td>Analog input value</td>
  −
      <td>141</td>
  −
        <td>142</td> 
  −
      <td>2</td>
  −
        <td>32 bit integer</td>
  −
    </tr>
  −
}}
  −
{{#ifeq:{{{gps}}}| 1|
  −
    <tr>
  −
      <td>GPS latitude coordinate</td>
  −
      <td>143</td>
  −
        <td>144</td>
  −
      <td>2</td>
  −
        <td>32 bit float</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS longitude coordinate</td>
  −
      <td>145</td>
  −
        <td>146</td>
  −
      <td>2</td>
  −
        <td>32 bit float</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS fix time</td>
  −
      <td>147</td>
  −
        <td>148</td>
  −
      <td>16</td>
  −
        <td>Text (Unix timestamp×1000)</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS date and time</td>
  −
      <td>163</td>
  −
        <td>164</td>
  −
      <td>16</td>
  −
        <td>Text (DDMMYYhhmmss)</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS speed</td>
  −
      <td>179</td>
  −
        <td>180</td>
  −
      <td>2</td>
  −
        <td>32 bit integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS satellite count</td>
  −
      <td>181</td>
  −
        <td>182</td>
  −
      <td>2</td>
  −
        <td>32 bit integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>GPS accuracy</td>
  −
      <td>183</td>
  −
        <td>184</td>
  −
      <td>2</td>
  −
        <td>32 bit float</td>
  −
    </tr>
  −
}}
  −
{{#ifeq:{{{mobile}}}| 1|
  −
    <tr>
  −
      <td>Mobile data received today (SIM1)</td>
  −
      <td>185</td>
  −
      <td>186</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data sent today (SIM1)</td>
  −
      <td>187</td>
  −
      <td>188</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data received this week  (SIM1)</td>
  −
      <td>189</td>
  −
      <td>190</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data sent this week  (SIM1)</td>
  −
      <td>191</td>
  −
      <td>192</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data received this month  (SIM1)</td>
  −
      <td>193</td>
  −
      <td>194</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data sent this month  (SIM1)</td>
  −
      <td>195</td>
  −
      <td>196</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data received last 24h  (SIM1)</td>
  −
        <td>197</td>
  −
        <td>198</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data sent last 24h  (SIM1)</td>
  −
        <td>199</td>
  −
        <td>200</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
}}
  −
{{#ifeq:{{{mobile}}}| 1|
  −
      <tr>
  −
        <td>Active SIM card</td>
  −
        <td>205</td>
  −
        <td>206</td>
  −
        <td>1</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data received last week (SIM1)</td>
  −
        <td>292</td>
  −
        <td>293</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data sent last week (SIM1)</td>
  −
        <td>294</td>
  −
        <td>295</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data received last month (SIM1)</td>
  −
        <td>296</td>
  −
        <td>297</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data sent last month (SIM1)</td>
  −
        <td>298</td>
  −
        <td>299</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
{{#ifeq:{{{name}}}|TRB14X| |
  −
      <tr>
  −
          <td>Mobile data received today (SIM2)</td>
  −
          <td>300</td>
  −
          <td>301</td>
  −
          <td>2</td>
  −
          <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data sent today (SIM2)</td>
  −
        <td>302</td>
  −
        <td>303</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
      </tr>
  −
      <tr>
  −
        <td>Mobile data received  this week  (SIM2)</td>
  −
        <td>304</td>
  −
        <td>305</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data sent  this week  (SIM2)</td>
  −
        <td>306</td>
  −
        <td>307</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data received  this month  (SIM2)</td>
  −
        <td>308</td>
  −
        <td>309</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data sent  this month  (SIM2)</td>
  −
        <td>310</td>
  −
        <td>311</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data received last 24h (SIM2)</td>
  −
      <td>312</td>
  −
      <td>313</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
        <td>Mobile data sent last 24h (SIM2)</td>
  −
        <td>314</td>
  −
        <td>315</td>
  −
        <td>2</td>
  −
        <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data received last week (SIM2)</td>
  −
      <td>316</td>
  −
      <td>317</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data sent last week (SIM2)</td>
  −
      <td>318</td>
  −
      <td>319</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data received last month(SIM2)</td>
  −
      <td>320</td>
  −
      <td>321</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Mobile data sent last month (SIM2)</td>
  −
      <td>322</td>
  −
      <td>323</td>
  −
      <td>2</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
}}
  −
}}
  −
{{#switch:{{{name}}}
  −
|RUTXR1=
  −
|TRB255=
  −
|TRB245=
  −
|
  −
    <tr>
  −
      <td>Digital non-isolated input (4 PIN connector)</td>
  −
      <td>324</td>
  −
      <td>325</td>
  −
      <td>1</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Digital open collector output (4 PIN connector)</td>
  −
      <td>325</td>
  −
      <td>326</td>
  −
      <td>1</td>
  −
      <td>32 bit unsigned integer</td>
  −
</tr>
  −
}}
  −
{{#switch:{{{name}}}
  −
|RUTXR1=
  −
|TRB255=
  −
|TRB245=
  −
|
  −
    <tr>
  −
      <td>Digital non-isolated input (4 PIN connector)</td>
  −
      <td>324</td>
  −
      <td>325</td>
  −
      <td>1</td>
  −
      <td>32 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Digital open collector output (4 PIN connector)</td>
  −
      <td>325</td>
  −
      <td>326</td>
  −
      <td>1</td>
  −
      <td>32 bit unsigned integer</td>
  −
</tr>
  −
}}
  −
{{#switch:{{{series}}}
  −
|RUTX=
  −
|
  −
    <tr>
  −
      <td> PIN 3 direction {{#ifeq:{{{series}}}|TRB14X|(4 PIN connector)}}</td>
  −
      <td>326</td>
  −
      <td>327</td>
  −
      <td>1</td>
  −
      <td>16 bit unsigned integer</td>
  −
    </tr>
  −
    <tr>
  −
      <td> PIN 4 direction {{#ifeq:{{{series}}}|TRB14X|(4 PIN connector)}} </td>
  −
      <td>327</td>
  −
      <td>328</td>
  −
      <td>1</td>
  −
      <td>16 bit unsigned integer</td>
  −
  </tr>
  −
}}
  −
{{#ifeq:{{{mobile}}}|1|
  −
    <tr>
  −
      <td> IMSI </td>
  −
      <td>348</td>
  −
      <td>349</td>
  −
      <td>16</td>
  −
      <td>Text</td>
  −
  </tr>
  −
</table>
   
}}
 
}}
   Line 478: Line 57:  
For the first example, lets use a modbus read command to attempt to obtain the router's uptime value in seconds. If you look back at the table above, you will see that the uptime value is stored in two registers starting from the first register, therefore:
 
For the first example, lets use a modbus read command to attempt to obtain the router's uptime value in seconds. If you look back at the table above, you will see that the uptime value is stored in two registers starting from the first register, therefore:
   −
  $ modbus read -w -p 12345 192.168.1.1 %MW001 2
+
  $ modbus read -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW001 2
    
'''-w''' specifies the data type. In this case, unsigned 16 bit integers.
 
'''-w''' specifies the data type. In this case, unsigned 16 bit integers.
Line 484: Line 63:  
'''-p''' specifies the port number.
 
'''-p''' specifies the port number.
   −
'''192.168.1.1''' - the router's LAN IP address.
+
'''{{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}}''' - the router's LAN IP address.
    
'''%MW001''' specifies the register address.
 
'''%MW001''' specifies the register address.
Line 515: Line 94:  
Lets examine a different, more complex example by issuing a request for the router's '''WAN IP address'''. If you look at the '''[[Monitoring_via_Modbus#List_of_parameters|table]]''' above, you will see that the WAN IP address value is contained within the 139th and 140th registers. Therefore, we should specify the 139th address and read 2 registers from that address:
 
Lets examine a different, more complex example by issuing a request for the router's '''WAN IP address'''. If you look at the '''[[Monitoring_via_Modbus#List_of_parameters|table]]''' above, you will see that the WAN IP address value is contained within the 139th and 140th registers. Therefore, we should specify the 139th address and read 2 registers from that address:
   −
  $ modbus read -w -p 12345 192.168.1.1 %MW139 2
+
  $ modbus read -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW139 2
    
[[File:Configuration examples modbus wan ip v2.png]]
 
[[File:Configuration examples modbus wan ip v2.png]]
Line 554: Line 133:  
Some values like Hostname, Router name, Network type are represented as text in their original form, but are stored in registers as numbers. You can interpret these values the same way as all discussed before (by converting them to binary and then to text), but a simpler way would be to get them in '''hexadecimal''' form and then convert them to text. To do so, we'll have to add the '''-D''' parameter to the command. Lets do it by asking for the router's Hostname:
 
Some values like Hostname, Router name, Network type are represented as text in their original form, but are stored in registers as numbers. You can interpret these values the same way as all discussed before (by converting them to binary and then to text), but a simpler way would be to get them in '''hexadecimal''' form and then convert them to text. To do so, we'll have to add the '''-D''' parameter to the command. Lets do it by asking for the router's Hostname:
   −
  $ modbus read -D -w -p 12345 192.168.1.1 %MW007 16
+
  $ modbus read -D -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW007 16
    
[[Image:Configuration examples modbus hostname example v2.png]]
 
[[Image:Configuration examples modbus hostname example v2.png]]
Line 564: Line 143:  
==Setting router values==
 
==Setting router values==
   −
The Modbus daemon also supports the setting of some system parameters. To accomplish this task the '''modbus write''' command is used. System related parameters and how to use them are described below. The register address specifies from which register to start writing the required values. All commands, except “Change APN”, accepts only one input parameter {{#ifeq:{{{mobile}}}|1|(more on changing APN can be found below)}}.
+
The Modbus daemon also supports the setting of some system parameters. To accomplish this task the '''modbus write''' command is used. System related parameters and how to use them are described below. The register address specifies from which register to start writing the required values. All commands, except “Change APN”, accepts only one input parameter {{#ifeq:{{{mobile}}}|1|(more on changing APN can be found below)}}.  
<table class="nd-othertables">
+
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table
    <tr>
+
|wifi={{{wifi}}}
        <th width="350">value to set</th>
+
|mobile={{{mobile}}}
      <th width="180">register address</th>
+
|series={{{series}}}
      <th width="150">register value</th>
+
|name={{{name}}}
      <th width="466">description</th>
+
|dualsim={{{dualsim}}}
    </tr>
  −
{{#ifeq:{{{wifi}}}|1|
  −
    <tr>
  −
      <td>Switch WiFi ON/OFF</td>
  −
      <td>203</td>
  −
      <td>1 {{!}} 0</td>
  −
        <td>Turns WiFi ON or OFF</td>
  −
    </tr>
  −
}}
  −
{{#ifeq:{{{mobile}}}|1|
  −
    <tr>
  −
      <td>Switch mobile data connection (ON/OFF<span class="asterisk">*</span>)</td>
  −
      <td>204</td>
  −
      <td>1 {{!}} 0</td>
  −
        <td>Turns mobile data connection ON or OFF</td>
  −
    </tr>
  −
    <tr>
  −
      <td>Switch SIM card</td>
  −
      <td>205</td>
  −
      <td>1 {{!}} 2 {{!}} 0</td>
  −
        <td>Changes the active SIM card slot
  −
            <ul>
  −
                <li>1 - switch to SIM1</li>
  −
                <li>2 - switch to SIM2</li>
  −
    <li>0 - switch from the the SIM card opposite of the one currently in use (SIM1 → SIM2 or SIM2 → SIM1</li>
  −
            </ul>
  −
</td>
  −
    </tr>
  −
}}
  −
    <tr>
  −
    <td>Reboot</td>
  −
        <td>206</td>
  −
        <td>1</td>
  −
        <td>Reboots the router</td>
  −
    </tr>
  −
{{#ifeq:{{{mobile}}}|1|
  −
    <tr>
  −
    <td>Change APN</td>
  −
        <td>207</td>
  −
        <td>APN code</td>
  −
        <td>Changes APN. <br> The number of input registers may vary depending on the length of the APN, but the very first byte of the set APN command denotes the number of the SIM card for which to set the APN. This byte should be set to:
  −
            <ul>
  −
                <li>1 - to set APN for SIM1</li>
  −
                <li>2 - to set APN for SIM2</li>
  −
    </ul>
  −
        </td>
  −
    </tr>
   
}}
 
}}
</table>
  −
   
{{#ifeq:{{{wifi}}}|1|
 
{{#ifeq:{{{wifi}}}|1|
 
As you can see most of the values are '''0''' and '''1''', 0 meaning OFF and 1 meaning ON. For example, if you want to turn '''WiFi OFF''', this command should be used:
 
As you can see most of the values are '''0''' and '''1''', 0 meaning OFF and 1 meaning ON. For example, if you want to turn '''WiFi OFF''', this command should be used:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW203 0
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW203 0
    
If you want to turn '''WiFi ON''', use this command instead:
 
If you want to turn '''WiFi ON''', use this command instead:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW203 1
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW203 1
 
}}
 
}}
{{#ifeq:{{{mobile}}}|1|
+
{{#ifeq:1|1|
 
As you can see, the only difference is the digit at the end - '''0 for OFF''', '''1 for ON'''. The same is true for all other parameters that accept only two input values.
 
As you can see, the only difference is the digit at the end - '''0 for OFF''', '''1 for ON'''. The same is true for all other parameters that accept only two input values.
    
In the case of '''SIM switch''' there are three values - '''0''', '''1''' and '''2'''. 1 makes the first SIM card slot in use, 2 makes the second SIM card slot in use and 0 initiates a switc from the SIM card in use to the opposite SIM card. For example, to initiate a switch to the second SIM card the command should look like this:
 
In the case of '''SIM switch''' there are three values - '''0''', '''1''' and '''2'''. 1 makes the first SIM card slot in use, 2 makes the second SIM card slot in use and 0 initiates a switc from the SIM card in use to the opposite SIM card. For example, to initiate a switch to the second SIM card the command should look like this:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW205 2
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW205 2
    
The '''reboot''' function only takes one value: '''1'''. It simply reboots the router. To initiate a reboot, use this command:
 
The '''reboot''' function only takes one value: '''1'''. It simply reboots the router. To initiate a reboot, use this command:
   −
  $ modbus write -w -p 12345 192.168.1.1 %MW206 1
+
  $ modbus write -w -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW206 1
    
===APN===
 
===APN===
Line 647: Line 177:  
As an example lets try to change the router's first SIM card's APN to '''gprs.fix-ip.omnitel1.net''':
 
As an example lets try to change the router's first SIM card's APN to '''gprs.fix-ip.omnitel1.net''':
   −
  $ modbus write -w -D -p 12345 192.168.1.1 %MW207 <span style="color:blue">'''1'''</span> <span style="color:green">'''103 112 114 115 46 102 105 120 45 105 112 46 111 109 110 105 116 101 108 49 46 110 101 116'''</span>
+
  $ modbus write -w -D -p 12345 {{#ifeq:{{{series}}}|TRB1|192.168.2.1|192.168.1.1}} %MW207 <span style="color:blue">'''1'''</span> <span style="color:green">'''103 112 114 115 46 102 105 120 45 105 112 46 111 109 110 105 116 101 108 49 46 110 101 116'''</span>
    
The value of the first byte is highlighted in <span style="color:blue">'''blue'''</span> and, in this case, it denotes that the APN value should be changed for the first SIM card. The value of the APN string itself is highlighted in <span style="color:green">'''green'''</span>. Use an ASCII to Decimal online converter to convert individual letters to Decimal code.
 
The value of the first byte is highlighted in <span style="color:blue">'''blue'''</span> and, in this case, it denotes that the APN value should be changed for the first SIM card. The value of the APN string itself is highlighted in <span style="color:green">'''green'''</span>. Use an ASCII to Decimal online converter to convert individual letters to Decimal code.
 +
 +
===Send SMS message===
 +
----
 +
To send an SMS message from the router using Modbus, first, we would need to specify the recipient‘s number and the message itself. This information should be stored in register address <b>397</b>, of which the first <b>10</b> registers are dedicated to a phone number while the remaining <b>80</b> registers – are for message content. Afterward, we would need to set the <b>396</b> register to a value of 1.
 +
 +
* Phone number:
 +
 +
Let’s say we have the following phone number, which would be used as a recipient <b>0011123456789</b> (where 00 is a substitute for a plus sign and 111 represents the country code). This number’s representation in hexadecimal format would be 30 30 31 31 31 32 33 34 35 36 37 38 39, but since <b>10</b> registers are reserved for a phone number, the remaining spaces should be filled with zeroes, resulting in the following phone number representation:
 +
0x3030 0x3131 0x3132 0x3334 0x3536 0x3738 0x3900 0 0 0
 +
 +
Here 0x characters are needed for the modbus-cli application to treat input as hexadecimal values.
 +
----
 +
* Message:
 +
 +
If we would want to send <b>Hello, this is a test SMS message</b>, this message’s representation in hexadecimal format would be
 +
0x4865 0x6C6C 0x6F2C 0x2074 0x6869 0x7320 0x6973 0x2061 0x2074 0x6573 0x7400
 +
----
 +
* Full command:
 +
 +
Executing the following two modbus-cli commands would allow us to send SMS message:
 +
$ modbus write -D -p 502 192.168.1.1 %MW397 0x3030 0x3131 0x3132 0x3334 0x3536 0x3738 0x3900 0 0 0 0x4865 0x6C6C 0x6F2C 0x2074 0x6869 0x7320 0x6973 0x2061 0x2074 0x6573 0x7400
 +
$ modbus write -D -p 502 192.168.1.1 %MW396 1
 
}}
 
}}
 +
 
==External links==
 
==External links==
   Line 656: Line 209:  
**http://www.unit-conversion.info/
 
**http://www.unit-conversion.info/
 
**http://www.binaryhexconverter.com/
 
**http://www.binaryhexconverter.com/
 +
 +
[[Category:{{{name}}} Configuration Examples]]

Navigation menu