Developing Cross Platform BLE Apps: Our Experience

September 30, 2016 Colin Karpfinger

Cli Loader Announcement 647w

Those who have successfully developed a connected product know it is a unique struggle. The idea of a product being one physical thing, where you build it, ship it, and move on, is over. Now the hardware is only one part of the puzzle, and often times, the smallest piece. For Bluetooth products supporting multiple platforms, the software tasks can be daunting.

The LightBlue Bean is compatible with 5 platforms: iOS, Android, macOS, Windows, and Linux. Each platform has both a user-facing application as well as an associated SDK, that can be used to easily build an app to interface with the Bean. The apps and SDKs are tested and maintained separately, essentially bringing the number of software products we support to 10. Daunting.

Differences in Bluetooth Functionality

Interfacing with Bluetooth peripherals varies quite a bit between platforms. Each platform has it's own Bluetooth stack and API, with unique capabilities, quirks, and bugs. This is a major point to consider when developing a Bluetooth product. These quirks will directly influence your approach to software, but also can influence your firmware architecture, and even in cases, your choice of silicon. For example, not all BLE system-on-chips can support the requirements of Apple's HomeKit, or the increased security needs of Bluetooth 4.2.

The evolving nature of the Bluetooth stacks on major platforms was the main reason we initially decided to build native versions of all of our loader applications. We launched the Bean in November 2013, at which point there weren’t many great cross platform options. With cross-platform BLE support maturing, now is a great time to explore some cross platform solutions; QT v5.5+ and Apache Cordova are both well supported and support BLE either out of the box or with community plugins.

However, one of our primary considerations was replacing our native Windows loader. Microsoft hasn't accepted the move to handle Bluetooth LE differently from Bluetooth 2, like Apple and Google have. In Windows, users must still connect through Control Panel / Settings. This experience feels like going back in time and installing sound card drivers. 

Node.js + Noble

With Windows support required, our software developer Steve Stack convinced us to spend a week exploring a different path. He built a proof of concept demo with Node.js along with a project called Noble which is a cross-platform BLE library that supports Windows, Linux and OS X. After only a week he was able to update firmware on Beans, and we decided to move forward. With emerging front-end frameworks and GUI toolkits such as React (from Facebook), React Native and Electron.js (from GitHub), a JavaScript solution seemed to fit the bill. This approach is already used by several industry leading apps, such as Slack and Github's Atom Editor. For anyone developing a Bluetooth app that will need to run on desktop OSes, Node.JS and Noble make for a great option.

Our new cross-platform Bean loader app

This week we announced our new cross platform loader app. Well done, @swstack! For Bean users, this brings some great updates. First, it means greatly improved support in Windows. By using Node and Noble, we can bypass Window’s Bluetooth process and maintain BLE connections and interactions inside of our app. We were also able to support Linux for the first time, with almost no added work. The same codebase was used, with the only difference being the install process, testing and documentation.

We are releasing a command line version at first, in order to release early and get feedback from users. It supports Mac, Windows, and Linux with one codebase, and represents our goal of providing better support and more frequent updates.

Mobile Considerations

For those targeting mobile devices, cross-platform solutions are in abundance, however, not surprisingly BLE support is still young. Each mobile OS have unique BLE interfaces, quirks and features such as Apple HomeKit. Currently there is no official support for Noble.js on mobile platforms but we will be working towards adding this support by writing native shim layers to maximize code reuse across desktop and mobile.

This release of our cross platform loader is in many ways an experiment. It is our minimum viable product. It is command-line only, and the install process requires some extra steps. It is not a replacement of our existing Mac GUI Loader. As we collect feedback and build upon it, it may become our main codebase that will be used for all of our future Bean loaders.

I would love to hear feedback from those using it. Check out our cross platform loader app here, and let us know about your experience building cross-platform Bluetooth apps. If you are building a cross platform Bluetooth product and need help, please don't hesitate to reach out. You can join the community discussion here, or reach us at sales@punchthrough.com or from our consulting page