aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-12-24 18:04:30 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-12-24 18:04:30 -0800
commitfabe54f1e90a068ed2db756ec6fc5d724c705e45 (patch)
tree93e760203eb24b8a57a5adc3f927390994bd5ce8 /src
parentb9d7296716168154ced0ad44f4ee8b334944ab72 (diff)
downloadtrackermap-server-fabe54f1e90a068ed2db756ec6fc5d724c705e45.tar.gz
trackermap-server-fabe54f1e90a068ed2db756ec6fc5d724c705e45.tar.bz2
trackermap-server-fabe54f1e90a068ed2db756ec6fc5d724c705e45.zip
Support more BLE sensors
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java2
-rw-r--r--src/main/java/org/traccar/protocol/T800xProtocolDecoder.java54
-rw-r--r--src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java3
3 files changed, 54 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
index 215aa0211..5aaacf5a1 100644
--- a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -500,7 +500,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_AXLE_WEIGHT, buf.readUnsignedShort() * 2);
break;
case 0x04:
- position.set("tyrePressure", buf.readUnsignedByte() * 10);
+ position.set("tirePressure", buf.readUnsignedByte() * 10);
position.set("pneumaticPressure", buf.readUnsignedByte() * 5);
break;
case 0x05:
diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
index 0c75a8997..8a047fd38 100644
--- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java
@@ -191,10 +191,56 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0);
- int dataCode = buf.readUnsignedShort();
-
- if (dataCode == 3) {
- position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(6)));
+ switch (buf.readUnsignedShort()) {
+ case 0x01:
+ position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 1.22);
+ position.set("tirePressure", buf.readUnsignedByte() * 1.527 * 2);
+ position.set("tagTemp", buf.readUnsignedByte() - 55);
+ position.set("tagStatus", buf.readUnsignedByte());
+ break;
+ case 0x02:
+ position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", BcdUtil.readInteger(buf, 2) * 0.1);
+ switch (buf.readUnsignedByte()) {
+ case 0:
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ break;
+ case 1:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ default:
+ break;
+ }
+ break;
+ case 0x03:
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", BcdUtil.readInteger(buf, 2) * 0.1);
+ if (buf.readUnsignedByte() == 1) {
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ }
+ break;
+ case 0x04:
+ position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
+ buf.readUnsignedByte(); // battery level
+ position.set(Position.KEY_DEVICE_TEMP, buf.readUnsignedShort() * 0.01);
+ position.set("humidity", buf.readUnsignedShort() * 0.01);
+ position.set("lightSensor", BitUtil.to(buf.readUnsignedByte(), 15));
+ break;
+ case 0x05:
+ position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
+ position.set(Position.KEY_DEVICE_TEMP, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_DOOR, buf.readUnsignedByte() > 0);
+ break;
+ case 0x06:
+ position.set("tagId", ByteBufUtil.hexDump(buf.readSlice(6)));
+ position.set("tagBattery", buf.readUnsignedByte() * 0.01 + 2);
+ position.set(Position.KEY_OUTPUT, buf.readUnsignedByte() > 0);
+ break;
+ default:
+ break;
}
sendResponse(channel, header, type, index, imei, 0);
diff --git a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
index d2532d091..9e443309a 100644
--- a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class T800xProtocolDecoderTest extends ProtocolTest {
T800xProtocolDecoder decoder = new T800xProtocolDecoder(null);
+ verifyAttributes(decoder, binary(
+ "252510003100180865284041080544201221191023000003ffff9702eff820014700000000912a6ac26dff09c200000000"));
+
verifyAttribute(decoder, binary(
"2727020049052e086528404072393849002008060310110000000068b7c8c286eaa441000000008000008100001617410700019ce782b0001e000002581e00000530d4801f00000000"),
Position.KEY_BATTERY_LEVEL, 100);