Module airvantage.asset Interface to ReadyAgent asset management.
The #asset instances should be created with airvantage.newAsset.

Type airvantage.asset

airvantage.asset.newasset(id) Creates and returns a new #asset instance.

Type asset

asset:close() Closes the racon.asset.
asset.newTable(path, columns, storage, sendPolicy) Creates and returns a airvantage.table#table instance.
asset:pushData(path, data, sendpolicy) Pushes some unstructured data to the agent.
asset:setUpdateHook(hook) Changes the hook function to be called when the asset receives a software update request from the portal.
asset:start() Registers a newly created racon.asset with the ReadyAgent.
asset.tree airvantage.asset data tree.

Type airvantage.asset

Field(s)

airvantage.asset.newasset(id)

Creates and returns a new #asset instance.
The newly created racon.asset is not registered with the ReadyAgent. No message can be sent or received by the instance at this point. See #asset.start to register the newly created instance.

Parameter

Return values

  1. #asset: instance on success.
  2. nil followed by an error message otherwise.

Type asset

@type asset

Field(s)

asset:close()

Closes the racon.asset.
Closes the link with the ReadyAgent so no new messages can be received.

Return value

"ok" on success.

asset.newTable(path, columns, storage, sendPolicy)

Creates and returns a airvantage.table#table instance.

Parameters

Return values

  1. airvantage.table#table: to store and consolidate structured data.
  2. nil + error message otherwise.

asset:pushData(path, data, sendpolicy)

Pushes some unstructured data to the agent.
This data will be sent to the server according to the specified send policy. Data can be a flat set of key/values in a record, or can contain nested sub-records. It can even be simple value out of a record, in which case the last path segment will be used as a datastore key.

Parameters

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.

asset:setUpdateHook(hook)

Changes the hook function to be called when the asset receives a software update request from the portal.

Notes:

- There can be only one SoftwareUpdate request at a time. - Only one hook can be registered for the whole asset - It is not possible to signify asynchronous reporting of update status, for now the only way to send update result is to return the status in the hook. - If no user update hook is set: then the error code 472 meaning not supported / not implemented will be returned. - Any error coming from this update request means that the whole update process will be set as failed. - When an update request asks for installing a version that is already installed then the application should return success value. In deed, in some cases ReadyAgent won't received the update hook result, e.g. asset reboot, device reboot etc, in those cases, the update request will be sent again to the asset with same hook parameters, and the asset hook is expected to answer with success code when that request have been executed successfully before.

Parameter

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.

asset:start()

Registers a newly created racon.asset with the ReadyAgent.
Sends the EMP Register command to the ReadyAgent registering a new asset. Incoming pending messages can be received after a call to this function. In the event of an unrecoverable error or an explicit call to racon.asset:close, the instance emits a "closed" event.

Return values

  1. "ok" on success.
  2. nil followed by an error message otherwise.

asset.tree

airvantage.asset data tree.
The airvantage.asset contains a data tree, in the field tree.

When the server sends data to an asset, the way it reacts is determined by the tree:

For instance, if the server sends myAsset.foo.bar=123:

Handlers are function which receive as parameters:

They must return: * the status code 0 to indicate success; * a non-zero numeric status code to indicate failure, optionally followed by an error message.

The data tree comes with a pre-wired functions on the special path id.commands (i.e ReadNode on id.commands.ReadNode).

Handler functions should be installed on the data tree before the asset is started: otherwise, some server messages might be lost.