Skip to content

Commit

Permalink
Support NatureLink parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jan 19, 2024
1 parent bb8ff94 commit 77a2b4f
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,12 @@ private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
case 0x02:
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedShort() * 0.1);
break;
case 0x25:
position.set(Position.KEY_INPUT, buf.readUnsignedInt());
break;
case 0x2b:
position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt());
position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
break;
case 0x30:
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
Expand Down Expand Up @@ -517,6 +521,36 @@ private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
buf.readUnsignedByte(); // rssi
}
break;
case 0x64:
buf.readUnsignedInt(); // alarm serial number
buf.readUnsignedByte(); // alarm status
position.set("adasAlarm", buf.readUnsignedByte());
break;
case 0x65:
buf.readUnsignedInt(); // alarm serial number
buf.readUnsignedByte(); // alarm status
position.set("dmsAlarm", buf.readUnsignedByte());
break;
case 0x70:
buf.readUnsignedInt(); // alarm serial number
buf.readUnsignedByte(); // alarm status
switch (buf.readUnsignedByte()) {
case 0x01:
position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION);
break;
case 0x02:
position.set(Position.KEY_ALARM, Position.ALARM_BRAKING);
break;
case 0x03:
position.set(Position.KEY_ALARM, Position.ALARM_CORNERING);
break;
case 0x16:
position.set(Position.KEY_ALARM, Position.ALARM_ACCIDENT);
break;
default:
break;
}
break;
case 0x69:
position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
break;
Expand Down Expand Up @@ -571,7 +605,11 @@ private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
break;
case 0xD4:
case 0xE1:
position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
if (length == 1) {
position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
} else {
position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(buf.readUnsignedInt()));
}
break;
case 0xD5:
if (length == 2) {
Expand All @@ -594,6 +632,9 @@ private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
position.set(Position.KEY_MOTION, BitUtil.check(deviceStatus, 2));
position.set("cover", BitUtil.check(deviceStatus, 3));
break;
case 0xE2:
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedInt() * 0.1);
break;
case 0xE6:
while (buf.readerIndex() < endIndex) {
int sensorIndex = buf.readUnsignedByte();
Expand Down

0 comments on commit 77a2b4f

Please sign in to comment.