Skip to content

Commit

Permalink
Improve TtnUplinkMessage.toString() with relevant info.
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrik committed Dec 16, 2023
1 parent 7c5e026 commit 7538421
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public byte[] getRawPayload() {
public String getDecodedFields() {
return decodedFields;
}

public int getPort() {
return port;
}
Expand All @@ -74,8 +74,8 @@ public int getSF() {

@Override
public String toString() {
return String.format(Locale.ROOT, "EUI %s, data %s, port %d, SF %d", devEui, HexConverter.toString(rawPayload),
port, sf);
return String.format(Locale.ROOT, "%s/%s: {data:'%s', fields:'%s'}", appId, devId,
HexConverter.toString(rawPayload), decodedFields);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import org.junit.Test;

public final class TtnUplinkMessageTest {

@Test
public void testString() {
TtnUplinkMessage message = new TtnUplinkMessage("app", "device", "eui", new byte[] {1, 2, 3}, "", 1);
TtnUplinkMessage message = new TtnUplinkMessage("app", "device", "eui", new byte[] { 1, 2, 3 }, "{}", 1);
Assert.assertNotNull(message.toString());
System.out.println(message);
}

}

0 comments on commit 7538421

Please sign in to comment.