ubus-websocket-communicator
v1.5.1
Published
Helper library for openWrt ubus communication over WebSocket using RPC. Can be used towards OpenWrt WebSocket Daemon (OWSD).
Downloads
21
Readme
ubus-websocket-communicator
Helper library for openWrt ubus communication over WebSocket using RPC. Can be used towards OpenWrt WebSocket Daemon (OWSD). See the example.js for usage guidance. Has only been tested with iopsysWRT is an enterprise software for CPE and gateway products which is based on OpenWrt.
prerequisites
If you a running iopsysWRT everything will be available by default. Just check that you have the correct access rights to access the ubus object. Access files can be found here: /usr/libexec/rpcd/ on your CPE.
Installation
> npm install ubus-websocket-communicator -g
Usage
An example to check if the PIN "1234" is valid as Wi-Fi Protected Setup (WPS) pin.
"use strict"
const wsUBUS = require('ubus-websocket-communicator');
const WS_IP = "192.168.1.1";
const WS_PORT = 80;
const WS_USER_NAME = "api";
const WS_PASSWORD = "api";
(async() => {
const communicator = new wsUBUS(WS_IP, WS_PORT, WS_USER_NAME, WS_PASSWORD);
try {
await communicator.init();
var command = {
method: 'call',
params: [
'router.wps',
'checkpin', {
pin: '1234'
}
],
expectedResult: {
valid: true
}
};
await communicator.sendMessage(command)
.then(response => {
console.log("successful -- response:\n", response);
})
.catch(err => {
console.log("failure -- response:\n", err);
});
process.exit();
} catch (e) {
console.log(e);
}
})();