The IoTGtw CoAP Service uses the standard CoAP (IETF core-coap-18 specification) for conveying payload between the IoT device and the platforms (SAP) in a simple but efficient way.
The service allows CoAP messaging in three ways:
1. Blob over CoAP – Fully transparent CoAP service for Private SAP. The service mainly consists of correlating and performing acknowledgement to/from the device using native CoAP capabilities.
2. SimplyTiny over CoAP (1) – Payload of CoAP packet is transparent (not touched). However SimplyTiny attributes are required to be added to the CoAP URI (for identifying the device etc).
3. SimplyTiny over CoAP (2) – CoAP payload is a SimplyTiny formatted structure (SimplyTiny Message). The SimplyTiny attributes are extracted from the SimplyTiny message. The device payload is also extracted from the SimplyTiny message.
The above CoAP services can support message acknowledgements.
The SimplyTiny over CoAP supports device bootstrapping service, device auth token auto update and be used to convey meta-data information such as GPS coordinates, power usage statistics, relative signal strength information and device timestamp.
To send a message from IoT device:
- Generate a CoAP message using for example libcoap
- Set the CoAP message destination host to your preferred IoTGtw SAP
- Set the path to /bcv1?udid=xxx&type=x&lat=xxx&long=xxx&ss=xxx&pw=1111111&tmst=xxx (highlighted fields are mandatory)
- Set the udid in the path to the udid configured on the platform.
- Set the Con/Non-Con/Ack which represent respectively: “Acknowledgement required”, “No acknowledgement required” and “This is an ack message”.
- Set the coap token to the token id configured for your device on the platform
- Transmit the message to the platform
Note the optional parameters in the url string may be used to convey meta-data information such as GPS coordinates, power usage statistics, relative signal strength information and device timestamp. The type parameter is derived from the SimplyTiny message-type-indicate and may set to the value: 8 to request the platform to return the current list of SAP as permitted by the device service template.
To perform a bootstrap request:
- Ensure the device service template > Device Bootstrap service is set to 1 or 2 (See IoT Device Bootstrapping section)
- Generate a CoAP message using for example libcoap
- Set target host to your preferred IoTGtw SAP
- Set the path to /bcv1?cid=xxx&type=xxx whereby cid = customer_id string and type = 9 (both parameters are mandatory)
- Set the coap token to the bootstrap token id configured for your device on the platform (bootstrap token is also mandatory)
- Transmit the message to the platform
The platform response are in similar fashion.
A message to IoT device from the platform:
- The coap packet token field is set to the device token
- If the message is a response/ack the message id received in the request is sent in the response in the coap packet message id field
- In the case of a downlink message to device, the payload is inserted in the coap packet payload section
- In the case of a bootstrap response, Token field is set to bootstrap token, udid and auth token are returned as url parameters, The SAP list (JSON array) is inserted in the payload section if applicable.
For more info refer to the IoT Device Bootstrapping Service Section