diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/TotemProtocolDecoder.java | 33 |
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; |