aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Avl301ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/BlackKiteProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/CarTrackProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CarcellProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java19
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java39
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java11
14 files changed, 69 insertions, 80 deletions
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index dd0f54af0..90e8ca103 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -169,7 +169,9 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
short status = buf.readUnsignedByte();
- position.set(Position.KEY_ALARM, BitUtil.check(status, 7));
+ if (BitUtil.check(status, 7)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
+ }
position.set(Position.KEY_BATTERY, BitUtil.to(status, 7));
buf.skipBytes(2); // remaining time
diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
index 4d2dfe126..818dd94df 100644
--- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
@@ -123,7 +123,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_LAC, buf.readUnsignedShort());
position.set(Position.KEY_CID, buf.readUnsignedMedium());
- position.set(Position.KEY_ALARM, true);
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
int flags = buf.readUnsignedByte();
position.set("acc", (flags & 0x2) != 0);
diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
index 92179072a..c2c051884 100644
--- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
+++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
@@ -122,7 +122,9 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
case TAG_STATUS:
int status = buf.readUnsignedShort();
position.set(Position.KEY_IGNITION, BitUtil.check(status, 9));
- position.set(Position.KEY_ALARM, BitUtil.check(status, 15));
+ if (BitUtil.check(status, 15)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
+ }
position.set(Position.KEY_POWER, BitUtil.check(status, 2));
break;
diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
index e0fd60b15..45f1b0812 100644
--- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
@@ -99,7 +99,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder {
odometer = odometer.replace("?", "F");
position.set(Position.KEY_ODOMETER, Integer.parseInt(odometer, 16));
- position.set(Position.KEY_ALARM, parser.next());
+ parser.next(); //there is no meaningful alarms
position.set(Position.PREFIX_ADC + 1, parser.next());
return position;
diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java
index 7aacfa4d0..e9b6cdf28 100644
--- a/src/org/traccar/protocol/CarcellProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java
@@ -143,7 +143,9 @@ public class CarcellProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // panic button status
String painelStatus = parser.next();
- position.set(Position.KEY_ALARM, painelStatus.equals("1"));
+ if (painelStatus.equals("1")) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
+ }
position.set("painel", painelStatus.equals("2"));
Double mainVoltage = parser.nextDouble() / 100d;
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 821cf2d21..9d3fda345 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -102,6 +102,23 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String decodeAlarm(String value) {
+ if (value == "tracker") {
+ return null;
+ } else if (value == "help me") {
+ return Position.ALARM_SOS;
+ } else if (value == "low battery") {
+ return Position.ALARM_LOW_BATTERY;
+ } else if (value == "stockade") {
+ return Position.ALARM_GEOFENCE;
+ } else if (value == "move") {
+ return Position.ALARM_MOVEMENT;
+ } else if (value == "speed") {
+ return Position.ALARM_OVERSPEED;
+ }
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -195,7 +212,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
String alarm = parser.next();
- position.set(Position.KEY_ALARM, alarm);
+ position.set(Position.KEY_ALARM, decodeAlarm(alarm));
if (channel != null && alarm.equals("help me")) {
channel.write("**,imei:" + imei + ",E;", remoteAddress);
}
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 3e875086e..d69f425ab 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -154,7 +154,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void decodeStatus(Position position, ChannelBuffer buf) {
- position.set(Position.KEY_ALARM, true);
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
int flags = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index bb18a68e2..fc6c9f17c 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -65,20 +65,15 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
private void processStatus(Position position, long status) {
if (!BitUtil.check(status, 0) || !BitUtil.check(status, 1)
- || !BitUtil.check(status, 3) || !BitUtil.check(status, 4) || !BitUtil.check(status, 7)) {
+ || !BitUtil.check(status, 2)) {
if (!BitUtil.check(status, 0)) {
position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
} else if (!BitUtil.check(status, 1)) {
- position.set(Position.KEY_ALARM, "robbery");
- } else if (!BitUtil.check(status, 3)) {
- position.set(Position.KEY_ALARM, "illegal ignition");
- } else if (!BitUtil.check(status, 4)) {
- position.set(Position.KEY_ALARM, "entering");
- } else if (!BitUtil.check(status, 7)) {
- position.set(Position.KEY_ALARM, "out");
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ } else if (!BitUtil.check(status, 2)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
}
-
}
position.set(Position.KEY_IGNITION, BitUtil.check(status, 10));
position.set(Position.KEY_STATUS, status);
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 7e0b54456..372b4cac1 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -151,7 +151,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.set(Position.KEY_ALARM, true);
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 196b24d27..f23641ddb 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -150,26 +150,14 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
return server;
}
-
+
private String decodeAlarm(short value) {
switch (value) {
case 0x01: return Position.ALARM_SOS;
- case 0x02: return Position.PREFIX_BUTTON + "B" + Position.ENDING_PRESSED;
- case 0x03: return Position.PREFIX_BUTTON + "C" + Position.ENDING_PRESSED;
- case 0x04: return Position.PREFIX_IO + "4" + Position.ENDING_ACTIVE;
- case 0x05: return Position.PREFIX_IO + "5" + Position.ENDING_ACTIVE;
case 0x10: return Position.ALARM_LOW_BATTERY;
case 0x11: return Position.ALARM_OVERSPEED;
case 0x12: return Position.ALARM_MOVEMENT;
case 0x13: return Position.ALARM_GEOFENCE_ENTER;
- case 0x14: return Position.ALARM_TRACKER_ON;
- case 0x15: return Position.ALARM_GPS_BLIND_ENTER;
- case 0x16: return Position.ALARM_GPS_BLIND_EXIT;
- case 0x31: return Position.ALARM_SOS + Position.ENDING_RELEASED;
- case 0x32: return Position.PREFIX_BUTTON + "B" + Position.ENDING_RELEASED;
- case 0x33: return Position.PREFIX_BUTTON + "C" + Position.ENDING_RELEASED;
- case 0x34: return Position.PREFIX_IO + "4" + Position.ENDING_INACTIVE;
- case 0x35: return Position.PREFIX_IO + "5" + Position.ENDING_INACTIVE;
case 0x50: return Position.ALARM_POWER_OFF;
case 0x53: return Position.ALARM_GPS_ANTENNA_CUT;
default: return null;
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index 7071b9625..5b4533422 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -91,16 +91,14 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
position.setValid(BitUtil.check(buf.readUnsignedByte(), 0));
short alarm = buf.readUnsignedByte();
- if (alarm != 0x80) {
- if (alarm == 1) {
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- } else if (alarm == 2) {
- position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
- } else if (alarm == 3) {
- position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT);
- } else if (alarm == 9) {
- position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF);
- }
+ if (alarm == 1) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ } else if (alarm == 2) {
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
+ } else if (alarm == 3) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT);
+ } else if (alarm == 9) {
+ position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF);
}
if (newFormat) {
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index a76c208b5..72ecdc2de 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -75,6 +75,19 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 0: return Position.ALARM_OIL_CUT;
+ case 1: return Position.ALARM_ACCIDENT;
+ case 2: return Position.ALARM_SOS;
+ case 3: return Position.ALARM_VIBRATION;
+ case 4: return Position.ALARM_LOW_SPEED;
+ case 5: return Position.ALARM_OVERSPEED;
+ case 6: return Position.ALARM_GEOFENCE_EXIT;
+ default: return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -160,7 +173,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
int alarm = sentence.indexOf("BO01");
if (alarm != -1) {
- position.set(Position.KEY_ALARM, Integer.parseInt(sentence.substring(alarm + 4, alarm + 5)));
+ position.set(Position.KEY_ALARM, decodeAlarm(Integer.parseInt(sentence.substring(alarm + 4, alarm + 5))));
}
DateBuilder dateBuilder = new DateBuilder();
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())
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index 7abe9fb70..0cde5c0d4 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -134,12 +134,6 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(alarm, 10)) {
return Position.ALARM_SOS;
}
- if (BitUtil.check(alarm, 11)) {
- return Position.ALARM_ODB;
- }
- if (BitUtil.check(alarm, 15)) {
- return Position.ALARM_POWER_LOW;
- }
return null;
}
@@ -209,10 +203,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
int status = buf.readUnsignedShort();
position.set(Position.KEY_IGNITION, BitUtil.check(status, 9));
position.set(Position.KEY_STATUS, status);
- String alarm = decodeAlarm(buf.readUnsignedShort());
- if (alarm != null) {
- position.set(Position.KEY_ALARM, alarm);
- }
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedShort()));
break;
case DATA_ODOMETER: