• Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us
  • Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us

Client Libraries & SDKs

home/Documentation/Client Libraries & SDKs
  • Device SDK Reference
    • Overview
    • Device Authentication Options
    • Data Flow
    • Public Methods
      • Device Connection
      • Send Telemetry
      • Get Attributes
      • Send acknowledgment
      • Update Twin
    • SDKs (Message version 1.0)
      • DOT NET (C#)
      • Node.js
      • Java
      • Python
      • iOS
      • Android
      • Embedded
      • C language
      • Build Your Own SDK
      • Node-RED
        • IoTConnect Node-red 1.0.9
        • IoTConnect Node-red 1.0.8
      • Node-RED Subflow
        • Single Device
        • Multiple Device
    • SDKs (Message version 2.1)
      • Python
      • DOT NET (C#)
      • C language
        • IoTConnect Generic C SDK
          • Linux Build Instructions
          • Windows Build Instructions
      • Python 1.1
    • Code Samples
      • Node.js
        • TPM 3.1
        • Standard SDK 3.0
        • Standard
        • TPM
        • Standard SDK 3.0.1
        • Standard 2.0
      • Java
        • Standard
        • Standard 2.0
        • Standard 3.0
      • Python
        • Standard 2.0
        • TPM 2.1
        • Standard 3.0.1
        • Standard
        • TPM
          • TPM 3.0.1
        • TPM 3.0
        • Standard 3.0.2
        • Standard 3.0.3
        • Standard 3.0.4
        • Python SDK
      • iOS
        • ios1.0.1
      • C Language
        • nRF9160 DK
        • STM32L4
        • ESP32
        • Standard 3.0
        • Standard 2.0
        • Standard 3.1
      • Android
        • Standard 3.0
        • Standard 2.0.6
        • Standard 2.0.0
      • DOT NET (C#)
        • Standard
        • Standard 2.0
        • Standard 3.0
    • Device Message 1.0
      • D2C (Device to Cloud)
        • IoTConnect SDK
        • Custom SDK
      • C2D (Cloud to Device)
        • IoTConnect SDK
        • Custom SDK
      • Troubleshooting & Response codes
      • Know Your Essentials
    • Device Message 2.1
    • AWS Device Message 2.1
    • SDK Deep-diving
Download PDF

Custom SDK

In this article
  • Device Telemetry
  • OTA Acknowledgement
  • Device Acknowledgement Command
  • Gateway Device Telemetry
  • Edge Device Telemetry
  • Edge Device Rule Match Telemetry
  • Twin Update Property
  • Offline Telemetry

Device Telemetry Data

JSON payload for users who use Bring your own SDK method to send Device telemetry.

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.

{
	"cpId": "<COMPANY CPID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 0, // Message type 0 : Reporting Data, 1 : Faulty data
	"dtg": "<DEVICE TEMPLATE GUID>",
	"sdk": {
		"l": "M_<LANGUAGE CODE>", //NodeJS (M_Node),  
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": [{
		"id": "<Device Unique ID>",
		"d": [{
			"temperature": 10,
			"humidity": 10,
			"Gyroscope": {
				"x": 1,
				"y": 1,
				"z": 1
			}
		}],
		"dt": "2020-01-24T10:06:17.857Z", //Date format should be "YYYY-HH-MMTHH:RR:SS.mmmz"
		"tg": ""
	}]
}

uniqueId: It is the device uniqueID
cpId: Company code CPID. Get it from portal “Settings -> Key Vault” page.
dtg: Device Template GUID
sdk.l: SDK language code. Use below language code for respective sdk flavour

  • C# : “M_C#”
  • Java : “M_JAVA”
  • Nodejs(Javascript) : “M_Node”
  • Python : “M_Python”
  • C++ : “M_C”
  • IoS : “M_ios”
  • Android : “M_android”

sdk.e: This is the Environment of your solution
id: It is the device uniqueID

OTA Acknowledgement Command D2C

JSON payload for users who use Bring your own SDK method to send Device acknowledgment commands D2C.

{
	"uniqueId": "<DEVICE UNIQUE ID>",
	"cpId": "<COMPANY CPID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 11, // Fixed
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": {
		"ackId": "<ACK GUID>",
		"st": "<7/4>",
		"msg": "OTA updated successfully.",
		"childId": null
	}
}

uniqueId : It is the device uniqueID
cpid : Get it from portal “Settings -> Key Vault” page.
sdk.l: SDK language code. You can refer from above sample.
sdk.e: This is the Environment of your solution
ackId: You will receive the Acknowledgement ID from callbackMessage() method while receiving the command.
st: 7 – success, 4 – failed.
msg: Msg (optional). It is used for sending your custom message.
childId: ChildId (optional). It is used when you have a gateway template.

D2C Device Acknowledgement Command

JSON payload for users who use Bring your own SDK method to send Device acknowledgment commands D2C.

{
	"uniqueId": "<DEVICE UNIQUE ID>",
	"cpId": "<COMPANY CPID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 5, // Fixed
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": {
		"ackId": "<ACK GUID>",
		"st": "<6/4>",
		"msg": "Device command received successfully.",
		"childId": null
	}
}

uniqueId : It is the device uniqueID
cpid : Get it from portal “Settings -> Key Vault” page.
sdk.l: SDK language code. You can refer from above sample.
sdk.e: This is the Environment of your solution
ackId: You will receive the Acknowledgement ID from callbackMessage() method while receiving the command.
st: 6 – success, 4 – failed.
msg: Msg (optional). It is used for sending your custom message.
childId: ChildId (optional). It is used when you have a gateway template.

Gateway Device Telemetry D2C

JSON payload for users who use Bring your own SDK method to send telemetry.

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.

