Support TLW2-12BL format

This commit is contained in:
Anton Tananaev 2021-10-11 23:13:02 -07:00
parent d6d8a33bd2
commit 0061b510de
2 changed files with 18 additions and 6 deletions

View File

@ -58,6 +58,8 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_DRIVER_BEHAVIOR_1 = 0x05; // 0x2626
public static final int MSG_DRIVER_BEHAVIOR_2 = 0x06; // 0x2626
public static final int MSG_BLE = 0x10;
public static final int MSG_GPS_2 = 0x13;
public static final int MSG_ALARM_2 = 0x14;
public static final int MSG_COMMAND = 0x81;
private void sendResponse(Channel channel, short header, int type, int index, ByteBuf imei, int alarm) {
@ -134,11 +136,11 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
return null;
}
if (type != MSG_GPS && type != MSG_ALARM) {
if (type != MSG_GPS && type != MSG_GPS_2 && type != MSG_ALARM) {
sendResponse(channel, header, type, index, imei, 0);
}
if (type == MSG_GPS || type == MSG_ALARM) {
if (type == MSG_GPS || type == MSG_GPS_2 ||type == MSG_ALARM || type == MSG_ALARM_2) {
return decodePosition(channel, deviceSession, buf, type, index, imei);
@ -343,12 +345,19 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.set("ac", BitUtil.check(io, 13));
position.set(Position.PREFIX_IN + 3, BitUtil.check(io, 12));
position.set(Position.PREFIX_IN + 4, BitUtil.check(io, 11));
position.set(Position.PREFIX_OUT + 1, BitUtil.check(io, 7));
position.set(Position.PREFIX_OUT + 2, BitUtil.check(io, 8));
position.set(Position.PREFIX_OUT + 3, BitUtil.check(io, 9));
if (type == MSG_GPS_2 || type == MSG_ALARM_2) {
position.set(Position.KEY_OUTPUT, buf.readUnsignedByte());
buf.readUnsignedByte(); // reserved
} else {
position.set(Position.PREFIX_OUT + 1, BitUtil.check(io, 7));
position.set(Position.PREFIX_OUT + 2, BitUtil.check(io, 8));
position.set(Position.PREFIX_OUT + 3, BitUtil.check(io, 9));
}
if (header != 0x2626) {
for (int i = 1; i <= 2; i++) {
int adcCount = type == MSG_GPS_2 || type == MSG_ALARM_2 ? 5 : 2;
for (int i = 1; i <= adcCount; i++) {
String value = ByteBufUtil.hexDump(buf.readSlice(2));
if (!value.equals("ffff")) {
position.set(Position.PREFIX_ADC + i, Integer.parseInt(value) * 0.01);

View File

@ -17,6 +17,9 @@ public class T800xProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, binary(
"27271000277bb30860112047066487210407022840000004e6215130c50fff620a0c1518000156"));
verifyPosition(decoder, binary(
"252514005901c00867730050941347001e46501e03e80064f2c0001401000041000000000000000000ffffffff160000034ec40021100719073800000000c2fb90c21291fd400000000003961237ffff0000002effffffffff"));
verifyPosition(decoder, binary(
"27270200497d880860112047066487470021040702270500006442d4e2e342f671b441000000008000008080881dff3900000384700640003c0000001e1e00641e30d2800000000000"));