aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java138
1 files changed, 4 insertions, 134 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index aa85ea061..37d7ae718 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -53,14 +53,12 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TERMINAL_CONTROL = 0x8105;
public static final int MSG_TERMINAL_AUTH = 0x0102;
public static final int MSG_LOCATION_REPORT = 0x0200;
- public static final int MSG_ACCELERATION = 0x2070;
public static final int MSG_LOCATION_REPORT_2 = 0x5501;
public static final int MSG_LOCATION_REPORT_BLIND = 0x5502;
public static final int MSG_LOCATION_BATCH = 0x0704;
public static final int MSG_OIL_CONTROL = 0XA006;
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 RESULT_SUCCESS = 0;
@@ -73,7 +71,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
if (shortIndex) {
buf.writeByte(1);
} else {
- buf.writeShort(0);
+ buf.writeShort(1);
}
buf.writeBytes(data);
data.release();
@@ -137,11 +135,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private int readSignedWord(ByteBuf buf) {
- int value = buf.readUnsignedShort();
- return BitUtil.check(value, 15) ? -BitUtil.to(value, 15) : BitUtil.to(value, 15);
- }
-
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -183,7 +176,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, false, response), remoteAddress));
}
- } else if (type == MSG_TERMINAL_AUTH || type == MSG_HEARTBEAT || type == MSG_PHOTO) {
+ } else if (type == MSG_TERMINAL_AUTH || type == MSG_HEARTBEAT) {
sendGeneralResponse(channel, remoteAddress, id, type, index);
@@ -222,33 +215,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, false, response), remoteAddress));
}
- } else if (type == MSG_ACCELERATION) {
-
- Position position = new Position(getProtocolName());
- position.setDeviceId(deviceSession.getDeviceId());
-
- getLastLocation(position, null);
-
- StringBuilder data = new StringBuilder("[");
- while (buf.readableBytes() > 2) {
- buf.skipBytes(6); // time
- if (data.length() > 1) {
- data.append(",");
- }
- data.append("[");
- data.append(readSignedWord(buf));
- data.append(",");
- data.append(readSignedWord(buf));
- data.append(",");
- data.append(readSignedWord(buf));
- data.append("]");
- }
- data.append("]");
-
- position.set(Position.KEY_G_SENSOR, data.toString());
-
- return position;
-
}
return null;
@@ -266,76 +232,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private void decodeExtension(Position position, ByteBuf buf, int endIndex) {
- while (buf.readerIndex() < endIndex) {
- int type = buf.readUnsignedByte();
- int length = buf.readUnsignedByte();
- switch (type) {
- case 0x01:
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100L);
- break;
- case 0x02:
- position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedShort() * 0.1);
- break;
- case 0x03:
- position.set(Position.KEY_OBD_SPEED, buf.readUnsignedShort() * 0.1);
- break;
- case 0x80:
- position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
- break;
- case 0x81:
- position.set(Position.KEY_RPM, buf.readUnsignedShort());
- break;
- case 0x82:
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.1);
- break;
- case 0x83:
- position.set(Position.KEY_ENGINE_LOAD, buf.readUnsignedByte());
- break;
- case 0x84:
- position.set(Position.KEY_COOLANT_TEMP, buf.readUnsignedByte() - 40);
- break;
- case 0x85:
- position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort());
- break;
- case 0x86:
- position.set("intakeTemp", buf.readUnsignedByte() - 40);
- break;
- case 0x87:
- position.set("intakeFlow", buf.readUnsignedShort());
- break;
- case 0x88:
- position.set("intakePressure", buf.readUnsignedByte());
- break;
- case 0x89:
- position.set(Position.KEY_THROTTLE, buf.readUnsignedByte());
- break;
- case 0x8B:
- position.set(Position.KEY_VIN, buf.readCharSequence(17, StandardCharsets.US_ASCII).toString());
- break;
- case 0x8C:
- position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 100L);
- break;
- case 0x8D:
- position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedShort() * 1000L);
- break;
- case 0x8E:
- position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte());
- break;
- case 0xA0:
- String codes = buf.readCharSequence(length, StandardCharsets.US_ASCII).toString();
- position.set(Position.KEY_DTCS, codes.replace(',', ' '));
- break;
- case 0xCC:
- position.set(Position.KEY_ICCID, buf.readCharSequence(20, StandardCharsets.US_ASCII).toString());
- break;
- default:
- buf.skipBytes(length);
- break;
- }
- }
- }
-
private Position decodeLocation(DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
@@ -416,11 +312,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, Integer.parseInt(lockStatus.substring(2, 5)) * 0.01);
}
break;
- case 0x80:
- buf.readUnsignedByte(); // content
- endIndex = buf.writerIndex() - 2;
- decodeExtension(position, buf, endIndex);
- break;
case 0x91:
position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.1);
position.set(Position.KEY_RPM, buf.readUnsignedShort());
@@ -441,13 +332,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
Position.KEY_VIN, buf.readCharSequence(length, StandardCharsets.US_ASCII).toString());
}
break;
- case 0xA7:
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
- break;
- case 0xAC:
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
- break;
case 0xD0:
long userStatus = buf.readUnsignedInt();
if (BitUtil.check(userStatus, 3)) {
@@ -505,16 +389,6 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
}
}
break;
- case 0xED:
- String license = buf.readCharSequence(length, StandardCharsets.US_ASCII).toString().trim();
- position.set("driverLicense", license);
- break;
- case 0xEE:
- position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- break;
default:
break;
}
@@ -576,15 +450,11 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
List<Position> positions = new LinkedList<>();
int count = buf.readUnsignedShort();
- int locationType = buf.readUnsignedByte();
+ buf.readUnsignedByte(); // location type
for (int i = 0; i < count; i++) {
int endIndex = buf.readUnsignedShort() + buf.readerIndex();
- Position position = decodeLocation(deviceSession, buf);
- if (locationType > 0) {
- position.set(Position.KEY_ARCHIVE, true);
- }
- positions.add(position);
+ positions.add(decodeLocation(deviceSession, buf));
buf.readerIndex(endIndex);
}