177
These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 703 Core Bluetooth Jason Conn Code Monkey & Radio Sponge Brian Tucker Bluetooth SIG Grand Wizard Renaud Lienhart Keeper of the Code & General Curmudgeon

Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

These are confidential sessions—please refrain from streaming, blogging, or taking pictures

Session 703

Core Bluetooth

Jason ConnCode Monkey & Radio Sponge

Brian TuckerBluetooth SIG Grand Wizard

Renaud LienhartKeeper of the Code & General Curmudgeon

Page 2: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 3: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 4: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 5: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 6: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 7: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE State of the Union

Evolution of Core Bluetooth

Core Bluetooth in iOS 7

Code Demo

Tips and Best Practices

Page 8: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

BLE: State of the Union

Brian TuckerBluetooth SIG Grand Wizard

Page 9: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 10: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Source ABI Research 2013

Projected BLE Accessories Shipped1 Billion+

Page 11: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Projected BLE Accessories Shipped

0

750

1,500

2,250

3,000

2012 2013 2014 2015 2016 2017 2018

Source ABI Research 2013

1,009,000,000 Devices

Page 12: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Proximity

Security

Automation

Health Care Sports/Fitness

Entertainment Toys

Pay Systems Time Services

Page 13: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Evolution of Core Bluetooth

Renaud LienhartKeeper of the Code & General Curmudgeon

Page 14: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Observer, Central, Client

• CBCentralManager■ Discover peripherals■ Connect

• CBPeripheral■ Access remote services

iOS 5

Page 15: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Broadcaster, Peripheral, ServeriOS 6

• CBPeripheralManager■ Host services■ Advertise information■ Field CBCentral requests

• Peripheral database caching

Page 16: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

LE, EvolvedCore Bluetooth in iOS 7.0

Page 17: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Ch-ch-ch-changes

• Simpler device management• Smarter peripherals• Performance improvements•Application persistence• Built-in services

What’s New

Page 18: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 19: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 20: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

That is the questionTo Simulate, or Not to Simulate

• Emerging market • Limited hardware available

■ No iOS devices

•Development difficult

Page 21: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

That is the questionTo Simulate, or Not to Simulate

• Exploding market•Many LE-compatible devices

■ All iOS hardware■ Macbook, Mac mini

• Third-party development kits

Page 22: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

That is the questionTo Simulate, or Not to Simulate

• Exploding market•Many LE-compatible devices

■ All iOS hardware■ Macbook, Mac mini

• Third-party development kits

Page 23: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

That is the questionTo Simulate, or Not to Simulate

• Exploding market•Many LE-compatible devices

■ All iOS hardware■ Most Mac hardware

• Third-party development kits

Page 24: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Handling centrals and peripheralsSimpler Device Management

Page 25: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Bye, bye CoreFoundation

Handling centrals and peripheralsSimpler Device Management

@property(readonly, nonatomic) CFUUIDRef *UUID;

Page 26: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Bye, bye CoreFoundation

Handling centrals and peripheralsSimpler Device Management

@property(readonly, nonatomic) CFUUIDRef *UUID;

@property(readonly, nonatomic) NSUUID *identifier;

Page 27: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Bye, bye CoreFoundation

Handling centrals and peripheralsSimpler Device Management

@property(readonly, nonatomic) CFUUIDRef *UUID;

@property(readonly, nonatomic) NSUUID *identifier;

• Identifiers created at discovery

Page 28: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

CBCentralManager <CBCentralManagerDelegate>

Page 29: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

CBCentralManager <CBCentralManagerDelegate>

Page 30: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

retrievePeripherals:

CBCentralManager <CBCentralManagerDelegate>

Page 31: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

didRetrievePeripherals:

retrievePeripherals:

CBCentralManager <CBCentralManagerDelegate>

Page 32: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

didRetrievePeripherals:

retrievePeripherals:

CBCentralManager <CBCentralManagerDelegate>

retrieveConnectedPeripherals

Page 33: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripherals, todaySimpler Device Management

didRetrievePeripherals:

retrievePeripherals:

CBCentralManager <CBCentralManagerDelegate>

retrieveConnectedPeripherals

didRetrieveConnectedPeripherals:

Page 34: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

CBCentralManager <CBCentralManagerDelegate>

Page 35: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

CBCentralManager <CBCentralManagerDelegate>

Page 36: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

retrievePeripheralsWithIdentifiers:

CBCentralManager <CBCentralManagerDelegate>

Page 37: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

retrievePeripheralsWithIdentifiers:

CBCentralManager <CBCentralManagerDelegate>

didRetrievePeripherals:

Page 38: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

CBCentralManager

