Payload not decoding properly from App Server

I’m successfully configured one of my custom Lora endpoints to talk through a Multitech gateway, to the MQTT packet forwarder, and on to my app server. I’ve set up an HTTP integration to push to my application that processes and stores the data and that is working well.

Where I have a problem is that even though the JSON that’s being pushed through the HTTP integration is perfect, the “data” element appears to be encoded or encrypted in some manner beyond the expected Base64 that’s in the documentation.

I’ve followed this thread, but it doesn’t make a whole lot of sense (as if it’s multiple conversations all mixed up):
https://forum.loraserver.io/t/receiving-decrypted-device-data-frmpayload/501/19

Following the advice of one poster there, I did a base 64 decode followed by a base 16 encode as my data is simply a hex string. This results in garbage data and not what I sent in.

I would expect that the “data” element in the JSON that is pushed out from the app server would match what the endpoint put in, minus the base 64 encoding issue. But this seems to not be the case.

What am I missing here?

Edit: Here’s a sample of what the JSON looks like for the end application that receives the HTTP Integration

{
"applicationID": "1", 
"applicationName": "Test1", 
"deviceName": "700010842", 
"devEUI": "cc3adf0029b9515a", 
"rxInfo": [{
		"mac": "00800000a00003b1",
		"rssi": -43,
		"loRaSNR": 9.8,
		"name": "mLinux1",
		"latitude": 0,
		"longitude": 0,
		"altitude": 0
	}
], "txInfo": {
	"frequency": 902900000,
	"dataRate": {
		"modulation": "LORA",
		"bandwidth": 125,
		"spreadFactor": 7
	},
	"adr": true,
	"codeRate": "4/5"
}, 
"fCnt": 7, 
"fPort": 1, 
"data": "BgApIN3zt4hgAAA="
}

The data is the decrypted base64 encoded payload. Example:
https://play.golang.org/p/POPMDjLXKol

1 Like

Thanks for the sample code! I’ve tried this already and am not getting the results I expect, but I’ll try it a different way and see if I can get it back to what I expect.

I’m not sure what is going wrong in your case, but this should be the data that is sent by your device (before encryption)…

I rewrote my application and did the base64 decode base16 encode a bit differently. Looks that it was an issue in my original implementation as I’m starting to see data as I would expect it. Thanks again for the sample code and clarification!

1 Like