how to fix TYPE_SET_TIMEZONE command in WatchProtocolEncoder

Hi,

I tried to set the timezone on a watch, but it doesn't work. It's because traccar sends: "LZ,,{timezone}", but the protocol doesn't enable omitting the language parameter. See in your own watch protocol doc: https://dl.dropboxusercontent.com/s/2hid9vaa2vno4jr/Communication%20Protocol.doc

So I'd like to fix traccar-server. I'll add Command.KEY_LANGUAGE="language", and the question is if it's ok if I fix WatchProtocolEncoder like this:

case Command.TYPE_SET_TIMEZONE:
                return formatTextCommand(channel, command, "LZ,{%s},{%s}", Command.KEY_LANGUAGE, Command.KEY_TIMEZONE);

Or do you want to change the command type to: Command.TYPE_SET_LANGUAGE_AND_TIMEZONE ?

Anton Tananaev5 years ago

It's ok to make it optional.

something like the following will do?

        case Command.TYPE_SET_TIMEZONE:
            if (command.getAttributes().containsKey(Command.KEY_LANGUAGE)) {
                return formatTextCommand(channel, command, "LZ,{%s},{%s}",
                        Command.KEY_LANGUAGE, Command.KEY_TIMEZONE);
            } else {
                return formatTextCommand(channel, command, "LZ,,{%s}", Command.KEY_TIMEZONE);
            }
Anton Tananaev5 years ago

Yes, or maybe update formatting function to automatically put empty string if the value is not provided.