diff options
-rw-r--r-- | src/org/traccar/protocol/T800xProtocolDecoder.java | 26 | ||||
-rw-r--r-- | test/org/traccar/protocol/T800xProtocolDecoderTest.java | 6 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java index 1fd37864e..a6a647f22 100644 --- a/src/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/org/traccar/protocol/T800xProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedShort(); // distance compensation buf.readUnsignedShort(); // speed alarm - int locationStatus = buf.readUnsignedByte(); + int status = buf.readUnsignedByte(); buf.readUnsignedByte(); // gsensor manager status buf.readUnsignedByte(); // other flags @@ -151,9 +151,9 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { .setMinute(BcdUtil.readInteger(buf, 2)) .setSecond(BcdUtil.readInteger(buf, 2)); - if (BitUtil.check(locationStatus, 6)) { + if (BitUtil.check(status, 6)) { - position.setValid(!BitUtil.check(locationStatus, 7)); + position.setValid(!BitUtil.check(status, 7)); position.setTime(dateBuilder.getDate()); position.setAltitude(readSwappedFloat(buf)); position.setLongitude(readSwappedFloat(buf)); @@ -170,14 +170,24 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { buf.readBytes(array); ChannelBuffer swapped = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, array); - position.setNetwork(new Network(CellTower.from( - swapped.readUnsignedShort(), swapped.readUnsignedShort(), - swapped.readUnsignedShort(), swapped.readUnsignedShort()))); + int mcc = swapped.readUnsignedShort(); + int mnc = swapped.readUnsignedShort(); - // two more cell towers + if (mcc != 0xffff && mnc != 0xffff) { + Network network = new Network(); + for (int i = 0; i < 3; i++) { + network.addCellTower(CellTower.from( + mcc, mnc, swapped.readUnsignedShort(), swapped.readUnsignedShort())); + } + position.setNetwork(network); + } } + if (buf.readableBytes() >= 2) { + position.set(Position.KEY_POWER, BcdUtil.readInteger(buf, 4) * 0.01); + } + return position; } diff --git a/test/org/traccar/protocol/T800xProtocolDecoderTest.java b/test/org/traccar/protocol/T800xProtocolDecoderTest.java index 0f311478f..fb8800a5c 100644 --- a/test/org/traccar/protocol/T800xProtocolDecoderTest.java +++ b/test/org/traccar/protocol/T800xProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class T800xProtocolDecoderTest extends ProtocolTest { T800xProtocolDecoder decoder = new T800xProtocolDecoder(new T800xProtocol()); verifyNull(decoder, binary( + "252501001504050880061689888888111111250350")); + + verifyPosition(decoder, binary( + "252502004400010880616898888888000A00FF2001000020409600989910101010055501550000101005050005051010050558866B4276D6E342912AB441111500051010")); + + verifyNull(decoder, binary( "232301001500000880316890202968140197625020")); verifyNull(decoder, binary( |