Central Peripheral
advertising
scan advertising
discover services
discover characteristics
Heart Monitor
BPM
read value 95
Slide 31
Slide 31 text
Central Peripheral
advertising
scan advertising
discover services
discover characteristics
Heart Monitor
BPM
read value 95
observe value BPM 95
Slide 32
Slide 32 text
Central Peripheral
advertising
scan advertising
discover services
discover characteristics
Heart Monitor
BPM
read value 95
observe value BPM 95
BPM 95
BPM 98
value changed
Slide 33
Slide 33 text
Service
A service is a human-readable specification of a
set of characteristics and their associated
behavior.
Slide 34
Slide 34 text
Two kinds of services
There are primary services and secondary
services.
Slide 35
Slide 35 text
Nested services
Services can contain other services.
Slide 36
Slide 36 text
Characteristic
A characteristic is a bit of data that has a known
format labeled with a UUID.
They are intended for computer-readable format
as opposed to human-readable text.
Slide 37
Slide 37 text
Profiles
A profile is a specification that describe two or
more devices, with one or more services on each
device, how they discover each other, connect,
and otherwise interact.
Profiles define roles for devices to play.
Slide 38
Slide 38 text
Heart Rate Profile
Collector Heart Rate Sensor
Heart Rate Service
Device Information Service
Slide 39
Slide 39 text
Heart Rate Profile
Collector Heart Rate Sensor
Heart Rate Service
Device Information Service
GATT CLIENT GATT SERVER
Slide 40
Slide 40 text
Profiles & Services
Profiles contain services.
Services can be contained by multiple profiles.
Slide 41
Slide 41 text
Peripheral
Characteristic
Characteristic
Service
Characteristic
Anatomy of a Peripheral
Descriptor
Service
Slide 42
Slide 42 text
Apple’s Approach to
BTLE
Slide 43
Slide 43 text
Simple
Powerful
Slide 44
Slide 44 text
Technology Stack
Slide 45
Slide 45 text
*Borrowed from 2012 WWDC CoreBluetooth Talk
Slide 46
Slide 46 text
Supported Profiles
• Generic Attribute Profile Service
• Generic Access Profile Service
• Bluetooth Low Energy HID Service
• Battery Service
• Time Service
• Apple Notification Center Service
Slide 47
Slide 47 text
CoreBluetooth
Slide 48
Slide 48 text
Object Model
Slide 49
Slide 49 text
CBCharacteristic
CBService
CBCentral
CBMutableCharacteristic
CBMutableService
Main Objects
Data Objects
Helper Objects
CBUUID CBATTRequest
CBCentralManagerDelegate CBPeripheralManagerDelegate
CBCentralManager CBPeripheralManager
CBPeripheralDelegate
CBPeripheral
CBMutableService
Initializing a Mutable Service!
– initWithType:primary:
!
Managing a Mutable Service!
– UUID
– isPrimary
– characteristics
– includedServices
Initializing a Mutable Characteristic!
– initWithType:properties:value:permissions:
!
Managing a Mutable Characteristic!
UUID
value
descriptors
properties
permissions
subscribedCentrals
CBMutableCharacteristic
Slide 61
Slide 61 text
> code <
Slide 62
Slide 62 text
Foreground vs.
Background
Slide 63
Slide 63 text
Two background
modes.
Slide 64
Slide 64 text
bluetooth-central
“Uses Bluetooth LE accessories” in Xcode
Slide 65
Slide 65 text
bluetooth-peripheral
“Acts as Bluetooth LE accessory” in Xcode
Slide 66
Slide 66 text
Specify background
modes in Info.plist.
Slide 67
Slide 67 text
Nuances of
backgrounding
Slide 68
Slide 68 text
Central Scanning
• Scanning (as a Central) acts differently in the
background.
• Scan options are ignored. Multiple discoveries
of a peripheral are coalesced into one.
• The scan interval may increase and your app
may take longer to discover a peripheral.
Slide 69
Slide 69 text
Peripheral Advertising
• Advertising in the background differs from
foreground mode:
• The CBAdvertisementDataLocalNameKey is not
advertised.
• The frequency at which your app advertises
may decrease.
• Service UUIDs may not be advertised. Apple
does best effort.
Slide 70
Slide 70 text
Peripheral Events
• iOS will wake up your app to receive events:
read, write, and subscribe events.
Slide 71
Slide 71 text
Caching
• Services, characteristics and characteristic
descriptors are cached
• Characteristic value is kind of cached. When
discovered the last read value will be provided,
but it’s put to you to use it (static values) or read
the value (dynamic values) from the peripheral.
Slide 72
Slide 72 text
State Preservation and
Restoration
• Optional feature.
• Why? if your app is background it can be terminated
the OS
• iOS will store the state of the application and act on
behalf of it as a proxy. When it receives an event your
app is waiting for it will start the app back up in the
background to allow it to process it
• Single method for you to implement to restore the
state of your app.
Slide 73
Slide 73 text
iBeacons
Slide 74
Slide 74 text
No content
Slide 75
Slide 75 text
A part of CoreLocation
Slide 76
Slide 76 text
Just a data format in the
advertising packets.
!
Apple to release actual
profile on ___________.
Slide 77
Slide 77 text
Tips
Slide 78
Slide 78 text
CoreBluetooth lives in
IOBluetooth for Mac
apps.
Slide 79
Slide 79 text
No more
simulator
support
as of
iOS7
Slide 80
Slide 80 text
Keep references to
CBPeripheral and CBCentrals
if you plan on using them.
Slide 81
Slide 81 text
YOSO!
YOCO!
DSWYDNT
Slide 82
Slide 82 text
Done with peripheral,
disconnect.
Slide 83
Slide 83 text
CBPeripheral and
CBCentral objects can be
dictionary keys.
Slide 84
Slide 84 text
If you’re a peripheral
support characteristic
notifications.
Slide 85
Slide 85 text
Require paired
connections to acquire
sensitive information
Slide 86
Slide 86 text
Finding peripherals the system
already knows about
– retrieveConnectedPeripheralsWithServices:
– retrievePeripheralsWithIdentifiers:
CentralManager
Slide 87
Slide 87 text
MTU Exchange Requests
*Borrowed from 2013 Apple WWDC talk
Slide 88
Slide 88 text
• Allows more data to be sent in one go
• Less packet overhead
• up to 20% increase in throughput
• Free.
MTU Exchange Requests
Slide 89
Slide 89 text
App store recommendations
from Apple
• include the device with your submission
• be explicit about services the device provides
• provide instructions for how to use the device/
app
• or don’t and cross your fingers