encodeDownlink input

I have been trying to setup my encodeDownlink to send a hexvalue to my lora device.
This is the payload I am trying to send:
{
“queueItem”: {
“confirmed”: true,
“data”: “65BC88E0”,
“fCntDown”: 0,
“fPort”: 10,
“id”: “”,
“isPending”: false,
“object”: {}
}
}

I am trying to convert that data string into byte values, for instance: [101, 188, 136, 224], but nothing really seems to work, the value always gets put into the downlink as something completely else, or I get the error :
{
“code”: 13,
“message”: “Exception generated by quickjs: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object\n at from (buffer:167)\n at (buffer:179)\n at encodeDownlink (eval_script:134)\n at (eval_script:150)\n”,
“details”: []
}
I read that removing the object helps, but I have found no such luck, however if I remove the object it seems I can access the fPort, which it seems I cant do if it is present

data is a bytes field and should be base64-encoded when using JSON:

https://www.chirpstack.io/docs/chirpstack/api/api.html#api-DeviceQueueItem

2 Likes

Pushing {“dev_eui”:“dev_eui”,“object”:{“a”:“010004b0”}} to ChirpStack www interface device Queue/JSON worked for me. Data from “object” shows up in input.data for encodeDownlink. MQTT works too:
mosquitto_pub -h ha.c24 -u *** -P **** -t application/appid/device/dev_eui/command/down -m ‘{“dev_eui”:“dev_eui”,“confirmed”: true,“fPort”:2,“object”:{“a”:“010004b0”}}’
(dev_eui in payload must match one in topic).

Integrating LoRaWAN sensors into Home Assistant - Share your Projects! - Home Assistant Community has good encoding debugging approach described.