198 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
Client Libraries For IBM IoT Foundation
Fri, Jan 29th 2016 3
Early 2016 Conferences And Sessions
Fri, Jan 22nd 2016 5
Building Cloud Native Applications With Spring – Part 8
Tue, Dec 15th 2015 5
Replay Of Docker Session From Qcon San Fran 2015
Tue, Dec 8th 2015 4
Building Cloud Native Apps With Spring – Part 7
Wed, Nov 4th 2015 5
Building Cloud Native Apps With Spring – Part 6
Thu, Oct 22nd 2015 5
Building Cloud Native Apps With Spring – Part 5
Mon, Oct 12th 2015 9
Top 10
Building REST APIs With Spring Boot
Wed, Dec 17th 2014 12
Building Cloud Native Apps With Spring – Part 5
Mon, Oct 12th 2015 9
Building Cloud Native Apps With Spring – Part 2
Mon, Sep 21st 2015 8
Using Microservices To Build Cloud Native Applications – Part 1
Wed, Jul 15th 2015 7
What Is Codename: BlueMix?
Mon, Feb 24th 2014 6
Sample Node-RED Flow Using Websockets
Tue, Jan 13th 2015 6
BlueMix Sample: ToDo Apps Built Using Your Favorite Language
Thu, May 1st 2014 5
Build a REST API For Your IoT Data Using MongoDB, Node-RED, and Bluemix
Mon, Jul 21st 2014 5
Building “Bootiful” Java Apps
Mon, Dec 8th 2014 5
Securing REST APIs With Spring Boot
Tue, Jan 6th 2015 5


Client Libraries For IBM IoT Foundation
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
ryanjbaxter    

If you are familiar with the IBM IoT Foundation, than you know the protocol used for communication between apps and devices is MQTT.  MQTT is an open protocol ideal for IoT solutions due to its lightweight nature.  It works very well when used by devices that might be running on a battery or my have a low bandwidth connection.  In the past when I have worked with the IBM IoT Foundation I have always used an MQTT library from mqtt.org.  These libraries work fine with the IBM IoT Foundation as long as they support MQTT 3.1.  However the IBM IoT Foundation offers its own set of client libraries for both devices and applications that make using the IBM IoT Foundation a little bit easier for developers.  Currently there are client libraries for Node.js, Java, Python, C#, Embedded C, and mBedC.  So what is the advantage of using the client libraries provided by the IBM IoT Foundation over the client libraries directly from mqtt.org?  One advantage that I am a huge fan of is simplicity of code!  Lets take a look.

Here is some sample code that will allow an application to connect to the IBM IoT Foundation Quickstart service using the open source MQTT Node.js library directly.

var mqtt = require('mqtt');
var clientId = 'a:quickstart:demoapp';
var messagingPort = 1883;
var messagingHost = 'quickstart.messaging.internetofthings.ibmcloud.com';
var client = mqtt.createClient(messagingPort, messagingHost, {"clientId" : clientId});
client.on('connect', function() {
  console.log('connected to iot cloud');
});

Here is some code that does the same thing as above but uses the IBM IoT Foundation Node.js client library.

var Client = require('ibmiotf').IotfApplication;
var config = {
  "id" : "demoapp",
  "org" : "quickstart"
};
var app = new Client(config);
app.connect();
app.on('connect', function() {
  console.log('connected to ibm iotf');
});

Yes the IBM IoT Foundation client library code is 2 lines longer than the MQTT client library, but number of lines is not the only measure of simplicity.  Look at what I didn’t need to know when using the IBM IoT Foundation client library.  I didn’t need to know the URL or port to the Quickstart service MQTT broker, and I didn’t need to know how to construct the client id.  I don’t know about you, but whenever I need to connect to the IBM IoT Foundation I am always searching through documentation to find the right MQTT broker URL and how to construct the client ID properly.  The IBM IoT Foundation client library is even a bigger help when connecting to your own organization in the IBM IoT Foundation.  When using your own organization you need to authenticate with an API key and token as well.  So if you are not already using the IBM IoT Foundation client libraries in your IoT apps I suggest you start doing so soon!



---------------------
http://ryanjbaxter.com/2016/01/29/client-libraries-for-ibm-iot-foundation/
Jan 29, 2016
4 hits



Recent Blog Posts




Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition