aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/FlexApiProtocol.java2
-rw-r--r--src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java16
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java6
3 files changed, 16 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/FlexApiProtocol.java b/src/main/java/org/traccar/protocol/FlexApiProtocol.java
index a1e741eee..bc6a49907 100644
--- a/src/main/java/org/traccar/protocol/FlexApiProtocol.java
+++ b/src/main/java/org/traccar/protocol/FlexApiProtocol.java
@@ -27,7 +27,7 @@ public class FlexApiProtocol extends BaseProtocol {
addServer(new TrackerServer(false, getName()) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
- pipeline.addLast(new LineBasedFrameDecoder(1024));
+ pipeline.addLast(new LineBasedFrameDecoder(5120));
pipeline.addLast(new StringDecoder());
pipeline.addLast(new FlexApiProtocolDecoder(FlexApiProtocol.this));
}
diff --git a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java
index d2b3c6960..25a8f7090 100644
--- a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java
@@ -68,10 +68,18 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, new Date(payload.getInt("obd.ts") * 1000L));
- position.set(Position.KEY_OBD_SPEED, payload.getJsonNumber("obd.speed").doubleValue());
- position.set(Position.KEY_OBD_ODOMETER, payload.getInt("obd.odo"));
- position.set(Position.KEY_RPM, payload.getInt("obd.rpm"));
- position.set(Position.KEY_VIN, payload.getString("obd.vin"));
+ if (payload.containsKey("obd.speed")) {
+ position.set(Position.KEY_OBD_SPEED, payload.getJsonNumber("obd.speed").doubleValue());
+ }
+ if (payload.containsKey("obd.odo")) {
+ position.set(Position.KEY_OBD_ODOMETER, payload.getInt("obd.odo"));
+ }
+ if (payload.containsKey("obd.rpm")) {
+ position.set(Position.KEY_RPM, payload.getInt("obd.rpm"));
+ }
+ if (payload.containsKey("obd.vin")) {
+ position.set(Position.KEY_VIN, payload.getString("obd.vin"));
+ }
} else {
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index 40a583f2a..4fe261aa4 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -193,10 +193,12 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
+ ByteBuf content = buf.retainedSlice(buf.readerIndex(), buf.readableBytes() - 2);
+
position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
buf.readUnsignedByte(); // timezone
- int interval = buf.readUnsignedByte();
+ buf.readUnsignedByte(); // interval
if (buf.readableBytes() >= 1 + 2) {
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
}
@@ -210,8 +212,6 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HEART_RATE, buf.readUnsignedByte());
}
- ByteBuf content = Unpooled.buffer();
- content.writeByte(interval);
sendResponse(channel, length, type, content);
return position;