Certain models can be updated using an file archive with a .pk extension. A .pk file is a firmware update package that can be transferred to the device, and once the transfer is complete, the device will go into DFU mode and apply the files.
To send the file to the device, you use the following functions from the SDK:
-(RETURN_CODE) sendPKUpdate:(NSData*)pkFile;
-(RETURN_CODE) device_sendPKUpdate:(NSData*)pkData;
[[IDT_Device sharedController] sendPKUpdate:fileData];
[[IDT_Device sharedController] device_sendPKUpdate:fileData];
IDT_Device.sharedController().sendPKUpdate(fileData)
IDT_Device.sharedController().device_sendPKUpdate(fileData)
To monitor firmware update progress and final outcome, use the updateStatus delegate:
-(void) updateStatus:(PK_STATUS_Type)type currentBlock:(int)currentBlock totalBlocks:(int)totalBlocks error:(RETURN_CODE)error;
-(void) updateStatus:(PK_STATUS_Type)type currentBlock:(int)currentBlock totalBlocks:(int)totalBlocks error:(RETURN_CODE)error{
switch (type) {
case PK_STATUS_COMPLETED:
[self appendMessageToResults:@"PK Update Process Complete"];
break;
case PK_STATUS_FAILED:
[self displayUpRet2: @"PK Update Process Failed: " returnValue: error];
break;
case PK_STATUS_STARTED:
[self appendMessageToResults:@"PK Update Process Started"];
break;
case PK_STATUS_APPLYING_UPDATE:
[self appendMessageToResults:@"PK Update Process Applying Update. Please wait..."];
break;
case PK_STATUS_SENDING_BLOCK:
[self appendMessageToResults:[NSString stringWithFormat:@"Sending block %d of %d", currentBlock, totalBlocks]];
break;
default:
break;
}
}
func updateStatus(_ type: PK_STATUS_Type, currentBlock: Int32, totalBlocks: Int32, error: RETURN_CODE) {
switch type {
case PK_STATUS_COMPLETED:
connection.appendMessageToDataField("PK Update Process Completed", field: resultsTextView)
connection.pkUpdate = false
return
case PK_STATUS_FAILED:
connection.appendMessageToDataField("PK Update Process Failed", field: resultsTextView)
return
case PK_STATUS_STARTED:
connection.appendMessageToDataField("PK Update Process Started", field: resultsTextView)
return
case PK_STATUS_APPLYING_UPDATE:
connection.appendMessageToDataField("PK Update Process Applying Update. Please wait...", field: resultsTextView)
return
case PK_STATUS_SENDING_BLOCK:
connection.appendMessageToDataField(String(format: "Sending block %d of %d", currentBlock, totalBlocks), field: resultsTextView)
return
default:
return
}
}