diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/UproProtocolDecoder.java | 23 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java | 3 |
2 files changed, 24 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, diff --git a/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java index e43ff322e..e758725f2 100644 --- a/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class UproProtocolDecoderTest extends ProtocolTest { UproProtocolDecoder decoder = new UproProtocolDecoder(null); + verifyPosition(decoder, buffer( + "*HQ201861909268000132,BA&A1820223307024309650492530000311019&B0100000000&F0000&V0036&R0500&J000182&M0052&W00000091&I231026027BD39090827BD5ACA04&X(501E0)(B0000)(E0136)(J01E0)(L3)(k8937204016201240376F)&K00200&T85&N01#")); + verifyAttribute(decoder, buffer( "*VK200867282036729446,BA&A1759265051877702037465660022210819&B0000000000&W00&G000030&M830&N26&O1706&o11&T0783#"), Position.KEY_BATTERY_LEVEL, 83.0); |