Can not make Javascript encodeDownlink payload formatter to work

I am working on a YouTube tutorial about Javascript payload formatters in the TTS CE console.
I don’t seem to make a simple encodeDownlink payload formatter to work.
The payload formatter is just a demo.
Can someone tell me what is wrong with my encodeDownlink function?

JSON payload:

    {
       "data": {
          "aa": 4
       }
    }

Downlink formatter:

    function encodeDownlink(input) {
    	var bytes = [1, 2, 3, input.data.aa];
    	return {
    		bytes: bytes
    	};
    }

The payload output is:
01 02 03 00

But i expected as result: 01 02 03 04

forum

Got the answer! This is the solution:
The json payload should be {“aa”: 4}

1 Like