aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-02-06 23:16:11 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-02-06 23:16:11 -0800
commite193ae4656a6e0555565b35e8c657ae0777b156b (patch)
tree7e81a648f50ca07647361cd550efd13b8f1ff79b /src/main/java
parenteaacf2e139b15e8d8c25f15b2d1559245184fffa (diff)
downloadtraccar-server-e193ae4656a6e0555565b35e8c657ae0777b156b.tar.gz
traccar-server-e193ae4656a6e0555565b35e8c657ae0777b156b.tar.bz2
traccar-server-e193ae4656a6e0555565b35e8c657ae0777b156b.zip
Decode additional data
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/BlueProtocolDecoder.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/BlueProtocolDecoder.java b/src/main/java/org/traccar/protocol/BlueProtocolDecoder.java
index 61edcd101..f35ac6fbe 100644
--- a/src/main/java/org/traccar/protocol/BlueProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/BlueProtocolDecoder.java
@@ -66,6 +66,19 @@ public class BlueProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 1:
+ return Position.ALARM_SOS;
+ case 8:
+ return Position.ALARM_OVERSPEED;
+ case 19:
+ return Position.ALARM_LOW_POWER;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -123,10 +136,25 @@ public class BlueProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // status 2
buf.readUnsignedByte(); // status 3
- buf.readUnsignedByte(); // status 4
+
+ status = buf.readUnsignedByte(); // status 4
+ int ignition = BitUtil.between(status, 2, 4);
+ if (ignition == 0b01) {
+ position.set(Position.KEY_IGNITION, false);
+ }
+ if (ignition == 0b10) {
+ position.set(Position.KEY_IGNITION, true);
+ }
+
buf.readUnsignedByte(); // status 5
buf.readUnsignedByte(); // status 6
+ position.set(Position.KEY_STATUS, buf.readUnsignedShort());
+
+ } else if (type == 0x81) {
+
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
+
} else if (type == 0x84) {
sendResponse(channel, index);