Skip to content

How to update scanner firmware

MarkFirmwareUpdate API enables you to track the FirmwareUpdate state. Currently, the firmware image is bundled into the SDK (SDK v1.1.0 and firmware v2.2.0), and based on the loaded configuration settings SDK will perform the update.

To track the FirmwareUpdate state, implement the PGFirmwareUpdateManagerDelegate delegate and set the PGFirmwareUpdateManager delegate property.

@interface ViewController ()<PGCentralManagerDelegate, PGFirmwareUpdateManagerDelegate>

@property id<PGFirmwareUpdateManager> firmwareUpdateManager;
@property PGCentralManager *central;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.central = [[PGCentralManager alloc] initWithDelegate:self enableRestoration:YES];
    self.firmwareUpdateManager = self.central.firmwareUpdateManager;
    self.firmwareUpdateManager.delegate = self;
}

@end
class ViewController: UIViewController, PGCentralManagerDelegate, PGFirmwareUpdateManagerDelegate {
  let firmwareUpdateManager: FirmwareUpdateManager?

  override func viewDidLoad() {
    central = PGCentralManager(delegate: self, enableRestoration: true)

    firmwareUpdateManager = central.firmwareUpdateManager
    firmwareUpdateManager?.delegate = self
  }
}

Once the update is triggered you will be informed via the didStartFirmwareUpdate delegate method:

- (void)didStartFirmwareUpdate {
    //Firmware update started.
}
func didStartFirmwareUpdate() {
  //Firmware update started.
}

The firmware update progress can be tracked via the didChangeFirmwareUpdateProgress delegate method:

- (void)didChangeFirmwareUpdateProgress:(NSInteger)percentage {
  //Current progress presented in percentage
}
func didChangeFirmwareUpdateProgress(_ percentage: NSInteger) {
  //Current progress presented in percentage
}

Once the update has been completed, the didCompleteFirmwareUpdate delegate method will be triggered:

- (void)didCompleteFirmwareUpdate {
  //Fimware update completed
}
func didCompleteFirmwareUpdate() {
  //Fimware update completed
}

If a firmware update fails, the didFailToUpdateFirmwareWithError delegate method will be triggered and an error object returned:

- (void)didFailToUpdateFirmwareWithError:(NSError * _Nullable)error {
  //Firmware update failed.
}
func didFailToUpdateFirmwareWithError(_ error: Error?) {
  //Firmware update failed.
}