aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-11-25 19:37:17 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-11-25 19:37:17 -0800
commit492dbe8014c4ffd83e92c641ddf416bb5bca5b8b (patch)
tree08f85a34675dafd69cf9e891534ec08e9036ba32 /src/main/java/org
parentb0618103672508fb16194afb1b14714a54373585 (diff)
downloadtrackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.tar.gz
trackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.tar.bz2
trackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.zip
Support Topten output command
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java14
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
index bd66cdc4b..81418f331 100644
--- a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -144,7 +144,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TRACK_ON_DEMAND = 0x4101;
public static final int MSG_TRACK_BY_INTERVAL = 0x4102;
public static final int MSG_MOVEMENT_ALARM = 0x4106;
- public static final int MSG_OUTPUT_CONTROL = 0x4115;
+ public static final int MSG_OUTPUT_CONTROL_1 = 0x4114;
+ public static final int MSG_OUTPUT_CONTROL_2 = 0x4115;
public static final int MSG_TIME_ZONE = 0x4132;
public static final int MSG_TAKE_PHOTO = 0x4151;
public static final int MSG_UPLOAD_PHOTO = 0x0800;
diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
index 36e94195c..e5b2cf4e7 100644
--- a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
+import org.traccar.Context;
import org.traccar.helper.Checksum;
import org.traccar.helper.DataConverter;
import org.traccar.model.Command;
@@ -58,6 +59,13 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
+ boolean alternative = Context.getIdentityManager().lookupAttributeBoolean(
+ command.getDeviceId(), getProtocolName() + ".alternative", false, false, true);
+
+ int outputControlMessageType = alternative
+ ? MeiligaoProtocolDecoder.MSG_OUTPUT_CONTROL_1
+ : MeiligaoProtocolDecoder.MSG_OUTPUT_CONTROL_2;
+
ByteBuf content = Unpooled.buffer();
switch (command.getType()) {
@@ -68,10 +76,10 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
return encodeContent(command.getDeviceId(), MeiligaoProtocolDecoder.MSG_TRACK_BY_INTERVAL, content);
case Command.TYPE_ENGINE_STOP:
content.writeByte(0x01);
- return encodeContent(command.getDeviceId(), MeiligaoProtocolDecoder.MSG_OUTPUT_CONTROL, content);
+ return encodeContent(command.getDeviceId(), outputControlMessageType, content);
case Command.TYPE_ENGINE_RESUME:
content.writeByte(0x00);
- return encodeContent(command.getDeviceId(), MeiligaoProtocolDecoder.MSG_OUTPUT_CONTROL, content);
+ return encodeContent(command.getDeviceId(), outputControlMessageType, content);
case Command.TYPE_ALARM_GEOFENCE:
content.writeShort(command.getInteger(Command.KEY_RADIUS));
return encodeContent(command.getDeviceId(), MeiligaoProtocolDecoder.MSG_MOVEMENT_ALARM, content);