February 12th, 2016

Bluetooth Devices Can Now Be Controlled From The Web Through Node.js

Mobile App Testing Learn tips, techniques and trends for launching great mobile apps Get It Now
Like what you're reading? Subscribe to the weekly newsletter. Subscribe For Free
written by

Control a mesh network of Bluetooth devices from the Internet.

Bluetooth is known as a useful and ubiquitous short-range communication technology. But what if you could control your Bluetooth devices from anywhere and everywhere through the power of the cloud?

Cloud-to-Bluetooth device communication is now possible. The Bluetooth Special Interest Group (SIG) this week announced a new architecture that makes it possible to create Bluetooth gateways with the power of Node.js allowing devices to be controlled remotely from the cloud.

“People want to monitor their home security system from their couch and office,” said Steve Hegenderfer, the director of developer programs at Bluetooth SIG in a press release. “The Bluetooth Internet gateway architecture provides a standard way for any developer to create this gateway functionality. Routers, thermostats, security systems – the always on, always connected infrastructure in the home – can now speak to and control tiny, low power sensors and relay that information to the cloud, providing control from anywhere.”

How does the new Bluetooth Internet gateway work? Like all things Bluetooth, it is fairly simple with some complex bits.

Mobile Beta Management Learn the benefits, best practices and toolkits for mobile beta management Get It Now

Build A Gateway: Node.js, RESTful Smart Server API

The Bluetooth Gateway is a Web server running Node.js that implements simple Bluetooth functionality the Generic Access Protocol (GAP) and Generic Attribute Protocol (GATT) APIs as RESTful Web services.

The Bluetooth Gateway developer starter kit describes the function as thus:

The gateway works by scanning for Bluetooth devices. When it finds a device, the gateway caches the data structure of the services and characteristics supported by the device. When an HTTP request for the data structure is processed by the gateway, it responds to most of these requests from the cached data. When there’s request for the real data from the target devices, the gateway will start a connection and get/set the data immediately.

Bluetooth’s example is performed using a Raspberry Pi running a Debian operating system setup running Node.js. The gateway is dependent on several Node.js and simple Bluetooth libraries including hapi.js (a framework for building rich applications and services), crc for calculating Cyclic Redundancy Check to verify that messages between devices do not become corrupted and noble.js, a library for Bluetooth Low Energy.

When the gateway is started it will scan to discover and connect to devices in range and looking for the services and characteristics (the building blocks of Bluetooth functionality) for each device.

Once the gate is up, it will implements portions of the RESTful Smart Server API for the following endpoints:


NaviBLE: A Web App To Power The Bluetooth Gateway

The Bluetooth Gateway is necessary to help a device connect to the Internet and thus the cloud, but to truly control a Bluetooth device from the Internet, a Web application called NaviBLE is needed.

NaviBLE is built with open source tools from the Node.js community and, “uses the gateway to display devices within its range and lets us explore the services they offer and make changes to their characteristics, all from a web browser,” according to Bluetooth.

The NaviBLE Web app and server will interact with the gateway server to identify the devices (along with all of their nodes, services, characteristics and values) within its range. A developer will need to build the NaviBLE Web app with all the appropriate HTML, CSS and JSON capabilities to give it form and function.

To finish the set up between the Bluetooth Gateway and NaviBLE, developers will need to perform all the normal and necessary functions to make the connection between the servers and Web apps. To view the communication between the devices, Bluetooth has included several JavaScript libraries that translate hexadecimal data (how two Bluetooth devices communicate) to more human-readable formats.

The Power Of Bluetooth From The Cloud

The equation is fairly simple: Bluetooth device to server to the Internet. In this way the middle device—the smartphone or tablet—that normally would have a one-to-one connection with Bluetooth device is replaced by a server connected to the cloud.

“The key value promised by the IoT is that we can make life a little better by linking technologies and giving people more knowledge and control,” said Errett Kroeter, Bluetooth’s vice president of marketing, in a press release. “Our new Bluetooth gateway architecture enables the IoT to do just that. We are extending the monitoring and control of Bluetooth enabled sensor devices to the cloud and making the data accessible.”

The power of the configuration is clear. Instead of connected devices being tied to one controller in the master-slave relationship (Bluetooth to tablet, for instance), whole system of Bluetooth devices can be controlled and managed from a distance through a Bluetooth-to-server relationship.

Think of an automated factory, for instance. Various sensors on the likes of beacons, drones or robots can be completely controlled from a human outside the factory, instead of having one person on the floor monitoring through a computer. The power of the mesh network promised by the likes of Bluetooth and the Internet of Things is greatly enhanced.

  • Ted

    Wow, this is amazing stuff. Great technology enhancements to leverage the millions of devices already out there in the market. Will the new architecture only be available in new devices (post-release), or can current devices be upgraded?