Motion attribute using Wialon protocol

alextruppel 3 years ago

Hello everyone,

I'm implementing my own tracker and I'm using the Wialon protocol. I know you can send extra information in the parameters list.

I want to send the motion parameter (KEY_MOTION). I can see here that the name for that parameter is "motion". Therefore, in the parameter list of the data packet that I send to Traccar, I add "motion:1:1" when the tracker is in motion and "motion:1:0" when it isn't.

But this seems to be shown in the interface differently than when Traccar calculates it itself. My guess is that KEY_MOTION is supposed to be a boolean attribute, and what I'm sending is an integer value.

However, Wialon does not have boolean attributes. I can either send "motion:1:1"/"motion:1:0" or "motion:3:true"/"motion:3:false" (1 = int attribute, 3 = string attribute). Looking at the code here, it seems that the attributes in the Wialon protocol are parsed always as doubles or strings.

I may be incorrect so far, I'm not sure. So my question is: is there a way to send the KEY_MOTION over Wialon in such a way that it is interpreted correctly by Traccar?

Thank you!

Anton Tananaev 3 years ago

One option is to send some custom attribute as a number and then use computed attributes to convert into a boolean "motion".

alextruppel 3 years ago

That is an extremely fast answer! Thank you very much.

I would rather avoid using computed attributes because:

  1. A few of my friends will also use these trackers and it would be easier for them if it "just works", and
  2. I cannot figure out how to add custom attributes. All the settings tabs (Devices, Groups, Drivers, Calendars, etc) have a plus button on the web interface, except Computed Attributes! How can I add one?

Is there another option?

Anton Tananaev 3 years ago

Another option is to support boolean attributes natively, but you would need some code changes for that. Don't forget to send a pull request if you manage to implement it.

alextruppel 3 years ago

Hmm I will see if I can do it myself, yes. Hopefully you'll have a pull request at some point.

The general problem with this is that Wialon does not support defining when a value is a boolean. So maybe the best option would be to detect when the value is defined as a string (type 3) and then if it is equal to "true" or "false", assume it is a boolean.

Also, there are a few more minor issues with Wialon parameter decoding. For example, the "accuracy" parameter is not part of the general LinkedHashMap of attributes. Instead, a "setAccuracy" function exists, but this function is never called by the Wialon decoder. Here, I sugest intercepting a value with name "accuracy" in this for loop and calling "setAccuracy" directly there.

Anton Tananaev 3 years ago

Agree with both.

alextruppel 3 years ago

Awesome, I'll get on it then.