Skip to content

Commit 77d97e4

Browse files
committed
[Explicit examples] Using 'format' when printing out receiving data.
Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
1 parent e8493d5 commit 77d97e4

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

examples/communication/explicit/ReceiveExplicitDataPollingSample/src/com/digi/xbee/api/receiveexplicitdatapolling/MainApp.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ public static void main(String[] args) {
6161
System.out.format("From %s >> %s | %s%n", explicitXBeeMessage.getDevice().get64BitAddress(),
6262
HexUtils.prettyHexString(HexUtils.byteArrayToHexString(explicitXBeeMessage.getData())),
6363
new String(explicitXBeeMessage.getData()));
64-
System.out.println(" - Source endpoint: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getSourceEndpoint(), 1));
65-
System.out.println(" - Destination endpoint: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getDestinationEndpoint(), 1));
66-
System.out.println(" - Cluster ID: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getClusterID(), 2));
67-
System.out.println(" - Profile ID: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getProfileID(), 2));
68-
System.out.println("");
64+
System.out.format(" - Source endpoint: 0x%02X%n", explicitXBeeMessage.getSourceEndpoint());
65+
System.out.format(" - Destination endpoint: 0x%02X%n", explicitXBeeMessage.getDestinationEndpoint());
66+
System.out.format(" - Cluster ID: 0x%04X%n", explicitXBeeMessage.getClusterID());
67+
System.out.format(" - Profile ID: 0x%04X%n%n",explicitXBeeMessage.getProfileID());
6968
}
7069
}
7170
}

examples/communication/explicit/ReceiveExplicitDataSample/src/com/digi/xbee/api/receiveexplicitdata/MyExplicitDataReceiveListener.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ public void explicitDataReceived(ExplicitXBeeMessage explicitXBeeMessage) {
2525
System.out.format("From %s >> %s | %s%n", explicitXBeeMessage.getDevice().get64BitAddress(),
2626
HexUtils.prettyHexString(HexUtils.byteArrayToHexString(explicitXBeeMessage.getData())),
2727
new String(explicitXBeeMessage.getData()));
28-
System.out.println(" - Source endpoint: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getSourceEndpoint(), 1));
29-
System.out.println(" - Destination endpoint: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getDestinationEndpoint(), 1));
30-
System.out.println(" - Cluster ID: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getClusterID(), 2));
31-
System.out.println(" - Profile ID: 0x" + HexUtils.integerToHexString(explicitXBeeMessage.getProfileID(), 2));
32-
System.out.println("");
28+
System.out.format(" - Source endpoint: 0x%02X%n", explicitXBeeMessage.getSourceEndpoint());
29+
System.out.format(" - Destination endpoint: 0x%02X%n", explicitXBeeMessage.getDestinationEndpoint());
30+
System.out.format(" - Cluster ID: 0x%04X%n", explicitXBeeMessage.getClusterID());
31+
System.out.format(" - Profile ID: 0x%04X%n%n", explicitXBeeMessage.getProfileID());
3332
}
3433
}

0 commit comments

Comments
 (0)