I use the template “Sending downlink using dashboard” to send a parameter (number of seconds, between 0 and 3600) to a device through TTN.
I created an Input Form and trigger the analysis from it.
When the input is of type “Number”, and I put for example ‘182’, the analysis log sends an error:
“The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received type number (182)”.
If I put other types of input, eg. Clock, or text, it seems the input is iterperted as Hexadecimal data. This means it should be a series of characters between 0 and F, (otherwise I get an error again from the script), and when received by my device, the payload is decoded from hexadecimal.
If input is ‘15’, the devices shows ‘21’ (= 1x16 + 5 ).
If input is ‘2345’, TTN downlink console shows ‘23 45’ and the device shows 35 and 69.
If input is ‘abcdef’, TTN downlink console shows ‘ABCDEF’ and the device shows 171 205 239.
If the input is ‘XYZ’, the scripts shows an error “Cannot read property ‘data’ of undefined”.
Can you help about having a simple and efficient encoding in the Analysis script so that data (number or text) is properly transferred, and received and decoded as the original data?