The Device API may be used by devices to perform all the tasks related to its lifecycle, or those that have to do only with the device itself, like sending an event. All other services related to management of devices, rules or apps, are in the management API.
The purpose of this API is to provide all the services needed to implement a working device able to communicate with Lhings.
It is composed of five web services:
- Device.register, to perform the registration of the device in Lhings.
- Device.setDescriptor, used to send the device descriptor to Lhings.
- Device.startSession, used to tell Lhings the device is online.
- Device.endSession, used to tell Lhings the device is offline.
- Device.sendEvent, used by the device to send an event to Lhings.
Connecting a device to Lhings using the API will be done in the following steps:
- Call Device.register. Store the UUID returned by Lhings, you will need to provide it in any other call to Lhings.
- Call Device.setDescriptor with the descriptor of your device as the body of the request.
- Call Device.startSession to start communicating with Lhings.
- When communication is no longer needed, call Device.endSession to notify Lhings about it.
In the meantime, your device may call Device.sendEvent to notify Lhings about the ocurrence of some events.