Changes

Line 40: Line 40:  
==Using JSON-RPC with Windows OS==
 
==Using JSON-RPC with Windows OS==
   −
This section describes how to use JSON-RPC with a Windows operating system. If you're using a Linux OS, you can find the guide '''[[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Linux_OS|here]]'''
+
This section describes how to use JSON-RPC with a Windows operating system. If you're using a Linux OS, jump to this section of the guide: '''[[Monitoring_via_JSON-RPC#Using_JSON-RPC_with_Linux_OS|JSON-RPC with Linux]]'''
    
===Obtaining a session ID===
 
===Obtaining a session ID===
 
----
 
----
To login to the router via JSON-RPC you will need software capable of sending '''HTTP POST''' requests to the router. The simplest solution is to install an add-on similar to Firefox’s '''“Poster”''': '''https://addons.mozilla.org/en-US/firefox/addon/poster/'''.  
+
To log in to the router via JSON-RPC you will need software capable of sending '''HTTP POST''' requests to the router. The simplest solution is to install an add-on similar to Firefox’s "'''Poster'''": '''https://addons.mozilla.org/en-US/firefox/addon/poster/'''.  
    
Once you've installed this add-on, you can launch it by opening the Mozilla Firefox browser and pressing '''Ctrl+Alt+p'''.  
 
Once you've installed this add-on, you can launch it by opening the Mozilla Firefox browser and pressing '''Ctrl+Alt+p'''.  
Line 59: Line 59:  
Click it to launch Chrome Poster.
 
Click it to launch Chrome Poster.
   −
The rest of this guide will focus on '''Firefox's Poster''', but all the steps bellow apply to '''Chrome Poster''' as well.
+
The rest of this guide will focus on '''Firefox's Poster''', but feel free to follow it whichever method you choose as all the steps bellow apply to '''Chrome Poster''' and similar add-ons as well.
      −
In order to obtain a Session ID you must send an HTTP POST request to the router asking for it. To do so, enter the router's '''[[LAN]]''' IP address (default: '''http://192.168.1.1/ubus''') into the '''URL''' field if you're logging into the router locally or if you wish to login remotely, enter the '''[[WAN]]''' IP address instead. Next, enter the login username and password in the '''User Auth.''' field. Then paste this command into the '''Content to send''' field and click '''Post''':
+
In order to obtain a Session ID you must send an HTTP POST request to the router asking for it. To do so, enter the router's '''[[LAN]]''' IP address (default: '''http://192.168.1.1/ubus''') into the '''URL''' field if you're logging into the router locally. Or if you wish to log in remotely, enter the '''[[WAN]]''' IP address instead.  
 +
 
 +
Next, enter the log in user name and password into the '''User Auth.''' field. Then paste this command into the '''Content to send''' field and click '''Post''':
      Line 74: Line 76:  
     ]
 
     ]
 
  }
 
  }
The section highlighted in orange is the router's admin password which by default is '''admin01'''. Replace this part with your router's password.
+
The section highlighted in orange is the router's admin password which by default is admin01. Replace this part with your own router's password.
      Line 89: Line 91:  
Copy the ID since you'll be needing it when issuing other commands to the router.
 
Copy the ID since you'll be needing it when issuing other commands to the router.
   −
'''NOTE:''' if your commands stop working and you get a Response like this: '''{"jsonrpc":"2.0","id":1,"error":{"code":-32002,"message":"<span style=color:red>Access denied</span>"}}''', it probably means that your Session ID has expired and that you need a new one. A Session ID expires after 300 seconds (5 minutes).
+
'''NOTE:''' if your commands stop working and you get a Response like this: '''{"jsonrpc":"2.0","id":1,"error":{"code":-32002,"message":"<span style=color:red>Access denied</span>"}}''', it probably means that your Session ID has expired so you'll need to ask for a new one. A Session ID expires after 300 seconds (5 minutes).
    
===Getting router parameters===
 
===Getting router parameters===
Line 109: Line 111:  
  }
 
  }
   −
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''' SSH 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''' SSH command that returns the router's RSSI value:
      Line 117: Line 119:  
The Response  '''{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style="color:green">-59</span>\n"}]}''' tells us that the router's current signal strength is <span style="color:green">-59 dBm </span>.
 
The Response  '''{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style="color:green">-59</span>\n"}]}''' tells us that the router's current signal strength is <span style="color:green">-59 dBm </span>.
   −
You can issue almost any Linux 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 Linux command in a similar manner. For example, if 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:
    
  {
 
  {
Line 132: Line 134:  
     ]
 
     ]
 
  }
 
  }
The command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) command is used to view the contents of the  '''/etc/config/network''' file. The Response is:
+
Again the command and the parameter are highlighted in orange. In this case the Linux '''cat'''(short for “concatenate“) command is used to view the contents of the  '''/etc/config/network''' file. The Response is:
      Line 139: Line 141:  
===Setting router parameters===
 
===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:
+
The '''uci set''' command is used to set router parameters. For more general information about the usage and syntax of UCI commands, check out our '''[[UCI command usage]]''' guide.  
    
====uci set====
 
====uci set====
 
----
 
----
 +
As an example, lets try to change the router's WiFi SSID. The command to do so looks like this:
 
  {
 
  {
 
     "jsonrpc":"2.0", "id":1, "method":"call", "params":
 
     "jsonrpc":"2.0", "id":1, "method":"call", "params":
Line 161: Line 164:  
     ]
 
     ]
 
  }
 
  }
The sections highlighted in orange describes the config file's 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 will 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:
+
The sections highlighted in orange describes the config file's name and section (in this case, '''wireless''' config and '''wifi-iface''' section). Highlighted in red is the option of the config section that you wish to change (in this case, the router's '''SSID'''). Finally, highlighted in green is the value that will 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:
      Line 168: Line 171:  
====uci commit====
 
====uci commit====
 
----
 
----
When you set changes using '''uci commit''', you're only changing a copy of the file that is located in the router's RAM memory. In order for the changes to take place you'll need to issue a '''uci commit''' command that will commit the changes from RAM to flash memory. Continuing from the example above, lets commit the Wireless SSID changes. The command to do so looks like this:
+
When you apply changes using ''uci set'', you're only changing a copy of the file that is located in the router's RAM memory. In order for the changes to take place you'll need to issue a '''uci commit''' command that will commit the changes from RAM to flash memory. Continuing from the example above, lets commit the Wireless SSID changes. The JSON-RPC command to do so looks like this:
    
  {
 
  {
Line 179: Line 182:  
     ]
 
     ]
 
  }
 
  }
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). 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, ''wireless'' config, which is highlighted in orange). If the commit was successful, you should see the same message as before:
    
'''{"jsonrpc":"2.0","id":1,"result":[0]}'''
 
'''{"jsonrpc":"2.0","id":1,"result":[0]}'''
Line 185: Line 188:  
====luci-reload====
 
====luci-reload====
 
----
 
----
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 of the router's services. The ''luci-reload'' command looks like this:
    
  {
 
  {

Navigation menu