Skip to content

Commit

Permalink
Add Space10X temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jan 11, 2021
1 parent 16c5d57 commit 9d91c66
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@ private Object decodeBasicOther(

} else if (isSupported(type)) {

decodeBasicUniversal(buf, deviceSession, type, position);
if (type == MSG_STATUS && buf.readableBytes() == 22) {
decodeHeartbeat(buf, position);
} else {
decodeBasicUniversal(buf, deviceSession, type, position);
}

} else if (type == MSG_ALARM) {
boolean extendedAlarm = dataLength > 7;
Expand Down Expand Up @@ -822,6 +826,27 @@ private Object decodeBasicOther(
return position;
}

private void decodeHeartbeat(ByteBuf buf, Position position) {

getLastLocation(position, null);

buf.readUnsignedByte(); // information content
buf.readUnsignedShort(); // satellites
buf.readUnsignedByte(); // alarm
buf.readUnsignedByte(); // language
buf.readUnsignedByte(); // battery
buf.readUnsignedByte(); // working mode
buf.readUnsignedShort(); // working voltage
buf.readUnsignedByte(); // reserved
buf.readUnsignedShort(); // working times
buf.readUnsignedShort(); // working time

int value = buf.readUnsignedShort();
double temperature = BitUtil.to(value, 15) * 0.1;
position.set(Position.PREFIX_TEMP + 1, BitUtil.check(value, 15) ? temperature : -temperature);

}

private void decodeBasicUniversal(ByteBuf buf, DeviceSession deviceSession, int type, Position position) {

if (hasGps(type)) {
Expand Down

0 comments on commit 9d91c66

Please sign in to comment.