Command result and API

Ibrahim2 months ago

Hello everyone,
Currently I have two issues regarding configuring and using the API:

  1. What configuration must I carry out to receive the response to my notification in the form of (Command result) per event and be able to transfer it via the MQTT protocol? For now, I only receive these events via MQTT:
{"event":{"id":15068,"attributes":{"media":"audio","file":"20240304191850.amr"},"deviceId":6,"type":"media", "eventTime":"2024-03-04T18:18:50.869+00:00","positionId":1341457,"geofenceId":0,"maintenanceId":0},"position":{"id":1341457, "attributes":{"audio":"20240304191850.amr","distance":0.0,"totalDistance":1.2404487352176593E8,"motion":true},"deviceId":6,"protocol":"watch"," serverTime":"2024-03-04T18:18:50.869+00:00","deviceTime":"2024-03-04T18:18:50.869+00:00","fixTime":"2024-03-04T18: 18:02.000+00:00","outdated":true,"valid":true,"latitude":9.547713,"longitude":-13.6759065,"altitude":15.5,"speed":25.49676954,"course": 223.2,"address":null,"accuracy":0.0,"network":null,"geofenceIds":null},"device":{"id":6,"attributes":{},"groupId":0 ,"calendarId":0,"name":"MONTRE","uniqueId":"9705260142","status":"online","lastUpdate":"2024-03-04T18:18:50.872+00:00" ,"positionId":1339405,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null}}

{"event":{"id":15069,"attributes":{},"deviceId":6,"type":"deviceOffline","eventTime":"2024-03-04T18:49:31.779+00: 00","positionId":0,"geofenceId":0,"maintenanceId":0},"device":{"id":6,"attributes":{},"groupId":0,"calendarId": 0,"name":"MONTRE","uniqueId":"9705260142","status":"offline","lastUpdate":"2024-03-04T18:49:00.779+00:00","positionId": 1339405,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null}}

{"event":{"id":15071,"attributes":{},"deviceId":6,"type":"deviceOnline","eventTime":"2024-03-04T18:55:52.938+00: 00","positionId":0,"geofenceId":0,"maintenanceId":0},"device":{"id":6,"attributes":{},"groupId":0,"calendarId": 0,"name":"MONTRE","uniqueId":"9705260142","status":"online","lastUpdate":"2024-03-04T18:54:38.000+00:00","positionId": 1341510,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null}}

I am not receiving response events from my << commandResult >> command, which is launched via the web interface.

  1. When I send commands through the API, for example:
{"id":0,"attributes":{"data":"hrtstart,300"},"deviceId":2,"type":"custom","textChannel":false,"description":null}

The answer is correct:

{"id":0,"attributes":{"data":"hrtstart,300"},"deviceId":2,"type":"custom","textChannel":false,"description":null}
  1. I check in the logs that the command was sent, that the watch responds correctly, and that the data is recorded in the database, in the "tc_positions" table. However, how can I identify and retrieve the response in this row of the "tc_positions" table still by API?
  2. Where can I find all JSON structure formats of types (deviceMoving, deviceOffline, deviceOnline, commandResult, alarm, media) sent by events, specifically by MQTT? For example :
{"event":{"id":15071,"attributes":{},"deviceId":6,"type":"deviceOnline","eventTime":"2024-03-04T18:55:52.938+00: 00","positionId":0,"geofenceId":0,"maintenanceId":0},"device":{"id":6,"attributes":{},"groupId":0,"calendarId": 0,"name":"MONTRE","uniqueId":"9705260142","status":"online","lastUpdate":"2024-03-04T18:54:38.000+00:00","positionId": 1341510,"phone":null,"model":null,"contact":null,"category":null,"disabled":false,"expirationTime":null}}
Anton Tananaev2 months ago
  1. What device and protocol are you using?
  2. Does it actually support results?
  3. Is it supported in the decoder on the server?
Ibrahim2 months ago

Thank you for your reply. The device in question is the RF-V48, which uses the "watch" protocol as shown in the previously mentioned event and is connected on port 5093. I am of the opinion that it succeeds in decoding the data, because in the "tc_positions" table, I find the following information:

{"bloodOxygen":99,"distance":0.0,"totalDistance":1.6291764509656426E8,"motion":false}
{"pressureHigh":"140","pressureLow":"96","heartRate":113,"distance":0.0,"totalDistance":1.6291764509656426E8,"motion":false}

This data appears to match well with the captured information.

Anton Tananaev2 months ago

It doesn't look like we support results for the Watch protocol.

Ibrahim2 months ago

So it can just decode and save to database? But no option to send by notification or event

Anton Tananaev2 months ago

You're confusing decoding a regular data message with command result. What you provided is just regular messages. Traccar does not know that it's a response to some command.

Ibrahim2 months ago

It's possible that I misunderstood your sentence, but as I just mentioned, the following data is the result of the custom order I made. In both cases, I received a positive response, and the message I just sent you is the one that has been decoded.

Anton Tananaev2 months ago

Can you please provide the evidence that it's a response for a command?

Ibrahim2 months ago

Of course, I'll send you the message as soon as I get home.

Ibrahim2 months ago

I would like to apologize for my mistake yesterday regarding the decoding of the RF-V48. Now, could you show me in which part of the code I need to add functions so that it can process the results of the command with type "commandResult" in the "watch" protocol? THANKS.

Anton Tananaev2 months ago

The decoder class.

Ibrahim2 months ago

I managed to locate the file to edit, but now I'm having difficulty compiling the project.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.134 s
[INFO] Finished at: 2024-03-06T18:16:48+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\Administrator\IdeaProjects\traccar). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException