diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-25 19:37:17 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-25 19:37:17 -0800 |
commit | 492dbe8014c4ffd83e92c641ddf416bb5bca5b8b (patch) | |
tree | 08f85a34675dafd69cf9e891534ec08e9036ba32 /src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java | |
parent | b0618103672508fb16194afb1b14714a54373585 (diff) | |
download | trackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.tar.gz trackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.tar.bz2 trackermap-server-492dbe8014c4ffd83e92c641ddf416bb5bca5b8b.zip |
Support Topten output command
Diffstat (limited to 'src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java | 14 |
1 files changed, 11 insertions, 3 deletions
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); |