Presentation About Bluetooth Low Energy
Presentation About Bluetooth Low Energy
Presentation About Bluetooth Low Energy
for starters
Bogdan Vlad
Staff Engineer @ Fitbit
1
Bluetooth Low Energy for starters
1. Introduction to Bluetooth Low Energy
2. CoreBluetooth.framework
3. Recent BLE improvements in iOS
4. Bluetooth profiles exposed by iOS
5. Useful resources
2
Introduction to Bluetooth Low Energy
• Bluetooth 4.0 specification in 2010
• Low power consumption
• Small size and low cost
• Targeted to support IoT Applications
3
Introduction to Bluetooth Low Energy
• Bluetooth 4.0 specification in 2010
• Low power consumption
• Small size and low cost
• Targeted to support IoT Applications
Fun facts:
• First phone with BLE: iPhone 4S (October 2011)
• The first two computers with BLE: MacMini and MacBook Air (July 2011)
• Apple and Nordic Semiconductor join the SIG Board of Directors (2011)
4
Introduction to Bluetooth Low Energy
• Peripheral
• the low power device (a fitness tracker or a smartwatch)
• can be connected to one central device
• Central
• More processing power needed
• Decides the connection parameters
• Can maintain a connection with multiple peripherals
5
6
Central Peripheral
7
Central Peripheral
ADV_IND
8
Central Peripheral
ADV_IND
9
Central Peripheral
CONNECT_REQ
10
Central Peripheral
t Empty PDU
Empty PDU
* sleep *
t + 15 ms Data exchange PDU
* sleep *
t + 30 ms Empty PDU
Empty PDU
11
Central Peripheral
t Empty PDU
Empty PDU
* sleep *
t + 15 ms Data exchange PDU
* sleep *
t + 30 ms Empty PDU
Empty PDU
Empty PDU
14
Central
Empty PDU
* cri cri *
15
Central
Empty PDU
* cri cri *
Disconnected!
16
Introduction Bluetooth Low Energy
• Two roles: Central and Peripheral
• Connection interval
17
Introduction Bluetooth Low Energy
• GATT (Generic Attribute Profile)
• Service, Characteristic
• GATT Server / GATT Client
struct Service {
let uuid: UUID
let characteristics: [Characterisic]
}
struct Characteristic {
let uuid: UUID
let value: Data
}
18
Introduction Bluetooth Low Energy
• Example:
• GATT Server
• Accelerometer Service
• X-axis Characteristic
• Y-axis Characteristic
• Z-axis Characteristic
• Outside Info Service
• Temperature Characteristic
• Humidity Characteristic
19
Central Peripheral
GATT Client GATT Server
20
Central Peripheral
GATT Client GATT Server
Characteristic 1, Characteristic 2
Characteristic 1
21
Introduction Bluetooth Low Energy
• GATT characteristic properties:
• Read
• Write without response
• Write
• Notify
• Indicate
• …
22
Introduction Bluetooth Low Energy
• GATT protocol • Heart Rate Sensor Profile
• Profile • Heart rate measurement service
• Service • Heart Rate Measurement Characteristic
• Characteristic • Body Sensor Location Characteristic
• Heart Rate Control Point Characteristic
• GATT Client
• Device Information Service
• GATT Server
• Device Information Service Characteristic
23
CoreBluetooth.framework
• Core Bluetooth
• CBCentralManager – master + GATT Client
• CBPeripheralManager – peripheral + GATT Server
24
CBCentralManager
• CBCentralManagerDelegate
• did update state
• did discover peripheral
• did connect to peripheral
• did disconnect from peripheral
• CBPeripheral
• connect
• discover services
• discover characteristics
• read
• write
• CBPeripheralDelegate
• Did discover services
• Did discover characteristics
• Did update value for characteristic
25
CBPeripheralManager
• CBPeripheralManagerDelegate
• Did update state
• Did add service
• Did start advertising
• Did subscribe / unsubscribe to characteristic
• Did receive read
• Did receive write
• CBCentral
26
Core Bluetooth Background Modes
• Two modes:
• bluetooth-central
• bluetooth-peripheral
• Needs to be declared in the plist
• App is woken up in background on Bluetooth events
27
Recent BLE Improvements in iOS
• Before iOS 11:
• only GATT
• From iOS 11:
• we have access to L2CAP
28
Recent BLE Improvements in iOS
• write without response = no ACK
• no feedback from Core Bluetooth API when buffers are full
29
Recent BLE Improvements in iOS
• Data length extension
• Enhancement introduced in the Bluetooth 4.2 specification
• Increases the maximum data length from 27 to 251
• Improves throughput
• The remote accessory must support DLE
• Supported on iPhone 7 and iPhone 7 Plus devices
30
ANCS – Apple Notification Center Service
• GATT Service hosted by the iOS
• Responsible for sending notifications that are generated on iOS
devices.
• Characteristics
• Notification Source (notifiable)
• Control Point (writeable without response)
• Data Source (notifiable)
• No code needed in the iOS App.
• Impossible to discover the service from an iOS / macOS app.
31
Other standard BLE profiles
• Time Profile
• Can be used to get information about phone’s time
• Timezone
• DST
• Time
• Battery Profile
32
Useful resources
• Apple Bluetooth Design Guidelines
• useful information about what connection parameters iOS devices can accept
• ANCS Protocol
• Core Bluetooth documentation
• Bluetooth LE Advertising and Connection Parameters for a stable
connection
• What's new in Core Bluetooth – WWDC 2017
33
Thank you!
34