Skip to content

Commit 55383a7

Browse files
better logging
1 parent b8b5ce7 commit 55383a7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/ru/r2cloud/lora/loraat/LoraAtSerialClient2.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ static String formatMessage(String message) {
251251
if (message.startsWith(prefix)) {
252252
message = message.substring(prefix.length());
253253
}
254-
message = message.substring(1); // I/E/W
254+
if (message.startsWith("I ") || message.startsWith("W ") || message.startsWith("E ")) {
255+
message = message.substring(1);
256+
}
255257
if (message.endsWith(suffix)) {
256258
message = message.substring(0, message.length() - suffix.length());
257259
}

src/test/java/ru/r2cloud/lora/loraat/LoraAtSerialClient2Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public void testMessageFormat() {
173173
(byte) 45, (byte) 97, (byte) 116, (byte) 58, (byte) 32, (byte) 114, (byte) 120, (byte) 32, (byte) 115, (byte) 116, (byte) 97, (byte) 114, (byte) 116, (byte) 101, (byte) 100, (byte) 32, (byte) 111, (byte) 110, (byte) 32, (byte) 52, (byte) 51, (byte) 54, (byte) 53, (byte) 53,
174174
(byte) 48, (byte) 48, (byte) 48, (byte) 48, (byte) 27, (byte) 91, (byte) 48, (byte) 109, (byte) 32 };
175175
assertEquals("(215215692) lora-at: rx started on 436550000", LoraAtSerialClient2.formatMessage(new String(data)));
176+
assertEquals("OK", LoraAtSerialClient2.formatMessage(new String("OK")));
176177
}
177178

178179
private static LoraObservationRequest createRequest() {

0 commit comments

Comments
 (0)