Skip to content
Snippets Groups Projects
Commit 8022cacf authored by Marin Karamihalev's avatar Marin Karamihalev
Browse files

README: Re-added new connection requirements

parent 7d36b408
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,28 @@
Helper library for easy usp communication using mqtt over tcp or ws.
* [API documentation for usp-js](https://iopsys.se/usp-js/index.html)
* [BBF's USP reference documentation](https://usp-data-models.broadband-forum.org/tr-181-2-13-0-usp.html)
- [API documentation for usp-js](https://iopsys.se/usp-js/index.html)
- [BBF's USP reference documentation](https://usp-data-models.broadband-forum.org/tr-181-2-13-0-usp.html)
# Installation
`npm install usp-js`
# Usage
```javascript
const connect = require("usp-js").default
const connect = require("usp-js").default;
const run = async () => {
// Connect
const usp = await connect({
host: "192.168.1.1",
username: "admin",
password: "admin"
host: "my.ip.here",
username: "username",
password: "password",
port: 90001,
protocol: "ws",
fromId: "from::id",
toId: "to::id",
});
// Get property
......@@ -33,8 +38,8 @@ run();
# API
- Connect
```javascript
// options are based on https://github.com/mqttjs/MQTT.js#mqttconnecturl-options
// they additionaly require fromId and toId, more info: url.here
......@@ -42,51 +47,60 @@ const usp = await connect(options);
```
- Get
- get object - all object end with a dot
```javascript
await usp.get("Device.Time.");
// => {
// "CurrentLocalTime": "2020-12-15T12:33:19Z",
// "Enable": true,
// ...
// }
```
- get property
```javascript
await usp.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z"
```
- get multiple paths
```javascript
await usp.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]);
// => [
// { ... },
// { ... }
// ]
```
- get using pattern
```javascript
await usp.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0
```
- resolve references in get
```javascript
await usp.get("Device.WiFi.Radio.1.").then(usp.resolve); // => { ... }
// or if deeper resolution is needed (be careful when using level, going above 3 often causes an infinite reference loop)
await usp.get("Device.WiFi.Radio.1.").then(msg => usp.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... }
```
- get object - all object end with a dot
```javascript
await usp.get("Device.Time.");
// => {
// "CurrentLocalTime": "2020-12-15T12:33:19Z",
// "Enable": true,
// ...
// }
```
- get property
```javascript
await usp.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z"
```
- get multiple paths
```javascript
await usp.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]);
// => [
// { ... },
// { ... }
// ]
```
- get using pattern
```javascript
await usp.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0
```
- resolve references in get
```javascript
await usp.get("Device.WiFi.Radio.1.").then(usp.resolve); // => { ... }
// or if deeper resolution is needed (be careful when using level, going above 3 often causes an infinite reference loop)
await usp
.get("Device.WiFi.Radio.1.")
.then((msg) => usp.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... }
```
- Set
- set object - does not need to have all attributes, but some may be required (check USP Reference)
```javascript
await usp.set("Device.WiFi.Radio.1.", { Name: "radio-1" }); // => void
```
- set property
```javascript
await usp.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void
```
......@@ -94,26 +108,29 @@ const usp = await connect(options);
- Operate - WIP (response message not working yet)
- operate without no arguments
```javascript
await usp.operate("Device.SelfTestDiagnostics()");
```
- operate with arguments (for required args check USP Reference)
```javascript
const [ping, cleanPing] = await usp.operate("Device.IP.Diagnostics.IPPing()");
const results = await ping({ Host: "iopsys.eu" })
await cleanPing() // clears ping subscription (optional)
const results = await ping({ Host: "iopsys.eu" });
await cleanPing(); // clears ping subscription (optional)
```
- Add
- add with no arguments - adds a new default object
```javascript
await usp.add("Device.NAT.PortMapping."); // => "Device.NAT.PortMapping.3."
await usp.add("Device.NAT.PortMapping."); // => "Device.NAT.PortMapping.3."
```
- add with arguments - adds a new object with provided values
```javascript
await usp.add("Device.NAT.PortMapping.", {
Description: "webserver1-set",
......@@ -127,6 +144,7 @@ const usp = await connect(options);
```
- Delete
```javascript
await usp.del("Device.NAT.PortMapping.4."); // => void
```
\ No newline at end of file
```
{
"name": "usp-js",
"version": "0.0.8",
"version": "0.0.9",
"description": "Helper library for easy usp communication using mqtt over tcp or ws.",
"main": "build/index.js",
"scripts": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment