diff options
author | Abyss777 <abyss@fox5.ru> | 2017-01-16 13:51:40 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-01-16 13:51:40 +0500 |
commit | b5eb48cbba215ca55c1a5e5ae5fae5b375243247 (patch) | |
tree | 64a25006deb6635853c0cc727db201f088566347 /src/org/traccar/protocol/At2000ProtocolDecoder.java | |
parent | cffbce4b3bc5ef817c4063a74f148a2a5986d58a (diff) | |
parent | 00caa503748a1dad3349bfb8444ef766efd60633 (diff) | |
download | trackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.gz trackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.bz2 trackermap-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.zip |
Merge remote-tracking branch 'upstream/master' into manager
# Conflicts:
# setup/default.xml
Diffstat (limited to 'src/org/traccar/protocol/At2000ProtocolDecoder.java')
-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; } |