|
@@ -54,7 +54,8 @@ public class JT808ProtocolUtils {
|
|
for (int i = 0; i < start; i++) {
|
|
for (int i = 0; i < start; i++) {
|
|
baos.write(bs[i]);
|
|
baos.write(bs[i]);
|
|
}
|
|
}
|
|
- for (int i = start; i < end - 1; i++) {
|
|
|
|
|
|
+ int i = start;
|
|
|
|
+ for (; i < end - 1; i++) {
|
|
if (bs[i] == 0x7d && bs[i + 1] == 0x01) {
|
|
if (bs[i] == 0x7d && bs[i + 1] == 0x01) {
|
|
baos.write(0x7d);
|
|
baos.write(0x7d);
|
|
i++;
|
|
i++;
|
|
@@ -65,8 +66,11 @@ public class JT808ProtocolUtils {
|
|
baos.write(bs[i]);
|
|
baos.write(bs[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- for (int i = end - 1; i < bs.length; i++) {
|
|
|
|
- baos.write(bs[i]);
|
|
|
|
|
|
+
|
|
|
|
+ if (i == (end - 1)) {
|
|
|
|
+ for (; i < bs.length; i++) {
|
|
|
|
+ baos.write(bs[i]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return baos.toByteArray();
|
|
return baos.toByteArray();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -111,6 +115,9 @@ public class JT808ProtocolUtils {
|
|
if (bs[i] == 0x7e) {
|
|
if (bs[i] == 0x7e) {
|
|
baos.write(0x7d);
|
|
baos.write(0x7d);
|
|
baos.write(0x02);
|
|
baos.write(0x02);
|
|
|
|
+ }else if (bs[i] == 0x7d) {
|
|
|
|
+ baos.write(0x7d);
|
|
|
|
+ baos.write(0x01);
|
|
} else {
|
|
} else {
|
|
baos.write(bs[i]);
|
|
baos.write(bs[i]);
|
|
}
|
|
}
|