I try to send downlink with mosquitto_pub -h “192.168.153.251” -p “1883” -t “application/9/device/72b1d27eg3017316/command/down” -m ‘{“confirmed”:true,“fPort”:1,“data”:“1234”, “obj”:{“status”: “on”}}’
My encode function in chirpstack API:
function Encode(fPort, obj, variables) {
var statuss = [“off”, “on”];
var bytes = ;
//obj = JSON.parse(obj);
//console.log("JSON parsed OBJ is "+obj);
bytes.push(0x00);
//bytes.push(statuss.indexOf(obj.status));
return bytes;
return fPort;
My Decode Function in Chirpstack API:
function Decode(fPort, bytes, variables) {
var statuss = [“off”, “on”];
var data ={};
data.pressure=((bytes[1] << 8) + bytes[2])/10;
data.temperature=((bytes[3]<<8)+bytes[4])/100;
data.humidity=((bytes[5]<<8)+bytes[6])/100;
data.battery=bytes[7];
voltageFromArduino_string=String.fromCharCode(bytes[13])+String.fromCharCode(bytes[14])+String.fromCharCode(bytes[15])+String.fromCharCode(bytes[16]);
data.voltageFromArduino=Number(voltageFromArduino_string);
if(fPort==1) {
data.status=statuss[0];
return {
data: data,
warnings: ,
errors:
};
}
return {
data: data,
warnings: ,
errors:
};
}
Then i receive this log from network server:
Aug 14 12:39:12 pi chirpstack-network-server[1241]: time=“2024-08-14T12:39:12.590555457+02:00” level=error msg=“backend/gateway: unmarshal downlink tx ack error” data_base64=“eyJnYXRld2F5SUQiOiJKT0VrLy83NDRmQT0iLCJ0b2tlbiI6Mjc4OTMsIml0ZW1zIjpbeyJzdGF0dXMiOiIxIn1dfQ==” error=“unknown value "\"1\"" for enum gw.TxAckStatus”
I receive this error in “Device data” from chirpstack API:
- error:“json: unsupported value: NaN”
I can receive uplink from my lora-e5 dev board, but downlink not working. I can not see the bytes array, which should send for my device.
What could be wrong in my set up. What can i do ?
As you can see in my pics. txack and ack=true from device and from gateway, but data still null and i don’t have any bytes HEX send to my LoRa-e5 dev board.
I try return simple bytes[0]=0x00 in encode function from chirpstack. Still same problem.
What i understand: After mosquitto_pub, my raspi send message for network server(chirpstack), network server use my encode function, send bytes array for gateway and gateway send to device. What i missunderstanding ?
Second pic is LoRaFrame from gateway, prove that, fPort1 have been use for my mosquitto_pub, which correct to my message send with mosquitto_pub
Can anyone help me, i stuck here for a week ?
Thank you all
Minh Thong Pham