From c6d6d0ae0c97c8c62c545965412736ea4508c16c Mon Sep 17 00:00:00 2001 From: Marin Karamihalev <marin.karamihalev@iopsys.eu> Date: Wed, 16 Dec 2020 11:06:40 +0100 Subject: [PATCH] README update --- README.md | 38 ++++++++++++++++++-------------------- package.json | 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 6884c4c..9adcc1e 100644 --- a/README.md +++ b/README.md @@ -13,18 +13,18 @@ Helper library for easy usp communication using mqtt over tcp or ws. const connect = require("usp-js").default const run = async () => { - // Connect to device - const device = await connect({ + // Connect + const usp = await connect({ host: "192.168.1.1", username: "admin", password: "admin" }); // Get property - await device.get("Device.WiFi.").then(console.log); + await usp.get("Device.WiFi.").then(console.log); // Disconnect - await device.disconnect(); + await usp.disconnect(); }; run(); @@ -36,13 +36,13 @@ run(); - Connect ```javascript // options are based on https://github.com/mqttjs/MQTT.js#mqttconnecturl-options -const device = await connect(options); +const usp = await connect(options); ``` - Get - get object - all object end with a dot ```javascript - await device.get("Device.Time."); + await usp.get("Device.Time."); // => { // "CurrentLocalTime": "2020-12-15T12:33:19Z", // "Enable": true, @@ -52,12 +52,12 @@ const device = await connect(options); - get property ```javascript - await device.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z" + await usp.get("Device.Time.CurrentLocalTime"); // => "2020-12-15T12:33:19Z" ``` - get multiple paths ```javascript - await device.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]); + await usp.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."]); // => [ // { ... }, // { ... } @@ -66,14 +66,14 @@ const device = await connect(options); - get using pattern ```javascript - await device.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0 + await usp.get('Device.Ethernet.Interface.[Alias=="WAN"].CurrentBitRate'); // => 0 ``` - resolve references in get ```javascript - await device.get("Device.WiFi.Radio.1.").then(device.resolve); // => { ... } + 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 device.get("Device.WiFi.Radio.1.").then(msg => device.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... } + await usp.get("Device.WiFi.Radio.1.").then(msg => usp.resolve(msg, 3 /* level - defaults to 1 */)); // => { ... } ``` @@ -81,39 +81,37 @@ const device = await connect(options); - set object - does not need to have all attributes, but some may be required (check USP Reference) ```javascript - await device.set("Device.WiFi.Radio.1.", { Name: "radio-1" }); // => void + await usp.set("Device.WiFi.Radio.1.", { Name: "radio-1" }); // => void ``` - set property ```javascript - await device.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void + await usp.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void ``` - Operate - WIP (response message not working yet) - operate without no arguments ```javascript - await device.operate("Device.SelfTestDiagnostics()"); + await usp.operate("Device.SelfTestDiagnostics()"); ``` - operate with arguments (for required args check USP Reference) ```javascript - await device.operate("Device.IP.Diagnostics.IPPing()", { Host: "iopsys.eu" }); + await usp.operate("Device.IP.Diagnostics.IPPing()", { Host: "iopsys.eu" }); ``` - Add - add with no arguments - adds a new default object - <br> ```javascript - await device.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 - <br> ```javascript - await device.add("Device.NAT.PortMapping.", { + await usp.add("Device.NAT.PortMapping.", { Description: "webserver1-set", ExternalPort: "80", Protocol: "TCP", @@ -126,5 +124,5 @@ const device = await connect(options); - Delete ```javascript -await device.del("Device.NAT.PortMapping.4."); // => void +await usp.del("Device.NAT.PortMapping.4."); // => void ``` \ No newline at end of file diff --git a/package.json b/package.json index 32a30dc..d5cc963 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "usp-js", - "version": "0.0.2", + "version": "0.0.3", "description": "Helper library for easy usp communication using mqtt over tcp or ws.", "main": "build/index.js", "scripts": { -- GitLab