Device to Cloud (D2C) messages

Device to Cloud (D2C) messages

This article merely provides the message data structures for the D2C communication with IoTConnect Device SDK or Bring your own Custom SDK.

Device Telemetry Data

The following JSON format is used to send data from your SDK client to IoTConnect. While sending telemetry data, your device can send a few or all sensor (Template attribute) values. It is not required always to send all sensor ( Template attributes) values. This is a normal message that a device should send to report their sensor value MQTT Library Approach – You need to send a message on rpttopic found in protocol information under the topics object.

Reporting Message

  • This is a normal message that a device should send to report its sensor value.
  • MQTT Library Approach – You need to send a message on rpttopic found in protocol information under topics object.
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
            "d": {
                "str_attr": "attVal",
                "int_attr": 1,
                "obj_attr": {
                    "int_attr": -240
                }
            }
        }
    ]
}
** "dt" is optional

NOTE:

  • Outer “dt”: It will be useful to identify that, at what time device has published the data, generally can be seen in live telemetry section
  • Inner “dt”: It will be displayed as historical data points and can be seen in historical data page
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "id": "Parent/child device unique id",
            "tg": "Tag of respective parent/child device",
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
            "d": {
                "str_attr": "attVal",
                "int_attr": 1,
                "obj_attr": {
                    "int_attr": -240
                }
            }
        }
    ]
}
** "dt" is optional

Fault

  • The device can send a fault message if something is invalid coming from the sensor or the value is
    not falling into the data validation applied to that device. The JSON format will be the same as reporting.

Edge Reporting

  • This message is sent by Edge Device; it can be a Normal Edge device or Gateway Edge device.
  • MQTT Library Approach – You need to send a message on erpttopic found in protocol information under topics object.
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
            "d": {
                "attrName1": [MIN, SUM, AVERAGE, COUNT, LATEST_VALUE],
                "attrName2": {
                    "childAttr1": [MIN, SUM, AVERAGE, COUNT, LATEST_VALUE]
                }
            }
        }
    ]
}
** "dt" is optional

NOTE:

  • Outer “dt”: It will be useful to identify that, at what time device has published the data, generally can be seen in live telemetry section
  • Inner “dt”: It will be displayed as historical data points and can be seen in historical data page
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "id": "Parent/child device unique id **",
            "tg": "Tag of respective parent/child device **",
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
            "d": {
                "attrName1": [MIN, SUM, AVERAGE, COUNT, LATEST_VALUE],
                "attrName2": {
                    "childAttr1": [MIN, SUM, AVERAGE, COUNT, LATEST_VALUE]
                }
            }
        }
    ]
}
** "dt" is optional

Edge Rule Match

  • Edge Device should send this message when any rule is evaluated as true on telemetry data. JSON
    the format will have all information of the rule and telemetry data
  • MQTT Library Approach – You need to send a message on ermtopic found in protocol information under topics object.
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "rg": "Rule GUID from rule response",
            "ct": "Rule condition from rule response",
            "cv": {"CONDITION_VALUE_TELEMETRY_DATA"},
            "sg": "event subscription GUID from rule response",
            "d": [
                    {
                        TELEMETRY_DATA
                    }
                ],
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
        }
    ]
}
** "dt" is optional
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": [
        {
            "id": "Child/Parent device uniqueid",
            "tg": "Child/Parent device tag",
            "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
            "rg": "Rule GUID from rule response",
            "ct": "Rule condition from rule response",
            "cv": {
                "CONDITION_VALUE_TELEMETRY_DATA"
            },
            "sg": "event subscription GUID from rule response",
            "d": [
                {
TELEMETRY_DATA
                }
            ],
        }
    ]
}
** "dt" is optional

Heartbeat Message

  • Need to send a blank message.
  • MQTT Library Approach – You need to send a message on hbtopic found in protocol information under topics object.
{}
{}

OTA Acknowledgement

The following JSON should be sent by the device to the cloud to acknowledge OTA Command MQTT Library Approach – You need to send a message on ack topic found in protocol information under the topics object.

{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "ack": "Acknowledgement GUID",
        "type": 1,
        "st": 0,
        "msg": "Your custom message for acknowledgment"
    }
}
** "dt" is optional
** "msg" is optional
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "ack": "Acknowledgement GUID",
        "type": 1,
        "st": 0,
        "msg": "Your custom message for acknowledgment",
        "cid": "child device id otherwise null"
    }
}
** "dt" is optional
** "msg" is optional
** "type": must be 1

Click here for more details on values of st tag

Device Command Acknowledgement

The following JSON should be sent by the device to the cloud to acknowledge Device Command, MQTT Library Approach – You need to send a message on acktopic found in protocol information under the topics object.

{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "ack": "Acknowledgement GUID",
        "type": 0,
        "st": 0,
        "msg": "Your custom message for acknowledgment"
    }
}
** "dt" is optional
** "msg" is optional
** "type": must be 0
{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "ack": "Acknowledgement GUID",
        "type": 0,
        "st": 0,
        "msg": "Your custom message for acknowledgment",
        "cid": "child device id otherwise null"
    }
}
** "dt" is optional
** "msg" is optional
** "type": must be 0

Click here for more details on values of st tag

Module Command Acknowledgement

The following JSON should be sent by the device to the cloud to acknowledge Module Command, MQTT Library Approach – You need to send a message on acktopic found in protocol information under the topics object.

{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "type": 2,
        "st": 0,
        "msg": "Your custom message for acknowledgment",
    }
}
** "dt" is optional
** "msg" is optional
** "type": must be 2

{
    "dt": "YYYY-MM-DDTHH:MM:SS.SSSZ",
    "d": {
        "type": 2,
        "st": 0,
        "msg": "Your custom message for acknowledgment",
    }
}
** "dt" is optional
** "msg" is optional
** "type": must be 2

Shadow Update Property

For MQTT there is support for shadow Property management as well. TO update the desired value you will get the below JSON.

{
    "frm_version": 1.5
}
{
    "frm_version": 1.5
}