aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-04-22 18:03:19 -0700
committerAnton Tananaev <anton@traccar.org>2022-04-22 18:03:19 -0700
commit91612195f286a538fb81291cb5604b329c015d64 (patch)
treeda23f09af499d4cfdd4c389459e8bb3023f98adc /src/main/java/org/traccar/protocol
parent1b601f506027c9f373de68ffca7f1f7a1dec815a (diff)
downloadtrackermap-server-91612195f286a538fb81291cb5604b329c015d64.tar.gz
trackermap-server-91612195f286a538fb81291cb5604b329c015d64.tar.bz2
trackermap-server-91612195f286a538fb81291cb5604b329c015d64.zip
Support Meitrack extension parameters
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
index a9cc1de3a..013e297c0 100644
--- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -404,7 +404,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int paramCount = buf.readUnsignedByte();
for (int j = 0; j < paramCount; j++) {
- int id = buf.readUnsignedByte();
+ boolean extension = buf.getUnsignedByte(buf.readerIndex()) == 0xFE;
+ int id = extension ? buf.readUnsignedShort() : buf.readUnsignedByte();
switch (id) {
case 0x01:
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
@@ -430,6 +431,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
case 0x9D:
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte());
break;
+ case 0xFE69:
+ position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
+ break;
default:
buf.readUnsignedByte();
break;
@@ -438,7 +442,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
paramCount = buf.readUnsignedByte();
for (int j = 0; j < paramCount; j++) {
- int id = buf.readUnsignedByte();
+ boolean extension = buf.getUnsignedByte(buf.readerIndex()) == 0xFE;
+ int id = extension ? buf.readUnsignedShort() : buf.readUnsignedByte();
switch (id) {
case 0x08:
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE()));
@@ -491,7 +496,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
paramCount = buf.readUnsignedByte();
for (int j = 0; j < paramCount; j++) {
- int id = buf.readUnsignedByte();
+ boolean extension = buf.getUnsignedByte(buf.readerIndex()) == 0xFE;
+ int id = extension ? buf.readUnsignedShort() : buf.readUnsignedByte();
switch (id) {
case 0x02:
position.setLatitude(buf.readIntLE() * 0.000001);
@@ -523,7 +529,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
paramCount = buf.readUnsignedByte();
for (int j = 0; j < paramCount; j++) {
- buf.readUnsignedByte(); // id
+ if (buf.getUnsignedByte(buf.readerIndex()) == 0xFE) {
+ buf.readUnsignedShort(); // extension id
+ } else {
+ buf.readUnsignedByte(); // id
+ }
buf.skipBytes(buf.readUnsignedByte()); // value
}