Changes

m
no edit summary
Line 1: Line 1:  
==Introduction==
 
==Introduction==
{{Template:Networking_rutxxx_manual_fw_disclosure | fw_version= {{{fw_version}}} }}
+
<span style="color: red;">The information in this page is updated in accordance with the <span style="color: #0054A6;"><b>RUTXXX_R_00_07_02</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 9: Line 9:  
Before we begin, let's overview the configuration that we are attempting to achieve and the prerequisites that make it possible.<br>
 
Before we begin, let's overview the configuration that we are attempting to achieve and the prerequisites that make it possible.<br>
 
'''Prerequisites''':
 
'''Prerequisites''':
* A PC for with a HTTP request software.
+
* A PC with HTTP request software.
* An Internet connection. (''This example is based in a local configuration, but also can be used via wired WAN or a remote installation with Public IP'')
+
* An Internet connection. (''This example is based on a local configuration, but also can be used via wired WAN or a remote installation with Public IP'')
 
* One RUTxxx series router.<br>
 
* One RUTxxx series router.<br>
 
'''Configuration scheme:'''
 
'''Configuration scheme:'''
[[File:{{{file_scheme}}}|border|class=tlt-border]]
+
[[File:Scheme02.jpg|border|class=tlt-border]]
 
  −
==Enabling JSON-RPC==
  −
Before anything else, you'll need to make sure JSON-RPC is enabled on your router. JSON-RPC is enabled by default, so if you haven't made any changes to the router's access settings, everything should be in order. Otherwise you can check JSON-RPC status by logging into your router's WebUI and navigating to '''System → Administration → Access Control'''. Look for the ''WebUI'' section; there will be an '''Enable JSON RPC''' field. Make sure it is checked:
  −
 
  −
[[File:WEBUI JSON.jpg|border|class=tlt-border]]
      
==Using JSON-RPC (Linux)==
 
==Using JSON-RPC (Linux)==
Line 28: Line 23:  
To log in to the router via JSON-RPC you must first obtain a Session ID. To do so, you must send an '''HTTP POST''' request to the router. Open the Linux '''Terminal''' app and execute this command:
 
To log in to the router via JSON-RPC you must first obtain a Session ID. To do so, you must send an '''HTTP POST''' request to the router. Open the Linux '''Terminal''' app and execute this command:
   −
  curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"00000000000000000000000000000000\", \"session\", \"login\", { \"username\": \"root\", \"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 '''[[{{{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.
      −
[[Image:Configuration examples json-rpc terminal get id.png|961px]]
+
[[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 blue 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.
Line 50: Line 45:       −
[[Image:Configuration examples json-rpc terminal gsmctl.png|961px]]
+
[[Image:Configuration examples json-rpc terminal gsmctl.png|961px|border|class=tlt-border]]
    
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 56: Line 51:  
  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]]
+
[[Image:Configuration examples json-rpc terminal ls.png|961px|border|class=tlt-border]]
    
The command is encapsulated in an orange rectangle and the answer - in a blue one.
 
The command is encapsulated in an orange rectangle and the answer - in a blue one.
Line 73: Line 68:       −
[[Image:Configuration examples json-rpc terminal uci set.png|961px]]
+
[[Image:Configuration examples json-rpc terminal uci set.png|961px|border|class=tlt-border]]
    
====UCI COMMIT====
 
====UCI COMMIT====
Line 193: Line 188:  
* '''batch''' - returns the router's Batch number
 
* '''batch''' - returns the router's Batch number
 
* '''hwver''' - returns the router's Hardware Revision number
 
* '''hwver''' - returns the router's Hardware Revision number
* '''simpin''' - returns the router's SIM card's PIN (as it is specified in the '''[[{{{name}}}_Mobile]]''' section)
+
* '''simpin''' - returns the router's SIM card's PIN (as it is specified in the '''[[RUT955 Mobile|Mobile]]''' section)
 
* '''blver''' - returns the router's Bootloader version
 
* '''blver''' - returns the router's Bootloader version
 
<br><br><br>
 
<br><br><br>
Line 236: Line 231:     
'''Response:'''
 
'''Response:'''
  {"jsonrpc":"2.0","id":1,"result":[0,{"data":"<span style=color:blue>RUT9XX_R_00.05.00.5</span>\n"}]}
+
  {"jsonrpc":"2.0","id":1,"result":[0,{"data":"<span style=color:blue>RUTXXX_R_00.07.02.0</span>\n"}]}
    
This command ('''file''', '''read''', highlighted in red) is an alternative to the Linux '''cat''' command. All you need is to specify the path (in this case '''/etc/version''', highlighted in red) to the file that you wish to read.
 
This command ('''file''', '''read''', highlighted in red) is an alternative to the Linux '''cat''' command. All you need is to specify the path (in this case '''/etc/version''', highlighted in red) to the file that you wish to read.
Line 292: Line 287:  
The command used is ''uci set'' (highlighted in red). The config file name is '''simcard''', section '''sim1''', options '''mtu''' and '''service''' (configs, sections and options highlighted in orange). The response shown above is a positive response, but don't forget to execute ''uci commit'' and ''luci-reload'' afterwards or else your changes will not take effect.
 
The command used is ''uci set'' (highlighted in red). The config file name is '''simcard''', section '''sim1''', options '''mtu''' and '''service''' (configs, sections and options highlighted in orange). The response shown above is a positive response, but don't forget to execute ''uci commit'' and ''luci-reload'' afterwards or else your changes will not take effect.
   −
[[Category:{{{name}}} Configuration Examples]]
+
[[Category: RutOS Configuration Examples]]

Navigation menu