Click or drag to resize

FirmwareUpdaterLinkOsUpdateFirmware Method (String, FirmwareUpdateHandler)

Update firmware on the printer using the default timeout of 10 minutes.

Namespace:  Zebra.Sdk.Printer
Assembly:  SdkApi_Core (in SdkApi_Core.dll) Version: 2.14.1869
Syntax
void UpdateFirmware(
	string firmwareFilePath,
	FirmwareUpdateHandler handler
)

Parameters

firmwareFilePath
Type: SystemString
File path of firmware file.
handler
Type: Zebra.Sdk.PrinterFirmwareUpdateHandler
Callback for firmware updating status
Exceptions
ExceptionCondition
ConnectionExceptionIf the connection can not be opened, is closed prematurely, or connection cannot be established after firmware download is complete.
ZebraPrinterLanguageUnknownExceptionIf the printer language can not be determined.
ZebraIllegalArgumentExceptionIf an invalid firmware file is specified for the printer.
DiscoveryExceptionIf an error occurs while waiting for the printer to come back online.
TimeoutExceptionIf the maximum timeout is reached prior to the printer coming back online with the new firmware.
FileNotFoundExceptionFirmware file not found.
Remarks
If the firmware currently on the printer has the same version number as the firmware file, the firmware will not be sent to the printer.
Examples
using System;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Printer;

public class UpdatePrinterFirmwareExample {

    public static void Main(string[] args) {
        string theIpAddress = "1.2.3.4";

        // File path, e.g. "D:\\ZV68_19_6Z.zpl"
        string firmwareFilePath = "fullPathToFirmwareFile";

        Connection connection = new TcpConnection(theIpAddress, TcpConnection.DEFAULT_ZPL_TCP_PORT);
        try {
            connection.Open();
            ZebraPrinterLinkOs p = ZebraPrinterFactory.GetLinkOsPrinter(connection);

            // Send the firmware file to the printer.
            p.UpdateFirmware(firmwareFilePath, new UpdateFirmareHandler());
        } catch (Exception e) {
            Console.WriteLine(e.ToString());
        } finally {
            connection.Close();
        }
    }

    private class UpdateFirmareHandler : FirmwareUpdateHandler {

        public override void FirmwareDownloadComplete() {
            Console.WriteLine("Firmware download complete.");
        }

        public override void PrinterOnline(ZebraPrinterLinkOs printer, string firmwareVersion) {
            Console.WriteLine($"Printer online with firmware version={firmwareVersion}");
        }

        public override void ProgressUpdate(int bytesWritten, int totalBytes) {
        }
    }
}
See Also