This method is used to send an acknowledgment about the completion of firmware processing to IoTConnect.
Method Parameters
d2cMsg– Json Object (see example below)
{ "AcknowledgeId" : , #you will received at callback() method "Status" : 7, #its status 6= for commands and 7 for firmware(OTA) "Msg" : "", #Msg(optional) its used for send your custom message "childId" : "" # childId(optional) its used when you have gateway template }
current_time – Datetime, exmaple, ‘2018-05-24T10:06:17.857Z’,
mt – Message Type , 11 for firmware update and 5 for command ack.
Javascript
iotConnectSDK.sendAck(d2cMsg, time, mt, function (response) { console.log("Command acknowledgement :: ",response); })
Java SDK
ioTConnectSDK.sendAck(String data, Integer messageType) data = "[{'data': {'ackId': '','st': ,'childId': ''},'uniqueId':''}]"
DOT NET (C#)
var commandData = JsonConvert.DeserializeObject(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(" ",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 d2cMsg = JsonConvert.SerializeObject(ackDetails); //SendAck(json, time, mt); client.SendAck(d2cMsg, current_time, isOta ? 11 : 5);
Python
SendACK(d2cMsg,current_time,mt)
C SDK
// Sending ACk of command with Json(String), msg Type(int) and Current Time(String) SendAck(Ack_Json_Data, Get_Time(), mt);