Data decoding for Chirpstack Web interface

Hi @brocaar,

Can you please let me know how to decode my data:

I used the decoder from here:

Please let me know. Thank you.


You need to read the docs - see THIS. Under CODEC tab, select “Custom JavaScript codec functions” and paste the decoder you linked in the UPPER field (just paste it at bottom of “automagical” text and then edit it to suit).

Then, you need to edit configuration for the device to use this device-profile. That’s all!

Hi @fmgst thanks for your response. I tried it:

but my Device Data is not showing the decoded data. It is still incoded.

1 Like

First, in Devices list, is your device configured to make use this particular device-profile? You may need to cycle power to device so that it pairs with gateway again - I think some of my devices REQUIRE this step, but maybe I’m mistaken. YMMV, but it’s easy to eliminate this possibility.

Second, did you try running your sensor data through your decoder manually, using an on-line javascript compiler? Here’s my flow:

  1. copy base64 encoded string & paste into THIS, with “Delimeter” field set to “,0x”. This decodes data into hex fields, except first one need “0x” prepended.
  2. Replace my data with yours HERE and modify your decoder to be run with your data - remember on-line compiler doesn’t have data, the way ChirpStack does, so you need to feed it some.

WARNING: if your decoder uses any ES6 javascript, it will work in on-line compilers BUT FAIL to run in ChirpStack for reasons I detail in same posting. Yours seems to be written specifically for ChirpStack so should work in both environments.

  1. This way you get to see if your code (a) compiles and (b) decodes data correctly.

@fmgst perhaps it is because I am new, but i want my data as a human readable string that has a value pair e,g, temperature : 54.37…
Not as hex.
Please let me know what you think. Thank you.


PS thank you for your reply

Yes, that’s the whole purpose of decoder/CODEC - you must get that working before you get readable data.

Did you follow steps in my message above?

1 Like

@fmgst I ended up creating my own, I needed the practise and knowledge. Thank you for your help, it is much appreciated.

@fmgst I was looking at your codee you sent. Where is your defintion for your decodeUplink function?

It was on TTN3 repository linked, but you had to drill down to particular sensor. In this case, this was:

As this whole approach doesn’t work because ChirpStack is limited to ES5 while TTN V3 repository is latest ES, I abandoned this: I have to continue to reinventing these wheels :-/

@fmgst fair enough. Would you happen to know how to happen how to use the atob() function in the decoder javascript section? I cannot import any libraries for some reason.
Also what is the purpose of the data being displayed in Base64 format?
Do i really need to decode the data in order to display it on a front end application?
Due to the fact i cannot import any libraries in order to decode it properly it would be easier that way. @brocaar Please let me know your thoughts on this matter. I would greatly appreciate it.Thank you both.

This needs more careful consideration, as you can see

Can you in-line (manually include by inserting into your code) the libs? That seems to be how Babel & core.js libraries work for getting around older browsers not supporting ES6 :slight_smile: