Firmware Update Tutorial

RFID SDK for MAUI 2.0.4.192

Applicable Devices : TC53E, EM45

Overview

This Tutorial provides a walk-through of the steps to update firmware

Create the Project

  • Start by creating a new project in Visual Studio. For help, see the Create Project.
  • Refer Hello RFID to prepare basic setup to work with RFID Reader and then follow this guide

Details

SDK can update the TC53E firmware using the following API.


rfidReader.Config.UpdateFirmware(String path, String ip)

User needs to make sure that path is obtained using the Android Storage Access Framework. IP address of the interface from where reader reach your android device hosting the firmware files.

NOTE : To receive the firmware update events set setFirmwareUpdateEvent as true.

reader.Events.SetFirmwareUpdateEvent(true);

Performing Operation

Selecting the firmware file


public async void SelectUpdateFirmware() {
    FileResult fileResult = await PickFirmwareFile();

    if (fileResult != null)
    {
        byte[] buffer = new byte[4096];
        var fileName = fileResult.FileName;
        var stream = await fileResult.OpenReadAsync();
        var cacheFilePath = Path.Combine(FileSystem.AppDataDirectory, "ZebraFirmware/", fileName);
    
        if (File.Exists(cacheFilePath))
        {
            File.Delete(cacheFilePath);
        }
        string directoryName = Path.GetDirectoryName(cacheFilePath);
    
        if (directoryName.Length > 0)
        {
            Directory.CreateDirectory(directoryName);
        }
        using (FileStream streamWriter = File.Create(cacheFilePath))
        {
            StreamUtils.Copy(stream, streamWriter, buffer);
            if (File.Exists(cacheFilePath))
            {
                directoryName = Path.GetDirectoryName(cacheFilePath);
                MySelectedFile = cacheFilePath;
                FirmwareButton = "Update Firmware";
            }
        }
    }
}
async Task PickFirmwareFile()
    {
        try
        {
            var result = await FilePicker.PickAsync(new PickOptions
            {
                PickerTitle = "Select firmware file"
            });
            return result;
        }
        catch (Exception ex)
        {
    
        }
        return null;
    }
                                                    
                                                    

Calling Firmware Update API


rfidReader.Config.UpdateFirmware(selectedFile, "127.0.0.1");

Getting firmware update status under event status notification


public class ReaderModel : Readers.IRFIDReaderEventHandler, IRfidEventsListener
{ 
    public void EventStatusNotify(RfidStatusEvents rfidStatusEvents)
    {
        if (rfidStatusEvents.StatusEventData.StatusEventType == STATUS_EVENT_TYPE.FirmwareUpdateEvent)
        {
            String status = rfidStatusEvents.StatusEventData.FWEventData.Status;
            int imageDownloadProgress = rfidStatusEvents.StatusEventData.FWEventData.ImageDownloadProgress;
            int overallUpdateProgress = rfidStatusEvents.StatusEventData.FWEventData.OverallUpdateProgress;
        }
    }
}