aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
-rw-r--r--src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java3
4 files changed, 19 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;
diff --git a/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java
index 04163294f..83f36f394 100644
--- a/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class FlexApiProtocolDecoderTest extends ProtocolTest {
var decoder = new FlexApiProtocolDecoder(null);
verifyAttributes(decoder, text(
+ "${\"topic\":\"v1/VF3102029000003/obd/info\",\"payload\":{\"obd.ts\":1639037377,\"obd.speed\":211,\"obd.f_lvl\":50.196079,\"obd.mil\":0,\"obd.dtcs\":0,\"obd.rpm\":14531.250000,\"obd.e_load\":50.980392,\"obd.c_temp\":118,\"obd.o_temp\":56,\"obd.a_temp\":-40,\"obd.f_press\":48,\"obd.t_pos\":51.764706,\"obd.b_volt\":13.782000,\"obd.up_time\":2265,\"obd.m_dist\":4643,\"obd.m_time\":257,\"obd.d_dist\":200,\"obd.d_time\":771,\"obd.vin\":\"LFV3B28R8A3025310\",\"obd.f_rate\":10,\"obd.t_dist\":4843,\"obd.b_press\":101,\"obd.f_r_press\":48,\"obd.i_temp\":37,\"obd.i_press\":32,\"obd.r_torque\":4128,\"obd.a_torque\":2,\"obd.mf_mon\":1,\"obd.f_s_mon\":0,\"obd.c_c_mon\":0,\"obd.c_mon\":1,\"obd.e_s_mon\":1,\"obd.e_v_s_mon\":1,\"obd.o_s_mon\":1,\"obd.o_s_h_mon\":1}}xx"));
+
+ verifyAttributes(decoder, text(
"${\"topic\":\"v1/VF3102021111601/obd/info\",\"payload\":{\"obd.ts\":1637225390,\"obd.speed\":0,\"obd.f_lvl\":null,\"obd.odo\":0,\"obd.e_hours\":0,\"obd.ab_level\":null,\"obd.mil\":0,\"obd.dtcs\":null,\"obd.rpm\":0,\"obd.e_load\":null,\"obd.c_temp\":-40,\"obd.o_temp\":-273,\"obd.a_temp\":null,\"obd.f_press\":null,\"obd.t_pos\":0,\"obd.b_volt\":null,\"obd.up_time\":null,\"obd.m_dist\":null,\"obd.m_time\":null,\"obd.d_dist\":null,\"obd.d_time\":null,\"obd.vin\":\"NLVIN123456789ABC\",\"obd.brake\":0,\"obd.parking\":0,\"obd.s_w_angle\":null,\"obd.f_rate\":0,\"obd.f_econ\":0,\"obd.a_pos\":null,\"obd.t_dist\":0,\"obd.b_press\":null,\"obd.f_r_press\":null,\"obd.i_temp\":null,\"obd.i_press\":null,\"obd.r_torque\":null,\"obd.f_torque\":null,\"obd.max_avl_torque\":null,\"obd.a_torque\":-125,\"obd.d_e_f_vol\":null,\"obd.mf_mon\":null,\"obd.f_s_mon\":null,\"obd.c_c_mon\":null,\"obd.c_mon\":null,\"obd.h_c_mon\":null,\"obd.e_s_mon\":null,\"obd.s_a_s_mon\":null,\"obd.a_s_r_mon\":null,\"obd.e_g_s_mon\":null,\"obd.e_g_s_h_mon\":null,\"obd.e_v_s_mon\":null,\"obd.c_s_a_s_mon\":null,\"obd.b_p_c_s_mon\":null,\"obd.dpf_mon\":null,\"obd.n_c_mon\":null,\"obd.nmhc_mon\":null,\"obd.o_s_mon\":null,\"obd.o_s_h_mon\":null,\"obd.pf_mon\":null}}xx"));
verifyPosition(decoder, text(