diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/At2000ProtocolDecoder.java | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java index 58b6f44e8..00973f2aa 100644 --- a/src/org/traccar/protocol/At2000ProtocolDecoder.java +++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java @@ -31,6 +31,8 @@ import java.net.SocketAddress; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.util.Date; +import java.util.LinkedList; +import java.util.List; public class At2000ProtocolDecoder extends BaseProtocolDecoder { @@ -100,28 +102,55 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder { return null; } - Position position = new Position(); - position.setProtocol(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - byte[] data = new byte[buf.capacity() - BLOCK_LENGTH]; buf.readBytes(data); buf = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, cipher.update(data)); - buf.readUnsignedShort(); // index - buf.readUnsignedShort(); // reserved + List<Position> positions = new LinkedList<>(); + + while (buf.readableBytes() >= 63) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + buf.readUnsignedShort(); // index + buf.readUnsignedShort(); // reserved + + position.setValid(true); + + position.setTime(new Date(buf.readLong() * 1000)); - position.setValid(true); + position.setLatitude(buf.readFloat()); + position.setLongitude(buf.readFloat()); + position.setAltitude(buf.readFloat()); + position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat())); + position.setCourse(buf.readFloat()); - position.setTime(new Date(buf.readLong() * 1000)); + buf.readUnsignedInt(); // geozone event + buf.readUnsignedInt(); // io events + buf.readUnsignedInt(); // geozone value + buf.readUnsignedInt(); // io values + buf.readUnsignedShort(); // operator - position.setLatitude(buf.readFloat()); - position.setLongitude(buf.readFloat()); - position.setAltitude(buf.readFloat()); - position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat())); - position.setCourse(buf.readFloat()); + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); + + position.set(Position.KEY_POWER, buf.readUnsignedShort() + "mV"); + + buf.readUnsignedShort(); // cid + buf.readUnsignedByte(); // rssi + buf.readUnsignedByte(); // current profile + + position.set(Position.KEY_BATTERY, buf.readUnsignedByte()); + position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + + positions.add(position); + + } - return position; + return positions; } |