1.5.1 • Published 4 years ago

ubus-websocket-communicator v1.5.1

Weekly downloads
1
License
GPL-2.0-only
Repository
github
Last release
4 years ago

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);
   }

})();

License

GPL2

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago