Fix Jimi JC261/JC400 alarm message

This commit is contained in:
Anton Tananaev 2024-11-17 08:27:28 -08:00
parent 747c3a26ed
commit a0c77b0c47
2 changed files with 15 additions and 6 deletions

View File

@ -270,12 +270,12 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
public static boolean decodeGps(Position position, ByteBuf buf, boolean hasLength, TimeZone timezone) {
return decodeGps(position, buf, hasLength, true, true, false, timezone);
return decodeGps(position, buf, hasLength, true, true, false, false, timezone);
}
public static boolean decodeGps(
Position position, ByteBuf buf, boolean hasLength, boolean hasSatellites,
boolean hasSpeed, boolean longSpeed, TimeZone timezone) {
boolean hasSpeed, boolean longSpeed, boolean swapFlags, TimeZone timezone) {
DateBuilder dateBuilder = new DateBuilder(timezone)
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
@ -293,12 +293,18 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
double latitude = buf.readUnsignedInt() / 60.0 / 30000.0;
double longitude = buf.readUnsignedInt() / 60.0 / 30000.0;
int flags = 0;
if (swapFlags) {
flags = buf.readUnsignedShort();
}
if (hasSpeed) {
position.setSpeed(UnitsConverter.knotsFromKph(
longSpeed ? buf.readUnsignedShort() : buf.readUnsignedByte()));
}
if (!swapFlags) {
flags = buf.readUnsignedShort();
}
int flags = buf.readUnsignedShort();
position.setCourse(BitUtil.to(flags, 10));
position.setValid(BitUtil.check(flags, 12));
@ -988,15 +994,15 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_ALARM) {
boolean jc400 = variant == Variant.JC400;
boolean extendedAlarm = dataLength > 7;
if (extendedAlarm) {
if (variant == Variant.JC400) {
if (jc400) {
buf.readUnsignedShort(); // marker
buf.readUnsignedByte(); // version
}
decodeGps(
position, buf, false,
variant == Variant.JC400, variant == Variant.JC400, variant == Variant.JC400,
position, buf, false, jc400, jc400, jc400, jc400,
deviceSession.get(DeviceSession.KEY_TIMEZONE));
} else {
DateBuilder dateBuilder = new DateBuilder((TimeZone) deviceSession.get(DeviceSession.KEY_TIMEZONE))

View File

@ -17,6 +17,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780D01086471700328358100093F040D0A"));
verifyPosition(decoder, binary(
"78789795ffff01180b0d031406da04b5ab0d08813df01ca9002c008a9200004556454e545f3836323739383035323432393038375f30303030303030305f323032345f31315f31325f32325f32305f30365f495f35362e6d70342c4556454e545f3836323739383035323432393038375f30303030303030305f323032345f31315f31325f32325f32305f30365f465f35352e6d70340037d45b0d0a"));
verifyPosition(decoder, binary(
"787840a2180b0f0f3407cf00602cd208354064001c6a02dc650000698100000000095674c9114100002a04000100004b31000000000863829079286793020001a22a8f0d0a"));