MQTT on the TI CC3200 LaunchPad thanks to Paho embedded client

What I really like with MQTT and CoAP is that they both are very simple protocols. When dealing with MQTT, the client itself has almost no state to maintain (at least when you stick to QoS 0 communications) and granted that you have an MQTT packet serializer/unserializer, it’s very simple to stuff such MQTT packets into TCP sockets using the networking APIs that your IoT microcontroller is providing.

I’ve had the opportunity to play with the TI CC3200 LaunchPad platform recently, and thought it would be a good candidate to try out the Paho embedded C Client.

The tutorial below, split into two parts (publishing and subscribing), gives a complete overview on how you can very easily port MQTT to the CC3200 and should probably be useful if you’re targeting another kind of platform, as it walks you through the process of tying in with the networking API of the underlying platform (TI SimpleLink™ in CC3200’s case)


How to setup Eclipse for Android Wear development

Last week at Google I/O, the Android Wear platform was officially launched, together with two smart watches from LG and Samsung.

I wanted to play around with the new APIs for Wear devices for an upcoming blog post on how to use MQTT with you smart watch, but I had to do a few things to properly set up my environment, and I thought I’d share :-)

I am assuming that if you read this blog post you have already a running, up-to-date, installation of the Android Development Tools.
Also, you should have installed, with the SDK manager, the Android 4.4W (API 20) SDK + Samples, as well as the Android Support Repository. And if you’ve done so already, it’s likely that you’ve been stuck not being able to compile an Android Wear project properly, for some classes seem to be missing…

Check out the following tips, and feel free to post a comment to report how it went for you!

The UI support library for Wear contains, among other things, a set of helpers to build UIs that work well on both square and round displays. In order to add this support library to your workspace, you must go find the file ./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar in your Android SDK folder. This is the support library in the AAR bundle format, that we need to convert in a project we can use in Eclipse.

  1. First, copy the .aar file to a location of your choice, change its extension to .zip, and unzip it
  2. In Eclipse, create a new project from this unzipped folder, using the File > New > Android Application Project wizard Capture d’écran 2014-07-04 à 10.10.59
  3. Once the project is created, there are two extra steps to perform to make it properly usable by your future Android Wear projects. First, is to move the classes.jar file in a “libs/” folder that you should create in the project. Second, is to edit the project preferences to make sure that the project is setup as a library project targeting Android API 20 (see screenshot below). Capture d’écran 2014-07-04 à 10.12.59

If you end up with something like this, you’re in a good shape! Capture d’écran 2014-07-05 à 12.14.55 You can now create you own Android Wear project, or import one of the samples that come with the SDK, and add the Wear support library as a dependency, as depicted below:
Capture d’écran 2014-07-05 à 12.45.19

WatchActivity is missing

Now you may notice that the “Blank Wear Activity” project template generates an Activity that extends WatchActivity, which is nowhere to be found in the SDK. Never mind this error, just extend a regular Activity instead and you should be just fine. See this StackOverflow answer.

Timeout when debugging over Bluetooth

ADB is an amazing tool for everything debug on Android platforms, and the ability to deploy apps on your watch and debug them over Bluetooth is really awesome. The setup of the debug link (which is actually done through your phone’s ADB connection) is well documented, but since the connection is rather slow you will need to update ADB connection timeout settings in your preferences.

Go to Preferences > Android > DDMS > ADB connection timeout (ms) and set a timeout of 30s (30000).
Capture d’écran 2014-07-05 à 13.00.57

Eclipse IoT Voting Machine

Powering EclipseCon France with IoT magic

In just about a week is EclipseCon France, and here’s one more reason why it’s going to be awesome! This year you will all be actors of a real-world Internet of Things setup, that leverages several Eclipse IoT technologies.

We’ve been wanting to do this for a couple years, and finally the great folks at the Grenoble University gave us a hand to build a system that will allow every EclipseCon France attendee to easily evaluate all the sessions!

How does it work?

Click on the drawing below and read the following chapters to learn more on how this voting mechanism has been implemented.

Voting machine drawing

NFC badges

nfc At the heart of the voting system is the NFC technology. In case you are not familiar, NFC (Near field Communication) allows to transmit information between devices when there are close to each other. The kind of information that can be exchanged depends on what devices are involved in the communication: two phones can e.g. use NFC to exchange contact infos or bookmarks (see Android Beam).

A use case that is very common is the use of RFID tags to “stick” information to an object, and allow this information to be retrieved later by any NFC-reader (smartphone, USB dongle attached to a computer, …). At a very minimum, this information is an ID that is unique to the tag and allows to identify the object you are “reading” ; other information can be stored in the tag but usually you only have just a few hundred bytes of memory on these lil’ things.

In the context of the voting machine, we will be adding an RFID tag to each participant’s badge, allowing to track who’s who when a vote will be performed, according to the unique ID of the badge.

Inside the voting machine, an MQTT publisher

Inside the voting machine is an Intel Galileo board (if you’ve ever heard of the Raspberry Pi, and I bet you did, the Galileo is a very similar beast, running on an Intel chip when the Raspberry Pi runs on an ARM architecture) that runs Linux, iPopo, and a Python MQTT client from Eclipse Paho. Attached to the Galileo are three NFC USB dongles that allow to detect the presence of a tag in front of the -1, 0, and +1 areas of the voting machine. iPopo is an OSGi-like container for Python scripts, and in our case it’s running several bundles for doing the NFC tags detection, handling the MQTT communication, etc. You can actually check out the source code of the Python bundles on Github.

Whenever a tag is in proximity of the voting machine’s -1/0/+1 areas, a very simple MQTT message (the NFC tag ID and the vote are the only informations transmitted) is sent to, allowing any consumer to subscribe to the broker to make sense of this information.

Interaction with

One of the strength of MQTT and an actual requirement for making scalable IoT architectures, is the ability to decouple data producers from consumers. And this is exactly what we are leveraging in the context of these voting machines: each voting machine publishes very naive messages to a broker, and it’s very easy to add a new node on the IoT network that will monitor such messages, and react. One node could be responsible for persisting the votes in a database, another could display them graphically, etc. The important point being that we’re not introducing any tight coupling between all these “agents”.

So in order to convert the raw vote “signals” into meaningful votes that can be fed into the website, we need to have a new node on the network that will have the knowledge of:

  • the mapping between NFC tags IDs and attendees (since we want to eventually post session reviews on behalf of a conference badge owner),
  • what session is in what room at a given time

Therefore in addition the voting machines, we’ve deployed a Raspberry Pi running a NodeJS application that uses MQTT to retrieve “raw” votes, compute the associated attendee + session for which the vote was made, and turns this information into ah HTTP POST request to the Drupal backend that powers!

See you real soon!

EclipseCon France 2014

Thanks again to the LIG team, and to Paul Guermonprez from the Intel Software Academic Program who provided most of the hardware used in the voting machines.

I’m really looking forward to seeing these cool machines in action next week! If you haven’t already, wait no longer and register today before the registration fee goes up!

Eclipse, open-source for the Internet of Things, and other random stuff