Changes

no edit summary
Line 77: Line 77:  
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. For example, this is a command that returns the router's '''[[RSSI]]'''(signal strength) value:
 
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. For example, this is a command that returns the router's '''[[RSSI]]'''(signal strength) value:
   −
{"jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "<span style="color:red">bde01a2da4a6f4a515bb9466f90bc58a</span>", "file", "exec", { "command": "<span style="color:orange">gsmctl</span>", "params":["<span style="color:orange">-q</span>"] } ] }"
+
'''{"jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "<span style="color:red">bde01a2da4a6f4a515bb9466f90bc58a</span>", "file", "exec", { "command": "<span style="color:orange">gsmctl</span>", "params":["<span style="color:orange">-q</span>"] } ] }'''
    
The section highlighted in red is your Session ID, and the sections highlighted in orange are the command and the parameter. In this example we're using a '''gsmctl -q''' command that returns the router's '''[[RSSI]]''' value:
 
The section highlighted in red is your Session ID, and the sections highlighted in orange are the command and the parameter. In this example we're using a '''gsmctl -q''' command that returns the router's '''[[RSSI]]''' value:
Line 88: Line 88:  
You can issue almost any SSH command in a similar manner. For example, you wish to check the '''network''' config file. The SSH command to do so would be '''cat /etc/config/network''', which, translated to JSON-RPC, would be:
 
You can issue almost any SSH command in a similar manner. For example, you wish to check the '''network''' config file. The SSH command to do so would be '''cat /etc/config/network''', which, translated to JSON-RPC, would be:
   −
{"jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "a74c8e07646f0da2bfddce35bf3de1f3", "file", "exec", { "command": "<span style="color:orange">cat</span>", "params":["<span style="color:orange">/etc/config/network</span>"] } ] }"
+
'''{"jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "a74c8e07646f0da2bfddce35bf3de1f3", "file", "exec", { "command": "<span style="color:orange">cat</span>", "params":["<span style="color:orange">/etc/config/network</span>"] } ] }'''
      Line 94: Line 94:     
The command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) is used to view the contents of the  '''/etc/config/network''' file.
 
The command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) is used to view the contents of the  '''/etc/config/network''' file.
 +
 +
 +
===Setting router parameters===
 +
 +
The '''UCI set''' command is used to set router parameters. As an example, lets try to change the router's WiFi SSID. The command to do so looks like this:
 +
 +
====UCI set====
 +
 +
'''{"jsonrpc":"2.0","id":1,"method":"call","params":[ "9704f676709d9dedc98d7718c4e3e7d2", "uci", "set",{ "config":"<span style=color:orange">wireless</span>","type":"<span style=color:orange">wifi-iface</span>","match": { "ssid": "<span style=color:red">Teltonika_Router</span>" } ,"values":{"ssid":"<span style=color:green">9999</span>"} }]}'''
 +
 +
The sections highlighted in orange describe the config files name and section (in this case, '''wireless''' config and '''wifi-iface''' section). Highlighted in red is the exact part of the config file that you wish to change (in this case, the router's '''SSID'''). Finally, highlighted in green is the value that is to replace the old value (in this case, change the router's SSID to '''9999'''). If the issued command was a success, you should see a Response like this:
 +
 +
 +
[[Image:Configuration examples json-rpc firefox poster uci response.PNG]]
 +
 +
====UCI commit====
 +
 +
In order for the changes to take effect, you must first send a UCI commit command. Continuing from the example above, lets commit the Wireless SSID changes. The command to do so looks like this:
 +
 +
{"jsonrpc":"2.0","id":1,"method":"call","params":["9704f676709d9dedc98d7718c4e3e7d2","uci","commit",{"config":"<span style=color:orange">wireless</span>"}]}
 +
 +
When committing changes, you will need to specify the name of the file where the changes took place (in this case, '''wireless''', which is highlighted in orange)
    
</font>
 
</font>