Hardware Reference
In-Depth Information
Developing apps for sensors primarily invloves using the Core Bluetooth framework,
while developing apps for iBeacon primarily involves the Core Location framework
(ANCS does not require an app). The Core Bluetooth framework ( CoreBluetooth ) is
the portion of the iOS API (application programming interface) that deals with BLE
functions and devices. Its CBCentralManager and CBPeripheral classes allow you to
work with the centrals and peripherals described in Chapter 3 . CBCentralManager
provides resources for scanning, discovering, and connecting to remote peripherals,
while CBPeripheral provides resources for working with services and characteristics
that are part of the remote peripheral.
This chapter provides practical familiarity with these frameworks by studying code
examples that focus on BLE functionality, especially the key classes and methods needed
to implement BLE-enabled apps. These examples illustrate the foundations upon which
a complete BLE-based app can be built. While the examples are not complete and pol‐
ished apps, they are fully functional on an iOS device, and understanding how they work
is a good start toward writing your own BLE-enabled apps for iOS.
Complete Xcode projects for all examples are availble in the GitHub
repository for this topic . All examples require iOS 7 or later and Xcode
5 or later.
A general discussion of app development for iOS and the Xcode development environ‐
ment is a broad and complex topic in itself, most of which is beyond the scope of this
chapter or topic. If you're looking for more information, we recommend Programming
iOS 7 and iOS 7 Programming Fundamentals (O'Reilly) by Matt Neuburg. Of course,
the most authoritative source is Apple iOS Developer Library, beginning with the Core
Bluetooth Programming Guide . The examples in this chapter will closely follow the
approach recommended in that guide.
Simple Battery-Level Peripheral
This first example programs a central iOS device to look for and connect to a simple
remote peripheral. The role of the remote peripheral is played by a Bluegiga BLE112
hardware module (see “Bluegiga's BLE112/BLE113 Modules” on page 81 for more in‐
formation in this module). The iOS device will act as a GATT client and the peripheral
as a GATT server (see “Roles” on page 51 ).
Search WWH ::




Custom Search