This page contains detailed information about the CoAP service in the Tartabit IoT Bridge. This service allows you to send and receive CoAP requests for easy integration with other systems and services.
POST
, GET
, PUT
, DELETE
, FETCH
, PATCH
, IFETCH
The CoAP Connector is used by both the CoAP client actions and server events. For servers, the service contains the webhook secret used to authenticate and route the incoming CoAP request. For clients, the service is used an an anchor for metering and additional functionality will be added in the future.
POST
request is JSON, the endpoint key field will be extracted and used to automatically define and associate with an endpoint using the key. This is not required, but allows use of the endpoint functionality to track devices.This event fires when a CoAP message is received by the server.
{
"method": "put",
"path": "wh/mysecret/myendpoint",
"pathSegments": [ "wh", "mysecret", "myendpoint",
"query": {
"key": "value"
},
"body":{
"key1":"abc",
"key2":456
}
}
This event can be replied to to return data back to the client, for example:
// returns Content (69 in coap, equivelant of 200 in HTTP, and body data),
trigger.reply({status:69, body:'myreturndata'})
If you do not reply to a request, the server will respond with an Internal Server Error to the client.
The reply object has the following data:
octets
, json
, or text
Send a CoAP packet and wait for a reply from the device, the type will default to confirmable unless overriden in the options.
// Issue a get to a device
var reply = coap.send('coap-svc', 'get', '10.220.31.12:5683', '/read')
// Issue a post to a device
var reply = coap.send('coap-svc', 'post', '10.220.31.12:5683', '/write', 'AT+RPT=300')
get
, post
, put
, or delete
.con
, noncon
, ack
, or reset
to set the type of the CoAP packet.octets
, json
, text
to set the contentFormat for the packet.register
or deregister
to set the observe flag in the request.The following events are considered billable:
While you can modify the webhook secret, keep in mind that it is a secret, and choosing a secret that is not cryptographically secure can result in unauthorized use of your account.