retrievePeripheralsWithIdentifiers:

<CBCentralManagerDelegate>

, the iOS 7 way

Page 39: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

CBCentralManager

retrievePeripheralsWithIdentifiers:

retrieveConnectedPeripheralsWithServices:

<CBCentralManagerDelegate>

, the iOS 7 way

Page 40: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Retrieving peripheralsSimpler Device Management

CBCentralManager

retrievePeripheralsWithIdentifiers:

retrieveConnectedPeripheralsWithServices:

connectPeripheral:options:

<CBCentralManagerDelegate>

, the iOS 7 way

Page 41: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

Page 42: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

•More connection-aware@property(readonly) BOOL isConnected;

typedef NS_ENUM(NSInteger, CBPeripheralState) { CBPeripheralStateDisconnected = 0, CBPeripheralStateConnecting, CBPeripheralStateConnected };

@property(readonly) CBPeripheralState state;

Page 43: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

•More connection-aware@property(readonly) BOOL isConnected;

typedef NS_ENUM(NSInteger, CBPeripheralState) { CBPeripheralStateDisconnected = 0, CBPeripheralStateConnecting, CBPeripheralStateConnected };

@property(readonly) CBPeripheralState state;

Page 44: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

Page 45: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

• Better service invalidation

Page 46: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

• Better service invalidation(void)peripheralDidInvalidateServices:(CBPeripheral *)

Page 47: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Smarter Peripherals

• Better service invalidation(void)peripheralDidInvalidateServices:(CBPeripheral *)

(void)peripheral:(CBPeripheral *)didModifyServices:(NSArray *)

Page 48: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

LE, EvolvedCore Bluetooth in iOS 7.0

Jason ConnCode Monkey & Radio Sponge

Page 49: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

Page 50: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Database caching, todayPerformance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

Characteristic Value190

DescriptorClient Configuration

Page 51: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Database caching, todayPerformance Improvements

• Introduced in iOS 6 ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

Characteristic Value190

DescriptorClient Configuration

Page 52: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Database caching, todayPerformance Improvements

• Introduced in iOS 6• Increases speed and battery life

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

Characteristic Value190

DescriptorClient Configuration

Page 53: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Database caching, todayPerformance Improvements

• Introduced in iOS 6• Increases speed and battery life• Cache services and characteristics

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

Characteristic Value190

DescriptorClient Configuration

Page 54: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Page 55: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Cache characteristic descriptors

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Page 56: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Cache characteristic descriptors• Caching for characteristic values?

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Page 57: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Cache characteristic descriptors• Caching for characteristic values?

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Page 58: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Cache characteristic descriptors• Caching for characteristic values?

■ Provide last-known characteristic values and descriptor values

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Characteristic Value73

Page 59: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

• Cache characteristic descriptors• Caching for characteristic values?

■ Provide last-known characteristic values and descriptor values

• Free!

Database caching, in iOS 7Performance Improvements

ServiceHeart Rate Monitor

CharacteristicHeart Rate Measurement

DescriptorClient Configuration

DescriptorClient Configuration

Characteristic Value190

Characteristic Value190

Characteristic Value73

Characteristic Value190

Characteristic Value73

Page 60: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Performance Improvements

Page 61: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

Page 62: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Page 63: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Page 64: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Page 65: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Page 66: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Mon Tues Weds Thurs

58

70

43

55

96

53

26

17

Mon Tues Weds Thurs

50%

28%

14%9%

Page 67: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

115 BPM

Sending dataPerformance Improvements

Mon Tues Weds Thurs

58

70

43

55

96

53

26

17

Mon Tues Weds Thurs

50%

28%

14%9%

Page 68: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 69: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

Page 70: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

• Support MTU exchange request

Page 71: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

• Support MTU exchange request•Maximum amount of data per PDU

Page 72: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

• Support MTU exchange request•Maximum amount of data per PDU• Send more data at a time

Page 73: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

Page 74: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending data

Default MTU23 bytes

Performance Improvements

Page 75: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending data

Default MTU23 bytes

Performance Improvements

Page 76: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending data

Default MTU23 bytes

Increased MTU??? bytes

Performance Improvements

Page 77: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending data

Default MTU23 bytes

Increased MTU??? bytes

Performance Improvements

Page 78: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

Page 79: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

•When central, ask for larger MTU

Page 80: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

•When central, ask for larger MTU•Up to 20% increase in throughput

Page 81: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Sending dataPerformance Improvements

•When central, ask for larger MTU•Up to 20% increase in throughput• Free!

Page 82: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Performing long-term actionsPerformance Improvements

Page 83: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Performing long-term actionsPerformance Improvements