{
	"cpId": "<COMPANY CPID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 0,  // 0 - Reporting Data, 1 - Faulty Data
	"dtg": "<DEVICE TEMPLATE GUID>",
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": [{
		"id": "<GATEWAY DEVICE UNIQUE ID>", // Gateway/Parent device Id
		"d": [{
			"Temperature": 1,
			"Humidity": 1
		}],
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": "gws"
	},
	{
		"id": "CHILD DEVICE'S UNIQUE ID", // Child ID associated with Gateway uniqueID
		"d": [{
			"Temperature": 1,
			"Gyroscope": {
				"x": "1",
				"y": "1",
				"z": "1"
			}
		}],
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": "light"
	},
	{
		"id": "CHILD DEVICE'S UNIQUE ID", // Child ID associated with Gateway uniqueID
		"d": [{
			"Temperature": 1,
			"Humidity": 1
		}],
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": "ac"
	}]
}

cpId: Company code CPID. Get it from portal “Settings -> Key Vault” page.
dtg: Device Template GUID
sdk.l: SDK language code. You can refer in above example on same page.
sdk.e: This is the Environment of your solution
id: It is the device uniqueID respective of Gateway/Parent and Child.

Edge Device Telemetry Data

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.

With number datatype attribute

NOTE : Need to calculate all aggregates and prepare as below

{
	"cpId": "<COMPANY CPID>",
	"dtg": "<DEVICE TEMPLATE GUID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 2,  // Message Type 2 - Edge Reporting Data
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": [{
		"id": "<EDGE DEVICE UNIQUE ID>", // It is Edge Device unique ID 
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": "ac1", // Mandatory for gateway device to set tag value else leave it blank("")
		"d": [{
			"Temperature": [
				10, //Min
				20, //Max
				30, //Sum
				15, //Average
				2,  //Count
				20  //LatestValue
			]
		}]
	}]
}

cpId: Company code CPID. Get it from portal “Settings -> Key Vault” page.
dtg: Device Template GUID
sdk.l: SDK language code. You can refer in above example on same page.
sdk.e: This is the Environment of your solution
id: It is the Edge device’s uniqueID

With Object datatype attribute

NOTE : Need to calculate all aggregates and prepare as below

{
	"cpId": "<COMPANY CPID>",
	"dtg": "<DEVICE TEMPLATE GUID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 2, // Message Type 2 - Edge Reporting Data
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": [{
		"id": "<EDGE DEVICE UNIQUE ID>", // It is Edge Device unique ID 
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": "ac1", // Mandatory for gateway device to set tag value else leave it blank("")
		"d": [{
			"Gyroscope": {
				"x": [
					55,  //Min
					55,  //Max
					110, //Sum
					55,  //Average
					2,   //Count
					55   //LatestValue
				],
				"y": [
					55,  //Min
					55,  //Max
					110, //Sum
					55,  //Average
					2,   //Count
					55   //LatestValue
				],
				"z": [
					55,  //Min
					55,  //Max
					110, //Sum
					55,  //Average
					2,   //Count
					55   //LatestValue
				]
			}
		}]
	}]
}

cpId: Company code CPID. Get it from portal “Settings -> Key Vault” page.
dtg: Device Template GUID
sdk.l: SDK language code. You can refer in above example on same page.
sdk.e: This is the Environment of your solution
id: It is the Edge device’s uniqueID

Edge Device Rules Match Telemetry

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.

{
	"cpId": "<COMPANY CPID>",
	"t": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
	"mt": 3, // Message Type 3 - Rule Matched Data
	"dtg": "<DEVICE TEMPLATE GUID>",
	"sdk": {
		"l": "M_<LANGUAGE CODE>",
		"v": "2.0",
		"e": "<ENV>"
	},
	"d": [{
		"rg": "2469D5E4-8E67-498B-AB12-33A119124265",
		"ct": "Gyroscope.x > -1",
		"cv": {
			"Gyroscope": {
				"x": 1
			}
		},
		"sg": "CB0D74B1-37F5-438C-83B1-5AA71B5ED117",
		"d": [{
			"temp": "11",
			"humidity": "80",
			"Temperature": "66",
			"aaa": "red",
			"gyro": {
				"x": "1",
				"y": "-5",
				"z": "8"
			}
		}],
		"id": "<EDGE DEVICE UNIQUE ID>", // It is Edge Device unique ID 
		"dt": "2020-01-24T10:06:17.857Z", //Date format <YYYY-HH-MMTHH:RR:SS.mmmz>
		"tg": ""
	}]
}

cpId: Company code CPID. Get it from portal “Settings -> Key Vault” page.
dtg: Device Template GUID
sdk.l: SDK language code. You can refer in above example on same page.
sdk.e: This is the Environment of your solution
id: It is the Edge device’s uniqueID
rg: It is Rule GUID
ct: Rule Condition Text
cv: Evaluated Condition value
sg: Subscription GUID

Twin update property

{
	"Key" : "value" // e.g { "frm_version": 1.5 }
}

key: Twin desired property key
value: value associated with the desired property key.

Offline Telemetry

In case of loss of internet connectivity and if device have capability to store telemetry on device either in memory or in IO to send it later when connectivity is available. When connectivity restored device can send data to cloud with an addition property to telemetry to mark this as offline telemetry

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.

{
    "cpId": "",
    "t": "", //Date format 
    "mt": 0, //Can be 0, 1, 2, 3
    "od": 1,
    "dtg": "",
    "sdk": {
        "l": "M_", //NodeJS (M_Node),
        "v": "2.0",
        "e": ""
    },
    "d": [{
           //TELEMETRY
        }
    ]
}

od: This is an additional property to identify its offline telemetry

Powered by Softweb – An Avnet Company.

Copyright ©2022 Avnet, Inc. All rights reserved.

Human Rights Privacy Terms of Use