Unable to decode the data with JavaScript codec


No need to convert into integer. Simply convert the base64 into text… search for some library that converts base64(decoded) to text…


Please don’t create additional topics for this, this is the right topic to discuss this issue.


That was the reason that i asked @brocaar…any tip about?


When I return this object:{"byte_array":bytes} It outputs as the base64 encoded string when I look at the “live device data” in the app server. Am I somehow not grabbing the base64 decoded array instead of the encoded string?

When I try and do something like byte_array=bytes[0] I get an error when trying to take index 0 of ‘undefined’


Potentially a device could send no data on a fPort > 0. In that case, make sure to first check bytes is non undefined or null, before further processing it.


I was able to figure out my issue. When I return {"byte_array":bytes} I see the base64 encoded value.

When I return {"byte_array":bytes[0]} I get the value.


I use thi function to print the bytes received by Decode in hex:

function toHexString(bytes) {
    return bytes.map(function(byte) {
        return ("00" + (byte & 0xFF).toString(16)).slice(-2)

function Decode(fPort, bytes) {

    var tempObj = new Object();
    tempObj.dataHex = toHexString(bytes);

    tempObj.message = "Raw message bytes";

    return tempObj;



I used this to get the original message (bypassing the decode issues), having the same issue as these people.

function Decode(fPort, bytes) {
  return {
    data: String.fromCharCode.apply(null,bytes)