private static Task DeviceCallback(string message) { /* Received command format for DeviceCommand from IOTConnect.Net SDK version < 2.0 */ //{"cpId":"<cpid>","guid":"00000000-0000-0000-0000-000000000000","uniqueId":"<deviceUniqueId>","command":"<Command> Command_Text","value":null,"ack":true,"ackId":"00000000-0000-0000-0000-000000000000"} /* Received command format for Firmware/OTA update from IOTConnect.Net SDK version < 2.0 */ //{"cpId":"<cpid>","guid":"00000000-0000-0000-0000-000000000000","uniqueId":"<deviceUniqueId>","command":"<Command> OTA_Update_Url","value":null,"ack":false,"ackId":"00000000-0000-0000-0000-000000000000"} /* Received command format for DeviceCommand from IOTConnect.Net SDK version 2.0 */ //{"cpId":"<cpid>","guid":"00000000-0000-0000-0000-000000000000","uniqueId":"<deviceUniqueId>","command":"<Command> Command_Text","value":null,"ack":true,"ackId":"00000000-0000-0000-0000-000000000000","cmdType": "0x01"} /* Received command format for Firmware/OTA update from IOTConnect.Net SDK version 2.0 */ //{"cpId":"<cpid>","guid":"00000000-0000-0000-0000-000000000000","uniqueId":"<deviceUniqueId>","command":"<Command>","value":null,"ack":false,"ackId":"00000000-0000-0000-0000-000000000000","cmdType": "0x02","urls": [{"url": "<URL1>"}, {"url": "<URL2>"}]} //"mt" = 5 - DeviceCommandAck, 11 - OtaAck/FirmwareUpgradeAck //"st" = 4 - Failed, 6 - ExecutedAck[DeviceCommandAck], 7 - Success[OtaAck/FirmwareUpgradeAck] try { var commandData = JsonConvert.DeserializeObject <CommandData>(message); DeviceAckModel ackDetails = new DeviceAckModel() { AckId = commandData.AcknowledgeId, ChildId = "" }; //IOTConnect.Net SDK version < 2.0 bool isOta = (commandData != null && !string.IsNullOrWhiteSpace(commandData.Command) && commandData.Command.StartsWith("<CommandPrefix> ", StringComparison.CurrentCultureIgnoreCase)); //IOTConnect.Net SDK version >= 2.0 isOta = commandData.CommandType.Equals("0x02", StringComparison.CurrentCultureIgnoreCase); if (isOta) { //TODO : download and save ota file from url [commandData.Command] ackDetails.Msg = "OTA updated successfully."; ackDetails.Status = 7; } else { ackDetails.Msg = "Device command received successfully."; ackDetails.Status = 6; } var dataOta = JsonConvert.SerializeObject(ackDetails); //NOTE: SendAck method have different arguments as per the SDK version. Choose accordingly. //IOTConnect.Net SDK version < 2.0 //client.SendAck(dataOta, isOta ? 11 : 5); //IOTConnect.Net SDK version >= 2.0 client.SendAck(dataOta, "2020-02-14T12:19:33.7769262Z", isOta ? 11 : 5); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(Task.CompletedTask); }