aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranton2920 <anton2920@gmail.com>2022-09-05 13:06:49 +0100
committeranton2920 <anton2920@gmail.com>2022-09-07 09:48:46 +0100
commit5dd61da7a9927bb28c880a5fe50997170aaf536c (patch)
tree94f35387fedde134a3c91db9023b476ac3e8ba78
parent6196ea366cfc5c668ef35940bcac50672badd82d (diff)
downloadtrackermap-server-5dd61da7a9927bb28c880a5fe50997170aaf536c.tar.gz
trackermap-server-5dd61da7a9927bb28c880a5fe50997170aaf536c.tar.bz2
trackermap-server-5dd61da7a9927bb28c880a5fe50997170aaf536c.zip
Added support for decoding more data from GPS sub-packet
-rw-r--r--src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java b/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
index 24bd69d45..fd30b170e 100644
--- a/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
@@ -159,16 +159,20 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
int subMask = readUnsignedShortUnescaped(buf);
if ((subMask & G1RUS_GPS_SIGN_MASK) == G1RUS_GPS_SIGN_MASK) {
- skipBytesUnescaped(buf, 1);
+ short signValid = readUnsignedByteUnescaped(buf);
+ LOGGER.info("Fix sign: " + ((signValid & 0b1100000) >> 5));
+ LOGGER.info("Satellite number: " + (signValid & 0b0011111));
+ position.setValid(((signValid & 0b1100000) >> 5) == 2);
+ position.set(Position.KEY_SATELLITES, signValid & 0b0011111);
}
if ((subMask & G1RUS_GPS_POS_MASK) == G1RUS_GPS_POS_MASK) {
- byte[] pos_buf = new byte[4];
- readBytesUnescaped(buf, pos_buf);
- position.setLatitude((float) Ints.fromByteArray(pos_buf) / 1000000);
+ byte[] posBuf = new byte[4];
+ readBytesUnescaped(buf, posBuf);
+ position.setLatitude((float) Ints.fromByteArray(posBuf) / 1000000);
LOGGER.info("Latitude: " + position.getLatitude());
- readBytesUnescaped(buf, pos_buf);
- position.setLongitude((float) Ints.fromByteArray(pos_buf) / 1000000);
+ readBytesUnescaped(buf, posBuf);
+ position.setLongitude((float) Ints.fromByteArray(posBuf) / 1000000);
LOGGER.info("Longitude: " + position.getLongitude());
}
if ((subMask & G1RUS_GPS_SPD_MASK) == G1RUS_GPS_SPD_MASK) {
@@ -184,10 +188,12 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
LOGGER.info("Altitude: " + position.getAltitude());
}
if ((subMask & G1RUS_GPS_HDOP_MASK) == G1RUS_GPS_HDOP_MASK) {
- skipBytesUnescaped(buf, 2);
+ position.set(Position.KEY_HDOP, readUnsignedShortUnescaped(buf));
+ LOGGER.info("HDOP: " + position.getAttributes().get(Position.KEY_HDOP));
}
if ((subMask & G1RUS_GPS_VDOP_MASK) == G1RUS_GPS_VDOP_MASK) {
- skipBytesUnescaped(buf, 2);
+ position.set(Position.KEY_VDOP, readUnsignedShortUnescaped(buf));
+ LOGGER.info("VDOP: " + position.getAttributes().get(Position.KEY_VDOP));
}
LOGGER.info("</GPS>");
@@ -311,8 +317,8 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
byte[] imei = new byte[8];
readBytesUnescaped(buf, imei, 0, 7);
- long imei_long = Longs.fromByteArray(imei);
- LOGGER.info("IMEI: " + imei_long);
+ long imeiLong = Longs.fromByteArray(imei);
+ LOGGER.info("IMEI: " + imeiLong);
List<Position> positions = null;
@@ -320,7 +326,7 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
return null;
} else if ((packetType & G1RUS_TYPE_BCD_MASK) == G1RUS_TYPE_REGULAR) {
positions = new LinkedList<>();
- Position position = decodeRegular(channel, remoteAddress, buf, imei_long, packetType);
+ Position position = decodeRegular(channel, remoteAddress, buf, imeiLong, packetType);
if (position != null) {
positions.add(position);
}
@@ -337,7 +343,7 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
printPacketType(subPacketType);
if ((subPacketType & G1RUS_TYPE_BCD_MASK) == G1RUS_TYPE_REGULAR) {
- Position position = decodeRegular(channel, remoteAddress, buf, imei_long, subPacketType);
+ Position position = decodeRegular(channel, remoteAddress, buf, imeiLong, subPacketType);
if (position != null) {
positions.add(position);
}