Monitoring via JSON-RPC linux RutOS: Difference between revisions
mNo edit summary |
No edit summary |
||
(6 intermediate revisions by 3 users not shown) | |||
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.08'''] firmware version .</p> | |||
==Introduction== | ==Introduction== | ||
'''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 | 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 | 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]] | |||
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 | |||
===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 | ====Getting signal levels==== | ||
---- | ---- | ||
This is a command that returns the router's | 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 | The picture bellow is a visual representation of this example. Encapsulated in a red rectangle is the answer to the ''gsmctl -q'': | ||
[[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 | ||
[[ | [[File:JSON ls config.png|border|center|class=tlt-border|833x481px]] | ||
The | 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. | 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. | 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: | ||
[[File:JSON change LAN IP.png|border|center|class=tlt-border|833x481px]] | |||
[[ | |||
====UCI COMMIT==== | ====UCI COMMIT==== | ||
Line 80: | Line 78: | ||
'''{"jsonrpc":"2.0","id":1,"result":[0]}''' | '''{"jsonrpc":"2.0","id":1,"result":[0]}''' | ||
==== | ====RELOAD_CONFIG==== | ||
---- | ---- | ||
In order for the changes to take effect, use the ''' | In order for the changes to take effect, use the '''reload_config''' command which restarts all of the router's services. The reload_config command looks like this: | ||
curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange> | curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"<span style=color:orange>reload_config</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. | ||
==Some Additional Commands== | ==Some Additional Commands== | ||
If the commands found in the guide above did not suffice your needs, this section provides a list of additional ones. The commands presented in this section will be for both Linux and Windows operating systems. They should be used as syntax examples for your own purposes. | If the commands found in the guide above did not suffice your needs, this section provides a list of additional ones. The commands presented in this section will be for both Linux and Windows operating systems. They should be used as syntax examples for your own purposes. | ||
===WiFi information=== | ===WiFi information=== | ||
---- | ---- | ||
Line 141: | Line 99: | ||
"a70ceeba344b6046625d8bcec132796c", "<span style=color:red>iwinfo</span>", "<span style=color:red>info</span>", | "a70ceeba344b6046625d8bcec132796c", "<span style=color:red>iwinfo</span>", "<span style=color:red>info</span>", | ||
{ | { | ||
"device":" | "device":"radio0" | ||
} | } | ||
] | ] | ||
Line 147: | Line 105: | ||
'''Linux:''' | '''Linux:''' | ||
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"a70ceeba344b6046625d8bcec132796c\", \"<span style=color:red>iwinfo</span>\", \"<span style=color:red>info</span>\", {\"device\":\" | curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"a70ceeba344b6046625d8bcec132796c\", \"<span style=color:red>iwinfo</span>\", \"<span style=color:red>info</span>\", {\"device\":\"radio0\"} ] }" http://<span style=color:black>192.168.1.1</span>/ubus | ||
'''Response:''' | '''Response:''' | ||
{"jsonrpc":"2.0","id":1,"result":[0, | {"jsonrpc":"2.0","id":1,"result":[0, | ||
{"phy":"<span style=color:blue>phy0</span>","ssid":"<span style=color:blue>HAL9000</span>","bssid":"<span style=color:blue>00:1E:42: | {"phy":"<span style=color:blue>phy0</span>","ssid":"<span style=color:blue>HAL9000</span>","bssid":"<span style=color:blue>00:1E:42:XX:XX:XX</span>","country":"<span style=color:blue>00</span>","mode":"<span style=color:blue>Master</span>","channel":<span style=color:blue>6</span>,"frequency":<span style=color:blue>2437</span>,"txpower":<span style=color:blue>20</span>, | ||
"quality":<span style=color:blue>22</span>,"quality_max":<span style=color:blue>70</span>,"signal":<span style=color:blue>22</span>,"noise":<span style=color:blue>-61</span>,"bitrate":<span style=color:blue>72200</span>,"encryption": | "quality":<span style=color:blue>22</span>,"quality_max":<span style=color:blue>70</span>,"signal":<span style=color:blue>22</span>,"noise":<span style=color:blue>-61</span>,"bitrate":<span style=color:blue>72200</span>,"encryption": | ||
{"enabled":<span style=color:blue>false</span>},"hwmodes":["<span style=color:blue>b</span>","<span style=color:blue>g</span>","<span style=color:blue>n</span>"],"hardware":{"name":"<span style=color:blue>Generic MAC80211</span>"}}]} | {"enabled":<span style=color:blue>false</span>},"hwmodes":["<span style=color:blue>b</span>","<span style=color:blue>g</span>","<span style=color:blue>n</span>"],"hardware":{"name":"<span style=color:blue>Generic MAC80211</span>"}}]} | ||
As with the clients list command described above, to obtain this information the Linux '''iwinfo''' command is used, but this time with the '''info''' parameter (red). The relevant information, such as WiFi SSID, WiFi MAC address, WiFi channel, Encryption type, etc., is highlighted in blue | As with the clients list command described above, to obtain this information the Linux '''iwinfo''' command is used, but this time with the '''info''' parameter (red). The relevant information, such as WiFi SSID, WiFi MAC address, WiFi channel, Encryption type, etc., is highlighted in blue | ||
===Manufacturing information=== | ===Manufacturing information=== | ||
---- | ---- | ||
Line 168: | Line 125: | ||
"805725a19ab0fba6c2b44ecf2f952fb9","file", "exec", | "805725a19ab0fba6c2b44ecf2f952fb9","file", "exec", | ||
{ | { | ||
"command":"<span style=color:red>mnf_info</span>", "params":["<span style=color:red>name</span>", "<span style=color:red> | "command":"<span style=color:red>mnf_info</span>", "params":["<span style=color:red>--name</span>", "<span style=color:red>--batch</span>"] | ||
} | } | ||
] | ] | ||
Line 174: | Line 131: | ||
'''Linux:''' | '''Linux:''' | ||
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"805725a19ab0fba6c2b44ecf2f952fb9\",\"file\", \"exec\",{ \"command\":\"<span style=color:red>mnf_info</span>\", \"params\":[\"<span style=color:red>name</span>\", \"<span style=color:red> | curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"805725a19ab0fba6c2b44ecf2f952fb9\",\"file\", \"exec\",{ \"command\":\"<span style=color:red>mnf_info</span>\", \"params\":[\"<span style=color:red>--name</span>\", \"<span style=color:red>--batch</span>\"] } ] }" http://<span style=color:black>192.168.1.1</span>/ubus | ||
'''Response:''' | '''Response:''' | ||
{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style=color:blue> | {"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style=color:blue>"RUT955003XXX</span>\n<span style=color:blue>0105</span>\n<span style=color:blue>001e4216d666</span>\n"}]} | ||
To obtain the manufacturing information the '''mnf_info''' (highlighted in red) command is used. In this case a query was sent asking for the device's Product Code (name), Serial Number (sn) and MAC Address (mac) (highlighted in red in the query; returned values highlighted in blue). Using ''mnf_info'', you can "ask" the router for any type of manufacturing information. Here is the list of possible ''mnf_info'' parameters: | To obtain the manufacturing information the '''mnf_info''' (highlighted in red) command is used. In this case a query was sent asking for the device's Product Code (name), Serial Number (sn) and MAC Address (mac) (highlighted in red in the query; returned values highlighted in blue). Using ''mnf_info'', you can "ask" the router for any type of manufacturing information. Here is the list of possible ''mnf_info'' parameters: | ||
* '''mac''' - returns the router's LAN MAC address | * '''--mac''' - returns the router's LAN MAC address | ||
* '''maceth''' - returns the router's WAN MAC address | * '''--maceth''' - returns the router's WAN MAC address | ||
* '''name''' - returns the router's Product Code | * '''--name''' - returns the router's Product Code | ||
* '''wps''' - returns the router's WPS PIN number | * '''--wps''' - returns the router's WPS PIN number | ||
* '''sn''' - returns the router's Serial number | * '''--sn''' - returns the router's Serial number | ||
* '''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 '''[[RUT955 Mobile|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 | ||
===GPS Data=== | ===GPS Data=== | ||
---- | ---- | ||
Line 211: | Line 167: | ||
{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style=color:blue>-23.612625\n-46.626355\</span>n"}]} | {"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"<span style=color:blue>-23.612625\n-46.626355\</span>n"}]} | ||
The blue part in the code are the Latitude and Longitude. | The blue part in the code are the Latitude and Longitude. | ||
===Firmware number=== | ===Firmware number=== | ||
---- | ---- | ||
Line 231: | Line 186: | ||
'''Response:''' | '''Response:''' | ||
{"jsonrpc":"2.0","id":1,"result":[0,{"data":"<span style=color:blue>RUTXXX_R_00.07. | {"jsonrpc":"2.0","id":1,"result":[0,{"data":"<span style=color:blue>RUTXXX_R_00.07.08</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. | ||
<br> | |||
===Reboot=== | ===Reboot=== | ||
---- | ---- | ||
Line 254: | Line 209: | ||
The success response for this command is an empty message. If the response contains no data, the command was executed successfully. | The success response for this command is an empty message. If the response contains no data, the command was executed successfully. | ||
==See Also== | |||
You may learn more about UCI commands [[UCI_command_usage|here]]. | |||
[[Category: | [[Category:Router control and monitoring]] |
Latest revision as of 12:38, 26 July 2024
Main Page > General Information > Configuration Examples > Router control and monitoring > Monitoring via JSON-RPC linux RutOSThe information on this page is updated in accordance with the 00.07.08 firmware version .
Introduction
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.
This article provides a guide on how to use JSON-RPC on RUTxxx routers.
Configuration overview and prerequisites
Before we begin, let's overview the configuration that we are attempting to achieve and the prerequisites that make it possible.
Prerequisites:
- A PC with HTTP request software.
- 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.
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 here.
Obtaining a session ID
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\": \"admin\", \"password\": \"admin01\" } ] }" http://192.168.1.1/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 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.
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.
Getting signal levels
This is a command that returns the router's signal levels value:
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", { \"command\":\"gsmctl\", \"params\": [\"-q\"] } ] }" http://192.168.1.1/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.
The picture bellow is a visual representation of this example. Encapsulated in a red rectangle is the answer to the gsmctl -q:
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:
curl -d "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"a74c8e07646f0da2bfddce35bf3de1f3\", \"file\", \"exec\", {\"command\":\"ls\", \"params\": [\"/etc/config\"] } ] }" http://192.168.1.1/ubus
The answer is encapsulated in an red rectangle.
Setting router parameters
This section will describe how to use uci set commands in order to set or change various router parameters via JSON-RPC. For more general information about the usage and syntax of UCI commands, check out our UCI command usage guide.
UCI SET
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\":\"network\", \"type\":\"interface\", \"match\": {\"ipaddr\":\"192.168.1.1\"}, \"values\": {\"ipaddr\":\"192.168.11.1\"} } ] }" http://192.168.1.1/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.11.1). If the command was issued successfully, you should see a Response like this:
UCI COMMIT
In order to commit the changes from RAM to flash memory, you must execute a uci commit command. Continuing from the example above, lets commit the changes made to the network config. The command to do so looks like this:
curl -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"call\", \"params\":[\"9704f676709d9dedc98d7718c4e3e7d2\", \"uci\", \"commit\", {\"config\":\"network\"} ] }" http://192.168.1.1/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:
{"jsonrpc":"2.0","id":1,"result":[0]}
RELOAD_CONFIG
In order for the changes to take effect, use the reload_config command which restarts all of the router's services. The reload_config command looks like this:
curl -d "{\"jsonrpc\":\"2.0\",\"id\":1, \"method\":\"call\", \"params\":[\"428a9fa57f1a391db0bd1b865fa16bb5\", \"file\", \"exec\", {\"command\": \"reload_config\"} ] }" http://192.168.56.1/ubus
The command itself is highlighted in orange.
Some Additional Commands
If the commands found in the guide above did not suffice your needs, this section provides a list of additional ones. The commands presented in this section will be for both Linux and Windows operating systems. They should be used as syntax examples for your own purposes.
WiFi information
This command returns information on your WiFi Access Point.
Windows:
{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "a70ceeba344b6046625d8bcec132796c", "iwinfo", "info", { "device":"radio0" } ] }
Linux:
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"a70ceeba344b6046625d8bcec132796c\", \"iwinfo\", \"info\", {\"device\":\"radio0\"} ] }" http://192.168.1.1/ubus
Response:
{"jsonrpc":"2.0","id":1,"result":[0, {"phy":"phy0","ssid":"HAL9000","bssid":"00:1E:42:XX:XX:XX","country":"00","mode":"Master","channel":6,"frequency":2437,"txpower":20, "quality":22,"quality_max":70,"signal":22,"noise":-61,"bitrate":72200,"encryption": {"enabled":false},"hwmodes":["b","g","n"],"hardware":{"name":"Generic MAC80211"}}]}
As with the clients list command described above, to obtain this information the Linux iwinfo command is used, but this time with the info parameter (red). The relevant information, such as WiFi SSID, WiFi MAC address, WiFi channel, Encryption type, etc., is highlighted in blue
Manufacturing information
This command returns information about the device's manufacturing details like device's Product Code, Serial Number MAC Address, etc.
Windows:
{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "805725a19ab0fba6c2b44ecf2f952fb9","file", "exec", { "command":"mnf_info", "params":["--name", "--batch"] } ] }
Linux:
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"805725a19ab0fba6c2b44ecf2f952fb9\",\"file\", \"exec\",{ \"command\":\"mnf_info\", \"params\":[\"--name\", \"--batch\"] } ] }" http://192.168.1.1/ubus
Response:
{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":""RUT955003XXX\n0105\n001e4216d666\n"}]}
To obtain the manufacturing information the mnf_info (highlighted in red) command is used. In this case a query was sent asking for the device's Product Code (name), Serial Number (sn) and MAC Address (mac) (highlighted in red in the query; returned values highlighted in blue). Using mnf_info, you can "ask" the router for any type of manufacturing information. Here is the list of possible mnf_info parameters:
- --mac - returns the router's LAN MAC address
- --maceth - returns the router's WAN MAC address
- --name - returns the router's Product Code
- --wps - returns the router's WPS PIN number
- --sn - returns the router's Serial number
- --batch - returns the router's Batch number
- --hwver - returns the router's Hardware Revision number
- --simpin - returns the router's SIM card's PIN (as it is specified in the Mobile section)
- --blver - returns the router's Bootloader version
GPS Data
This command returns the device's GPS GPS latitude and longitude.
Windows:
{
"jsonrpc": "2.0", "id": 1, "method": "call", "params":
[
"456f77f6b686bf5972daa3a26bee60b0","file", "exec",
{
"command":"gpsctl", "params":["-ix"]
}
]
}
Linux:
curl -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"call\",\"params\":[\"5363304b3ed4ee0806f101295fc52e93\",\"file\",\"exec\",{\"command\":\"gpsctl\",\"params\":[\"-ix\"]}]}" http://192.168.1.1/ubus
Response:
{"jsonrpc":"2.0","id":1,"result":[0,{"code":0,"stdout":"-23.612625\n-46.626355\n"}]}
The blue part in the code are the Latitude and Longitude.
Firmware number
This command returns the device's Firmware version number.
Windows:
{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "85ea4cb00398d8387b22d8fa6f75f753", "file", "read", { "path":"/etc/version" } ] }
Linux:
curl -d "{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [ \"85ea4cb00398d8387b22d8fa6f75f753\",\"file\", \"read\",{ \"path\":\"/etc/version\"} ] }" http://192.168.1.1/ubus
Response:
{"jsonrpc":"2.0","id":1,"result":[0,{"data":"RUTXXX_R_00.07.08\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.
Reboot
Windows:
{ "jsonrpc":"2.0","id":1,"method":"call","params": [ "5cd4b143b182c07bc578ae3310d6280e","file","exec", { "command":"reboot","params":["config"] } ] }
Linux:
curl -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"call\",\"params\":[\"5cd4b143b182c07bc578ae3310d6280e\",\"file\",\"exec\",{\"command\":\"reboot\",\"params\":[\"config\"]}]}" http://192.168.1.1/ubus
Response:
The success response for this command is an empty message. If the response contains no data, the command was executed successfully.
See Also
You may learn more about UCI commands here.