Page 84: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

Page 85: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

• Backgrounding modes

Page 86: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

• Backgrounding modes■ App communicates using CoreBluetooth

Page 87: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

• Backgrounding modes■ App communicates using CoreBluetooth■ App shares data using CoreBluetooth

Page 88: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

• Backgrounding modes■ App communicates using CoreBluetooth■ App shares data using CoreBluetooth

• Background applications can be terminated by system

Page 89: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Living in a multitasking worldPerforming Long-Term Actions

• Backgrounding modes■ App communicates using CoreBluetooth■ App shares data using CoreBluetooth

• Background applications can be terminated by system• Some use-cases take hours

Page 90: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 91: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 92: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 93: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 94: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth
Page 95: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

Page 96: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state

Page 97: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state•When application is terminated…

Page 98: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state•When application is terminated…

■ If cause is memory pressure

Page 99: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state•When application is terminated…

■ If cause is memory pressure■ If application is performing long-term action(s)

Page 100: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state•When application is terminated…

■ If cause is memory pressure■ If application is performing long-term action(s)

• System acts as application proxy

Page 101: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Our solutionPerforming Long-term Actions

• System watches application state•When application is terminated…

■ If cause is memory pressure■ If application is performing long-term action(s)

• System acts as application proxy•When needed, application is re-launched

Page 102: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

State Preservation and Restoration

Page 103: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

State Preservation and Restoration

•Opt-in

Page 104: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

State Preservation and Restoration

•Opt-in• Supported by CBCentralManager and CBPeripheralManager

Page 105: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

State Preservation and Restoration

•Opt-in• Supported by CBCentralManager and CBPeripheralManager•Minimal implementation

■ Provide unique “identifier” for manager■ Implement new delegate method

Page 106: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

Page 107: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination

Page 108: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

Page 109: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state

Page 110: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections

Page 111: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections■ Peripheral subscriptions

Page 112: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections■ Peripheral subscriptions

• CBPeripheralManager

Page 113: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections■ Peripheral subscriptions

• CBPeripheralManager■Advertising state

Page 114: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections■ Peripheral subscriptions

• CBPeripheralManager■Advertising state■ Published services

Page 115: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

A picture is worth a thousand wordsState Preservation and Restoration

• Snapshot taken before termination• CBCentralManager

■ Scanning state■ Pending/active connections■ Peripheral subscriptions

• CBPeripheralManager■Advertising state■ Published services■Central subscriptions

Page 116: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

Page 117: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

Page 118: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch

Page 119: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

Page 120: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

•Application re-launched into background, running

Page 121: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

•Application re-launched into background, running■ Re-instantiates appropriate manager object(s)

Page 122: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

•Application re-launched into background, running■ Re-instantiates appropriate manager object(s)■ Delegate callback provides all preserved state

Page 123: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

•Application re-launched into background, running■ Re-instantiates appropriate manager object(s)■ Delegate callback provides all preserved state■ Power on event

Page 124: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Back from the deadState Preservation and Restoration

• Events that system can’t handle trigger application re-launch■ Peripheral connects, central subscribes, notification received, etc.

•Application re-launched into background, running■ Re-instantiates appropriate manager object(s)■ Delegate callback provides all preserved state■ Power on event■ Delegate callback for triggering event

Page 125: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

DemoAdding State Preservation and Restoration Support

Jason ConnCode Monkey & Radio Sponge

Page 126: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Bluetooth Low Energy graduatesBuilt-in Services

Renaud LienhartKeeper of the Code & General Curmudgeon

Page 127: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ClientBuilt-in Services

Page 128: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ClientBuilt-in Services

•HID Over GATT Profile ■ HID, Battery, Device Information services

Page 129: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ClientBuilt-in Services

•HID Over GATT Profile ■ HID, Battery, Device Information services

•Works just like Bluetooth Classic■ Managed from Bluetooth Settings■ iOS automatically reconnects paired peripherals

Page 130: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ServerBuilt-in Services

Page 131: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ServerBuilt-in Services

• Battery Service

Page 132: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ServerBuilt-in Services

• Battery Service• Current Time Service

■ Accurate time and date■ Time zone information

Page 133: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

GATT ServerBuilt-in Services

• Battery Service• Current Time Service

■ Accurate time and date■ Time zone information

•One more thing…

Page 134: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

Page 135: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)

Page 136: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage

Page 137: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

Page 138: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

•Alert Notification Service

Page 139: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

•Alert Notification Service■ Very limited

Page 140: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

•Alert Notification Service■ Very limited

• Custom app tailored to a specific accessory

Page 141: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

•Alert Notification Service■ Very limited

