From c3c9e08e33c726fa05e42969f9f82b396107d6bb Mon Sep 17 00:00:00 2001 From: Yordan Date: Thu, 21 Feb 2019 18:09:04 +0300 Subject: [PATCH] HEX prefix '0x' added to thing's versions. (#384) HEX prefix '0x' added to thing's versions. This change is needed in order ESH firmware update mechanism to be able to distinguish between HEX and DEC version formats. Signed-off-by: YordanDZhelev --- .../org/openhab/binding/zigbee/ZigBeeBindingConstants.java | 1 + .../binding/zigbee/discovery/ZigBeeNodePropertyDiscoverer.java | 3 ++- .../org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java index 30ee6ef6b..fa7e8ec3a 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/ZigBeeBindingConstants.java @@ -245,6 +245,7 @@ public class ZigBeeBindingConstants { public static final String OFFLINE_DISCOVERY_INCOMPLETE = "@text/zigbee.status.offline_discoveryincomplete"; public static final String FIRMWARE_FAILED = "@text/zigbee.firmware.failed"; + public static final String FIRMWARE_VERSION_HEX_PREFIX = "0x"; // List of channel state constants public static final String STATE_OPTION_BATTERY_MIN_THRESHOLD = "minThreshold"; diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeNodePropertyDiscoverer.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeNodePropertyDiscoverer.java index ef7c41292..a836af420 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeNodePropertyDiscoverer.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/discovery/ZigBeeNodePropertyDiscoverer.java @@ -185,7 +185,8 @@ public Map getProperties(final ZigBeeNode node) { if (otaCluster != null) { Integer fileVersion = otaCluster.getCurrentFileVersion(Long.MAX_VALUE); if (fileVersion != null) { - properties.put(Thing.PROPERTY_FIRMWARE_VERSION, String.format("%08X", fileVersion)); + properties.put(Thing.PROPERTY_FIRMWARE_VERSION, + String.format("%s%08X", ZigBeeBindingConstants.FIRMWARE_VERSION_HEX_PREFIX, fileVersion)); } else { logger.debug("{}: OTA firmware failed", node.getIeeeAddress()); } diff --git a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java index db049490b..211ede8dd 100644 --- a/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java +++ b/org.openhab.binding.zigbee/src/main/java/org/openhab/binding/zigbee/handler/ZigBeeThingHandler.java @@ -884,7 +884,8 @@ public void otaStatusUpdate(ZigBeeOtaServerStatus status, int percent) { for (int retry = 0; retry < 3; retry++) { Integer fileVersion = finalOtaServer.getCurrentFileVersion(); if (fileVersion != null) { - updateProperty(Thing.PROPERTY_FIRMWARE_VERSION, String.format("%08X", fileVersion)); + updateProperty(Thing.PROPERTY_FIRMWARE_VERSION, String.format("%s%08X", + ZigBeeBindingConstants.FIRMWARE_VERSION_HEX_PREFIX, fileVersion)); break; } else { logger.debug("{}: OTA firmware request timeout (retry {})", node.getIeeeAddress(), retry);