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/Gl200BinaryProtocolDecoder.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/Gl200BinaryProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/Gl200BinaryProtocolDecoder.java | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/src/main/java/org/traccar/protocol/Gl200BinaryProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200BinaryProtocolDecoder.java index ecd1f5bfa..359af8e5a 100644 --- a/src/main/java/org/traccar/protocol/Gl200BinaryProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gl200BinaryProtocolDecoder.java @@ -230,52 +230,39 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); switch (type) { - case MSG_EVT_BPL: - buf.readUnsignedShort(); // backup battery voltage - break; - case MSG_EVT_VGN: - case MSG_EVT_VGF: + case MSG_EVT_BPL -> buf.readUnsignedShort(); // backup battery voltage + case MSG_EVT_VGN, MSG_EVT_VGF -> { buf.readUnsignedShort(); // reserved buf.readUnsignedByte(); // report type buf.readUnsignedInt(); // ignition duration - break; - case MSG_EVT_UPD: + } + case MSG_EVT_UPD -> { buf.readUnsignedShort(); // code buf.readUnsignedByte(); // retry - break; - case MSG_EVT_IDF: - buf.readUnsignedInt(); // idling duration - break; - case MSG_EVT_GSS: + } + case MSG_EVT_IDF -> buf.readUnsignedInt(); // idling duration + case MSG_EVT_GSS -> { buf.readUnsignedByte(); // gps signal status buf.readUnsignedInt(); // reserved - break; - case MSG_EVT_GES: + } + case MSG_EVT_GES -> { buf.readUnsignedShort(); // trigger geo id buf.readUnsignedByte(); // trigger geo enable buf.readUnsignedByte(); // trigger mode buf.readUnsignedInt(); // radius buf.readUnsignedInt(); // check interval - break; - case MSG_EVT_GPJ: + } + case MSG_EVT_GPJ -> { buf.readUnsignedByte(); // cw jamming value buf.readUnsignedByte(); // gps jamming state - break; - case MSG_EVT_RMD: - buf.readUnsignedByte(); // roaming state - break; - case MSG_EVT_JDS: - buf.readUnsignedByte(); // jamming state - break; - case MSG_EVT_CRA: - buf.readUnsignedByte(); // crash counter - break; - case MSG_EVT_UPC: + } + case MSG_EVT_RMD -> buf.readUnsignedByte(); // roaming state + case MSG_EVT_JDS -> buf.readUnsignedByte(); // jamming state + case MSG_EVT_CRA -> buf.readUnsignedByte(); // crash counter + case MSG_EVT_UPC -> { buf.readUnsignedByte(); // command id buf.readUnsignedShort(); // result - break; - default: - break; + } } buf.readUnsignedByte(); // count @@ -388,16 +375,12 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder { ByteBuf buf = (ByteBuf) msg; - switch (buf.readSlice(4).toString(StandardCharsets.US_ASCII)) { - case "+RSP": - return decodeLocation(channel, remoteAddress, buf); - case "+INF": - return decodeInformation(channel, remoteAddress, buf); - case "+EVT": - return decodeEvent(channel, remoteAddress, buf); - default: - return null; - } + return switch (buf.readSlice(4).toString(StandardCharsets.US_ASCII)) { + case "+RSP" -> decodeLocation(channel, remoteAddress, buf); + case "+INF" -> decodeInformation(channel, remoteAddress, buf); + case "+EVT" -> decodeEvent(channel, remoteAddress, buf); + default -> null; + }; } } |