MQTT publish on The Things Stack

Hi everyone,

I am trying to publish a message with MQTT on The Things Stack. I followed the instructions here Send Messages | The Things Stack for LoRaWAN and I used the code found at the following link (TheThingsNetwork TTN decrypt payload · GitHub) as downlink payload formatter (on The Things Stack)..I have no errors but no message arrives at The Thing Stack... Do you have any suggestions?

Hi can you copy your flow please
Also looks like your trying to decode your downlink the only thing you need to do is
base64 encode your payload

Take read of this
https://www.thethingsindustries.com/docs/integrations/mqtt/#publishing-downlink-traffic

This is the sort of thing you need in a function node

var hexPL    = var hexPL = Buffer.from('01557733', 'hex');
var base64PL = hexPL.toString('base64');
msg.payload  = {
    "downlinks": [
        {
            "f_port": 2,
            "frm_payload": base64PL,
            "priority": "NORMAL",
            "confirmed": false,
            "correlation_ids": ["my-dowlink"]
        }
    ]
  };
msg.topic = "v3/app1@tenant1/devices/dev1/down/push";

This is the json code :

[
    {
        "id": "d991ed90e03c724c",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": ""
    },
    {
        "id": "8945234d519c3224",
        "type": "inject",
        "z": "d991ed90e03c724c",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "10",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[0, 42, 255, 0]",
        "payloadType": "bin",
        "x": 490,
        "y": 240,
        "wires": [
            [
                "940a7ad4781f5ee8"
            ]
        ]
    },
    {
        "id": "6ae6832d05fae10e",
        "type": "mqtt out",
        "z": "d991ed90e03c724c",
        "name": "",
        "topic": "v3/***@tenant1/devices/***/down/push",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "07b5ab05d787cc85",
        "x": 1090,
        "y": 240,
        "wires": []
    },
    {
        "id": "940a7ad4781f5ee8",
        "type": "function",
        "z": "d991ed90e03c724c",
        "name": "",
        "func": "return {\n  \"payload\": {\n    \"downlinks\": [{\n      \"f_port\": 15,\n      \"frm_payload\": msg.payload.toString(\"base64\"),\n      \"priority\": \"NORMAL\"\n    }]\n  }\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 240,
        "wires": [
            [
                "239e6e5bc72e41c9",
                "6ae6832d05fae10e"
            ]
        ]
    },
    {
        "id": "239e6e5bc72e41c9",
        "type": "debug",
        "z": "d991ed90e03c724c",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 160,
        "wires": []
    },
    {
        "id": "07b5ab05d787cc85",
        "type": "mqtt-broker",
        "name": "",
        "broker": "eu1.cloud.thethings.industries",
        "port": "1883",
        "tls": "283a670c.e20a28",
        "clientid": "",
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "283a670c.e20a28",
        "type": "tls-config",
        "name": "Default",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "",
        "verifyservercert": true,
        "alpnprotocol": ""
    }
] 

I can't copy the file because I am a new user. Maybe from the the photos you can understand...

ok that looks good to me
a wee note don't share your MQTT Username
obscure it v3/xxx@yyyy/devices/70b3d5e75e00dea2/down/push
Assume for your End device ID you've used the LoRaWAN devEUI?
Also looks like a Lansite device?

Add these topics to mqtt in node and create a debug node on each
And see if that helps also in the TTN/i console put verbose logging on, your should see your downlink scheduled.

v3/xxxyyy@tenant1/devices/+/down/queued
v3/xxxyyy@tenant1/devices/+/down/sent
v3/xxxyyy@tenant1/devices/+/down/failed
v3/xxxyyy@tenant1/devices/+/down/ack

Thank you!!

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