Bluetooth Low Energy is a new Bluetooth standard that is exciting for a couple reasons- it enables very low power battery applications, and it further opens the smartphone accessory market.
LightBlue allows you to test and simulate Bluetooth Low Energy devices. Testing devices is done in Central mode, where you can scan and connect to any nearby devices. Simulating devices sets the iOS device into Peripheral mode, where you can emulate a device.
(You can find LightBlue in the app store by searching, or from following this link: LightBlue iTunes Store)
First, a quick primer on BLE. The 2 most common roles of devices are Central and Peripheral. (There are 2 others, Broadcaster and Observer, but less commonly used). The Peripheral is generally an embedded sensor, the device that ‘Has Data’. The Central is generally a Phone or PC, the device that wants to access the data. You can also think of these as Server- a sensor (has data) and Client- an iPhone (wants the data).
Devices are found through Advertising. A Peripheral broadcasts an Advertisement at intervals, generally somewhere between 50ms to 2s. This interval is known as the advertising interval, and there is a similar interval once you’re connected. The Central scans for these devices by picking up advertisement packets. The advertisements have a small amount of data in them, regarding what type of device they are.
The data on Peripherals are organized according to their Profile. This profile is made up of services and characteristics. Characteristics are the holders of data, and can be accessed in 3 ways- Read, Write, and Notify. Services are just a description of a set of Characteristics.
There are some existing profiles that have already been agreed to by the Bluetooth SIG (Special Interest Group). These are just well defined groups of data for certain kinds of accessories. They allow you communicate with an accessory in a predefined way. You can find the list of these here: http://developer.bluetooth.org/gatt/profiles/Pages/ProfilesHome.aspx
Now on to LightBlue, the BLE testing app. First we’ll cover Central Mode, which is the most common use if you’re developing a hardware accessory.
Open LightBlue and touch the 'Central’ icon at the bottom of the screen, and pull down in the main window to scan for devices. In this example we’re scanning and connecting to a LightBlueM Dev Kit.
Once you connect, you’ll see the RSSI indicated in the upper right corner of the screen. Touching a service will show the corresponding characteristics of that service. You can see the various types of characteristics, Read, Write, Notify. There is also a Write Without Response type that can be used to send data more quickly in your final application.
Now we’re browsing the characteristic 0xFF13 which is a Read/Write type. Lets first read the value. You can see the ASCII text is 'hello’.
To test a write, let’s type 'world’ in the ASCII box. You can send data both in ASCII or Hex format. You’ll also notice the recent history of sent values below, so you can quickly repeat any previous writes. Now if we go back and read the characteristic’s value, we can see it is set to 'world’.
All actions are recorded in the Logs tab for debugging purposes. You can select and copy this text if you want to share it with your colleagues.
To recap, Central mode is used when you want to test a BLE peripheral. This could be a sensor you’re developing, a heart rate monitor, a temperature sensor, etc.
One of the coolest things about BLE is that you can openly connect to just about anything and check out its structure of characteristics and services.
Now say you are developing an awesome app that connects to a sensor, and you want to prototype the app before the hardware sensor is available. For this you want to use Peripheral Mode.
In this view you can add services by pulling down from the top of the screen. Swiping horizontally on any of the UUID rows lets you rename or delete that service. Touching a service takes you to the corresponding characteristics.
The characteristics view acts much the same, pull down to add characteristics, or swipe horizontally to rename or delete them.
Touching a characteristic lets you set the type (Read, Write, Notify) and the value.
You can also save any edits you make by hitting Save Profile in the upper right corner. All of your profiles will appear in the profiles tab. In addition, common profiles (Heart Rate, Temperature) will be added automatically through our web server. This list can grow to accommodate new BLE devices.
If you have any features you would like to see, or just want to say hello, you can reach us at info at punchthrough.com. And if you’re feeling really generous, leave a review on the app store!