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.
Image Source: Eclipse.org ponte team.
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 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.
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
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):
Here is an output from my PC when i run Ponte in verbose mode:
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
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.
Following links provide more information on 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: