diff options
-rw-r--r-- | src/org/traccar/protocol/CguardProtocolDecoder.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/CguardProtocolDecoderTest.java | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java index 9786afd6a..d934921f1 100644 --- a/src/org/traccar/protocol/CguardProtocolDecoder.java +++ b/src/org/traccar/protocol/CguardProtocolDecoder.java @@ -101,7 +101,11 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, Integer.parseInt(value)); break; case "BAT1": - position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value)); + if (value.contains(".")) { + position.set(Position.KEY_BATTERY, Double.parseDouble(value)); + } else { + position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value)); + } break; case "PWR1": position.set(Position.KEY_POWER, Double.parseDouble(value)); diff --git a/test/org/traccar/protocol/CguardProtocolDecoderTest.java b/test/org/traccar/protocol/CguardProtocolDecoderTest.java index 1be301069..a386b6b47 100644 --- a/test/org/traccar/protocol/CguardProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CguardProtocolDecoderTest.java @@ -14,6 +14,15 @@ public class CguardProtocolDecoderTest extends ProtocolTest { "IDRO:354868050655283")); verifyPosition(decoder, text( + "NV:190225 144543:55.776505:37.729000:0:10:0:0")); + + verifyAttributes(decoder, text( + "BC:190225 144543:CSQ1:64:NSQ1:0:NSQ2:1:BAT1:100")); + + verifyAttributes(decoder, text( + "BC:190225 142653:CSQ1:80:NSQ1:0:NSQ2:1:BAT1:3.53")); + + verifyPosition(decoder, text( "NV:170409 031456:56.808553:60.595476:0:NAN:0")); verifyAttributes(decoder, text( |