corebluetooth

Upload: gaurang

Post on 10-Jan-2016

10 views

Category:

Documents


0 download

DESCRIPTION

Design Documents for corebluetooth fremawork ios.

TRANSCRIPT

  • These are confidential sessionsplease 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

  • BLE State of the Union

    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 in iOS 7

    Code Demo

    Tips and Best Practices

  • BLE State of the Union

    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 in iOS 7

    Code Demo

    Tips and Best Practices

  • BLE State of the Union

    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 in iOS 7

    Code Demo

    Tips and Best Practices

  • BLE: State of the Union

    Brian TuckerBluetooth SIG Grand Wizard

  • Source ABI Research 2013

    Projected BLE Accessories Shipped1 Billion+

  • 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

  • Proximity

    Security

    Automation

    Health Care Sports/Fitness

    Entertainment Toys

    Pay Systems Time Services

  • Evolution of Core Bluetooth

    Renaud LienhartKeeper of the Code & General Curmudgeon

  • Observer, Central, Client

    CBCentralManager Discover peripherals Connect

    CBPeripheral Access remote services

    iOS 5

  • Broadcaster, Peripheral, ServeriOS 6

    CBPeripheralManager Host services Advertise information Field CBCentral requests

    Peripheral database caching

  • LE, EvolvedCore Bluetooth in iOS 7.0

  • Ch-ch-ch-changes

    Simpler device management Smarter peripherals Performance improvementsApplication persistence Built-in services

    Whats New

  • That is the questionTo Simulate, or Not to Simulate

    Emerging market Limited hardware available

    No iOS devices

    Development difficult

  • That is the questionTo Simulate, or Not to Simulate

    Exploding marketMany LE-compatible devices

    All iOS hardware Macbook, Mac mini

    Third-party development kits

  • That is the questionTo Simulate, or Not to Simulate

    Exploding marketMany LE-compatible devices

    All iOS hardware Macbook, Mac mini

    Third-party development kits

  • That is the questionTo Simulate, or Not to Simulate

    Exploding marketMany LE-compatible devices

    All iOS hardware Most Mac hardware

    Third-party development kits

  • Handling centrals and peripheralsSimpler Device Management

  • Bye, bye CoreFoundation

    Handling centrals and peripheralsSimpler Device Management

    @property(readonly, nonatomic) CFUUIDRef *UUID;

  • Bye, bye CoreFoundation

    Handling centrals and peripheralsSimpler Device Management

    @property(readonly, nonatomic) CFUUIDRef *UUID;

    @property(readonly, nonatomic) NSUUID *identifier;

  • Bye, bye CoreFoundation

    Handling centrals and peripheralsSimpler Device Management

    @property(readonly, nonatomic) CFUUIDRef *UUID;

    @property(readonly, nonatomic) NSUUID *identifier;

    Identifiers created at discovery

  • Retrieving peripherals, todaySimpler Device Management

    CBCentralManager

  • Retrieving peripherals, todaySimpler Device Management

    CBCentralManager

  • Retrieving peripherals, todaySimpler Device Management

    retrievePeripherals:

    CBCentralManager

  • Retrieving peripherals, todaySimpler Device Management

    didRetrievePeripherals:

    retrievePeripherals:

    CBCentralManager

  • Retrieving peripherals, todaySimpler Device Management

    didRetrievePeripherals:

    retrievePeripherals:

    CBCentralManager

    retrieveConnectedPeripherals

  • Retrieving peripherals, todaySimpler Device Management

    didRetrievePeripherals:

    retrievePeripherals:

    CBCentralManager

    retrieveConnectedPeripherals

    didRetrieveConnectedPeripherals:

  • Retrieving peripheralsSimpler Device Management

    CBCentralManager

  • Retrieving peripheralsSimpler Device Management

    CBCentralManager

  • Retrieving peripheralsSimpler Device Management

    retrievePeripheralsWithIdentifiers:

    CBCentralManager

  • Retrieving peripheralsSimpler Device Management

    retrievePeripheralsWithIdentifiers:

    CBCentralManager

    didRetrievePeripherals:

  • Retrieving peripheralsSimpler Device Management

    CBCentralManager

    retrievePeripheralsWithIdentifiers:

    , the iOS 7 way

  • Retrieving peripheralsSimpler Device Management

    CBCentralManager

    retrievePeripheralsWithIdentifiers:

    retrieveConnectedPeripheralsWithServices:

    , the iOS 7 way

  • Retrieving peripheralsSimpler Device Management

    CBCentralManager

    retrievePeripheralsWithIdentifiers:

    retrieveConnectedPeripheralsWithServices:

    connectPeripheral:options:

    , the iOS 7 way

  • Smarter Peripherals

  • Smarter Peripherals

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

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

    @property(readonly) CBPeripheralState state;

  • Smarter Peripherals

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

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

    @property(readonly) CBPeripheralState state;

  • Smarter Peripherals

  • Smarter Peripherals

    Better service invalidation

  • Smarter Peripherals

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

  • Smarter Peripherals

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

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

  • LE, EvolvedCore Bluetooth in iOS 7.0

    Jason ConnCode Monkey & Radio Sponge

  • Performance Improvements

    ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

  • Database caching, todayPerformance Improvements

    ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

    ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

    Characteristic Value190

    DescriptorClient Configuration

  • Database caching, todayPerformance Improvements

    Introduced in iOS 6 ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

    ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

    Characteristic Value190

    DescriptorClient Configuration

  • 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

  • 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

  • Database caching, in iOS 7Performance Improvements

    ServiceHeart Rate Monitor

    CharacteristicHeart Rate Measurement

    DescriptorClient Configuration

    DescriptorClient Configuration

    Characteristic Value190

    Characteristic Value190

    Characteristic Value73

    Characteristic Value190

  • 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

  • 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

  • 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

  • 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

  • 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

  • Performance Improvements

  • Sending dataPerformance Improvements

  • 115 BPM

    Sending dataPerformance Improvements

  • 115 BPM

    Sending dataPerformance Improvements

  • 115 BPM

    Sending dataPerformance Improvements

  • 115 BPM

    Sending dataPerformance Improvements

  • 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%

  • 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%

  • Sending dataPerformance Improvements

  • Sending dataPerformance Improvements

    Support MTU exchange request

  • Sending dataPerformance Improvements

    Support MTU exchange requestMaximum amount of data per PDU

  • Sending dataPerformance Improvements

    Support MTU exchange requestMaximum amount of data per PDU Send more data at a time

  • Sending dataPerformance Improvements

  • Sending data

    Default MTU23 bytes

    Performance Improvements

  • Sending data

    Default MTU23 bytes

    Performance Improvements

  • Sending data

    Default MTU23 bytes

    Increased MTU??? bytes

    Performance Improvements

  • Sending data

    Default MTU23 bytes

    Increased MTU??? bytes

    Performance Improvements

  • Sending dataPerformance Improvements

  • Sending dataPerformance Improvements

    When central, ask for larger MTU

  • Sending dataPerformance Improvements

    When central, ask for larger MTUUp to 20% increase in throughput

  • Sending dataPerformance Improvements

    When central, ask for larger MTUUp to 20% increase in throughput Free!

  • Performing long-term actionsPerformance Improvements

  • Performing long-term actionsPerformance Improvements

  • Living in a multitasking worldPerforming Long-Term Actions

  • Living in a multitasking worldPerforming Long-Term Actions

    Backgrounding modes

  • Living in a multitasking worldPerforming Long-Term Actions

    Backgrounding modes App communicates using CoreBluetooth

  • Living in a multitasking worldPerforming Long-Term Actions

    Backgrounding modes App communicates using CoreBluetooth App shares data using CoreBluetooth

  • 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

  • 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

  • Our solutionPerforming Long-term Actions

  • Our solutionPerforming Long-term Actions

    System watches application state

  • Our solutionPerforming Long-term Actions

    System watches application stateWhen application is terminated

  • Our solutionPerforming Long-term Actions

    System watches application stateWhen application is terminated

    If cause is memory pressure

  • Our solutionPerforming Long-term Actions

    System watches application stateWhen application is terminated

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

  • Our solutionPerforming Long-term Actions

    System watches application stateWhen application is terminated

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

    System acts as application proxy

  • Our solutionPerforming Long-term Actions

    System watches application stateWhen application is terminated

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

    System acts as application proxyWhen needed, application is re-launched

  • State Preservation and Restoration

  • State Preservation and Restoration

    Opt-in

  • State Preservation and Restoration

    Opt-in Supported by CBCentralManager and CBPeripheralManager

  • State Preservation and Restoration

    Opt-in Supported by CBCentralManager and CBPeripheralManagerMinimal implementation

    Provide unique identifier for manager Implement new delegate method

  • A picture is worth a thousand wordsState Preservation and Restoration

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination CBCentralManager

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination CBCentralManager

    Scanning state

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination CBCentralManager

    Scanning state Pending/active connections

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination CBCentralManager

    Scanning state Pending/active connections Peripheral subscriptions

  • A picture is worth a thousand wordsState Preservation and Restoration

    Snapshot taken before termination CBCentralManager

    Scanning state Pending/active connections Peripheral subscriptions

    CBPeripheralManager

  • 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

  • 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

  • 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

  • Back from the deadState Preservation and Restoration

  • Back from the deadState Preservation and Restoration

  • Back from the deadState Preservation and Restoration

    Events that system cant handle trigger application re-launch

  • Back from the deadState Preservation and Restoration

    Events that system cant handle trigger application re-launch Peripheral connects, central subscribes, notification received, etc.

  • Back from the deadState Preservation and Restoration

    Events that system cant handle trigger application re-launch Peripheral connects, central subscribes, notification received, etc.

    Application re-launched into background, running

  • Back from the deadState Preservation and Restoration

    Events that system cant handle trigger application re-launch Peripheral connects, central subscribes, notification received, etc.

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

  • Back from the deadState Preservation and Restoration

    Events that system cant 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

  • Back from the deadState Preservation and Restoration

    Events that system cant 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

  • Back from the deadState Preservation and Restoration

    Events that system cant 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

  • DemoAdding State Preservation and Restoration Support

    Jason ConnCode Monkey & Radio Sponge

  • Bluetooth Low Energy graduatesBuilt-in Services

    Renaud LienhartKeeper of the Code & General Curmudgeon

  • GATT ClientBuilt-in Services

  • GATT ClientBuilt-in Services

    HID Over GATT Profile HID, Battery, Device Information services

  • 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

  • GATT ServerBuilt-in Services

  • GATT ServerBuilt-in Services

    Battery Service

  • GATT ServerBuilt-in Services

    Battery Service Current Time Service

    Accurate time and date Time zone information

  • GATT ServerBuilt-in Services

    Battery Service Current Time Service

    Accurate time and date Time zone information

    One more thing

  • Notificationsthe problemsBuilt-in Services

  • Notificationsthe problemsBuilt-in Services

    Message Access Profile (MAP)

  • Notificationsthe problemsBuilt-in Services

    Message Access Profile (MAP) Developed for an automotive usage

  • Notificationsthe problemsBuilt-in Services

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

  • Notificationsthe problemsBuilt-in Services

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

    Alert Notification Service

  • Notificationsthe problemsBuilt-in Services

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

    Alert Notification Service Very limited

  • Notificationsthe 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

  • Notificationsthe 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

  • Notificationsthe 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

  • Notificationsour solutionBuilt-in Services

  • Notificationsour solutionBuilt-in Services

    Apple Notification Center Service

  • Notificationsour solutionBuilt-in Services

    Apple Notification Center Service Apple-specific

  • Notificationsour solutionBuilt-in Services

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

  • Notificationsour solutionBuilt-in Services

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

    Incoming and Missed calls, Voicemails

  • Notificationsour solutionBuilt-in Services

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

    Incoming and Missed calls, Voicemails Instant messages, Emails

  • Notificationsour 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

  • Notificationsour 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

  • Notificationsour 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

  • Notificationsour 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

  • Apple Notification Center ServiceBuilt-in Services

  • New iMessage

  • New iMessageNew Social Notification, UID=1

  • New iMessageNew Social Notification, UID=1

    GetAttributes(UID=1,Title,Msg)

  • New iMessageNew Social Notification, UID=1

    GetAttributes(UID=1,Title,Msg)

    Title=Jason,Msg=Beers?

  • New iMessageNew Social Notification, UID=1

    GetAttributes(UID=1,Title,Msg)

    Title=Jason,Msg=Beers?

    Alert User

  • New iMessageNew Social Notification, UID=1

    GetAttributes(UID=1,Title,Msg)

    Title=Jason,Msg=Beers?

    iMessage Read

    Alert User

  • New iMessageNew Social Notification, UID=1

    GetAttributes(UID=1,Title,Msg)

    Title=Jason,Msg=Beers?

    iMessage Read Notification Removed, UID=1

    Alert User

  • 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

  • Tips and Best Practices

  • Tips and Best Practices

    Core Bluetooth needs to know if you intend to use CBPeripheralskeep a reference to them

  • Tips and Best Practices

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

  • Tips and Best Practices

    Core Bluetooth needs to know if you intend to use CBPeripheralskeep 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

  • Tips and Best Practices

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

  • Tips and Best Practices

    Core Bluetooth needs to know if you intend to use CBPeripheralskeep a reference to them Scanning and connection requests do not time out CBPeripheral and CBCentral conform to NSCopying and can be used as dictionary keysDo not touch Client Configuration Characteristic Descriptors directlyDo not game the background mechanisms

  • Bluetooth best practices

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

    Apple Guidelines

  • Core Bluetooth Programming Guide

    Finally!

    Apple Guidelines

  • Craig KeithleyMFi & I/O Technology [email protected]

    Stephen ChickiPhone [email protected]

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

    More Information

  • 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

  • Whats New in Core Location PresidioThursday 11:30AM

    Related Sessions

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

  • 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

  • ProximitySecurityAutomationHealth CareSports/FitnessEntertainmentToysPay Systems

  • Proximity

    Security

    Automation

    Health Care Sports/Fitness

    Entertainment

    Toys

    Pay Systems

  • Proximity

    Security

    Automation

    Health Care Sports/Fitness

    Entertainment

    Toys

    Pay Systems

    Connect the World