From 3226dac7a8831d96a0adbee9740f78693ea601b9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 Oct 2018 11:01:50 +1300 Subject: Fix GPSMTA battery level decoding --- src/org/traccar/protocol/GpsmtaProtocolDecoder.java | 20 ++++++++++---------- .../traccar/protocol/GpsmtaProtocolDecoderTest.java | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java index 0cb4b611e..332811263 100644 --- a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java @@ -69,17 +69,17 @@ public class GpsmtaProtocolDecoder extends BaseProtocolDecoder { String time = parser.next(); position.setTime(new Date(Long.parseLong(time) * 1000)); - position.setLatitude(parser.nextDouble(0)); - position.setLongitude(parser.nextDouble(0)); - position.setSpeed(parser.nextInt(0)); - position.setCourse(parser.nextInt(0)); - position.setAccuracy(parser.nextInt(0)); - position.setAltitude(parser.nextInt(0)); + position.setLatitude(parser.nextDouble()); + position.setLongitude(parser.nextDouble()); + position.setSpeed(parser.nextInt()); + position.setCourse(parser.nextInt()); + position.setAccuracy(parser.nextInt()); + position.setAltitude(parser.nextInt()); - position.set(Position.KEY_STATUS, parser.nextInt(0)); - position.set(Position.KEY_BATTERY, parser.nextInt(0)); - position.set(Position.PREFIX_TEMP + 1, parser.nextInt(0)); - position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1); + position.set(Position.KEY_STATUS, parser.nextInt()); + position.set(Position.KEY_BATTERY_LEVEL, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); + position.set(Position.KEY_CHARGE, parser.nextInt() == 1); if (channel != null) { channel.writeAndFlush(new NetworkMessage(time, remoteAddress)); diff --git a/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java b/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java index 27922bdbc..00d30a357 100644 --- a/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java @@ -16,7 +16,7 @@ public class GpsmtaProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "864528021249771 1446116686 49.85073 24.004438 0 217 6 338 00 59 27 0 0")); - verifyPosition(decoder, text( + verifyNotNull(decoder, text( "359144048138856 1442932957 -49.85064 -24.003979 1 0 40 0 10 110 26 0 0")); } -- cgit v1.2.3