aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-16 17:29:52 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-16 17:29:52 -0700
commit823795e40bf9b029a5c6c80fe58744244d24a5c7 (patch)
tree3b4076b3afaa6d05f7c1f32b98b03cf83ae84745 /src/main/java/org
parentbac331ebf2a67d0bdc4f96c78f0dfbeb0c4b6da6 (diff)
downloadtrackermap-server-823795e40bf9b029a5c6c80fe58744244d24a5c7.tar.gz
trackermap-server-823795e40bf9b029a5c6c80fe58744244d24a5c7.tar.bz2
trackermap-server-823795e40bf9b029a5c6c80fe58744244d24a5c7.zip
Add Concox/Jimi VL502 transparent data
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java157
1 files changed, 142 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index b0ad9a229..c280ee9b2 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -64,6 +64,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TIME_SYNC_REQUEST = 0x0109;
public static final int MSG_TIME_SYNC_RESPONSE = 0x8109;
public static final int MSG_PHOTO = 0x8888;
+ public static final int MSG_TRANSPARENT = 0x0900;
public static final int RESULT_SUCCESS = 0;
@@ -148,6 +149,17 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return BitUtil.check(value, 15) ? -BitUtil.to(value, 15) : BitUtil.to(value, 15);
}
+ private Date readDate(ByteBuf buf, TimeZone timeZone) {
+ DateBuilder dateBuilder = new DateBuilder(timeZone)
+ .setYear(BcdUtil.readInteger(buf, 2))
+ .setMonth(BcdUtil.readInteger(buf, 2))
+ .setDay(BcdUtil.readInteger(buf, 2))
+ .setHour(BcdUtil.readInteger(buf, 2))
+ .setMinute(BcdUtil.readInteger(buf, 2))
+ .setSecond(BcdUtil.readInteger(buf, 2));
+ return dateBuilder.getDate();
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -267,6 +279,10 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type == MSG_TRANSPARENT) {
+
+ return decodeTransparent(deviceSession, buf);
+
}
return null;
@@ -354,12 +370,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
-
- Position position = new Position(getProtocolName());
- position.setDeviceId(deviceSession.getDeviceId());
-
- position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedInt()));
+ private void decodeCoordinates(Position position, ByteBuf buf) {
int status = buf.readInt();
@@ -382,19 +393,21 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
} else {
position.setLongitude(lon);
}
+ }
+
+ private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedInt()));
+
+ decodeCoordinates(position, buf);
position.setAltitude(buf.readShort());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1));
position.setCourse(buf.readUnsignedShort());
-
- DateBuilder dateBuilder = new DateBuilder(deviceSession.getTimeZone())
- .setYear(BcdUtil.readInteger(buf, 2))
- .setMonth(BcdUtil.readInteger(buf, 2))
- .setDay(BcdUtil.readInteger(buf, 2))
- .setHour(BcdUtil.readInteger(buf, 2))
- .setMinute(BcdUtil.readInteger(buf, 2))
- .setSecond(BcdUtil.readInteger(buf, 2));
- position.setTime(dateBuilder.getDate());
+ position.setTime(readDate(buf, deviceSession.getTimeZone()));
if (buf.readableBytes() == 20) {
@@ -609,4 +622,118 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
+ private Position decodeTransparent(DeviceSession deviceSession, ByteBuf buf) {
+
+ int type = buf.readUnsignedByte();
+
+ if (type == 0xF0) {
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ Date time = readDate(buf, deviceSession.getTimeZone());
+
+ if (buf.readUnsignedByte() > 0) {
+ position.set(Position.KEY_ARCHIVE, true);
+ }
+
+ buf.readUnsignedByte(); // vehicle type
+
+ int count;
+ int subtype = buf.readUnsignedByte();
+ switch (subtype) {
+ case 0x01:
+ count = buf.readUnsignedByte();
+ for (int i = 0; i < count; i++) {
+ int id = buf.readUnsignedShort();
+ int length = buf.readUnsignedByte();
+ switch (id) {
+ case 0x0102:
+ case 0x0528:
+ case 0x0546:
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100);
+ break;
+ case 0x0103:
+ position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedInt() * 0.01);
+ break;
+ case 0x052A:
+ position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedShort() * 0.01);
+ break;
+ case 0x0105:
+ case 0x052C:
+ position.set(Position.KEY_FUEL_USED, buf.readUnsignedInt() * 0.01);
+ break;
+ case 0x014A:
+ case 0x0537:
+ case 0x0538:
+ case 0x0539:
+ position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort() * 0.01);
+ break;
+ default:
+ switch (length) {
+ case 1:
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedByte());
+ break;
+ case 2:
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedShort());
+ break;
+ case 4:
+ position.set(Position.PREFIX_IO + id, buf.readUnsignedInt());
+ break;
+ default:
+ buf.skipBytes(length);
+ break;
+ }
+ break;
+ }
+ }
+ decodeCoordinates(position, buf);
+ position.setTime(time);
+ break;
+ case 0x03:
+ count = buf.readUnsignedByte();
+ for (int i = 0; i < count; i++) {
+ int id = buf.readUnsignedShort();
+ int length = buf.readUnsignedByte();
+ switch (id) {
+ case 0x1A:
+ position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION);
+ break;
+ case 0x1B:
+ position.set(Position.KEY_ALARM, Position.ALARM_BRAKING);
+ break;
+ case 0x1C:
+ position.set(Position.KEY_ALARM, Position.ALARM_CORNERING);
+ break;
+ case 0x1D:
+ case 0x1E:
+ case 0x1F:
+ position.set(Position.KEY_ALARM, Position.ALARM_LANE_CHANGE);
+ break;
+ case 0x23:
+ position.set(Position.KEY_ALARM, Position.ALARM_FATIGUE_DRIVING);
+ break;
+ default:
+ break;
+ }
+ buf.skipBytes(length);
+ }
+ decodeCoordinates(position, buf);
+ position.setTime(time);
+ break;
+ case 0x0B:
+ if (buf.readUnsignedByte() > 0) {
+ position.set(Position.KEY_VIN, buf.readCharSequence(17, StandardCharsets.US_ASCII).toString());
+ }
+ getLastLocation(position, time);
+ break;
+ default:
+ return null;
+ }
+
+ return position;
+ }
+
+ return null;
+ }
+
}