Compartir a través de


AllJoyn Cordova Plugin

The Problem

The AllJoyn protocol is an emerging leader in the device communications space. Think of it as “Internet of Things” on your local LAN — connecting your TV, lights, stereo and dishwasher to each other. See www.allseenalliance.org for details about the protocol and the alliance behind it.

With active support from most major electronics manufacturers, devices are starting to be released to the public.  All new LG smart TVs have AllJoyn support, and LifX, an exciting new Kickstarter-funded smart lightbulb is quickly gaining traction.  Qualcomm is building AllJoyn-enabled chipsets to power a wide assortment of upcoming consumer devices.  

Unfortunately, despite significant support from manufacturers, software to actually manage these devices and leverage AllJoyn is almost nonexistent.  OEMs still prefer propriety communications protocols for their applications and third party developers have mostly avoided participating. 

Several barriers have prevented significant software investment in the space and limited consumer adoption:

  • No direct cross-platform support in existing AllJoyn code
    • It is possible to leverage the existing code on a variety of devices, but each must be built independently and with little prior art.
  • Lack of community involvement
    • The existing code and documentation are extremely complex and inaccessible to most developers.
    • Third-party samples and frameworks are rare.
  • AllJoyn Routers are uncommon on most LANs.
    • AllJoyn requires a router or gateway on the local network to facilitate communications.  These have been challenging to setup and out of reach of most consumers.

Overview of the Solution

To bring AllJoyn to a broader audience it is critical to unleash a broad developer community that can quickly build applications and frameworks to support the protocol.  To do this we must lower the barriers to entry in the space by providing solutions that work with common tools and efficient workflows.

Microsoft Technical Evangelism & Development (TED) took the approach of building a fully cross-platform solution that enables developers to rapidly build AllJoyn applications with modern web technologies which can be deployed to iOS, Android, Windows Phone and Windows Desktop from a single code base.

The core of this solution is the AllJoyn Plugin for Cordova.  Apache Cordova is arguably the most robust option for cross platform mobile development in JavaScript and HTML.  It powers PhoneGap, Ionic, AppGyver and many other popular platforms.  This AllJoyn plugin can be used in any Cordova based framework to enable authoring of AllJoyn applications in JavaScript to run across all devices.

The AllJoyn Plugin for Cordova seamlessly ports and compiles the native C AllJoyn SDK for all platforms.  It then wraps the SDK with platform-specific shimming layers, and finally unifies it across all platforms with a simplified JavaScript API.  The plugin provides an abstraction layer that enables developers to simply start writing JavaScript and trust that their code will run across platforms, without worrying about challenges with native code. 

The second facet of our solution is to help spur development by clearly demonstrating approaches to common scenarios.   Three samples have been built using the plugin to illustrate approaches for AllJoyn lighting systems, televisions, and custom peer-to-peer implementations.

Finally, a major contribution from Windows is the inclusion of an AllJoyn Router in Windows 10 – ensuring that any LAN can trivially include the required router functionality by simply connecting a Windows PC or Xbox.

These tools, released in March 2015 at Mobile World Congress, are having an immediate impact on the AllJoyn landscape.  Several partners are currently in development with them and plan to release applications this year to control and manage their devices.

Additional Information

Find the Code

The core plugin lives on Github
https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn

It can be installed from the Cordova plugin repository, or directly from the repo:

 cordova plugin add org.allseen.alljoyn

or

 cordova plugin add https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn.git
  

Learn

We have put together several samples to help you get started.  Each is a Cordova application based on the plugin.  You can clone them; add the plugin; and build/deploy them right away.

Controlling a TV

https://github.com/AllJoyn-Cordova/cordova-tv-alljoyn

See the blog post covering the sample.

As well as an in depth look.

Controlling a Lightbulb

https://github.com/AllJoyn-Cordova/cordova-lighting-alljoyn

See the blog post about the sample.

and a more in depth overview.

Peer to Peer chat

https://github.com/AllJoyn-Cordova/cordova-chat-alljoyn

 

Stefan Gordon is a Principal Software Engineer on the Partner Catalyst Team where he uses his distributed services background to help build innovative open source tools and platforms. You can follow his other work at stefangordon.com