Overview
A firmware update needs a firmware file in “.dat” or “.SCNPLG” format.
The update runs through the barcode SDK: the sdkApi object created in Initialize Barcode SDK runs the update commands, and its delegate receives sbtEventFirmwareUpdate:.
The example starts the update with the command type that matches the file: SBT_UPDATE_FIRMWARE for a “.dat” file and SBT_UPDATE_FIRMWARE_FROM_PLUGIN for a plugin file.
Details
Start Firmware Update
- (IBAction)btnFirmwareUpdate:(id)sender
{
NSString *inputXML = [NSString stringWithFormat:@"<inArgs><scannerID>%d</scannerID><cmdArgs><arg-string>%@</arg-string></cmdArgs></inArgs>", readerID, @"FIRMWARE_FILE_PATH"];
int firmwareFileTypeCommand = 0;
// If the firmware file is a ".dat" file then the command type is SBT_UPDATE_FIRMWARE.
// If the firmware file is a plugin then the command type is SBT_UPDATE_FIRMWARE_FROM_PLUGIN.
firmwareFileTypeCommand = SBT_UPDATE_FIRMWARE;
SBT_RESULT result = [self executeCommand:firmwareFileTypeCommand aInXML:inputXML];
if (SBT_RESULT_SUCCESS == result) {
NSString *in_xml = [NSString stringWithFormat:@"<inArgs><scannerID>%d</scannerID></inArgs>", readerID];
[self performStartNewFirmware:in_xml];
}else{
NSLog(@"Firmware update failed");
}
}
Perform Start New Firmware
The performStartNewFirmware: method starts the new firmware with the given input XML.
/// Perform start new firmware
/// @param param The inXML value
- (void)performStartNewFirmware:(NSString*)param
{
SBT_RESULT result = [self executeCommand:SBT_START_NEW_FIRMWARE aInXML:param];
if (result != SBT_RESULT_SUCCESS)
{
NSLog(@"Firmware Update Failed.");
}else{
NSLog(@"Firmware Update Success.");
}
}
Firmware Update Event
The SDK calls sbtEventFirmwareUpdate: with the progress of the update.
// Firmware update event
/// @param fwUpdateEventObj SDK's firmware update event object
- (void)sbtEventFirmwareUpdate:(FirmwareUpdateEvent *)event{
NSLog(@"Current Record : %f",(float)event.currentRecord);
NSLog(@"Max Record : %f",(float)event.maxRecords);
int currentProgressInPercentage = (int)((float)event.currentRecord/event.maxRecords*100);
NSLog(@"Current Progress In Percentage %d",currentProgressInPercentage);
}
Execute Command
The executeCommand:aInXML: method runs an SDK command with the given input XML.
/// Execute command inXML only
/// @param opCode Command code
/// @param inXML Input XML
/// @Return SBT Result
- (SBT_RESULT)executeCommand:(int)opCode aInXML:(NSString*)inXML{
if (sdkApi != nil){
SBT_RESULT resultExecuteCommand = [sdkApi sbtExecuteCommand:opCode aInXML:inXML aOutXML:NULL forScanner:readerID];
return resultExecuteCommand;
}
return SBT_RESULT_FAILURE;
}