Module: caf_iot/ca/proxy_iot

Proxy that a CA uses to interact with an IoT device.

Source:

Extends

Members

NOW :number

Force the bundle to execute as soon as it arrives to its destination.

Type:
  • number
Source:

Methods

iotApply(method, args)

Force the invocation of a method on the device. No delay or other timing constraints are enforced.

If the device is not connected, it will execute when it comes back online.

Parameters:
Name Type Description
method string

A device method to invoke.

args Array.<jsonType>

An array with method arguments.

Source:

iotMethodsMeta() → {bundleDescriptionType}

Returns the name and arguments of the device methods.

We use this info internally to add bundle methods that construct commands.

The type bundleDescriptionType is:

    Object<string, Array.<string>>

where the key is the name of the command, and the value an array of strings with the argument names of this command (ignoring the last callback).

Source:
Returns:

An object with device method names as keys, and an array with argument names as values.

Type
bundleDescriptionType

newBundle(marginopt) → {bundleObjectType}

Creates a new bundle of commands.

Parameters:
Name Type Attributes Description
margin number <optional>

A safety time margin in msec added to the starting time to allow bundle propagation. Defaults to a system wide margin.

Source:
See:
Returns:

A new bundle.

Type
bundleObjectType

registerToken(tokenStropt)

Registers a token with the caf_gadget application instance that manages this device.

After the token has been registered, the device can have access to it through its local manager, enabling secure interactions with this CA.

Parameters:
Name Type Attributes Description
tokenStr string <optional>

A serialized token to access this CA. If missing, the call is a no-op.

Source:

sendBundle(bundle, offsetopt) → {number}

Sends to the device a bundle to be executed.

The offset value could be:

  • NOW: whenever the bundle arrives to its target, it will start executing right away.
  • undefined: use the current time plus the margin specified in the factory method.
  • number: an offset in msec to be added to the current time plus the margin as above.

To know whether the bundle was late (and ignored) we use responses in this.state.acks, i.e., an array of max size this.state.maxAcks, and elements of type:

 {response: boolean, index: number}

where:

  • response: False if the bundle was late, True otherwise.
  • index: An identifier for the bundle. It matches the one returned by this method.
Parameters:
Name Type Attributes Description
bundle bundleObjectType

A bundle to execute.

offset number <optional>

Time offset, see above.

Source:
Returns:

An identifier for the bundle.

Type
number

sendBundleAt(bundle, atTime) → {number}

Submits a bundle to be executed by the device at a specific time.

Note that margin is still added. To get rid of margin, set it to 0 when the bundle gets created (see newBundle).

Parameters:
Name Type Description
bundle bundleObjectType

A bundle to execute.

atTime number

Time in msec since 1/1/1970 before bundle execution or NOW.

Source:
Returns:

An id for the bundle.

Type
number