11 Nov 2012

I’ve just tagged a new release of the Arduino Client for MQTT – v1.9.1. This release includes an API change that will break existing sketches, something I’m very concious of doing – particular as the last release had such changes as well. But ultimately I decided this one was needed.

Previously, an instance of the client would be created with a call such as:

PubSubClient client(server, 1883, callback);

The library would then create an instance of EthernetClient under the covers. This was fine for hardware that used that class, but there are an increasing number of shields that use their own instance of the common Client API.

So, now the constructors for the client require an instance of Client to be passed in. For the vast majority of existing sketches, this just means changing the above line to something like:

EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

Amongst the other functional changes are the ability to publish a payload stored in PROGMEM, connect with a username/password and also the changes described in the previous post to not fragment MQTT packets over multiple TCP packets.

There is also now a regression test suite for the library. Built using python and Ino, the suite first verifies each of the examples compiles cleanly, and if an Arduino is connected, it will upload each sketch in turn and run unit tests against it. So far the focus has been on the scaffolding of the test suite, with only a couple actual tests in place for the example sketches. I’ve tried to write it in a way to be agnostic of the library it’s testing. There’s more work to do on that side of things, but ultimately it could well be reused by others. I imagine it’ll branch into its own repository when it gets to that point.

I’ve also given the project page a tidy and moved the API docs to their own page.

Finally, I’m considering closing the comments on the project page. with 75 comments already, it isn’t the best medium through which to provide support. I’m not sure pointing to the library’s issue tracker on github is necessarily the right thing either – it’s an issue tracker, not a support forum. Perhaps I should set up a dedicated Google group for the library – or is that overkill?

Feedback, as ever, is welcome.

  1. Karl Miller • October 23, 2013

    I am very interested in your Arduino client for MQTT. I noticed that you seem to have implemented for IP, and wondered if you considered another popular IoT protocol-ZigBee?

    Do you think it is possible? From what I have seen of your source, I would think so, but I haven’t done any legwork on it.

    Thanks,
    Karl Miller

  2. nickOctober 23, 2013

    Hi Karl,

    MQTT is principally a TCP-based protocol, hence the focus there.

    The transport layer used by the client is pluggable; the constructor takes an implementation of Client.h which provides a common interface with connect/read/write type methods. If someone produced an implementation of Client.h that worked with ZigBee, then it could be passed straight into the PubSubClient constructor and it’ll Just Work.

    Cheers,
    Nick

  3. leave a comment

    You must be logged in to post a comment.