Encoder commands JMAK protocol

Antonio Junior last year

I'm trying to implement the lock/unlock commands for the JMAK protocol but I'm not having any success. Could someone help? Am I doing something wrong?

Link to the command protocol
excerpt from the manual - engineStop

Jmak Protocol

public class JmakProtocol extends BaseProtocol {

    @Inject
    public JmakProtocol(Config config) {
        setSupportedDataCommands(
                Command.TYPE_CUSTOM,
                Command.TYPE_ENGINE_STOP,
                Command.TYPE_ENGINE_RESUME);
        addServer(new TrackerServer(config, getName(), false) {
            @Override
            protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
                pipeline.addLast(new LoggingHandler(LogLevel.DEBUG));
                pipeline.addLast(new JmakFrameDecoder());
                pipeline.addLast(new StringEncoder());
                pipeline.addLast(new StringDecoder());
                pipeline.addLast(new JmakProtocolEncoder(JmakProtocol.this));
                pipeline.addLast(new JmakProtocolDecoder(JmakProtocol.this));
            }
        });
    }
}

JmakProtocolEncoder

public class JmakProtocolEncoder extends BaseProtocolEncoder {

    public JmakProtocolEncoder(Protocol protocol) {
        super(protocol);
    }

    @Override
    protected Object encodeCommand(Command command) {
        return switch (command.getType()) {
            case Command.TYPE_ENGINE_STOP -> "$34;1;#";
            case Command.TYPE_ENGINE_RESUME -> "$34;0;#";
            case Command.TYPE_CUSTOM -> {
                String data = command.getString(Command.KEY_DATA);
                yield data != null ? formatCustomCommand(data) : null;
            }
            default -> null;
        };
    }

    private String formatCustomCommand(String data) {
        data = data.trim();
        if (data.startsWith("$")) data = data.substring(1);
        if (data.endsWith("#")) data = data.substring(0, data.length() - 1);
        return "$" + data + "#";
    }
}

LOGS

2025-11-13 10:41:47  INFO: Preparando comando: type=engineStop, deviceId=6
2025-11-13 10:41:47  INFO: Comando CORTA CORRENTE ATIVAR para deviceId: 6
2025-11-13 10:41:47  INFO: Comando formatado para envio ao dispositivo 6: $34;1;#
2025-11-13 10:41:47  INFO: Aguardando resposta do dispositivo no formato: $IMEI;ok;# ou $IMEI;err;ID;#
2025-11-13 10:41:47  INFO: [Td9f7593f] id: 860710052018036, command type: engineStop sent
2025-11-13 10:41:47  INFO: [Td9f7593f: jmak > 177.69.143.158] $34;1;#
2025-11-13 10:42:05  INFO: [Td9f7593f: jmak < 177.69.143.158] ~000000001D63FFFF;202509-00104-0018490;860710052018036;5982;Bancada;1763041316000;-24.33366;-50.62481;749.20;B;0.00;33;18;0.74;46.40;0;0;19.17;4.37;12693;4108;4;3;0;0$
2025-11-13 10:42:05  INFO: Recebido JMAK: ~000000001D63FFFF;202509-00104-0018490;860710052018036;5982;Bancada;1763041316000;-24.33366;-50.62481;749.20;B;0.00;33;18;0.74;46.40;0;0;19.17;4.37;12693;4108;4;3;0;0$
2025-11-13 10:42:05  INFO: [Td9f7593f: jmak > 177.69.143.158] ACK

The command is being sent successfully, but the device does not perform the engine cut (no blocking action happens).

Antonio Junior last year

That's right, @Anton, could you help us? Logs no print erros.

Anton Tananaev last year

This is probably beyond what I can do via forum.

Antonio Junior last year

I thought this would help the community, but if you're not interested, we'll figure it out anyway.

Anton Tananaev last year

Great. Please share once you figure it out.

Antonio Junior last year

Hello, this command work for JR12. Tested.