aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-18 15:52:36 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-02-18 15:52:54 +1300
commit4753e462767812712bafbc8e9985f355021c6f16 (patch)
tree98e1821ec7b579c1a91332da2b8b62cc1ad886a8
parent5b75e0a58fbcc11a1c66448bfbd9d3466b015668 (diff)
downloadtrackermap-server-4753e462767812712bafbc8e9985f355021c6f16.tar.gz
trackermap-server-4753e462767812712bafbc8e9985f355021c6f16.tar.bz2
trackermap-server-4753e462767812712bafbc8e9985f355021c6f16.zip
Support some Cellocator alarms
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolDecoder.java18
-rw-r--r--test/org/traccar/protocol/CellocatorProtocolDecoderTest.java6
2 files changed, 22 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
index 14325e619..7df8cad8a 100644
--- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,6 +68,19 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm(short reason) {
+ switch (reason) {
+ case 70:
+ return Position.ALARM_SOS;
+ case 80:
+ return Position.ALARM_POWER_CUT;
+ case 81:
+ return Position.ALARM_LOW_POWER;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -106,7 +119,8 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
operator += buf.readUnsignedByte();
buf.readUnsignedByte(); // reason data
- buf.readUnsignedByte(); // reason
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
+
buf.readUnsignedByte(); // mode
buf.readUnsignedInt(); // IO
diff --git a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
index fe03bc3d5..cdda0fca7 100644
--- a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
@@ -13,6 +13,12 @@ public class CellocatorProtocolDecoderTest extends ProtocolTest {
CellocatorProtocolDecoder decoder = new CellocatorProtocolDecoder(new CellocatorProtocol());
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "4D434750008AD01500080103011804000000460020000000005E750000000000000000000000C34300040204DA4DA30367195703E803000000000000000001030F0802E10778"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "4D434750008AD01500080102011804000000360060000000005E750000000000000000000000C24300040204DA4DA30367195703E80300000000000000003B020F0802E107DF"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"4D4347500006000000081A02021204000000210062300000006B00E100000000000000000000E5A100040206614EA303181A57034E1200000000000000001525071403D60749"));
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,