Skip to content

Commit

Permalink
Decode Aplicom device time
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jul 2, 2018
1 parent 3ceee5b commit ef3bf24
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/org/traccar/protocol/AplicomProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ private void decodeD(Position position, ByteBuf buf, int selector, int event) {
}

if ((selector & 0x0004) != 0) {
buf.skipBytes(4); // snapshot time
position.setDeviceTime(new Date(buf.readUnsignedInt() * 1000));
}

if ((selector & 0x0008) != 0) {
position.setTime(new Date(buf.readUnsignedInt() * 1000));
position.setFixTime(new Date(buf.readUnsignedInt() * 1000));
if (position.getDeviceTime() == null) {
position.setDeviceTime(position.getFixTime());
}
position.setLatitude(buf.readInt() / 1000000.0);
position.setLongitude(buf.readInt() / 1000000.0);
position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte());
Expand Down Expand Up @@ -540,12 +543,14 @@ private void decodeEB(Position position, ByteBuf buf) {

private void decodeF(Position position, ByteBuf buf, int selector) {

getLastLocation(position, null);
Date deviceTime = null;

if ((selector & 0x0004) != 0) {
buf.skipBytes(4); // snapshot time
deviceTime = new Date(buf.readUnsignedInt() * 1000);
}

getLastLocation(position, deviceTime);

buf.readUnsignedByte(); // data validity

if ((selector & 0x0008) != 0) {
Expand Down

0 comments on commit ef3bf24

Please sign in to comment.