Connect HTTP

3.3 Connect Device

3.4 Publish Device data

Publish send telemetry/attributes data to cervello.

3.4.1 Publish using default schema

When a device credintials is created default schema topics is created to simplify the data transmistion

user can find device default topics in cervello following this steps:

From Device Manager -> Devices -> select device

alt text

On Device details page select Topics each topic is discriped briefly

alt text

3.4.2 Publish Telemetry

In order to send device telemetry user can use the default telemetry topic and schema to send device readings.

  • Topic: /device/ACCESS_KEY/telemetry
  • Message:
{
    "data": {
        "key": value
    },
    "ts": "unixtimestamp" #(optional)
}

curl

curl -X POST \
  'https://broker.cervello.io:7443?t=/device/{ACCESSKEY}/telemetry' \
  -H 'Authorization: Basic MWl1bXkwa3k3azNoeWo6bnBmNmVsa29reXF2dng=' \ #basic authentication usign ACCESSKEY, ACCESSTOKEN
  -H 'Content-Type: application/json' \
  -H 'x-client-id: {ACCESSKEY}' \
  -d '{
    "data": {
        "key": "value"
    },
    "ts": "unixtimestamp"
}'

Postman

Prepare Request publisher

Select method of type POST

Type the URL as Follows https://broker.cervello.io:7443?t=/device/{ACCESSKEY}/telemetry, - Where ‘{ACCESSKEY}` is the device Access key.

alt text

Authorization: - Select the Authorization tab - Select authorization type of Basic Auth - Type the device Access Key in the Username field and the device Access Token in the Password field - Click on Preview Request button to generate Authorization key in Headers Tap

alt text

Headers: - Select the Headers tab - Authorization Key should be generated due to clicking on Preview Request button in the previous step - Add x-client-id key and the device Access Key in the value field - Add Content-Type key and application/json in the value field

alt text

Body: - Select the Body tab - Select raw - Select JSON(application/json) - Provide boy as the following formate:

{
    "data": {
        "key": "value"
    },
    "ts": "unixtimestamp"
}
  • Click Send

alt text

Response should be recived as follows:

{
    "code": 2005,
    "messageKeys": "success",
    "message": "success"
}

once the message telemetry received and validated the data stored in device data set.

alt text

3.4.3 Publish Attribute

In order to send device attribute user can use the default attribute topic and schema to send device readings.

  • Topic: /device/ACCESS_KEY/attribute
  • Message:
{
    "data": {
        "key": value
    },
    "ts": "unixtimestamp" #(optional)
}

curl

curl -X POST \
  'https://broker.cervello.io:7443?t=/device/{ACCESSKEY}/attribute' \
  -H 'Authorization: Basic MWl1bXkwa3k3azNoeWo6bnBmNmVsa29reXF2dng=' \ #basic authentication usign ACCESSKEY, ACCESSTOKEN
  -H 'Content-Type: application/json' \
  -H 'x-client-id: {ACCESSKEY}' \
  -d '{
    "data": {
        "key": "value"
    },
    "ts": "unixtimestamp"
}'

Postman

Prepare Request publisher

Select method of type POST

Type the URL as Follows https://broker.cervello.io:7443?t=/device/{ACCESSKEY}/attribute, - Where ‘{ACCESSKEY}` is the device Access key.

alt text

Authorization: - Select the Authorization tab - Select authorization type of Basic Auth - Type the device Access Key in the Username field and the device Access Token in the Password field - Click on Preview Request button to generate Authorization key in Headers Tap

alt text

Headers: - Select the Headers tab - Authorization Key should be generated due to clicking on Preview Request button in the previous step - Add x-client-id key and the device Access Key in the value field - Add Content-Type key and application/json in the value field

alt text

Body: - Select the Body tab - Select raw - Select JSON(application/json) - Provide boy as the following formate:

{
    "data": {
        "key": "value"
    },
    "ts": "unixtimestamp"
}
  • Click Send

alt text

Response should be recived as follows:

{
    "code": 2005,
    "messageKeys": "success",
    "message": "success"
}

once the message telemetry received and validated the data stored in device data set.

alt text

Errors

code messageKey message
401 unauthenticated Unautenticated request
403 unautherized Unautherized action