aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Gt06ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 11:53:11 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-09 11:53:11 +1200
commitc40928cd674144fa5ed3dc7306c33b16823b2fad (patch)
tree1180e335ca1ad10c4cb40033c7acf2b62dfbc8d1 /src/org/traccar/protocol/Gt06ProtocolDecoder.java
parent44cdc3449fccd22b21fec1c9a0febea807cc2489 (diff)
downloadtraccar-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.tar.gz
traccar-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.tar.bz2
traccar-server-c40928cd674144fa5ed3dc7306c33b16823b2fad.zip
Use slices instead of new buffers
Diffstat (limited to 'src/org/traccar/protocol/Gt06ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 490c366ea..cc37d5602 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -388,7 +388,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGIN) {
- String imei = ByteBufUtil.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
buf.readUnsignedShort(); // type
deviceSession = getDeviceSession(channel, remoteAddress, imei);
@@ -573,7 +573,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (type != MSG_LBS_MULTIPLE && type != MSG_LBS_2) {
int wifiCount = buf.readUnsignedByte();
for (int i = 0; i < wifiCount; i++) {
- String mac = ByteBufUtil.hexDump(buf.readBytes(6)).replaceAll("(..)", "$1:");
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
network.addWifiAccessPoint(WifiAccessPoint.from(
mac.substring(0, mac.length() - 1), buf.readUnsignedByte()));
}
@@ -590,7 +590,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (commandLength > 0) {
buf.readUnsignedByte(); // server flag (reserved)
position.set(Position.KEY_RESULT,
- buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(commandLength - 1).toString(StandardCharsets.US_ASCII));
}
} else if (isSupported(type)) {
@@ -666,9 +666,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedInt(); // server flag
String data;
if (buf.readUnsignedByte() == 1) {
- data = buf.readBytes(buf.readableBytes() - 6).toString(StandardCharsets.US_ASCII);
+ data = buf.readSlice(buf.readableBytes() - 6).toString(StandardCharsets.US_ASCII);
} else {
- data = buf.readBytes(buf.readableBytes() - 6).toString(StandardCharsets.UTF_16BE);
+ data = buf.readSlice(buf.readableBytes() - 6).toString(StandardCharsets.UTF_16BE);
}
if (decodeLocationString(position, data) == null) {