diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-13 07:24:21 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-13 06:24:21 +1300 |
commit | 8a250a2a57d9750a92433c33660dc6e24151cbe3 (patch) | |
tree | c29274b8a05a31803ea6388dda65aa9693edaf7b /src/org/traccar/protocol | |
parent | 96f2ddba048b064381cf9375514f7b9d84186218 (diff) | |
download | trackermap-server-8a250a2a57d9750a92433c33660dc6e24151cbe3.tar.gz trackermap-server-8a250a2a57d9750a92433c33660dc6e24151cbe3.tar.bz2 trackermap-server-8a250a2a57d9750a92433c33660dc6e24151cbe3.zip |
Decode multiple AT2000 positions
Diffstat (limited to 'src/org/traccar/protocol')
-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; } |