diff --git a/README.md b/README.md index eed532233f3a564d08c1c4800709451f93e7c383..41af4ad50b6f16044fed6d6ee3a4f887a260c6fd 100644 --- a/README.md +++ b/README.md @@ -101,21 +101,19 @@ const usp = await connect(options); await usp.set("Device.WiFi.Radio.1.", { Name: "radio-1" }); // => void ``` - - set property + - set object with allowPartial and required attributes ```javascript - await usp.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void + await usp.set("Device.WiFi.Radio.1.", { Name: { required: true, value: "radio-1" }, allowPartial: true }); // => void ``` -- Operate - WIP (response message not working yet) - - - operate without no arguments + - set property ```javascript - await usp.operate("Device.SelfTestDiagnostics()"); + await usp.set("Device.WiFi.Radio.1.Name", "radio-1"); // => void ``` - - operate with arguments (for required args check USP Reference) +- Operate ```javascript const [ping, cleanPing] = await usp.operate("Device.IP.Diagnostics.IPPing()"); @@ -145,8 +143,66 @@ const usp = await connect(options); }); // => "Device.NAT.PortMapping.4." ``` + - add with with allowPartial and required attributes + + ```javascript + await usp.add("Device.NAT.PortMapping.", { + allowPartial: true, + Description: { + required: true, + value: "webserver1-set", + } + ExternalPort: "80", + Protocol: "TCP", + Interface: "Device.IP.Interface.1", + Enable: "true", + InternalClient: "192.168.1.125", + InternalPort: "5000", + }); // => "Device.NAT.PortMapping.4." + ``` + - Delete ```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 })) +``` +