In an earlier post i described how i setup a Mosquitto MQTT broker locally. In this post i will introduce you to "Ponte" a brilliant project that's in development at the Eclipse foundation.


What is Ponte


Ponte is a M2M bridge framework that aims to close the gap between M2M interactions and the rest of the Internet. The current implementation is built on top of NodeJs.

architecture.png

 

Image Source: Eclipse.org ponte team.


Why Ponte


Protocols like MQTT and CoAP are playing a major role in standardizing M2M communications. These protocols have been making it easier for building connected devices as we have seen in this RoadTest and elsewhere in several of the design challenges at Element14.


For the vision of Internet of Things to be fully realized, these devices need to be accessible to the world wide web in a language that WWW speaks. WWW and Internet don't speak MQTT or CoAP naturally. They speak HTTP.  For example you cannot easily have your PC or a MAC or smart phone access the information from the MQTT/CoAP bridges without resorting to custom applications that use specific libraries (like the Paho MQTT client Libraries.. kartben introduced the MQTT  Javascript and C library in this example.. Here is an example of using the Java MQTT Library with processing)


That's where a bridge like Ponte becomes extremely useful. It can speak MQTT, CoAP and HTTP.. That makes it imminently suitable for connecting the resource constrained devices with the rest of the world. Also it supports excellent array of storage engines (a.k.a Database) that allow data from the connected things to be stored, analyzed, syndicated and do whatever we do with regular databases.


For example consider the Sudden Impact design challenge currently running on Element 14. Multiple sensors and devices would be sending data to the Ponte bridge using MQTT or CoAP. A Ponte Bridge will allow that data to be collated in one place and analyzed. Web/mobile applications can be easily written using the HTTP bridge on Ponte to present it to users.


For the Holiday lights IoT challenge i will present a small use case later that will demonstrate the power of Ponte over other MQTT bridges.

(Update: Please see the following posts for use cases.

Part 3.2: Reading a MQTT topic with HttpClient On Arduino Yun

Part 3.3: Arduino Uno + ESP8266 + Eclipse Ponte HTTP Bridge = MQTT Magic

)

Installing Ponte


1. If you do not have nodejs already installed, install it from http://nodejs.org/download/

2. Do a  npm update to make sure that node package manager is up to date

3. Install Ponte by running the following:

npm install ponte -g $ ponte


Running Ponte:

1. If you are already running a MQTT broker like mosquitto, stop it. (In windows use the windows services control panel.)

2. then run Ponte from command line (with a verbose flag if you want to see more information as each connection is made):

ponte -v


Here is an output from my PC when i run Ponte in verbose mode:

C:\RnD\nodejs\node_modules>ponte -v
{"name":"ponte","hostname":"MATRIXPC","pid":17440,"service":"MQTT","level":30
,"mqtt":1883,"msg":"server started","time":"2014-12-26T18:25:43.234Z","v":0}
{"name":"ponte","hostname":"MATRIXPC","pid":17440,"service":"HTTP","level":30

,"port":6000,"msg":"server started","time":"2014-12-26T18:25:43.253Z","v":0}
{"name":"ponte","hostname":"MATRIXPC","pid":17440,"service":"CoAP","level":30

,"port":6683,"msg":"server started","time":"2014-12-26T18:25:43.254Z","v":0}


Note the ports at which each of the HTTP, MQTT and CoAP srvers are running. In my machine i edited the HTTP port number and the CoAP port numbers in the Server.js file (found at C:\Users\XXX_User_name\AppData\Roaming\npm\node_modules\ponte\lib)


Note down the port number for HTTP.. It should be 3000 by default.


Accessing MQTT Topics from HTTP:


Each MQTT Topic can be accessed from the Ponte HTTP Endpoint by adding the topic name after resources:


For example: Considering that your "MyHostName" is your host name and the http port for Ponte is 3000, the http URL for the topic "MyFirstTopic" is


http://MyHostName:3000/resources/MyFirstTopic


Now to subscribe to messages from this topic we use "GET" and to publish messages to this topic we use "PUT"


Publishing from HTTP to MQTT


Go to Terminal or command prompt and use curl (On windows i installed curl from http://curl.haxx.se/download.html). Also if you have already installed mosquitto broker as described here, it would have come with a two very handy utilities for publishing and subscribing (mosquitto_pub and mosquitto_sub). I will be using them as well here:


First run mosquitto_sub to listen to messages on all the topics. (This is just for testing and verifying. Typically you will be listening to specific topics in actual client implementations)


mosquitto_sub -v -h localhost -t "#"


Then open another terminal and run curl to "PUT" mqtt message "255,255,0" to topic name "RGB"


curl -X PUT -d "255,255,0" http://localhost:3000/resources/RGB


Now you should see the message popping up on the mosquitto_sub window


Publishing from MQTT to HTTP


use mosquitto_pub to send a test message. Make sure the retain flag ( -r ) is set to ensure the broker retains the message until some client reads the message.

mosquitto_pub -r -h localhost -t FromPC/TestPonte -m "Are you There?" 


use Curl to issue a GET to read the message


Now you should see the message in the curl response.


Resources


Following links provide more information on Ponte:

Ponte - Bringing Things to REST developers

http://eclipse.org/proposals/technology.ponte/

https://github.com/eclipse/ponte

 


Stay tuned for more articles on how i use Ponte bridge in my IoT Holiday lights project.

Update: see here for additional blog entries:

Part 3.2: Reading a MQTT topic with HttpClient On Arduino Yun

Part 3.3: Arduino Uno + ESP8266 + Eclipse Ponte HTTP Bridge = MQTT Magic

)