diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
commit | 55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch) | |
tree | b86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java | |
parent | c04ad7d48331253c095fc123ded1b00f6ff871d3 (diff) | |
parent | 2788174193def918a3a1a5be3bbed24c9613323f (diff) | |
download | trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2 trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip |
Merge tag 'tags/v6.3'
Diffstat (limited to 'src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java b/src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java index e7ab23e5b..c929621b5 100644 --- a/src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/ThinkPowerProtocolDecoder.java @@ -63,67 +63,43 @@ public class ThinkPowerProtocolDecoder extends BaseProtocolDecoder { private void decodeValue(Position position, int type, ByteBuf buf) { switch (type) { - case 0x01: + case 0x01 -> { position.setValid(true); position.setLatitude(BufferUtil.readSignedMagnitudeInt(buf) * 0.0000001); position.setLongitude(BufferUtil.readSignedMagnitudeInt(buf) * 0.0000001); position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1)); position.setCourse(buf.readUnsignedShort() * 0.01); - break; - case 0x02: - position.setValid(buf.readUnsignedByte() > 0); - break; - case 0x03: - buf.skipBytes(3); // geofence - break; - case 0x06: - case 0x07: - case 0x08: - buf.skipBytes(2); // g-sensor x/y/z - break; - case 0x09: - buf.readUnsignedByte(); // collision alarm - break; - case 0x0A: - buf.readUnsignedByte(); // drop alarm - break; - case 0x10: + } + case 0x02 -> position.setValid(buf.readUnsignedByte() > 0); + case 0x03 -> buf.skipBytes(3); // geofence + case 0x06, 0x07, 0x08 -> buf.skipBytes(2); // g-sensor x/y/z + case 0x09 -> buf.readUnsignedByte(); // collision alarm + case 0x0A -> buf.readUnsignedByte(); // drop alarm + case 0x10 -> { if (buf.readUnsignedByte() > 0) { position.set(Position.KEY_ALARM, Position.ALARM_SOS); } - break; - case 0x12: - position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.1); - break; - case 0x13: + } + case 0x12 -> position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.1); + case 0x13 -> { if (buf.readUnsignedByte() > 0) { position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); } - break; - case 0x16: - buf.readUnsignedShort(); // temperature - break; - case 0x17: - buf.readUnsignedByte(); // humidity - break; - case 0x18: - buf.readUnsignedShort(); // high temperature - break; - case 0x19: - buf.readUnsignedByte(); // high humidity - break; - case 0x50: + } + case 0x16 -> buf.readUnsignedShort(); // temperature + case 0x17 -> buf.readUnsignedByte(); // humidity + case 0x18 -> buf.readUnsignedShort(); // high temperature + case 0x19 -> buf.readUnsignedByte(); // high humidity + case 0x50 -> { if (buf.readUnsignedByte() > 0) { position.set(Position.KEY_ALARM, Position.ALARM_REMOVING); } - break; - case 0x51: + } + case 0x51 -> { if (buf.readUnsignedByte() > 0) { position.set(Position.KEY_ALARM, Position.ALARM_TAMPERING); } - break; - default: - break; + } } } |