FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

4167 questions

4739 answers

3460 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
1,090 views
in Vehicle tracking by

Hello,

I was "playing" with some BLE sensors (Blue Coin T from ELA) and I have seen (here : https://wiki.teltonika.lt/view/FMB_AVL_ID) that there are data which length are variable.
For  exemple Beacon (ID 385) and BLE Sensors (ID 331 -> 334) data.

Values can have different length, but they are also Hexadecimal values or ASCII strings. For example it should be interesting to get string value instead of hexadecimal or number for ISO6709 Coordinates (ID 387).

Next, my goal is to put it in database. However I get "0" value.

Thus, my problem is inside of the Codec8E.cs class which can be found here : Teltonika.Parser (source code) > Teltonika.Codec > Codecs > Codec8E.cs.

This is the last block of code of the Codec8E.cs file.

If we look at IoProperty.Create() methode, value is a "long" variable.
And if we look at ReadBytes() C# method, it return an array of bytes.

When I have "translated" this code to java, I hadn't paid attention to this problem.
I can't put bytes array in a long value and mostly if I want to get hexadecimal or string value.

In addition, I have seen that in the Teltonika Data Parser, there is no string value for the "ISO6709 Coordinates" data... only extracted bytes.
So...I think I am at the same level as the Teltonika data parser... I am blocked at this moment. :/

Do you have idea of how to extract string properly from data in order to put it in a database ?
I have a method to convert bytes array to HEX or String value. This is not the problem.
It is very... "How to do properly without destroying the clean teltonika structure ?"

Also, I am already able to store all other numeric values or hexadecimal values that represents numbers.
This is only variables values length which mainly represents string which are difficult to treat and store.

Sorry for this fairly technical problem... Meanwhile, I will continue to search a solution. :)

Thanks a lot for your help,
Sincerely,
AlliageSphere

EDIT 1 : Maybe I can make an other IoProperty class to manage only strings...
Thus. I have to get the variable type of the data and after, I will redirect the data value and id to IoPropertyNumeric or IoPropertyString. It should work ! :D
But I don't know if there will be some issues after...So, I will try it this afternoon. ^^

I will keep you posted.

by

Where  can i find : Teltonika.Parser (source code) > Teltonika.Codec > Codecs > Codec8E.cs.?

2 Answers

0 votes
by anonymous

Hello,

Unfortunately we are not able to help you in coding.There should be codec 8 extended implemented as well to get two bytes of element lenght and variable size elements. In your exmple Beacon (ID 385) and BLE Sensors (ID 331 -> 334)  must have codec 8 extended enabled.

More information about codec 8E @ https://wiki.teltonika.lt/view/Codec#Differences_between_Codec_8.2C_Codec_8_Extended_and_Codec_16

Regards,

0 votes
by anonymous
Hello,

An example how to parse the x bytes for codec 8E can be as bellow. This code it works very well for my server:

  private static void getXBytesProperties(IoBuffer ioBuff, List<IOProperty> elements) {

    short ioCountX = ioBuff.getShort(); // 2 Bytes

    for (int j = 0; j < ioCountX; j++) {

      int propertyId = ioBuff.getUnsignedShort(); // 2 Bytes

      short propertyLength = ioBuff.getShort(); // 2 Bytes

      try {

        String propertyValue = ioBuff.getString(propertyLength, DECODER); // defined by propertyLength

        if(StringUtils.isNotBlank(propertyValue)) {

          elements.add(new IOProperty(propertyId, propertyValue));

        }

      } catch (CharacterCodingException e) {

        log.error("Error while trying to parse X-Bytes Codec8E", e);

      }

    }

  }