Watch Protocol Audio Sending in Server 4.2

Michael 7 years ago

Hi, I just updated from 4.0 to 4.2.

When I send command type 'voiceMessage' to watch devices, in server logs there are no information about commands sent to the device and no response from device.
I tried to enable ALL loggin level but no run time errors or similar were recorded.

Is this normal? Where I am wrong?

Thanks for help.

Anton Tananaev 7 years ago

No, it's not. You should see at least a message confirming that command was sent.

Michael 7 years ago

Hi, I do a full debug with a watch protocol device.

After call formatCommand() with no keys in keys argument the execution stopped at
StringProtocolEncoder:30
WatchProtocolEncoder:56

The exception is launched by
String result = String.format(format, (Object[]) keys);
java.util.UnknownFormatConversionException: Conversion = 'Y'

I don't know if this is a bug or is something about me.
After this exception no audio is sent to the device.

I tried to bypass this exception setting result directly to format and the command was sent, but no audio received by device.

Have I to open an issue?

Anton Tananaev 7 years ago

The problem is with the command that you are sending. What exactly are you sending?

Michael 7 years ago

After bypass the exception this is what was logged:

2019-01-03 09:24:31  INFO: [ef5b671f] id: 8003450618, command type: voiceMessage sent
2019-01-03 09:24:31  INFO: [ef5b671f: 5093 > 5.90.82.134] HEX: 5b33472a383030333435303631382a316263362a544b2c2321414d520a7d04efbfbdefbfbd7c00efbfbd01efbfbdefbfbdefbfbd2f50efbfbd262fefbfbdefbfbdefbfbd60efbfbd527d04efbfbdefbfbd7c00efbfbd01efbfbdefbfbdefbfbd2f ... defbfbdefbfbdefbfbd7234efbfbd6e7d04586b19efbfbd57efbfbd04efbfbdefbfbd7d047560efbfbdefbfbdefbfbdefbfbd6e00efbfbd307d04586befbfbd68400a21efbfbd3fefbfbd3aefbfbdefbfbdefbfbd78efbfbd20711c367d046aefbfbdefbfbdefbfbd6215efbfbdefbfbd534a2befbfbdefbfbdefbfbd393d53efbfbd04427c5d
2019-01-03 09:25:01  INFO: [ef5b671f: 5093 < 5.90.82.134] HEX: 5b33472a383030333435303631382a303030392a4c4b2c302c302c37355d
2019-01-03 09:25:01  INFO: [ef5b671f: 5093 > 5.90.82.134] HEX: 5b33472a383030333435303631382a303030322a4c4b5d
2019-01-03 09:25:01  INFO: [ef5b671f] id: 8003450618, time: 2019-01-03 08:45:35, lat: 45.30585, lon: 12.03477, course: 0.0
2019-01-03 09:25:11  INFO: [ef5b671f: 5093 < 5.90.82.134] HEX: 5b33472a383030333435303631382a303030332a544b515d
2019-01-03 09:25:11  INFO: [ef5b671f: 5093 > 5.90.82.134] HEX: 5b33472a383030333435303631382a303030332a544b515d
2019-01-03 09:25:12  INFO: [ef5b671f: 5093 < 5.90.82.134] HEX: 5b33472a383030333435303631382a303030342a544b51325d
Michael 7 years ago

I'm sending a voiceMessage through the web interface, I pasted an HEX of an AMR audio file.

Michael 7 years ago

I last tried to convert AMR by hand and I get a totally different Hex command to send to device.
The commands are translated using US-ASCII which is 7-bit but the AMR audio have to be sent with 8-bit byte sequences, isn't it?
I have no way to test this... I'm in stuck, voice messages are not sending...

I'm refering to WatchProtocolEncoder method

private String getBinaryData(Command command) 

last row:

return new String(encodedData, StandardCharsets.US_ASCII);

This returns me a string totally different from mine.

Anton Tananaev 7 years ago

What do you get and how is it different?

Michael 7 years ago

Here the first 30 bytes of the original AMR file:

2321414D520A2C9EC07C00FF01FCB9A32F508B262FB3F58360AF522C9EC0

My first 30 bytes encoded (32 in tot) conforming to the protocol:

2321414D520A7D049EC07C00FF01FCB9A32F508B262FB3F58360AF527D049EC0

The first 30 bytes encoded (32 in tot) from traccar debug:

2321414D520A7D04EFBE9EEFBF807C00EFBFBF01EFBFBCEFBEB9EFBEA32F50EF

I'm trying to understand why I am wrong, and why the traccar can't send the voiceMessage successful to the device...

Michael 7 years ago

I attach my device on demo5 server, and retry voiceMessage sending with a new AMR.
The web interface said "Command sent" but no msg received by the device.
In past version I tried some voiceMessage (with wrong encoding) and the message arrived to the device but the device was not able to replay the audio because it was a failing encoding.
Now the device received nothing.

If you need I can send you the AMR source file.

Anton Tananaev 7 years ago

I think StringEncoder doesn't handle it properly, so I guess it won't work as it is.

Michael 7 years ago

Ok, this is one of my theories.
I'll try some kind of bypass in order to get it working temporarily.

Gavriel Fleischer 7 years ago

Michael, did you manage to fix this?

Gavriel Fleischer 7 years ago

I think I found a fix. I'll have to test it tonight with the real watch:

In WatchProtocol.java:49:

change:

                pipeline.addLast(new StringEncoder());

to:

                pipeline.addLast(new StringEncoder(StandardCharsets.US_ASCII));

What do you think? Will this work for the other commands?

Gavriel Fleischer 7 years ago

Well, now the voice message arrives to the watch and I can listen to it, but it sounds like noise.