From 34a5bba16f96adf521557abdfbb05350a6088053 Mon Sep 17 00:00:00 2001 From: Marin Karamihalev <marin.karamihalev@iopsys.eu> Date: Wed, 10 Feb 2021 17:30:57 +0000 Subject: [PATCH] Update README.md --- README.md | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index eed5322..33d2aac 100644 --- a/README.md +++ b/README.md @@ -107,15 +107,7 @@ const usp = await connect(options); await usp.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void ``` -- 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) +- Operate ```javascript const [ping, cleanPing] = await usp.operate("Device.IP.Diagnostics.IPPing()"); @@ -150,3 +142,43 @@ const usp = await connect(options); ```javascript await usp.del("Device.NAT.PortMapping.4."); // => void ``` + + +- Get Supported DM + +```javascript +await usp.supportedDM("Device.WiFi.") +``` +- Get Supported Protocols + +```javascript +await usp.supportedProto("Device.WiFi.") +``` + +- Get Instances + +```javascript +await usp.instances("Device.WiFi.") +``` + +- Subscribe + +```javascript +const clearSub = await usp.subscribe({ id: '1234', notif: 'ObjectCreation', reference: 'Device.NAT.PortMapping.' }, console.log) +``` + + - optional second argument to callback gives access to full message. + ```javascript + await usp.subscribe({ id: '1234', notif: 'ObjectCreation', reference: 'Device.NAT.PortMapping.' }, (_, fullMsg) => console.log(fullMsg) ) + ``` + +- On (WIP) + + Id can be a string or a regexp. Messages, generally, have their id in the form COMMAND@random_string (i.e. NOTIFY@12345). + (Note: does not add subscription to USP model, instead allows for internal monitoring of received messages) + Optional second argument to callback gives access to full message. + +```javascript +const clear = usp.on(/NOTIFY.*/, (data, msg) => console.log({ data, msg })) +``` + -- GitLab