diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2022-01-13 23:31:03 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2022-01-13 23:31:03 -0800 |
commit | 839751e76e329adb573150644bd6198beba0d3b6 (patch) | |
tree | 2185e076e09281249451d76dd72e77d2f809101f /src/main/java/org/traccar/protocol | |
parent | 9453cb6f684b26cc87a8d81c46b714319ff0cbaa (diff) | |
download | trackermap-server-839751e76e329adb573150644bd6198beba0d3b6.tar.gz trackermap-server-839751e76e329adb573150644bd6198beba0d3b6.tar.bz2 trackermap-server-839751e76e329adb573150644bd6198beba0d3b6.zip |
Decode remaining FlexAPI data
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r-- | src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java index 3dfcd459b..20ff78c21 100644 --- a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java @@ -19,6 +19,8 @@ import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.Protocol; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; import javax.json.Json; @@ -52,7 +54,7 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { JsonObject payload = root.getJsonObject("payload"); - if (topic.contains("gnss")) { + if (topic.contains("/gnss/")) { position.setValid(true); @@ -72,7 +74,25 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, payload.getInt("gnss.num_sv")); - } else if (topic.contains("obd")) { + } else if (topic.contains("/cellular1/")) { + + getLastLocation(position, new Date(payload.getInt("modem1.ts") * 1000L)); + + position.set("imei", payload.getString("modem1.imei")); + position.set("imsi", payload.getString("modem1.imsi")); + position.set(Position.KEY_ICCID, payload.getString("modem1.iccid")); + + String operator = payload.getString("modem1.operator"); + if (!operator.isEmpty()) { + position.setNetwork(new Network(CellTower.from( + Integer.parseInt(operator.substring(0, 3)), + Integer.parseInt(operator.substring(3)), + Integer.parseInt(payload.getString("modem1.lac"), 16), + Integer.parseInt(payload.getString("modem1.cell_id"), 16), + payload.getInt("modem1.rssi")))); + } + + } else if (topic.contains("/obd/")) { getLastLocation(position, new Date(payload.getInt("obd.ts") * 1000L)); @@ -89,7 +109,7 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_VIN, payload.getString("obd.vin")); } - } else if (topic.contains("motion")) { + } else if (topic.contains("/motion/")) { getLastLocation(position, new Date(payload.getInt("motion.ts") * 1000L)); @@ -100,6 +120,31 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { position.set("gy", payload.getJsonNumber("motion.gy").doubleValue()); position.set("gz", payload.getJsonNumber("motion.gz").doubleValue()); + } else if (topic.contains("/io/")) { + + getLastLocation(position, new Date(payload.getInt("io.ts") * 1000L)); + + if (payload.containsKey("io.IGN")) { + position.set(Position.KEY_IGNITION, payload.getInt("io.IGN") > 0); + } + + for (String key : payload.keySet()) { + if (key.startsWith("io.AI")) { + position.set(Position.PREFIX_ADC + key.substring(5), payload.getJsonNumber(key).doubleValue()); + } else if (key.startsWith("io.DI") && !key.endsWith("_pullup")) { + position.set(Position.PREFIX_IN + key.substring(5), payload.getInt(key) > 0); + } else if (key.startsWith("io.DO")) { + position.set(Position.PREFIX_OUT + key.substring(5), payload.getInt(key) > 0); + } + } + + } else if (topic.contains("/sysinfo/")) { + + getLastLocation(position, new Date(payload.getInt("sysinfo.ts") * 1000L)); + + position.set("serial", payload.getString("sysinfo.serial_number")); + position.set(Position.KEY_VERSION_FW, payload.getString("sysinfo.firmware_version")); + } else { return null; |