Use TTN as an MQTT Broker


#1

Hello, there,

I have a Multitech Conduit gateway and some ABP motes that need to be controlled by ADR.
According to How can I see if ADR (Adaptive Data Rate) is working with my end device (MultiTech's mDot module)?, ADR seems to be still under developing.

I want to keep the LoRa server service alive on the Conduit.
Could I use TTN just as an MQTT broker?
Here’s my Node-RED flow.

I can’t publish any upframe data to the TTN broker in MQTTlens nor Java. (or the TTN server side filters my data so I can’t see any of them from subscription).

Is it possible to publish arbitary data to the TTN MQTT broker?

I tried the https://www.thethingsnetwork.org/docs/current/multitech/ for testing purpose.
I was able to build the MQTT connection with TTN broker and see data coming through by subscribing topic “+/devices/+/+”.

I’m new to LoRa and TTN and I’m sorry if I put the question under the wrong category.

Thanks!
Ji


(Jac Kersing) #2

You can only read from the MQTT broker /up/. The only way to publish node data to TTN is by having a packet forwarder push it to TTN. You can install the poly forwarder and have it push data to both the conduit software and TTN, however you will have to configure this yourself as it is not a supported (nor recommended) configuration.


#3

Does that mean I have to modify the "gateway_conf"object in global_conf.json?

"gateway_conf": {
        "server_address": "router.us.thethings.network", // Should I keep this or change it to my localhost?
        "serv_port_up": 1700,
        "serv_port_down": 1700,
        "servers": [
            {
                "server_address": "router.us.thethings.network",
                "serv_port_up": 1700,
                "serv_port_down": 1700,
                "serv_enabled": true
            },
           {//Add my localhost here??}    
        ],
        "upstream": true,
        "downstream": true,
        "radiostream": true,
        "statusstream": true,
        "keepalive_interval": 10,
        "stat_interval": 30,
        "push_timeout_ms": 100,
        "platform": "*"
    }

Why there are duplicated server_address fields, one is outside of the servers list and another is inside the “servers” array? What’s the meaning of them?
I think I have to add my localhost (127.0.0.1) into the “servers” array, is there anything else I need to configure?

Thank you!


(Jac Kersing) #4

The list is used by the poly forwarder if present. Adding your local host would be a good start. Did you install the poly forwarder with the install.sh script? In that case the MultiTech software will be disabled and you will need to re-enable part of it (not the packet forwarder) which requires editing startup script(s).
When I wrote this setup is not supported I meant it, I do not have the spare time to help with these kinds of non-standard setups, sorry.


#5

TTN mqtt Subscribe
How to display a specific field?

C:\Users\alanf\Desktop>mosquitto_sub -h us-west.thethings.network -t “+/devices/+/up” -u “quick” -P “ttn-account-v2.pqq6c7i5gxnGKQ8jpGskGNLbaK7s1fx5pNStVfj7yGE” –v quick/devices/lopy1/up

{“app_id”:“quick”,“dev_id”:“lopy1”,“hardware_serial”:“70B3D54996B86685”,“port”:2,“counter”:248,“payload_raw”:“NjI4”,“metadata”:{“time”:“2017-10-24T18:39:30.347423678Z”,“frequency”:904.6,“modulation”:“LORA”,“data_rate”:“SF8BW500”,“coding_rate”:“4/5”,“gateways”:[{“gtw_id”:“eui-40d63cfffe031020”,“timestamp”:3956276946,“time”:“2017-10-24T18:39:29.14788Z”,“channel”:8,“rssi”:-65,“snr”:9.8,“rf_chain”:0,“latitude”:43.82279,“longitude”:-79.42452,“altitude”:180}]}}
quick/devices/mdot/up {“app_id”:“quick”,“dev_id”:“mdot”,“hardware_serial”:“008000000000C708”,“port”:1,“counter”:153,“payload_raw”:“BxA=”,“metadata”:{“time”:“2017-10-24T18:40:53.290938743Z”,“frequency”:903.9,“modulation”:“LORA”,“data_rate”:“SF10BW125”,“coding_rate”:“4/5”,“gateways”:[{“gtw_id”:“eui-40d63cfffe031020”,“timestamp”:4038943764,“time”:“2017-10-24T18:40:51.814738Z”,“channel”:0,“rssi”:-72,“snr”:12.5,“rf_chain”:0,“latitude”:43.82239,“longitude”:-79.42447,“altitude”:178}]}}
quick/devices/lopy1/up {“app_id”:“quick”,“dev_id”:“lopy1”,“hardware_serial”:“70B3D54996B86685”,“port”:2,“counter”:249,“payload_raw”:“NTc2”,“metadata”:{“time”:“2017-10-24T18:41:30.673285808Z”,“frequency”:904.6,“modulation”:“LORA”,“data_rate”:“SF8BW500”,“coding_rate”:“4/5”,“gateways”:[{“gtw_id”:“eui-40d63cfffe031020”,“timestamp”:4076580156,“time”:“2017-10-24T18:41:29.451149Z”,“channel”:8,“rssi”:-70,“snr”:10,“rf_chain”:0,“latitude”:43.82241,“longitude”:-79.42437,“altitude”:184}]}}

C:\Users\alanf\Desktop>mosquitto_sub -h us-west.thethings.network -t “+/devices/+/up/counter” -u “quick” -P “ttn-account-v2.pqq6c7i5gxnGKQ8jpGskGNLbaK7s1fx5pNStVfj7yGE” -v

NO DISPLAY

https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html

Subscribe to a specific field

You can also subscribe to a specific field. Building on The Things Uno / Quick Startyou could subscribe to get just the ledfield:
Copy
mosquitto_sub -h .thethings.network -t ‘+/devices/+/up/led’ -u ‘’ -P ‘’ -v

hello-world/devices/my-uno/up/led true