aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-10-29 23:27:33 -0700
committerGitHub <noreply@github.com>2020-10-29 23:27:33 -0700
commit2f6d252cca600f1a9cf326b13c614d46ee2197b5 (patch)
tree45e7dfac1d35916f752e11eac1b6838dcc12a51e /src/main/java/org
parent36d5da225b4c9e986a8cae1af4133204b148c885 (diff)
parent11c243661e8c81b7244393277dc257952ff9c4a2 (diff)
downloadtrackermap-server-2f6d252cca600f1a9cf326b13c614d46ee2197b5.tar.gz
trackermap-server-2f6d252cca600f1a9cf326b13c614d46ee2197b5.tar.bz2
trackermap-server-2f6d252cca600f1a9cf326b13c614d46ee2197b5.zip
Merge pull request #4595 from elderstudios/feat/jc400-device-alerts
Added support for JC400 alarm messages
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 7b510639a..e003db51a 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -213,6 +213,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
public static boolean decodeGps(Position position, ByteBuf buf, boolean hasLength, TimeZone timezone) {
+ return decodeGps(position, buf, hasLength, true, true, timezone);
+ }
+
+ public static boolean decodeGps(Position position, ByteBuf buf, boolean hasLength, boolean hasSatellites,
+ boolean hasSpeed, TimeZone timezone) {
DateBuilder dateBuilder = new DateBuilder(timezone)
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
@@ -223,11 +228,16 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return false;
}
- position.set(Position.KEY_SATELLITES, BitUtil.to(buf.readUnsignedByte(), 4));
+ if (hasSatellites) {
+ position.set(Position.KEY_SATELLITES, BitUtil.to(buf.readUnsignedByte(), 4));
+ }
double latitude = buf.readUnsignedInt() / 60.0 / 30000.0;
double longitude = buf.readUnsignedInt() / 60.0 / 30000.0;
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+
+ if (hasSpeed) {
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+ }
int flags = buf.readUnsignedShort();
position.setCourse(BitUtil.to(flags, 10));
@@ -732,16 +742,20 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
decodeBasicUniversal(buf, deviceSession, type, position);
} else if (type == MSG_ALARM) {
-
- DateBuilder dateBuilder = new DateBuilder(deviceSession.getTimeZone())
- .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
- .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
-
- getLastLocation(position, dateBuilder.getDate());
-
+ boolean extendedAlarm = dataLength > 7;
+ if (extendedAlarm) {
+ decodeGps(position, buf, false, false, false, deviceSession.getTimeZone());
+ } else {
+ DateBuilder dateBuilder = new DateBuilder(deviceSession.getTimeZone())
+ .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
+ getLastLocation(position, dateBuilder.getDate());
+ }
short alarmType = buf.readUnsignedByte();
-
switch (alarmType) {
+ case 0x01:
+ position.set(Position.KEY_ALARM, extendedAlarm ? Position.ALARM_SOS : Position.ALARM_GENERAL);
+ break;
case 0x80:
position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
break;
@@ -757,13 +771,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case 0x92:
position.set(Position.KEY_ALARM, Position.ALARM_CORNERING);
break;
+ case 0x93:
+ position.set(Position.KEY_ALARM, Position.ALARM_ACCIDENT);
+ break;
default:
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
break;
}
-
- position.set("alarmValue", buf.readShort());
-
} else {
if (dataLength > 0) {