caf_iot/ca/proxy_iot

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

Source:

Extends

Members

NOW :number

Source:

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

Type:
  • number

NOW_SAFE :number

Source:

Force the bundle to execute as soon as it arrives to its destination unless it is really old, i.e., it is older than constants_iot.NOW_SAFE_EXPIRE_TIME_MSEC.

By setting a time bound in, e.g., minutes, we can safely garbage collect requests when the device is offline for an extended period.

Type:
  • number

Methods

iotApply(method, args, isSafeopt)

Source:

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 if the isSafe argument is falsy.

Parameters:
Name Type Attributes Description
method string

A device method to invoke.

args Array.<jsonType>

An array with method arguments.

isSafe boolean <optional>

Whether to ignore really old requests.

iotMethodsMeta() → {bundleDescriptionType}

Source:

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).

Returns:

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

Type
bundleDescriptionType

newBundle(marginopt) → {bundleObjectType}

Source:
See:

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.

Returns:

A new bundle.

Type
bundleObjectType

registerToken(tokenStropt)

Source:

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.

sendBundle(bundle, offsetopt) → {number}

Source:

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.
  • NOW_SAFE: same as NOW but ignoring really old bundles.
  • 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.

Returns:

An identifier for the bundle.

Type
number

sendBundleAt(bundle, atTime) → {number}

Source:

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. If negative assumed a preprocessed NOW_SAFE request.

Returns:

An id for the bundle.

Type
number