Blog

Connecting People with the Internet of Things

Thus far, the vast majority of our blog posts have focused on the machine-to-machine opportunities the Internet of Things affords. Today I thought I would show a simple but powerful example of how easy it is to extend that connectedness to one of the tools we use every day--the web browser. And in so doing, I hope to illustrate some of the power of the wot.io data service exchange™.

As you probably already know, virtually all of the modern web browsers offer the ability to create plugins that extend the functionality of the browser. Today we will create a simple extension for Google Chrome that will send some metadata about the current web page off to the wot.io data service exchange™.

Here's a quick video demonstration:

A Peek at the Code

The heart of the extension is just a simple JavaScript file. In fact, the rest of the extension is really just the HTML and CSS for the popup and options pages.

Because one of the protocol adapters that wot.io supports is HTTP, we can implement our "send to wot.io" functionality with a simple AJAX request:

var send = function() {  
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        if (tabs.length) {
            var tab = tabs[0],
                xhr = new XMLHttpRequest(),
                msg = JSON.stringify(["link", tab.url, tab.title, tab.favIconUrl])
            xhr.onreadystatechange = function() {
                if (xhr.readyState === 4) {
document.getElementById('status').textContent = 'Sent successfully'  
                    setTimeout(function() {
                        window.close()
                    }, 750)
                }
            }
            xhr.open('PUT', options.url)
            xhr.setRequestHeader('Authorization', 'Bearer ' + options.token)
            xhr.send(msg)
        }
    })
}

var buildUrl = function(options) {  
    return 'http://' + options.cluster + '.wot.io/' + options.cluster +
        '/' + options.exchange + '/' + options.meta
}

Connecting People to All the Things...

Cool, right? And apparently useful, too, seeing as there are whole companies whose products do essentially what our simple extension does—create a web-accessible RSS list of bookmarks.

But how does that relate to IoT?

So glad you asked.

Remember back in the last section when I said how convenient it was that wot.io offers adapters for protocols like HTTP? What I didn't point out at the time was that any data resource on the wot.io data service exchange can be referenced via any of those protocols (subject to the authorization permissions of the user's access token, of course).

This means that if my data topology contained a resource whose messages are sent through a device management platform like ARM mbed Device Server, ThingWorx, or InterDigital's oneMPOWER Platform, sending data from the web browser to one of their connected devices would be as simple as changing a single value in the settings dialog. Same thing with devices or applications connected to a connectivity platform like PubNub.

And of course, any of the other 70+ data services on the wot.io data service exchange™ also get modeled as simple named data resources, making it as easy to send data interactively from a web browser to NGData's Lily Enterprise Hadoop platform as it is to send it to business logic in scriptr or to device connected to one of the aforementioned device management platforms.

Connecting All the Things to People...

But that's not even all! Because wot.io adapters are bi-directional, we could have just as easily selected the Web Socket protocol instead of HTTP for our Chrome extension's implementation. In that case, we could have still configured it to send data to the wot.io exchange just as before, but we could have also configured it to receive data from the exchange.

Whether that was data directly from devices or data that had been transformed by one or more data services, the possibilities are limited only by the logical data topology and your imagination.

Powerful Abstractions

The point of this post is hardly to claim that a toy browser extension rivals a polished product like Pocket. And of course, it could have just as easily been a web application as a browser extension. Nor was this post even intended to claim that sending IoT data to and from a web browser is novel.

The point of this post is to show how little effort was required to connect a hypothetical, real-world application to and from literally any of the connected data streams that we model on our wot.io data service exchange™ because they are all accessible through unique URLs via any of the numerous supported protocols.

Let that sink in, because it's really powerful.