aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-08 04:47:26 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-12-08 04:47:26 +1300
commitf839ca4c24d80dcd78b5ad1d65f10cdf534d94d8 (patch)
treebfd49d986a21fea69460948e114dfb0f018f0d2e /src
parentaf8875896e06ac3ac034c493b5a355d32cffb026 (diff)
downloadtraccar-server-f839ca4c24d80dcd78b5ad1d65f10cdf534d94d8.tar.gz
traccar-server-f839ca4c24d80dcd78b5ad1d65f10cdf534d94d8.tar.bz2
traccar-server-f839ca4c24d80dcd78b5ad1d65f10cdf534d94d8.zip
Extend GK310 message format support
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;