Latest Version: 1.1.0
This library provides integration with Exosite by wrapping the Exosite HTTPS Device API.
You can view the library’s source code on GitHub. Click here to see information on the available versions of this library.
To include this library in your project, add
#require "Exosite.agent.lib.nut:1.1.0"
at the top of your agent code
data_in
signal.config_io
write.config_io
and data_in
defined in resources
.The main things to implement when using this library are:
config_io
signal defines the type of data that will be transmitted to ExoSense. This can either be set from the device or from the cloud. For more information on config_io
, please see the ExoSense documentation on channel configuration.config_io
given to ExoSense.For a more complete example of the library's usage, please see the Example directory, which contains sample agent and device code, and en example config_io
file.
Parameter | Type | Required? | Description |
---|---|---|---|
mode | Enum | Yes | The mode in which to execute the library. The available modes are listed below. |
settings | Table | Yes | A table of settings for the selected mode |
const PRODUCT_ID = <MY_PRODUCT_ID>;
local settings = {};
settings.productId <- PRODUCT_ID;
exositeAgent <- Exosite(EXOSITE_MODES.MURANO_PRODUCT, settings);
This method provisions the device with ExoSense using the information provided in the constructor.
A successful request will contain the CIK Auth token in response.body. You will need this value in order to write data and perform other tasks.
Parameter | Type | Required? | Description |
---|---|---|---|
callback | Function | Yes | A function to be executed to handle the read request's response |
Nothing.
This method writes a table of data to the data_in
signal in Murano.
For more information on data_in
and config_io
, please see the ExoSense documentation on channel configuration.
Parameter | Type | Required? | Description |
---|---|---|---|
data | Table | Yes | The data to be written to data_in . Each key should match a channel identifier in your config_io |
token | String | Yes | The device's CIK Authorization token |
Nothing.
This method uses long polling to check for updates to the config_io
. This should be used if the config_io
could be set from the cloud.
Parameter | Type | Required? | Description |
---|---|---|---|
token | String | Yes | The device's CIK Authorization token |
Nothing.
This method writes the given config_io
to the server. This will not need to be used directly if the config_io
is updated from the cloud.
Parameter | Type | Required? | Description |
---|---|---|---|
config_io | String | Yes | The config_io to post formatted as "config_io=<jsonencoded_config_io_table>" |
token | String | Yes | The device's CIK Authorization token |
Nothing.
This method requests the value of the specified attribute.
Parameter | Type | Required? | Description |
---|---|---|---|
attribute | String | Yes | The attribute whose value is to be read |
callback | Function | Yes | A function to be executed to handle the read request's response |
token | String | Yes | The device's CIK Authorization token |
Nothing — the attribute's value is accessed via the registered callback.
Debug mode enables extra logging in the impCentral™ log.
Parameter | Type | Required? | Description |
---|---|---|---|
value | Boolean | Yes | Set to true to enable extra debugging information, or false to silence the extra logging |
Nothing.
Changes the timeout length for a configIO long poll, defaults to 15000000 ms
Parameter | Type | Required | Description |
---|---|---|---|
timeout | Integer | Yes | The time in milliseconds (ms) before the long poll times out and re-requests |
Nothing.
In order to configure the channels in ExoSense to read information from the device correctly, the key that the device uses for the data needs to be defined.
To achieve this, the user must have a Custom
Protocol, with ElectricImp
as the Application and {"key":<device's corresponding key>}
as the app_specific_config.
For example, if the device calls the following Squirrel code:
local conditions = {};
conditions.temp <- reading.temperature;
agent.send("reading.sent", conditions);
A corresponding channel configuration would look like this:
This library supports the following usage modes.
The EXOSITE_MODES.MURANO_PRODUCT
mode should be selected when a user has their own Murano Product to add their device to.
Key | Type | Required? | Description |
---|---|---|---|
productId | String | Yes | The Murano Product ID to connect and send data to |
deviceId | String | No | The Device ID to provision as. If not provided, the Electric Imp agent ID will be used. This must be unique between devices in the product |
local settings = {};
settings.productId = "c449gfcd11ky00002";
settings.deviceId = "device0001";
The Exosite_modes.IOT_CONNECTOR
mode should be selected when connecting to ExoSense using the ElectricImp IoT Connector Service.
Currently no settings are required when using the IoT Connector mode.
To assist in troubleshooting, please ensure that Debug Mode is enabled. The debug log will viewable be in impCentral.
If you are receiving 401 Unauthorized error responses, the auth token may be out of sync with the Exosite Product. To deal with this issue, clear the saved token in the agent, clear the credentials in the Murano device, and re-provision the device.
The Electric Imp Dev Center documents the latest version of the library. For past versions, please see the Electric Imp public GitHub repos listed below.
Version | Source Code | Notes |
---|---|---|
1.0.0 | GitHub | Initial release |
1.1.0 | GitHub | Added IoT Connector mode; updated config_io file interaction |
This library is licensed under the terms of the MIT License and is copyright © 2019 Exosite.