• Custom app tailored to a specific accessory■ Heavyweight

Page 142: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—the problemsBuilt-in Services

•Message Access Profile (MAP)■ Developed for an automotive usage■ Very constrained: SMS, MMS, Email

•Alert Notification Service■ Very limited

• Custom app tailored to a specific accessory■ Heavyweight■ Data limited to what the sandbox allows

Page 143: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

Page 144: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service

Page 145: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific

Page 146: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

Page 147: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails

Page 148: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails■ Instant messages, Emails

Page 149: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails■ Instant messages, Emails■ Calendar alerts

Page 150: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails■ Instant messages, Emails■ Calendar alerts■ App notifications

Page 151: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails■ Instant messages, Emails■ Calendar alerts■ App notifications

■ System automatically reconnects

Page 152: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Notifications—our solutionBuilt-in Services

•Apple Notification Center Service■ Apple-specific■ Notification about any events on your phone

■ Incoming and Missed calls, Voicemails■ Instant messages, Emails■ Calendar alerts■ App notifications

■ System automatically reconnects ■ Detailed specification posted on the developer portal soon

Page 153: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Apple Notification Center ServiceBuilt-in Services

Page 154: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessage

Page 155: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

Page 156: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Page 157: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Title=”Jason”,Msg=”Beers?”

Page 158: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Title=”Jason”,Msg=”Beers?”

Alert User

Page 159: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Title=”Jason”,Msg=”Beers?”

iMessage Read

Alert User

Page 160: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Title=”Jason”,Msg=”Beers?”

iMessage Read Notification Removed, UID=1

Alert User

Page 161: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

New iMessageNew Social Notification, UID=1

GetAttributes(UID=1,Title,Msg)

Title=”Jason”,Msg=”Beers?”

iMessage Read Notification Removed, UID=1

Alert User

Dismiss Alert

Page 162: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

Page 163: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

• Core Bluetooth needs to know if you intend to use CBPeripherals—keep a reference to them

Page 164: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

• Core Bluetooth needs to know if you intend to use CBPeripherals—keep a reference to them• Scanning and connection requests do not time out

Page 165: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

• Core Bluetooth needs to know if you intend to use CBPeripherals—keep a reference to them• Scanning and connection requests do not time out• CBPeripheral and CBCentral conform to NSCopying and can be used as dictionary keys

Page 166: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

• Core Bluetooth needs to know if you intend to use CBPeripherals—keep a reference to them• Scanning and connection requests do not time out• CBPeripheral and CBCentral conform to NSCopying and can be used as dictionary keys•Do not touch Client Configuration Characteristic Descriptors directly

Page 167: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Tips and Best Practices

• Core Bluetooth needs to know if you intend to use CBPeripherals—keep a reference to them• Scanning and connection requests do not time out• CBPeripheral and CBCentral conform to NSCopying and can be used as dictionary keys•Do not touch Client Configuration Characteristic Descriptors directly•Do not game the background mechanisms

Page 168: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Bluetooth best practices

http://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

Apple Guidelines

Page 169: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Core Bluetooth Programming Guide

Finally!

Apple Guidelines

Page 170: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Craig KeithleyMFi & I/O Technology [email protected]

Stephen ChickiPhone [email protected]

Developer ProgramsMFi Programhttp://developer.apple.com/mfi/

More Information

Page 171: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Bluetooth Accessory Design Guidelineshttp://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

Reporting Bugshttp://bugreport.apple.com

Apple Developer Forumshttps://devforums.apple.com/community/ios/core/cbthttps://devforums.apple.com/community/mac/coreos/cbt

Bluetooth Developer Sitehttp://developer.bluetooth.org

More Information

Page 172: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

What’s New in Core Location PresidioThursday 11:30AM

Related Sessions

Designing Accessories for iOS and OS X Nob HillTuesday 10:15AM

Page 173: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Labs

iOS and OS X Accessories Lab Core OS Lab BThursday 9:00AM

iOS and OS X Accessories Lab Core OS Lab ATuesday 11:30AM

Page 174: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

ProximitySecurityAutomationHealth CareSports/FitnessEntertainmentToysPay Systems

Page 175: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Proximity

Security

Automation

Health Care Sports/Fitness

Entertainment

Toys

Pay Systems

Page 176: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth

Proximity

Security

Automation

Health Care Sports/Fitness

Entertainment

Toys

Pay Systems

Connect the World

Page 177: Core Bluetooth - Apple Inc. · 2016. 7. 10. · Evolution of Core Bluetooth Core Bluetooth in iOS 7 Code Demo Tips and Best Practices. BLE State of the Union Evolution of Core Bluetooth