aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-23 04:47:06 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-03-23 04:47:06 +1300
commit7e1da0e6223f1b07269fb3e43369e35c1f3baf3e (patch)
tree774695116a34695a1ff7fb29bf1d50ad5b6f5e35 /src/org/traccar
parentacc6a57605c81e9bb4c897b3da95aa8c875237f8 (diff)
downloadtrackermap-server-7e1da0e6223f1b07269fb3e43369e35c1f3baf3e.tar.gz
trackermap-server-7e1da0e6223f1b07269fb3e43369e35c1f3baf3e.tar.bz2
trackermap-server-7e1da0e6223f1b07269fb3e43369e35c1f3baf3e.zip
Additional Totem alarms
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 7d8a22f8c..8da188f60 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -132,7 +132,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN4 = new PatternBuilder()
.text("$$") // header
.number("dddd") // length
- .expression("A[ABC]") // type
+ .number("(xx)") // type
.number("(d+)|") // imei
.number("(x{8})") // status
.number("(dd)(dd)(dd)") // date (yymmdd)
@@ -164,7 +164,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
- private String decodeAlarm(Short value) {
+ private String decodeAlarm123(int value) {
switch (value) {
case 0x01:
return Position.ALARM_SOS;
@@ -183,10 +183,31 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm4(int value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_SOS;
+ case 0x02:
+ return Position.ALARM_OVERSPEED;
+ case 0x04:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 0x05:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 0x40:
+ return Position.ALARM_SHOCK;
+ case 0x42:
+ return Position.ALARM_ACCELERATION;
+ case 0x43:
+ return Position.ALARM_BRAKING;
+ default:
+ return null;
+ }
+ }
+
private boolean decode12(Position position, Parser parser, Pattern pattern) {
if (parser.hasNext()) {
- position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
+ position.set(Position.KEY_ALARM, decodeAlarm123(Short.parseShort(parser.next(), 16)));
}
DateBuilder dateBuilder = new DateBuilder();
int year = 0, month = 0, day = 0;
@@ -246,7 +267,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
private boolean decode3(Position position, Parser parser) {
if (parser.hasNext()) {
- position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
+ position.set(Position.KEY_ALARM, decodeAlarm123(Short.parseShort(parser.next(), 16)));
}
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
@@ -350,6 +371,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
+ if (pattern == PATTERN4) {
+ position.set(Position.KEY_ALARM, decodeAlarm4(parser.nextHexInt()));
+ }
+
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;