Sintaxis in function for downloading a MQTT downlink message to a device in TTN

Hello,

For testing I have created a small TTN network using a Mikrotik wAP LoRA8 Kit gateway and an application in which I have a LoRAWAN modul that I'm controlling by AT commands.

The Node Red project I am using for testing in what you can see in the image:

imagen

When I send an uplink message I receive it well in the Debug window of the Node Red.

When I send a downlink message (just 3 bytes: 0x11 0x22 0x33) to the device, I can see that the Gateway receives the data, but this data is not forwarded to the application and neither the device. In the function node I have written the next:

return {
    "end_device_ids":{     
        "device_id": "eui-70b3d57ed005629d",
        "application_ids": {
            "application_id": "rfm6601-test-1"
        },
        "dev_eui": "70B3D57ED005629D",
        "join_eui": "323531322F002E00",
        "dev_addr": "260B7D71"
    },
    "payload": {
        "downlinks": [{
            "f_port": 15,
            "frm_payload": msg.payload.toString("base64"),
            "priority": "NORMAL"
        }]
    }
}

When I downlink the message, the debug window shows the next:

msg.payload : Object

object

downlinks: array[1]

0: object

f_port: 15

frm_payload: "17,34,51"

priority: "NORMAL"

The euis and IDs are the same than those I receive when I uplink data to the Node Red MQTT node.

Please, may you help me in developing the right function to get the message arrives to the end device in the TTN network? Excuse me if I have limited knowledge on this and this could be more a sintaxis issue.

Thank you very much in advance for your help.

Regards,
Joel

I don't use any of that equipment nor do I use LoRa - however, looking at other posts I suspect your message structure is not right.

Try this instead...

msg.payload = {
    "end_device_ids":{
        "device_id": "eui-70b3d57ed005629d",
        "application_ids": {
            "application_id": "rfm6601-test-1"
        },
        "dev_eui": "70B3D57ED005629D",
        "join_eui": "323531322F002E00",
        "dev_addr": "260B7D71"
    },
    "downlinks": [{
            "f_port": 15,
            "frm_payload": msg.payload.toString("base64"),
            "priority": "NORMAL"
    }]
}
return msg;

(this ↑ is pure guess work - if it does not work, point me to documentation and I'll try to help further)

Thank you for your quick proposal.
I have tested the changes but I have not seen that the downlink data could arrive to the TTN Application.
What I have been able to recover from the former version of the function that I published, is a message like this:
"Failed to transmit downlink".
And the even details:

{
"name": "ns.down.transmission.fail",
"time": "2022-10-09T11:43:17.701176736Z",
"identifiers": [
{
"device_ids": {
"device_id": "eui-70b3d57ed005629d",
"application_ids": {
"application_id": "rfm6601-test-1"
}
}
}
],
"context": {
"tenant-id": "CgN0dG4="
},
"visibility": {
"rights": [
"RIGHT_APPLICATION_TRAFFIC_READ"
]
},
"unique_id": "01GEY8WYP5N9QM02MWQY3Q4R97"
}

Regards,
Joel

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.