aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/model/Command.java1
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocol.java5
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocolEncoder.java52
3 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java
index 99988dd82..e0c1c3976 100644
--- a/src/main/java/org/traccar/model/Command.java
+++ b/src/main/java/org/traccar/model/Command.java
@@ -45,6 +45,7 @@ public class Command extends BaseCommand {
public static final String TYPE_SILENCE_TIME = "silenceTime";
public static final String TYPE_SET_PHONEBOOK = "setPhonebook";
public static final String TYPE_MESSAGE = "message";
+ public static final String TYPE_ROLLCALL = "rollcall";
public static final String TYPE_VOICE_MESSAGE = "voiceMessage";
public static final String TYPE_OUTPUT_CONTROL = "outputControl";
public static final String TYPE_VOICE_MONITORING = "voiceMonitoring";
diff --git a/src/main/java/org/traccar/protocol/GatorProtocol.java b/src/main/java/org/traccar/protocol/GatorProtocol.java
index 7341b69a3..c54b1b53d 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocol.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocol.java
@@ -20,6 +20,7 @@ import org.traccar.BaseProtocol;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.config.Config;
+import org.traccar.model.Command;
import javax.inject.Inject;
@@ -27,10 +28,14 @@ public class GatorProtocol extends BaseProtocol {
@Inject
public GatorProtocol(Config config) {
+ setSupportedDataCommands(
+ Command.TYPE_ROLLCALL
+ );
addServer(new TrackerServer(config, getName(), false) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 3, 2));
+ pipeline.addLast(new GatorProtocolEncoder(GatorProtocol.this));
pipeline.addLast(new GatorProtocolDecoder(GatorProtocol.this));
}
});
diff --git a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
new file mode 100644
index 000000000..452fde275
--- /dev/null
+++ b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2023 - Hossain Mohammad Seym
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.traccar.BaseProtocolEncoder;
+import org.traccar.Protocol;
+import org.traccar.config.Keys;
+import org.traccar.helper.Checksum;
+import org.traccar.helper.model.AttributeUtil;
+import org.traccar.model.Command;
+import org.traccar.model.Device;
+
+import java.nio.charset.StandardCharsets;
+
+public class GatorProtocolEncoder extends BaseProtocolEncoder {
+
+ public GatorProtocolEncoder(Protocol protocol) {
+ super(protocol);
+ }
+
+ private ByteBuf encodeContent(long deviceId, String content) {
+ // FIXME: implement this method
+ return null;
+ }
+
+ @Override
+ protected Object encodeCommand(Command command) {
+
+ switch (command.getType()) {
+ case Command.TYPE_ROLLCALL:
+ return encodeContent(command.getDeviceId(), "0x30");
+ default:
+ return null;
+ }
+ }
+
+}