Changes

no edit summary
Line 178: Line 178:  
The last step to take in order for the changes to take effect is the '''luci-reload''' command which restarts all the services relevant to our configuration. The '''luci-reload''' command looks like this:
 
The last step to take in order for the changes to take effect is the '''luci-reload''' command which restarts all the services relevant to our configuration. The '''luci-reload''' command looks like this:
   −
  {
+
{
      "jsonrpc": "2.0", "id": 1, "method": "call", "params":
+
    "jsonrpc": "2.0", "id": 1, "method": "call", "params":
      [
+
    [
          "428a9fa57f1a391db0bd1b865fa16bb5", "file", "exec",  
+
        "428a9fa57f1a391db0bd1b865fa16bb5", "file", "exec",  
          {
+
        {
              "command": "<span style=color:orange>luci-reload</span>"
+
            "command": "<span style=color:orange>luci-reload</span>"
          }  
+
        }  
      ]
+
    ]
  }
+
}
 
The command itself is highlighted in orange.
 
The command itself is highlighted in orange.
   Line 223: Line 223:  
To login to the router via JSON-RPC you must first obtain a Session ID. To do so, open the '''Terminal''' app and execute this command:
 
To login to the router via JSON-RPC you must first obtain a Session ID. To do so, open the '''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\": \"root\", \"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 '''[[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.
 
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.
Line 236: Line 236:  
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:
   −
  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 this with your own Session ID. Highlighted in orange is the command that we used and highlighted in green is the parameter for the command - '''gsmctl -q'''. Shortly put, you can replace the Session ID, command and parameter with your needed values.  
 
Highlighted in red is the '''Session ID'''. Replace this with your own Session ID. Highlighted in orange is the command that we used and highlighted in green is the parameter for the command - '''gsmctl -q'''. Shortly put, you can replace the Session ID, command and parameter with your needed values.  
   Line 258: Line 258:  
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.56.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 exact part of 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 is to replace the old value (in this case, change the router's LAN IP address to 192.168.56.1). If the issued command was a success, 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 exact part of 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 is to replace the old value (in this case, change the router's LAN IP address to 192.168.56.1). If the issued command was a success, you should see a Response like this:
Line 271: Line 271:  
In order to commit the changes from RAM to flash memory, you must first send a UCI commit command. Continuing from the example above, lets commit the network changes. The command to do so looks like this:
 
In order to commit the changes from RAM to flash memory, you must first send a UCI commit command. Continuing from the example above, lets commit the network changes. The command to do so looks like this:
   −
  curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"9704f676709d9dedc98d7718c4e3e7d2\", \"uci\", \"commit\", {\"config\":\"<span style=color=orange>network</span>\"} ] }" http://<span style=color:black>192.168.1.1</span>/ubus
+
curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"9704f676709d9dedc98d7718c4e3e7d2\", \"uci\", \"commit\", {\"config\":\"<span style=color=orange>network</span>\"} ] }" http://<span style=color:black>192.168.1.1</span>/ubus
    
When committing changes, you will need to specify the name of the file where the changes took place (in this case, network, which is highlighted in orange). If the commit was successful, you should see the same message as before:
 
When committing changes, you will need to specify the name of the file where the changes took place (in this case, network, which is highlighted in orange). If the commit was successful, you should see the same message as before:
Line 281: Line 281:  
The last step to take in order for the changes to take effect is the luci-reload command which restarts all the services relevant to our configuration. The luci-reload command looks like this:
 
The last step to take in order for the changes to take effect is the luci-reload command which restarts all the services relevant to our configuration. The luci-reload command looks like this:
   −
  curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange>luci-reload</span>\"} ] }" http://<span style=color:black>192.168.56.1</span>/ubus
+
curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange>luci-reload</span>\"} ] }" http://<span style=color:black>192.168.56.1</span>/ubus
    
The command itself is highlighted in orange.
 
The command itself is highlighted in orange.