-
Notifications
You must be signed in to change notification settings - Fork 12
Skygear IoT Feature Spec
Each IoT device must provide a platform interface object to the SDK:
{
action: { // platform specific action, all optional.
shutdown: async function() {}
restart: async function() {}
},
// return a string that is unique to the hardware
// could be SoC model + serial number
deviceSecret: string
appVersion: string
}
Each device has:
- a
deviceSecretprovided by the hardware - a
deviceIDafter registration - a
loginIDafter logging in (like a session ID)
API Doc: https://doc.esdoc.org/github.com/SkygearIO/iot-SDK-JS/
There are 2 Skygera IoT specific roles:
-
iot-devicecan call device-specific lambdas. -
iot-managercan read/writeiot_*tables and send messages to devices using a lambda.
-
iot_device(ACL: public = no, iot-manager = rw)- _id (skygear user id)
- secret (string)
- class (string)
- active (bool, true unless the device has been de-registered)
-
iot_device_login(ACL: public = no, iot-manager = rw- deviceID (FK:
iot_device._id) - sdkVersion (string)
- appVersion (string)
- deviceID (FK:
-
iot_device_status(ACL: public = no, iot-manager = rw)- deviceID (FK:
iot_device._id) - loginID (FK:
iot_device_login._id) - status (online, offline)
- metadata (JSON)
- ip (string)
- deviceID (FK:
A device is online iff the latest iot_device_status record is created within X minutes of the current time AND the status field is online.
-
iot-request-statusa channel for the server to globally request status reports from all devices subscribing to it. -
iot-<SHA256(deviceSecret)>a secure channel for the server to send messages to a device, payload must be an object with atleast 1 key: "action". Some pre-defined actions are:iot-shutdowniot-restart
{
action: "",
...
}
-
iot:add-device-role()adds the roleiot-deviceto the request user -
iot:report-status({deviceID: "", loginID: "", status: "online"})used by devices to report its current status -
iot:device-publish([deviceID, data])(requires either master key ORiot-managerrole) publish messages to device's secure channels -
iot:log(message)logs message to the skygear portal
- Add pubsub subscribe once helper function