diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-05 23:21:24 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-11-05 23:21:24 -0800 |
commit | a41841ac8ce200aa0c3836f4c35ce4524eef077c (patch) | |
tree | 12877213fc9f53f8eeec14c8320e899fe25d39c9 /src/main | |
parent | cce68c7e6c116dc23a66dde7ca5476ad7ea575b2 (diff) | |
download | trackermap-server-a41841ac8ce200aa0c3836f4c35ce4524eef077c.tar.gz trackermap-server-a41841ac8ce200aa0c3836f4c35ce4524eef077c.tar.bz2 trackermap-server-a41841ac8ce200aa0c3836f4c35ce4524eef077c.zip |
Decode temperature and humidity
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/UproProtocolDecoder.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/UproProtocolDecoder.java b/src/main/java/org/traccar/protocol/UproProtocolDecoder.java index 873b22006..a17003fc8 100644 --- a/src/main/java/org/traccar/protocol/UproProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/UproProtocolDecoder.java @@ -171,12 +171,31 @@ public class UproProtocolDecoder extends BaseProtocolDecoder { position.setAltitude( Integer.parseInt(data.readSlice(6).toString(StandardCharsets.US_ASCII)) * 0.1); break; + case 'J': + if (data.readableBytes() == 6) { + char index = (char) data.readUnsignedByte(); + int status = data.readUnsignedByte(); + double value = Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)) * 0.1; + if (BitUtil.check(status, 0)) { + value = -value; + } + position.set(Position.PREFIX_TEMP + index, value); + } + break; case 'K': position.set("statusExtended", data.toString(StandardCharsets.US_ASCII)); break; case 'M': - position.set(Position.KEY_BATTERY_LEVEL, - Integer.parseInt(data.readSlice(3).toString(StandardCharsets.US_ASCII)) * 0.1); + if (data.readableBytes() == 3) { + position.set(Position.KEY_BATTERY_LEVEL, + Integer.parseInt(data.readSlice(3).toString(StandardCharsets.US_ASCII)) * 0.1); + } else if (data.readableBytes() == 4) { + char index = (char) data.readUnsignedByte(); + data.readUnsignedByte(); // status + position.set( + "humidity" + index, + Integer.parseInt(data.readSlice(2).toString(StandardCharsets.US_ASCII))); + } break; case 'N': position.set(Position.KEY_RSSI, |