This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT-SN Client For Thread SDK (UDP to TCP Bridge)

The Thread SDK is pretty awesome! :) However, It does has a bit of a learning curve for me because it only uses UDP instead of TCP.

While searching I found an MQTT variant that uses UDP called MQTT-SN. For some reason it doesn't seem widely adopted or documented and I am trying to figure out why.

Are there any guides on how connect Thread devices through MQTT using MQTT-SN? Are there any alternative solutions?

Thank you for your help!

  • Hi,

    It is nice to hear that you enjoy the Thread SDK.

    Thread protocol was designed to support low-power devices (battery powered). To achieve low power operation, communication between nodes has be limited to minimum. TCP adds a lot of undesired overhead in communication. It is why Thread designers chose UDP instead which is much more efficient choice for constrained devices.

    The most popular protocol based on UDP and intended for sensor networks is CoAP. CoAP is used in Thread protocol for some of the control messages, but can also be used as an application layer protocol (since Thread itself does not specify any). And it is what we did in our Thread SDK (Thread MTD CoAP Client, Thread Simple CoAP Client, and Thread Simple CoAP Server examples).

    However, those examples use OpenThread's built-in CoAP which implements only limited number of CoAP features, which brings some limitations what you can do. If you would like to use more feature-rich implementation of CoAP on top of OpenThread, look into our Thread DFU example which uses more complete implementation of CoAP on top of OpenThread.

    MQTT-SN is an interesting alternative for CoAP. Probably less popular because of success of its counterpart. But thank you for an interesting link. Maybe one day we will add MQTT-SN to our SDK. If you would like to make something in this regard on your own, you have to use OpenThread's UPD API.

  • Thank you for your VERY informative answer! CoAP looks like a pretty attractive option if we can't get MQTT-SN working. However, I want to keep MQTT around as much as possible because my telemetry and infrastructure is based around events with large numbers of devices. Swapping protocols mid-project would involve quite a bit of re-work.

    For now I am going to try out this mqtt-sn tutorial. It's not perfect but looks like it fits the project requirements a little closer.

  • Update: Found an mbed MQTT-SN implementation for mbed. RIOT implementation is here. Coniki is here. It will also become a standard in the latest versions of paho this June. Hope this helps :)

Related