Thingsboard Questions

There are two questions on the topic of the Thingsboard integration that have received no responses. One is 4 days old and another has been up since March 24.

Is this forum not the right way to get answers to questions about the Chirpstack to Thingsboard integration?

start read from here

I did. It’s not useful, and the Thingsboard integration doesn’t work.

Please refer to the two posts on Thingsboard that STILL have no answer.

One way is just to use the HTTP integration (and switch to newer JSON format so you can differentiate between the various messages if you want more than just uplink).
You can decode the base64 payload with some helper functions.
It gives more flexibility too.

var base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function decodeBase64(input) {
    var length = input.indexOf("=");
    if (length == -1) length = input.length;
    length = input.length / 4 * 3 - (input.length - length); // 1 or 2 bytes padding = 1 or 2 bytes off

    var arrayBuffer = new ArrayBuffer(length);
	var uarray = new Uint8Array(arrayBuffer);

	var j = 0;

	for (var i=0; i<length; i+=3) {
		var enc1 = base64.indexOf(input.charAt(j++));
		var enc2 = base64.indexOf(input.charAt(j++));
		var enc3 = base64.indexOf(input.charAt(j++));
		var enc4 = base64.indexOf(input.charAt(j++));

		var chr1 = (enc1 << 2) | (enc2 >> 4);
		var chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		var chr3 = ((enc3 & 3) << 6) | enc4;

		uarray[i + 0] = chr1;
		if (enc3 != 64) uarray[i + 1] = chr2;
		if (enc4 != 64) uarray[i + 2] = chr3;
	}

	return arrayBuffer;
}

function buf2hex(buffer) {
    var byteArray = new Uint8Array(buffer);
    var hex = "";
    for (var i = 0; i < byteArray.length; i++) {
        hex += ("0" + byteArray[i].toString(16)).slice(-2);
    }
    return hex;
}

try {

    var payloadStr = String.fromCharCode.apply(String,
        payload);
    var json = JSON.parse(payloadStr);

if (json.dev_eui !== undefined) {
        var devEUI = json.dev_eui;
        if (devEUI.endsWith("=")) {
            devEUI = buf2hex(decodeBase64(devEUI));
        }


var decodedData = decodeBase64(base64data);
var x = new Uint16Array(decodedData, 0, 1))[0];
loop, slice your data, whatever you want.
At the end, you return the attribute/telemetry (optionally timestamped based on gateway time or timestamp in payload).

I also have some questions on Thingsboard Integration. I am using Thingsboard PE, not sure if PE integration is same as CE or Cloud edition? Whether I need do something in TB PE side. for example add Chirpstack application Server IP address?