• 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 Command
  • OTA Command
  • Module Command
  • Template Attributes Change
  • Template Settings Change
  • Rule Change Command
  • Device Change Command
  • Password Change Command
  • Hard Stop Command
  • Device Twin Message

Device Command C2D

JSON payload for users who use Bring your own SDK method to received Device Commands.

{
	"cmdType": "0x01",
	"data": {
		"cpid": ""<cpid>"",
		"guid": "<guid>", //Device Guid
		"uniqueId": "<cpid-uniqueid>",
		"command": "OnOff ::Manual Command::",
		"ack": false,
		"ackId": "<guid>",
		"cmdType": "0x01"
	}
}

cpid: It indicates the CPID of the device’s company
ack: Acknowledgement status
command: Command Text
uniqueId: It is the device uniqueID
cmdType: Command type constant code 0x01 – Device command, 0x02 – OTA COmmand
ackId: Acknowledgement ID/GUID
guid: Command GUID

Retry Policy: If the device offline/disconnected from the IotConnect then the Device will not receive the device command, Platform will not resent when its online.

OTA Command C2D

JSON for the OTA command Cloud to Device payload

Device and Edge Device
{
	"cmdType": "0x02",
	"data": {
		"cpid": "<cpid get it from portal>",
		"guid": "<device_guid>",
		"uniqueId": "<uniqueId>",
		"command": "ota",
		"ack": false,
		"ackId": "<acknowledgement_guid>",
		"cmdType": "0x02",
		"ver": {
			"sw": "<Software Version>",
			"hw": "<Hardware Version>",
		},
		"urls": [{
			"url": "<url1>>",
			"tag": ""
		},
		{
			"url": "<url2>>",
			"tag": ""
		}]
	}
}
Gateway and Edge Gateway Device
{
	"cmdType": "0x02",
	"data": {
		"cpid": "<cpid get it from portal>",
		"guid": "<device_guid>",
		"uniqueId": "<uniqueId>",
		"command": "ota",
		"ack": false,
		"ackId": "<acknowledgement_guid>",
		"cmdType": "0x02",
		"ver": {
			"sw": "<Software Version>",
			"hw": "<Hardware Version>",
		},
		"urls": [{​​​​​​​
			"url": "<url1>",
			"tag": "<child device1 tag>"
		}​​​​​​​,
		{​​​​​​​
			"url": "<url2>",
			"tag": "<child device1 tag>"
		}​​​​​​​,
		{​​​​​​​
			"url": "<url1>",
			"tag": "<child device2 tag>"
		}​​​​​​​,
		{​​​​​​​
			"url": "<url1>",
			"tag": "<Gateway device tag>"
		}​​​​​​​]
	}
}

urls: OTA Firmware bundle file URLs to update the firmware
ver: Firmware version
tag: It is the associated tag with the device and template (Blank for normal Device)
– sw: Software version of the Firmware
– hw: Hardware version of the Firmware

If you are using less than 2.0 version then follow the below JSON for the payload.

{
	"cmdType": "0x02",
	"data": {
		"cpid": "",
		"guid": "",
		"uniqueId": "",
		"command": "ota ,",
		"ack": false,
		"ackId": "",
		"cmdType": "0x02",
		"ver": {
				"sw": "1.0.0",
				"hw": "1.0.0"
			},
		"urls": ["",""]
	}
}

Retry Policy: If device offline/disconnected from the IotConnect then Device will not receive OTA command, But when its online again or connected with IotConnect Platform will resent all OTA command to Device.

Module Command

JSON payload for users who use Bring your own SDK method to received Module Commands.

{
	"cmdType": "0x03",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>",
		"uniqueId": "<device id>",
		"command": "module",
		"ack": false,
		"ackId": "5334453f-cd4d-49ac-a755-4ecf368d2732",
		"cmdType": "0x03",
		"urls": [
			{
				"url": ""
			}
		]
	}
}

Template Attribute Change

JSON payload for users who are not using our SDK or bring your own SDK users to received Template Attribute Change commands.

{
	"cmdType": "0x10",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

Template Settings Change

JSON payload for users who are not using our SDK or bring your own SDK users to received Template Settings Change commands.

{
	"cmdType": "0x11",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

Rule Change Command

JSON payload for users who are not using our SDK or bring your own SDK users for Rule Change commands.

{
	"cmdType": "0x15",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

Device Change Command

JSON payload for users who are not using our SDK or bring your own SDK users for Rule Change commands.

{
	"cmdType": "0x13",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

Password Change Command

JSON payload for users who are not using our SDK or bring your own SDK users for Rule Change commands.

{
	"cmdType": "0x12",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

Hard Stop Command

JSON payload for users who are not using our SDK or bring your own SDK users for Rule Change commands.

{
	"cmdType": "0x99",
	"data": {
		"cpid": "<cpid>",
		"guid": "<guide>", //Device Guid
		"uniqueId": "<device id>",
		"command": null,
		"ack": false,
		"ackId": null
	}
}

NOTE : Attribute, Setting, Rule, Device, Password change, Hard Stop commands will be handled internally in IoTConnect SDK. So it will be available for non IoTConnect SDK only. Also, it is not required acknowledgment.

Device Twin Message

To get all whole device twin you need to publish blank message on $iothub/twin/GET/?$rid=0 topic, IoTConnect (iothub) will send whole device twin on $iothub/twin/res/# topic, so you need to subscribe $iothub/twin/res/# topic.

You will receive Twin property in the below JSON format.

{
	"desired": {
		"frm_version": 1.5   
		"$version": 48
	},
	"reported": {
		"$version": 44	
	}
}

desired: Native property of the Twin message
– frm_version: It is the property and value added into the iotconnect portal from “Template -> Twin property”
reported: Native property of the Twin message
$version: Version will be auto increment done by IoTHub for both desired and reported properties.

On change of desired property for the device, a message from IoTConnect (IotHub) will be published and you can receive it on $iothub/twin/PATCH/properties/desired/# topic. So, you need to subscribe to this topic to receive desired property value.

You will receive Twin Desired property in the below JSON format.

{
	"frm_version": 1.6,
	"$version": 49
}

Powered by Softweb – An Avnet Company.

Copyright ©2022 Avnet, Inc. All rights reserved.

Human Rights Privacy Terms of Use