Web Bluetooth ❤ WebSockets

Kevin Valdek
Life After Data
2 min readAug 18, 2016

--

Chrome OS has shown how a browser can morph into an operating system and get widespread usage through cheap cloud-based laptops. Web apps can already be full-featured music streaming players or used for video-conferencing. It is exciting to now see Bluetooth Low Energy emerge as a component thanks to the Web Bluetooth workgroup.

This new API allows web apps to enter the IOT-era by utilising a lightweight wireless protocol that many smart devices are equipped with. There are sample apps to get started, which allow you to use common Bluetooth profiles such as sensor data or receive updates from a heart rate monitor. The snippets needed for this are minimal, but there might be other occasions when more complex Bluetooth apps are built. It might also be that apps that traditionally are deployed on embedded systems are now built to support Web Bluetooth as well. In these scenarios it can benefit to have the Bluetooth service running in a back-end system, while using the Web Bluetooth API of the browser.

This was the case for us at HIGH MOBILITY. We provide SDKs to build apps that can interact with car APIs directly over Bluetooth Low Energy. We wanted to include a car emulator directly in our Developer Center without the need to install additional software — and this is now possible with Web Bluetooth. To avoid code duplication, and to keep the private keys, well, private, we deployed our entire Car SDK in our back-end. Now all that was needed was data transfer between the back-end and the browser front-end — naturally WebSockets filled this task nicely.

Together with Recruit Technologies we created an Open Source library to add a WebSocket abstraction layer on top of the JavaScript Bluetooth functions. Now on GitHub as Bluetooth WebSocket API. It turns out that this mixture works very well and we hope that it can be of use to more people. Today the library supports the WebSocket implementation of Phoenix channels, but it has been built with the intention that WebSocket adapters for other protocols can easily be added.

Still early days for Web Bluetooth, but it is coming along with a new dimension of web and IOT apps.

--

--

Kevin Valdek
Life After Data

Entrepreneurial software engineer — co-founder & CTO at High-Mobility. @highmobility