Getting started with MQTT-SN in RSMB

Now that the source for RSMB with MQTT-SN is available, here is the quickest of quick starts to get going with MQTT-SN. More to come in due course.

The source is at http://git.eclipse.org/c/mosquitto/org.eclipse.mosquitto.rsmb.git/
in the rsmb directory. To build, go into rsmb/src and call “make”. That works well for Linux. You need a make from cygwin or similar to build for Windows.

This is an example configuration file for RSMB with MQTT-SN:


# will show you packets being sent and received
trace_output protocol						

# normal MQTT listener
listener 1883 INADDR_ANY	
		
# MQTT-S listener
listener 1884 INADDR_ANY mqtts					
	# optional multicast groups to listen on
	multicast_groups 224.0.18.83	
	# optional advertise packets parameters: address, interval, gateway_id			
	advertise 225.0.18.83:1883 30 33			

# MQTT-S outgoing multicast bridge (QoS -1)
connection mqtts_multicast						
	protocol mqtts_multicast  
	# only one address is used at the moment, plan is that a list can be used
	address 225.0.18.83:1883					
	topic a out
	topic abcdef out

# QoS 2 MQTT-S bridge
connection mqtts							
	protocol mqtts
	address 127.0.0.1:1885
	topic a out

At the moment predefined topics and sleeping clients aren’t implemented.

There is a Python MQTT-SN client in rsmb/src/MQTTSClient/Python – see mqtts.py, in the main section, for an example of using it.

8 thoughts on “Getting started with MQTT-SN in RSMB

  1. Thanks for the instructions. Sadly I can’t get it to work. I have tried on Debian Linux and Mac OS X:

    20131124 215009.143 CWNAN0124I Starting bridge connection mqtts
    20131124 215009.143 4 127.0.0.1:1885 star.mqtts -> MQTT-S CONNECT cleansession: 0 (0)
    20131124 215009.144 CWNAN0075W Socket error 111 (Connection refused) in UDP read error for socket 4
    20131124 215009.144 CWNAN0018W Socket error for client identifier star.mqtts, socket 4, peer address 127.0.0.1:1885; ending connection
    20131124 215009.144 CWNAN0099I Trying bridge connection mqtts address 127.0.0.1:1885 again, without private protocol

    Any idea what is wrong?

    • So I just did this (on RedHat, Intel). First RSMB has outgoing bridge:

      connection mqtts
      protocol mqtts
      address 127.0.0.1:1885
      topic a out

      Second RSMB has listener on matching port:

      listener 1885 INADDR_ANY mqtts

      Then the MQTT-SN bridge connected to the other broker. Two things to watch out for:

      1) To build RSMB on some platforms (not the usual ones) you need the -DREVERSED compiler flag. This because I use bitfields in the MQTT packet processing. Whether you need it is entirely arbitrary – processor architecture can affect it. If any client, MQTT or MQTT-SN can connects, you’re ok.

      2) Firewalls often block multicast traffic. In this case we’re not using multicast of course.

    • Ha ha. Soon my friend, we’ll have the new spec out, and the name will be officially changed, and I’ll update it all!

  2. Hello Ian,

    first of all, thank you for all of your MQTT and RSMB posts. Now, i´ve got a question regarding the configuration of the RSMB using MQTT topic names and MQTT-SN topic ids over a MQTT-SN gateway.
    Using the this post and the “Getting started with the Really Small Message Broker” information is very useful to figure out how to configure topic name mapping in the case of connecting two Really Small Message Brokers together.
    Regarding to the MQTT-SN specification v1.2 in section “6.10 Gateway’s Publish Procedure”, the gateway (in my case the RSMB, using the broker_mqtts implementation) may send a REGISTER message to inform the client about the topic name and its assigned topic id value. Now, i would like to configure the mapping of MQTT topic names to pre-defined MQTT-SN topic ids.
    Is it possible to configure a mapping in the RSMB broker.cfg configuration to tell a MQTT-SN client the pre-defined topic id after a successful connection to the RSMB?

    Thank you for your feedback.

    Dennis

    • Hello Dennis,

      thanks for your question. The short answer is unfortunately no :-(. Predefined topics are one of the two MQTT-SN functions, the other being sleeping clients, that were not yet implemented in RSMB. My plan is that all the MQTT-SN functions would be added to a) Mosquitto, when it has MQTT-SN added and b) an MQTT-SN to MQTT transparent gateway which I plan to add to Paho.

      However, adding pre-defined topic ids to RSMB should not be a big task, and I would gladly accept a contribution. Or I might get to it myself as a stop gap until Mosquitto supports MQTT-SN itself.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>