aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TotemProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/TotemProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 97201521d..fed1c3bd8 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -159,30 +159,13 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
- private String decodeAlarm(String value) {
+ private String decodeAlarm(Short value) {
switch (value) {
- case "01": return Position.ALARM_SOS;
- case "49": return Position.PREFIX_BUTTON + "A" + Position.ENDING_PRESSED;
- case "09": return Position.ALARM_SHUTDOWN;
- case "10": return Position.ALARM_LOW_BATTERY;
- case "11": return Position.ALARM_OVERSPEED;
- case "13": return Position.ALARM_OVERSPEED_END;
- case "30": return Position.ALARM_PARKING;
- case "42": return Position.ALARM_GEOFENCE_EXIT;
- case "43": return Position.ALARM_GEOFENCE_ENTER;
- case "50": return Position.PREFIX_IO + "1" + Position.ENDING_CLOSE;
- case "51": return Position.PREFIX_IO + "1" + Position.ENDING_OPEN;
- case "52": return Position.PREFIX_IO + "2" + Position.ENDING_CLOSE;
- case "53": return Position.PREFIX_IO + "2" + Position.ENDING_OPEN;
- case "54": return Position.PREFIX_IO + "3" + Position.ENDING_CLOSE;
- case "55": return Position.PREFIX_IO + "3" + Position.ENDING_OPEN;
- case "56": return Position.PREFIX_IO + "4" + Position.ENDING_CLOSE;
- case "57": return Position.PREFIX_IO + "4" + Position.ENDING_OPEN;
- case "60": return Position.ALARM_CHARGE_BEGIN;
- case "61": return Position.ALARM_CHARGE_END;
- case "66": return Position.ALARM_RFID_NEW;
- case "91": return Position.ALARM_SLEEP_INTO;
- case "92": return Position.ALARM_SLEEP_FROM;
+ case 0x01: return Position.ALARM_SOS;
+ case 0x10: return Position.ALARM_LOW_BATTERY;
+ case 0x11: return Position.ALARM_OVERSPEED;
+ case 0x42: return Position.ALARM_GEOFENCE_EXIT;
+ case 0x43: return Position.ALARM_GEOFENCE_ENTER;
default: return null;
}
}
@@ -221,9 +204,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
if (pattern == PATTERN1 || pattern == PATTERN2) {
- String alarm = decodeAlarm(parser.next());
- if (alarm != null) {
- position.set(Position.KEY_ALARM, alarm);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
}
DateBuilder dateBuilder = new DateBuilder();
int year = 0;
@@ -267,9 +249,8 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, parser.next());
} else if (pattern == PATTERN3) {
- String alarm = decodeAlarm(parser.next());
- if (alarm != null) {
- position.set(Position.KEY_ALARM, alarm);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16)));
}
DateBuilder dateBuilder = new DateBuilder()
.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt())