sending voice message via the api

Hi,

I'm trying to send a voice message using the api. So I send something like this:

{"id":0,"attributes":{"data":"2321414d520a....."},"deviceId":1,"type":"voiceMessage","textChannel":false,"description":null}

but nothing happens. I mean it gets to the server, but there it's stopped in CommandResource.send in one of the checks. I couldn't figure out what should be the value of "id" I send. Where can I find documentation about it? There's nothing here: https://www.traccar.org/api-reference/#/definitions/Command

Anton Tananaev5 years ago

You don't need to include id, or if you include it, it can be any number.

What is supposed to happen when I send it?
In the server I only see:

1.1.1.1 - - [13/Jan/2019:17:07:19 +0200] "POST /api/commands/send HTTP/1.1" 200 8439 "-" "okhttp/3.12.1"

In the client I see: code=200, message=OK

I was hoping the server will send it to that device (watch protocol) like: [3G * 0123456789 * 0234 * TK,#!AMR...]

Anton Tananaev5 years ago

Where do you see that? It doesn't look like Traccar log.

right, that's my nginx log. In traccar's log you don't see anything :(

I found the problem(s):

  1. fixed here: https://github.com/traccar/traccar/pull/4191

  2. in general if there are exceptions somewhere in the code, there's not much one can see in the logs. That makes findind bugs (not to talk about debugging) very hard. Even when I set the loglevel to "all" I only see debug messages that don't really help.

Anton Tananaev5 years ago
  1. Any examples?
<entry key='logger.level'>all</entry>

I intentionally added:

throw new NullPointerException("foo");

instead of the return line in org/traccar/StringProtocolEncoder.java:44, but nothing in the logs. IMHO it should be logged as an error, but it's not even mentioned as debug:

2019-01-13 21:38:12 DEBUG: unhandle HttpChannelState@6bc31938{s=DISPATCHED a=NOT_ASYNC i=true r=IDLE w=false}
2019-01-13 21:38:21 DEBUG: HttpChannelOverHttp@6e4cda2a{r=10,c=true,a=COMPLETING,uri=//10.0.2.2:8082/api/commands/send,age=18875} action COMPLETE
...
2019-01-13 21:38:23 DEBUG: updates 0
2019-01-13 21:38:23 DEBUG: Selector sun.nio.ch.EPollSelectorImpl@4315a29f waiting with 1 keys
Anton Tananaev5 years ago

It definitely works in decoder, which covers 90% of Traccar use cases. So, your statement that exceptions don't work "in general" is not correct. If it doesn't work correctly in encoder, feel free to send a pull request with a fix.

ok, give me an example where you catch something and log it, so I see how you prefer it.

Anton Tananaev5 years ago

Here is an example:

2019-01-13 13:43:00  INFO: [cdfeadbf] connected
2019-01-13 13:43:00  INFO: [cdfeadbf: 5055 < 0:0:0:0:0:0:0:1] HEX: 474554203f69643d3132333435363738393031323334352674696d657374616d703d31353437343135373830266c61743d34382e3835333738266c6f6e3d322e3334343334372662656172696e673d33342e323338363531303736352673706565643d3026616c61726d3d736f732661636375726163793d3130302672706d3d33353939266675656c3d373726647269766572556e6971756549643d31323334353620485454502f312e310d0a486f73743a206c6f63616c686f73743a353035350d0a4163636570742d456e636f64696e673a206964656e746974790d0a0d0a
2019-01-13 13:43:00  WARN: [cdfeadbf] error - test - RuntimeException (OsmAndProtocolDecoder:49 < ExtendedObjectDecoder:51 < ... < WrapperContext:102 < ...)
Rod DC5 years ago

Is this working? Is it possible to send voice messages to a device(lets say a Q50 watch)? Is there a place where I can find some examples to work with the API? Sending a voice message from the web UI is not possible, is it?

Can Traccar get a message from the device? where is that stored? can that be accessible in the UI or either the API?

I couldn't find any documentation. Thanks for the help.

Yes it works for me. I can send voice messages to/from Q50 watch. When the watch sends a message it's stored in a file and the filename is added in the 'audio' tag.

Rod DC5 years ago

Thats good to know! thank you for the info! can you provide more details on it? how would you send a message to the watch? Is there any documentation available? What Traccar's API calls should I use?