Application Design Tools - Getting Started with Bluetooth Low Energy (2014)

Getting Started with Bluetooth Low Energy (2014)

Chapter 7. Application Design Tools

This chapter introduces useful tools for mobile application developers, including code templates available for common mobile operating systems, inexpensive hardware platforms that can be used to simulate physical BLE devices (useful if you don’t have your own hardware available at the early stages of app development), as well as some purely software-based tools that can help debug and develop your application.

Bluetooth Application Accelerator

Bluetooth Low Energy is heavily concentrated on the mobile computing space, specifically mobile phones and tablets, with some adoption on traditional desktop computer and laptops—especially in the human interface device (HID) category, mostly for mice and keyboards. In recognition of this, the Bluetooth SIG introduced the Bluetooth Application Accelerator initiative to make adopting Bluetooth Low Energy much easier for application designers.

The Application Accelerator is essentially a set of software templates that make it relatively painless to create basic BLE applications on iOS, Android, and Windows RT 8.1 platforms. It also includes simple example code that shows how to connect and work with GATT services and characteristics.

Some knowledge of the specific platform is required, of course, but the templates should make it relatively easy to get up to speed on the BLE-specific calls required to interact with the target peripheral devices. The program requires registration, but no fees. For more details, see theBluetooth Developer Portal.

SensorTag

While most people would associate Texas Instruments (TI) with hardware design, as part of its BLE development ecosystem, TI has released an interesting and low-cost BLE development tool called SensorTag (Figure 7-1) that is extremely useful to mobile application developers.

Texas Instruments’ SensorTag BLE device

Figure 7-1. Texas Instruments’ SensorTag BLE device

Mobile applications are obviously only one half of the picture for most BLE use cases, and you generally need hardware for your application to interact with. But hardware might not be available in the early stages of the development process, or if you are simply interested in learning to work with the BLE APIs on a mobile platform, you might not know where to start finding a device to talk to.

The SensorTag solves this problem by providing an impressive collection of sensors in a relatively inexpensive and easy-to-order device, with example apps for both iOS and Android that show how to interact with those sensors.

The battery-powered Bluetooth Low Energy SensorTag platform includes the following sensors:

§ Temperature sensor

§ Humidity sensor

§ Pressure sensor

§ Accelerometer

§ Gyroscope

§ Magnetometer

This combination of sensors opens up a number of unique opportunities for data collection and rich user interaction. The accelerometer and magnetometer can be combined to collect reasonably accurate three-axis rotational data, the pressure sensor can measure changes in altitude as the device moves up or down, and so on.

Most importantly, the SensorTag platform allows application developpers to talk to real hardware and get real sensor data with a minimum of fuss and without having to learn how to design peripherals themselves or make progress on the app while they wait for working hardware from other specialists working on the project.

For more details, or to order a device, visit TI’s SensorTag product page.

LightBlue for iOS

Many mobile application developers might not be interested in designing their own BLE hardware, but instead want to talk to existing BLE peripherals that are already available on the market.

While some of the debugging tools discussed in Chapter 6 will no doubt be useful to app designers, anyone with a recent iOS device has access to an extremely useful tool from Punch Through Design called LightBlue. This free application, which is available in the App Store, can be used to reverse engineer or even emulate any BLE peripheral from an iPhone or an iPad.

You can use LightBlue to interact with services and characteristics a device exposes—for example, reading or writing individual values. You can also use it to capture the unique signature of an existing BLE peripheral once and then play that signature back for development purposes, essentially emulating the device that you might not have access to day to day.

If you know what the device should look like, but real hardware isn’t available, you can also create a profile to imitate your peripheral and then create a device that will appear exactly the same as the hardware once it is available, as shown in Figure 7-2.

A version of LightBlue is also available for OS X in Apple’s App Store, although the iOS version offers more functionality at the time of this writing.

Application developers can also use LightBlue when developing a BLE peripheral but before the counterpart iOS or Android application has been completed. You can simulate the over-the-air interactions between central and peripheral, allowing you to debug the peripheral’s firmware without yet having a custom application developed on the central.

LightBlue showing a BLE device simulated on another instance of LightBlue

Figure 7-2. LightBlue showing a BLE device simulated on another instance of LightBlue

nRF Master Control Panel for Android

If you are running Android 4.3 or higher on a device that supports Bluetooth Low Energy, the Android version of Nordic’s Master Control Panel allows you to debug, reverse-engineer, or interact with existing BLE hardware in an easy-to-use UI.

You can download this free tool from Google’s Play Store and find the UUID for any service or characteristic present on nearby BLE peripherals, subscribe to notifications sent by the characteristics, or write values back to the peripheral, similar to the way LightBlue (see LightBlue for iOS) and the PC-based Master Control Panel application (see PCA10000 USB Dongle and the Master Control Panel) work.

Figure 7-3 shows the results of a Heart Rate Monitor service, where the Body Sensor Location and Heart Rate Measurement are both visible.

nRF Master Control Panel showing a Heart Rate Monitor service

Figure 7-3. nRF Master Control Panel showing a Heart Rate Monitor service

Further information about the Master Control Panel app and other Android applications from Nordic Semiconductors is available on its support pages.