caf_iot/plug_iot_handler

A handler for wrapping application code.

Properties:

 {methodsFileName: string}

where:

  • methodsFileName: the name of a file containing the application logic. It defaults to ./iot_methods.js.
Source:

Extends

Members

fromCloud :refMapType

Source:

SharedMap to download information from the CA.

It is read-only.

Type:

scratch :Object

Source:

Scratch state of this device handler.

It never rollbacks and contains anything.

Type:
  • Object

state :Object

Source:

State of this device handler.

It roll backs changes on abort, and contains JSON-serializable data only.

Type:
  • Object

toCloud :refMapType

Source:

SharedMap to upload information to the CA.

Type:

Methods

__ca_fullCycle__(cb0)

Source:

Internal function.

Triggers two pulses, the second one after cloud sync finishes.

Sync is always at the end of a pulse, and fullCycle minimizes latency because it can process a cloud request without waiting for the cron process.

Parameters:
Name Type Description
cb0 cbType

A callback to continue after the first pulse.

__ca_getAppName__() → {string}

Source:

Returns the application name.

Returns:

The application name.

Type
string

__ca_getName__() → {string}

Source:

Returns the name of this device.

Matches the name of its CA in the cloud.

Returns:

The name of this device.

Type
string

__ca_pulse__(cb0)

Source:

Internal function.

Main loop periodically called by the framework.

Parameters:
Name Type Description
cb0 cbType

A callback to continue after pulse.

__iot_error__()

Source:

Optional error handler provided by the application.

This method is null unless provided by the application.

Strategy to handle errors:

  1. Call this handler with the error

    1.1 If handler propagates error in callback, shutdown top level. If shutdown fails exit process.

    1.2 If handler does not propagate the error in callback, just abort transaction. If abort fails follow as in 1.1

  2. If this handler is null, follow as in 1.1

The type of the handler is function(Error, cbType) where:

Error: An error raised by the last processed command. cbType: A callback that will propagate the error if it wants a shutdown, or, if the error is not propagated, just abort.

__iot_loop__(cb0)

Source:

Application main method called periodically by the framework.

This method is typically customized by the application.

Parameters:
Name Type Description
cb0 cbType

A callback to continue after setup.

__iot_setup__(cb0)

Source:

Application setup method called every time the framework resets.

This method is typically customized by the application.

Parameters:
Name Type Description
cb0 cbType

A callback to continue after setup.