aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/H02FrameDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/H02FrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index b2da64847..f1d305ab6 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -44,34 +44,44 @@ public class H02FrameDecoder extends FrameDecoder {
}
}
- if (marker == '*') {
+ switch (marker) {
+ case '*':
- // Return text message
- int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
- if (index != -1) {
- return buf.readBytes(index + 1 - buf.readerIndex());
- }
+ // Return text message
+ int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
+ if (index != -1) {
+ return buf.readBytes(index + 1 - buf.readerIndex());
+ }
+
+ break;
- } else if (marker == '$') {
+ case '$':
- if (messageLength == 0) {
- if (buf.readableBytes() == MESSAGE_LONG) {
- messageLength = MESSAGE_LONG;
- } else {
- messageLength = MESSAGE_SHORT;
+ if (messageLength == 0) {
+ if (buf.readableBytes() == MESSAGE_LONG) {
+ messageLength = MESSAGE_LONG;
+ } else {
+ messageLength = MESSAGE_SHORT;
+ }
}
- }
- if (buf.readableBytes() >= messageLength) {
- return buf.readBytes(messageLength);
- }
+ if (buf.readableBytes() >= messageLength) {
+ return buf.readBytes(messageLength);
+ }
- } else if (marker == 'X') {
+ break;
- if (buf.readableBytes() >= MESSAGE_SHORT) {
- return buf.readBytes(MESSAGE_SHORT);
- }
+ case 'X':
+
+ if (buf.readableBytes() >= MESSAGE_SHORT) {
+ return buf.readBytes(MESSAGE_SHORT);
+ }
+
+ break;
+
+ default:
+ throw new IllegalArgumentException();
}
return null;