# ubus-websocket-communicator

> Helper library for openWrt ubus communication over WebSocket using RPC. Can be used towards OpenWrt WebSocket Daemon (OWSD).

Latest version **1.5.1** (published 2020-05-05) · GPL-2.0-only license · 0 weekly downloads

## Install

```sh
npm install ubus-websocket-communicator
pnpm add ubus-websocket-communicator
yarn add ubus-websocket-communicator
bun add ubus-websocket-communicator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2020-05-05 |
| First published | 2018-06-14 |
| Weekly downloads | 0 |
| License | GPL-2.0-only |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.4.1 |
| Dependencies | 3 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Suru Dissanaike |
| Maintainers | suru.dissanaike |

## Links

- npm: https://www.npmjs.com/package/ubus-websocket-communicator
- Repository: https://github.com/suru-dissanaike/ubus-websocket-communicator
- Homepage: https://github.com/suru-dissanaike/ubus-websocket-communicator#readme
- Issues: https://github.com/suru-dissanaike/ubus-websocket-communicator/issues
- npm.io page: https://npm.io/package/ubus-websocket-communicator

## Dependencies (3)

- [np](https://npm.io/package/np.md) ^6.2.3
- [ws](https://npm.io/package/ws.md) ^7.2.5
- [npmlog](https://npm.io/package/npmlog.md) ^4.1.2

## Recent versions

- 1.5.1 (latest) — 2020-05-05
- 1.5.0 — 2020-05-05
- 1.4.0 — 2018-09-28
- 1.3.0 — 2018-09-28
- 1.2.0 — 2018-09-28
- 1.1.0 — 2018-09-28
- 1.0.0 — 2018-09-28
- 0.0.2 — 2018-06-14
- 0.0.1 — 2018-06-14

## 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](https://iopsys.eu/) is an enterprise software for CPE and gateway products which is based on [OpenWrt](https://openwrt.org/).

## 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.

```javascript

"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](https://opensource.org/licenses/LGPL-2.0)

---
_Source: https://npm.io/package/ubus-websocket-communicator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
