Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface USP

Device API

Hierarchy

  • USP

Index

Properties

_operate

_operate: OperateCommand

Directly call operate without creating a subscription (avoid using unless certain subscription exists), useful for calling sync operate commands for which either output is expected in response or no output is expected

param

Full path of command (e.g. "Device.IP.Diagnostics.IPPing()")

param

Full id of subscription (can be found in Device.LocalAgent.Subscription.)

param

to get the response of operate command, useful when response has output

param

Optional arguments for command

returns

Command results

await usp._operate("Device.Reboot()", 'msg-1', false)
await usp._operate("Device.LocalAgent.ControllerTrust.RequestChallenge()", 'msg-2', true, {ChallengeRef: "Device.LocalAgent.ControllerTrust.Challenge.1"})

add

Add object to path

param

Path to add to (e.g. "Device.NAT.PortMapping." or ["Device.NAT.PortMapping."] for multiple)

param

Optional object to add (if skipped will use default values), allows using arrays for multiple objects

returns

Full path(s) of new object(s)

await usp.add("Device.NAT.PortMapping.")
await usp.add("Device.NAT.PortMapping.", { Description: "cpe-1" })
await usp.add("Device.NAT.PortMapping.", { Description: "cpe-1", allowPartial: true })
await usp.add("Device.NAT.PortMapping.", { Description: { value: "cpe-1", required: false }, allowPartial: true })
await usp.add(
["Device.NAT.PortMapping.", "Device.NAT.PortMapping."],
[{ Description: "cpe-1" }, { Description: "cpe-2" }]
);
await device.add([
["Device.NAT.PortMapping.", { Description: "bbbb" }],
["Device.NAT.PortMapping.", { Description: "bbbb" }],
]);

del

Delete object at path

param

Full path to delete (e.g. "Device.NAT.PortMapping.1.")

param

Allow partial (defaults to false)

returns

String array of affected paths

await usp.del("Device.NAT.PortMapping.1.")
await usp.del("Device.NAT.PortMapping.1.", true)

disconnect

disconnect: () => Promise<void>

Disconnect from device

await usp.disconnect()

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

get

Get value at path

param

Location of value (e.g. "Device.DeviceInfo." or an array of multiple paths)

param

Get options (not required)

await usp.get("Device.WiFi.Radio.1.")
// or
await usp.get(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."])

await usp.get("Device.WiFi.Radio.1.", { raw: true }) // skips parsing, produces raw results

getNested

getNested: GetNestedCommand

Get value at path, returns values with their full path stored in "query" key

param

Location of value (e.g. "Device.DeviceInfo." or an array of multiple paths)

param

Get options (not required)

await usp.getNested("Device.WiFi.Radio.1.")

await usp.getNested(["Device.WiFi.Radio.1.", "Device.WiFi.Radio.2."])

await usp.getNested("Device.WiFi.Radio.1.", { max_depth: 4 })
// providing return type
await usp.getNested<UspProperty>("Device.WiFi.Radio.1.Alias")

await usp.getNested<UspPropertyList>("Device.WiFi.Radio.*.Alias")

await usp.getNested<UspObject>("Device.WiFi.Radio.1.")

await usp.getNested<UspObjectList>("Device.WiFi.Radio.*.")

await usp.getNested<UspProperty>(["Device.WiFi.Radio.1.Alias", "Device.WiFi.Radio.2.Alias"])

getUSPVersion

getUSPVersion: () => "1.0" | "1.1" | "1.2"

Gets current usp version (used by usp-js library for parsing incoming messages)

returns

USP Version

usp.getUspVersion()

Type declaration

    • (): "1.0" | "1.1" | "1.2"
    • Returns "1.0" | "1.1" | "1.2"

instances

instances: InstancesCommand

Get instances

param

Path(s)

param

Response options

await usp.instances("Device.WiFi.", { firstLevelOnly: true })

on

on: OnFn

Add handler for messages

param

Message identifier (identifies by id, can be a string or regexp)

param

Callback on relevant message

returns

Returns function to clear handler

const clear = usp.on("error", () => console.log('An error!'))

operate

operate: OperateRecipe

Create a command

param

Full path of command (e.g. "Device.IP.Diagnostics.IPPing()")

param

Subscription options (not required)

returns

Function that executes command

const [ping, cleanPing] = await usp.operate("Device.IP.Diagnostics.IPPing()")
const results = await ping({ Host: "iopsys.eu" })
await cleanPing()
// sync command example, no need to get cleanup function as there is nothing to clean up with sync commands
const [op] = await device.operate("Device.WiFi.Reset()", { isAsync: false })
await op().then(log).catch(log)

options

options: (opts: Options) => USP

Add general options to commands, extending their functionality

param

Options

returns

Entire USP API

await usp.options({ timeout: 1000 }).get("Device.DeviceInfo.SerialNumber")

Type declaration

resolve

resolve: ResolveRecipe

Resolve references in message

param

Message with reference in it

param

Optional level of nesting to resolve to (avoid using high numbers)

await usp.get("Device.WiFi.Radio.1.").then(device.resolve)

set

Set value at path

param

Location of value (e.g. "Device.DeviceInfo.")

param

Value to assign

returns

Object that respresents executed change

await usp.set("Device.WiFi.Radio.1.", { Name: "radio-1" })
// or
await usp.set("Device.WiFi.Radio.1.Name", "radio-1")
// or
await usp.set(
["Device.NAT.PortMapping.1.", "Device.NAT.PortMapping.2."],
[{ Description: "cat-1" }, { Description: "cat-2" }]
)
// or
await device.set([
["Device.NAT.PortMapping.1.Description", "desc 1"],
["Device.NAT.PortMapping.2.Description", "desc 2"],
]);

subscribe

subscribe: SubscribeRecipe

Subscribe to event

param

Subscription options

param

Callback on relevant message

returns

Returns function to clear subscription

const clearSub = await usp.subscribe({ id: '1234', notif: 'ObjectCreation', reference: 'Device.NAT.PortMapping.' }, console.log)

supportedDM

supportedDM: SupportedDMCommand

Get Supported DM

param

Path(s)

param

Response options

await usp.supportedDM("Device.WiFi.")

supportedProto

supportedProto: SupportedProtoCommand

Get Supported Protocols

param

Controller supported protocol versions

await usp.supportedProto()
await usp.supportedProto("1.0")

Generated using TypeDoc