Changes

no edit summary
Line 1: Line 1:  +
<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>
 
==Introduction==
 
==Introduction==
<span style="color: red;">The information in this page is updated in accordance with the <span style="color: #0054A6;"><b>RUTXXX_R_00.07.04</b></span> firmware version.</span>
      
'''JSON-RPC''' is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered out of order.
 
'''JSON-RPC''' is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a few data types and commands. JSON-RPC allows for notifications (data sent to the server that does not require a response) and for multiple calls to be sent to the server which may be answered out of order.
Line 17: Line 17:  
==Using JSON-RPC (Linux)==
 
==Using JSON-RPC (Linux)==
   −
This section describes how to use JSON-RPC commands with a Linux OS system. To find the guide for Windows users, jump to this section: '''[[{{{link}}}|JSON-RPC on Widnows]]'''
+
This section describes how to use JSON-RPC commands with a Linux OS system. To find the guide for Windows users, jump to this section [[Monitoring_via_JSON-RPC_windows_RutOS|here]].
    
===Obtaining a session ID===
 
===Obtaining a session ID===
Line 25: Line 25:  
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"admin\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
 
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"admin\", \"password\": \"<span style=color:orange>admin01</span>\"  } ] }" http://<span style=color:green>192.168.1.1</span>/ubus   
   −
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from '''[[{{{name}}}_LAN|LAN]]''', use the local IP address (default: 192.168.1.1), if you're trying to reach the router from '''[[{{{name}}} WAN|WAN]]''', use the router's WAN IP address.
+
The section highlighted in orange is the router's admin password. admin01 is the default value, replace it with your router's password. The address highlighted in green is the router's IP address. Replace this value with your router's IP. If you're trying to reach the router from LAN, use the local IP address (default: 192.168.1.1), if you're trying to reach the router from WAN, use the router's WAN IP address.
    +
[[File:JSON ID.png|border|center|class=tlt-border|835x481px]]
   −
[[Image:Configuration examples json-rpc terminal get id.png|961px|border|class=tlt-border]]
+
The picture above depicts the process of obtaining a Session ID. The ID itself is encapsulated in a red rectangle. Copy this ID as you will need it to authenticate yourself when using other commands.
 
  −
The picture above depicts the process of obtaining a Session ID. The ID itself is encapsulated in a blue rectangle. Copy this ID as you will need it to authenticate yourself when using other commands.
      
===Getting router parameters===
 
===Getting router parameters===
 
----
 
----
 
Now that you have obtained a Session ID, you can issue commands to the router. Lets start with commands that return information about the router.  
 
Now that you have obtained a Session ID, you can issue commands to the router. Lets start with commands that return information about the router.  
====Getting RSSI====
+
====Getting signal levels====
 
----
 
----
This is a command that returns the router's '''[[RSSI]]'''(signal strength) value:
+
This is a command that returns the router's signal levels value:
    
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"<span style=color:red>a74c8e07646f0da2bfddce35bf3de1f3</span>\", \"file\", \"exec\", { \"command\":\"<span style=color:orange>gsmctl</span>\", \"params\": [\"<span style=color:green>-q</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"<span style=color:red>a74c8e07646f0da2bfddce35bf3de1f3</span>\", \"file\", \"exec\", { \"command\":\"<span style=color:orange>gsmctl</span>\", \"params\": [\"<span style=color:green>-q</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 +
 
Highlighted in red is the Session ID. Replace it with the Session ID that was provided to you. Highlighted in orange is the command that we used for our query and highlighted in green is the parameter for the command: '''gsmctl -q'''.
 
Highlighted in red is the Session ID. Replace it with the Session ID that was provided to you. Highlighted in orange is the command that we used for our query and highlighted in green is the parameter for the command: '''gsmctl -q'''.
   −
The picture bellow is a visual representation of this example. Encapsulated in a blue rectangle is the answer to the ''gsmctl -q'' query: '''-73 dBm'''.
+
The picture bellow is a visual representation of this example. Encapsulated in a red rectangle is the answer to the ''gsmctl -q'':  
 
     −
[[Image:Configuration examples json-rpc terminal gsmctl.png|961px|border|class=tlt-border]]
+
[[File:JSON gsmctl.png|border|center|class=tlt-border|833x481px]]
    
You can issue almost any Linux command in a similar manner. For example, if you wish to get a list of file names contained in the config folder, the Linux command to do so would be '''ls /etc/config''', which, translated to JSON-RPC, would be:
 
You can issue almost any Linux command in a similar manner. For example, if you wish to get a list of file names contained in the config folder, the Linux command to do so would be '''ls /etc/config''', which, translated to JSON-RPC, would be:
Line 51: Line 50:  
  curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"<span style=color:orange>ls</span>\", \"params\": [\"<span style=color:orange>/etc/config</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"<span style=color:orange>ls</span>\", \"params\": [\"<span style=color:orange>/etc/config</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
   −
[[Image:Configuration examples json-rpc terminal ls.png|961px|border|class=tlt-border]]
+
[[File:JSON ls config.png|border|center|class=tlt-border|833x481px]]
   −
The command is encapsulated in an orange rectangle and the answer - in a blue one.
+
The answer is encapsulated in an red rectangle.
    
===Setting router parameters===
 
===Setting router parameters===
Line 63: Line 62:  
The ''uci set'' command is used to set router parameters. As an example, lets try to change the router's '''LAN IP address'''. The command to do so looks like this:
 
The ''uci set'' command is used to set router parameters. As an example, lets try to change the router's '''LAN IP address'''. The command to do so looks like this:
   −
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"590bde71578da2fabfe77ba86c00e4e5\", \"uci\", \"set\", { \"config\":\"<span style=color:orange>network</span>\", \"type\":\"<span style=color:orange>interface</span>\", \"match\": {\"ipaddr\":\"<span style=color:red>192.168.1.1</span>\"}, \"values\": {\"ipaddr\":\"<span style=color:green>192.168.56.1</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
+
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"590bde71578da2fabfe77ba86c00e4e5\", \"uci\", \"set\", { \"config\":\"<span style=color:orange>network</span>\", \"type\":\"<span style=color:orange>interface</span>\", \"match\": {\"ipaddr\":\"<span style=color:red>192.168.1.1</span>\"}, \"values\": {\"ipaddr\":\"<span style=color:green>192.168.11.1</span>\"} } ] }" http://<span style=color:black>192.168.1.1</span>/ubus
 
  −
The sections highlighted in orange describe the config file's name and section (in this case, network config and interface section). Highlighted in red is the option in the config file that you wish to change (in this case, the router's LAN IP address, '''ipaddr'''). Finally, highlighted in green is the value that will to replace the old value (in this case, change the router's LAN IP address to 192.168.56.1). If the command was issued successfully, you should see a Response like this:
      +
The sections highlighted in orange describe the config file's name and section (in this case, network config and interface section). Highlighted in red is the option in the config file that you wish to change (in this case, the router's LAN IP address, '''ipaddr'''). Finally, highlighted in green is the value that will to replace the old value (in this case, change the router's LAN IP address to 192.168.11.1). If the command was issued successfully, you should see a Response like this:
   −
[[Image:Configuration examples json-rpc terminal uci set.png|961px|border|class=tlt-border]]
+
[[File:JSON change LAN IP.png|border|center|class=tlt-border|833x481px]]
    
====UCI COMMIT====
 
====UCI COMMIT====

Navigation menu