aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorseym45 <seym45@gmail.com>2023-08-29 17:29:30 +0400
committerseym45 <seym45@gmail.com>2023-08-29 17:31:57 +0400
commitf6f210592413157006776ba454d29834e167688c (patch)
treefe4752e629ca63e69a8265dbc6217a870958c878 /src
parent63ea08a14e381261568192a999f51e8c3cc3f574 (diff)
downloadtrackermap-server-f6f210592413157006776ba454d29834e167688c.tar.gz
trackermap-server-f6f210592413157006776ba454d29834e167688c.tar.bz2
trackermap-server-f6f210592413157006776ba454d29834e167688c.zip
- Set supported commands in one call
- Remove timing interval command - Rename messages according to codebase standard
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocol.java12
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocolDecoder.java9
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocolEncoder.java19
-rw-r--r--src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java13
4 files changed, 16 insertions, 37 deletions
diff --git a/src/main/java/org/traccar/protocol/GatorProtocol.java b/src/main/java/org/traccar/protocol/GatorProtocol.java
index 0f44fbf47..e6793875b 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocol.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocol.java
@@ -28,12 +28,12 @@ public class GatorProtocol extends BaseProtocol {
@Inject
public GatorProtocol(Config config) {
- setSupportedDataCommands(Command.TYPE_POSITION_SINGLE);
- setSupportedDataCommands(Command.TYPE_ENGINE_RESUME);
- setSupportedDataCommands(Command.TYPE_ENGINE_STOP);
- setSupportedDataCommands(Command.TYPE_POSITION_PERIODIC);
- setSupportedDataCommands(Command.TYPE_SET_SPEED_LIMIT);
- setSupportedDataCommands(Command.TYPE_SET_ODOMETER);
+ setSupportedDataCommands(
+ Command.TYPE_POSITION_SINGLE,
+ Command.TYPE_ENGINE_RESUME,
+ Command.TYPE_ENGINE_STOP,
+ Command.TYPE_SET_SPEED_LIMIT,
+ Command.TYPE_SET_ODOMETER);
addServer(new TrackerServer(config, getName(), false) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
diff --git a/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java b/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
index 0202ed7d0..53b8909be 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
@@ -38,11 +38,10 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_HEARTBEAT = 0x21;
public static final int MSG_POSITION_REQUEST = 0x30;
- public static final int MSG_POSITION_PERIODIC = 0x34;
- public static final int MSG_SET_SPEED_LIMIT = 0x3F;
- public static final int MSG_SET_ODOMETER = 0x6B;
- public static final int MSG_RESTORES_THE_OIL_DUCT = 0x38;
- public static final int MSG_CLOSE_THE_OIL_DUCT = 0x39;
+ public static final int MSG_OVERSPEED_ALARM = 0x3F;
+ public static final int MSG_RESET_MILEAGE = 0x6B;
+ public static final int MSG_RESTORE_OIL_DUCT = 0x38;
+ public static final int MSG_CLOSE_OIL_DUCT = 0x39;
public static final int MSG_POSITION_DATA = 0x80;
public static final int MSG_ROLLCALL_RESPONSE = 0x81;
public static final int MSG_ALARM_DATA = 0x82;
diff --git a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
index 895c68af5..6c6b9a54a 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
@@ -51,8 +51,7 @@ public class GatorProtocolEncoder extends BaseProtocolEncoder {
buf.writeByte(type);
buf.writeByte(0x00);
- // ip 4 bytes, content length, checksum and end byte
- buf.writeByte(4 + 1 + (content != null ? content.readableBytes() : 0) + 1);
+ buf.writeByte(4 + 1 + (content != null ? content.readableBytes() : 0) + 1); // length
ByteBuf pseudoIPAddress = encodeId(deviceId);
buf.writeBytes(pseudoIPAddress);
@@ -76,23 +75,17 @@ public class GatorProtocolEncoder extends BaseProtocolEncoder {
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_REQUEST, content);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_REQUEST, null);
case Command.TYPE_ENGINE_STOP:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_CLOSE_THE_OIL_DUCT, content);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_CLOSE_OIL_DUCT, null);
case Command.TYPE_ENGINE_RESUME:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_RESTORES_THE_OIL_DUCT, content);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_RESTORE_OIL_DUCT, null);
case Command.TYPE_SET_SPEED_LIMIT:
content.writeByte(command.getInteger(Command.KEY_DATA));
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_SET_SPEED_LIMIT, content);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_RESET_MILEAGE, content);
case Command.TYPE_SET_ODOMETER:
content.writeShort(command.getInteger(Command.KEY_DATA));
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_SET_ODOMETER, content);
- case Command.TYPE_POSITION_PERIODIC:
- String[] data = command.getString(Command.KEY_FREQUENCY).split(";");
- content.writeShort(Integer.valueOf(data[0]));
- content.writeShort(Integer.valueOf(data[1]));
- content.writeByte(Integer.valueOf(data[2]));
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_PERIODIC, content);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_OVERSPEED_ALARM, content);
default:
return null;
}
diff --git a/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
index 1559e8294..af6c71e37 100644
--- a/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
+++ b/src/test/java/org/traccar/protocol/GatorProtocolEncoderTest.java
@@ -20,17 +20,4 @@ public class GatorProtocolEncoderTest extends ProtocolTest {
command.setType(Command.TYPE_POSITION_SINGLE);
verifyCommand(encoder, command, binary("24243000062008958C070D"));
}
-
- @Test
- public void testEncodePeriodicPositionRetrievalIntervalSet() throws Exception {
- var encoder = inject(new GatorProtocolEncoder(null));
- var device = encoder.getCacheManager().getObject(Device.class, 1);
- when(device.getUniqueId()).thenReturn("13088005658");
-
- Command command = new Command();
- command.setDeviceId(1);
- command.set(command.KEY_FREQUENCY, "5;5;120");
- command.setType(Command.TYPE_POSITION_PERIODIC);
- verifyCommand(encoder, command, binary("242434000b5800383a00050005781d0d"));
- }
}