IoTConnect SDK

IoTConnect SDK

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": "
		}]
	}
	
	{
		"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

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": "<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": "<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 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 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 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 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" : "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
			}
		]
	}
	
	{
		"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