Firmware Management
Keep your Pathfinder Edge devices up to date with the latest firmware. This guide covers how to check the current firmware version and update device firmware using the SDK.
Why Update Firmware?
Firmware updates provide:
- Bug fixes — Resolve known issues
- New features — Access the latest capabilities
- Security patches — Protect against vulnerabilities
- Performance improvements — Better reliability and speed
- Compatibility — Support for new SDK versions
Checking Firmware Version
Get Current Version
Use DeviceAdapter.getDeviceInfo() to retrieve device information, including the firmware version:
import com.averydennison.addevicemanager.adapters.DeviceAdapter;
import com.averydennison.addevicemanager.models.info.DeviceInfo;
import com.averydennison.addevicemanager.models.info.GeneralInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Logger logger = LoggerFactory.getLogger(getClass());
deviceAdapter.getDeviceInfo()
.thenAccept(deviceInfo -> {
GeneralInfo generalInfo = deviceInfo.getGeneralInfo();
String firmwareVersion = generalInfo.getFirmwareVersion();
String printerModel = generalInfo.getPrinterModel();
String serialNumber = generalInfo.getSerialNumber();
String vendorSdkVersion = generalInfo.getVendorSdkVersion();
logger.info("Firmware version: {}", firmwareVersion);
logger.info("Printer model: {}", printerModel);
logger.info("Serial number: {}", serialNumber);
logger.info("Vendor SDK version: {}", vendorSdkVersion);
runOnUiThread(() -> {
if (firmwareVersion != null && !firmwareVersion.isEmpty()) {
firmwareVersionText.setText("Firmware: " + firmwareVersion);
} else {
firmwareVersionText.setText("Firmware: N/A");
}
});
})
.exceptionally(error -> {
logger.error("Failed to get device info: {}", error.getMessage());
return null;
});
GeneralInfo Properties
| Property | Method | Description |
|---|---|---|
| Printer Model | getPrinterModel() | Device model identifier |
| Serial Number | getSerialNumber() | Device serial number |
| Firmware Version | getFirmwareVersion() | Firmware version string |
| Vendor SDK Version | getVendorSdkVersion() | Version of the underlying vendor SDK |
Complete DeviceInfo Structure
The DeviceInfo object provides comprehensive device information:
deviceAdapter.getDeviceInfo()
.thenAccept(deviceInfo -> {
// General info (model, serial, firmware)
GeneralInfo generalInfo = deviceInfo.getGeneralInfo();
// Printer settings (speed, contrast, backfeed)
PrinterInfo printerInfo = deviceInfo.getPrinterInfo();
// Battery status
BatteryInfo batteryInfo = deviceInfo.getBatteryInfo();
// Label specifications
LabelInfo labelInfo = deviceInfo.getLabelInfo();
// Scanner trigger mode
TriggerMode triggerMode = deviceInfo.getTriggerMode();
// Registered resources
List<Resource> resources = deviceInfo.getResources();
});
Checking Firmware Update Capability
Before attempting a firmware update, verify that the device supports this capability:
import com.averydennison.addevicemanager.capabilities.FirmwareUpdateCapability;
if (deviceAdapter.hasCapability(FirmwareUpdateCapability.class)) {
// Device supports firmware updates
enableUpdateButton(true);
} else {
// Device does not support firmware updates via SDK
enableUpdateButton(false);
showMessage("This device does not support firmware updates.");
}
Applying Firmware Updates
Update from InputStream
The primary method for firmware updates uses an InputStream. This is useful when the firmware file is selected by the user or downloaded from a server:
import com.averydennison.addevicemanager.capabilities.FirmwareUpdateCapability;
import com.averydennison.addevicemanager.callbacks.ProgressCallback;
import java.io.InputStream;
private void updateFirmware(InputStream firmwareStream, String fileName) {
// Check connection and capability
if (deviceAdapter == null || !deviceAdapter.isConnected()) {
showMessage("Error: Not connected to any device.");
return;
}
if (!deviceAdapter.hasCapability(FirmwareUpdateCapability.class)) {
showMessage("Error: Device does not support firmware updates.");
return;
}
// Cast to FirmwareUpdateCapability
FirmwareUpdateCapability firmwareUpdater = (FirmwareUpdateCapability) deviceAdapter;
// Show progress UI
showProgressDialog("Updating firmware...");
firmwareUpdater.updateFirmware(firmwareStream, fileName,
(currentFile, currentItem, totalItems, itemProgress) -> {
// Update progress UI
String message = String.format(Locale.getDefault(),
"Updating firmware %s... %.2f%%", currentFile, itemProgress);
runOnUiThread(() -> {
progressText.setText(message);
progressBar.setProgress((int) itemProgress);
});
})
.thenRun(() -> {
runOnUiThread(() -> {
hideProgressDialog();
showMessage("Firmware update file upload complete. " +
"Please wait for the device to restart.");
});
})
.exceptionally(e -> {
String errorMessage = "Firmware update failed: " + e.getMessage();
logger.error(errorMessage, e);
runOnUiThread(() -> {
hideProgressDialog();
showMessage(errorMessage);
});
return null;
});
}
Update from Byte Array
Alternatively, you can update firmware from a byte array:
private void updateFirmwareFromBytes(byte[] firmwareData, String fileName) {
if (!deviceAdapter.hasCapability(FirmwareUpdateCapability.class)) {
showMessage("Error: Device does not support firmware updates.");
return;
}
FirmwareUpdateCapability firmwareUpdater = (FirmwareUpdateCapability) deviceAdapter;
firmwareUpdater.updateFirmware(firmwareData, fileName,
(currentFile, currentItem, totalItems, itemProgress) -> {
runOnUiThread(() -> {
progressBar.setProgress((int) itemProgress);
});
})
.thenRun(() -> {
runOnUiThread(() -> showMessage("Firmware upload complete."));
})
.exceptionally(e -> {
runOnUiThread(() -> showMessage("Update failed: " + e.getMessage()));
return null;
});
}
Progress Callback
The ProgressCallback interface provides real-time update progress. Generally, only one file is uploaded, so currentItem and totalItems will be 1.
public interface ProgressCallback {
void onProgress(String currentFile, int current, int total, double currentProgress);
}
Pre-Update Checklist
| Condition | Why It Matters |
|---|---|
| Device connected | Must have active connection to transfer firmware |
| Sufficient battery | Update shouldn't be interrupted by power loss |
| Capability check | Not all devices support firmware updates via SDK |
| No active print jobs | Avoid conflicts during update |
| User confirmation | User should understand device will restart |
Best Practices
1. Always Check Capability First
if (!deviceAdapter.hasCapability(FirmwareUpdateCapability.class)) {
showMessage("This device doesn't support firmware updates.");
return;
}
2. Handle Back Button
@Override
public void onBackPressed() {
if (isUpdating) {
showMessage("Please wait for update to complete");
return;
}
super.onBackPressed();
}
3. Log Update Events
logger.info("Starting firmware update: {}", fileName);
// In progress callback
logger.debug("Firmware update progress: {}%", itemProgress);
// On completion
logger.info("Firmware upload complete");
// On error
logger.error("Firmware update failed", e);
Error Handling
| Error Scenario | Recovery Action |
|---|---|
| Not connected | Ensure device is connected before update |
| Capability not supported | Verify device model supports firmware updates |
| Update failed | Check connection, retry, or power cycle device |
| Connection lost during update | Reconnect and retry; device may need manual recovery |
Next Steps
| Guide | What You'll Learn |
|---|---|
| Getting Started | Basic device connection |
| Error Handling | Handle update failures |
| Logging | Debug firmware issues |