logo

flickr.com
MqttDotNet

.net Implementation of the client half of the MQTT messaging protocol.

Project Home at sourceforge
Download from sourceforge

What is MQTT

MQTT is a lightweight, open specification publish and subscribe protocol cheifly developed by IBM at IBM Hursley. Details of MQTT can be found at MQTT.org.

Over the years, I've mentioned MQTT a lot. Now that you can get your grubby paws on a free MQTT messaging broker over at MQTT.org I thought it was about time I polished up the client Brenton and I wrote a year or so ago and made it available.

The code is being released with a permissive MIT licence. Contributers are welcome. Neither Brenton or I have worked on the code base for some time, and may not find time to respond to questions, though you're free to try us.

Features

  • MQTT Version 3 Client side protocol support
  • .Net Framework Support
  • .Net Compact Framework Support
  • Interface that mirrors Java IA92 client, but makes extensive use of .net primitives, like delegates.
  • Support for Bluetooth connections (via bluetooth passthrough for broker) care of in the hand's 32feet.net library for bluetooth and IR communication.

Partial Work

  • Implementation of topic match tree (Abstract data structure capable of efficiently matching topic wildcards against a tree of 'subscriptions')
  • Experimental shared MQTT connection for managing multiple logical local clients using a single connection

Building the code

The source code can be found on sourceforge. The repository trunk contains MqttLib, and MqttLibMobile. MqttLibMobile contains no source, only a modified Visual Studio project file that targets the compact framework, and points to MqttLib's classes.

Open MqttDotNet.sln in Visual Studio to get started

Enabling Bluetooth support

You will need to download and install in the hand's 32feet.net library.

Once installed, set the WITH_BLUETOOTH flag in the desired project's properties. You may also need to adjust the libraries reference.

So how do you actually connect to a broker via bluetooth? You will need to write some software that accepts bluetooth connections and forwards them onto your broker.

Connection Strings

  • TCP connection, eg. tcp://brokerhost.com:1883
  • Bluetooth connection, eg. bt://00:10:dc:af:66:48:

Using the library

The source repository contains a project called Sample. It demonstrates a simple app which publishes to a topic, subscribes on another, and waits.

You can view it here: Program.cs

Shoutback

by Steven Lovegrove Jump to top