aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolEncoder.java16
2 files changed, 15 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 2018fb6a6..bff04b36d 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -236,8 +236,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
+ int mcc = buf.readUnsignedShort();
+ int mnc = BitUtil.check(mcc, 15) ? buf.readUnsignedShort() : buf.readUnsignedByte();
+
position.setNetwork(new Network(CellTower.from(
- buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedShort(), buf.readUnsignedMedium())));
+ BitUtil.to(mcc, 15), mnc, buf.readUnsignedShort(), buf.readUnsignedMedium())));
if (length > 0) {
buf.skipBytes(length - (hasLength ? 9 : 8));
diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
index a3e0a2264..daf045f4f 100644
--- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
@@ -27,14 +27,16 @@ import java.nio.charset.StandardCharsets;
public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(String content) {
+ private ChannelBuffer encodeContent(long deviceId, String content) {
+
+ boolean language = Context.getIdentityManager().lookupAttributeBoolean(deviceId, "gt06.language", false, true);
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
buf.writeByte(0x78);
buf.writeByte(0x78);
- buf.writeByte(1 + 1 + 4 + content.length() + 2 + 2); // message length
+ buf.writeByte(1 + 1 + 4 + content.length() + 2 + 2 + (language ? 2 : 0)); // message length
buf.writeByte(0x80); // message type
@@ -42,6 +44,10 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
buf.writeInt(0);
buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII)); // command
+ if (language) {
+ buf.writeShort(2); // english language
+ }
+
buf.writeShort(0); // message index
buf.writeShort(Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer(2, buf.writerIndex() - 2)));
@@ -60,11 +66,11 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
- return encodeContent(alternative ? "DYD,123456#" : "Relay,1#");
+ return encodeContent(command.getDeviceId(), alternative ? "DYD,123456#" : "Relay,1#");
case Command.TYPE_ENGINE_RESUME:
- return encodeContent(alternative ? "HFYD,123456#" : "Relay,0#");
+ return encodeContent(command.getDeviceId(), alternative ? "HFYD,123456#" : "Relay,0#");
case Command.TYPE_CUSTOM:
- return encodeContent(command.getString(Command.KEY_DATA));
+ return encodeContent(command.getDeviceId(), command.getString(Command.KEY_DATA));
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;