Designing Accessories For IOS And OS X - Apple

Transcription

Core OSDesigning Accessories foriOS and OS XSession 701Robert WalshManager, Platform Accessories 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.#WWDC14

IntroductionAccessory interfacesAccessory protocolsWhat’s new in iOS 8 and OS X YosemiteProgram information and wrap up

Health thermometersGlucose metersApp-enabled accessoriesLight bulbsWireless speakersBlood pressure monitorsSpeakersStorage devicesAudio devicesGarage door openersHeadphonesHearing aidsHeart rate monitorsiBeaconGame controllersVideo devicesThermostatsCases

Health thermometersGlucose metersApp-enabled accessoriesLight bulbsWireless speakersBlood pressure monitorsSpeakersStorage devicesAudio devicesGarage door openersHeadphonesHearing aidsHeart rate monitorsiBeaconGame controllersVideo devicesThermostatsCases

Accessory InterfacesWireless Bluetooth Wi-FiWired Lightning connector USB Thunderbolt 2 Headphone remote and mic

Bluetooth

Bluetooth Low EnergySupported featuresGeneral communication with appsiOSOS X App framework For more information Apple Notification Center Service (ANCS) Hearing aid audio transport Core BluetoothBluetooth Design GuidelinesNotification CenterBluetooth Design GuidelinesCore AudioMFi ProgramHealthKit HealthKitBluetooth DesignGuidelines MFi ProgramHomeKit HomeKitMFi ProgramiBeacon Core LocationiBeacon Licensing

Bluetooth Low EnergySupported featuresGeneral communication with appsiOSOS X App framework For more information Apple Notification Center Service (ANCS) Hearing aid audio transport Core BluetoothBluetooth Design GuidelinesNotification CenterBluetooth Design GuidelinesCore AudioMFi ProgramHealthKit HealthKitBluetooth DesignGuidelines MFi ProgramHomeKit HomeKitMFi ProgramiBeacon Core LocationiBeacon Licensing

Bluetooth Low EnergySupported featuresGeneral communication with appsiOSOS X App framework For more information Apple Notification Center Service (ANCS) Hearing aid audio transport Core BluetoothBluetooth Design GuidelinesNotification CenterBluetooth Design GuidelinesCore AudioMFi ProgramHealthKit HealthKitBluetooth DesignGuidelines MFi ProgramHomeKit HomeKitMFi ProgramiBeacon Core LocationiBeacon Licensing

Classic BluetoothSupport for standard featuresiOSOS X App frameworkAdvanced Audio Distribution Profile (A2DP) Advanced Audio Distribution Profile (A2DP)Audio/Video Remove Control Profile (AVRCP) Audio/Video Remove Control Profile (AVRCP)Dial Up Network (DUN) Profile Dial Up Network (DUN) ProfileFile Transfer Profile (FTP) File Transfer Profile (FTP)Hands-Free Profile (HFP) Hands-Free Profile (HFP)Hardcopy Cable Replacement Profile (HCRP) Hardcopy Cable Replacement Profile (HCRP)Headset Profile (HSP) Headset Profile (HSP) Human Interface Device (HID) ProfileHuman Interface Device (HID) Profile Message Access Profile (MAP) Message Access Profile (MAP) Object Push Profile (OPP)Object Push Profile (OPP)Personal Area Network Profile (PAN) Personal Area Network Profile (PAN)Phone Book Access Profile (PBAP) Phone Book Access Profile (PBAP)Serial Port Profile (SPP) Serial Port Profile (SPP)

Classic BluetoothSupport for extended features on iOSFor more informationHeadset battery level indicationBluetooth Design GuidelinesSiri Eyes FreeBluetooth Design GuidelinesiAP Access to media library Access to location Proprietary communication with apps Direct users to App Store when accessory is paired Game controllersMFi Program

Wi-FiWi-Fi Alliance certification 802.11a/b/g, 802.11n, 802.11acDual-band operation 2.4 and 5 GHzWPA2 security modeQuality of services Wireless Multimedia (WMM)IPv6

Lightning ConnectorLightning headphone module Richer controls, including iTunes Radio App-enabled headphonesNew connector modules

USBAll current Macs ship with USB 3 portsAll current Macs support 5 Gbps per port900 mA per port for device powerand chargingHigh performance storage devicesshould use UASBuilt-in driver support for XHCI 1.0compliant host controllers

Thunderbolt 2High speed data and 4K video on one cablePCI Express and DisplayPort protocolDual-channel, bi-directional 20 Gbps per portUp to 10W for bus-powered devicesDaisy chain up to six devices per portCertification program ensures highquality devicesRefer to Thunderbolt Device DriverProgramming Guide

Headphone Remote and MicApps can receive remote control eventsStandardized microphone

What’s New in iOS 8 and OS X Yosemite

HealthKit AccessoriesTerry WorleySoftware Engineer, HealthKit team

HealthKit Sneak Peek

HealthKit Sneak PeekNew framework in iOS 8

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness data

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data security

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data securityUser privacy settings

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data securityUser privacy settingsSearches and statistical queries

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data securityUser privacy settingsSearches and statistical queriesUnit conversions

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data securityUser privacy settingsSearches and statistical queriesUnit conversionsNotifications of new data

HealthKit Sneak PeekNew framework in iOS 8Save and access health and fitness dataClass A data securityUser privacy settingsSearches and statistical queriesUnit conversionsNotifications of new dataIntegration with accessories

Health and Fitness Accessories

Health and Fitness AccessoriesBluetooth Low Energy is ideal for health and fitness

Health and Fitness AccessoriesBluetooth Low Energy is ideal for health and fitnessAccessories play the leading role in providing HealthKit data

Health and Fitness AccessoriesBluetooth Low Energy is ideal for health and fitnessAccessories play the leading role in providing HealthKit dataAccessories with built-in HealthKit support Heart rate monitor Glucose sensor Blood pressure monitor Health thermometer

Health and Fitness AccessoriesBluetooth Low Energy is ideal for health and fitnessAccessories play the leading role in providing HealthKit dataAccessories with built-in HealthKit support Heart rate monitor Glucose sensor Blood pressure monitor Health thermometerOnce paired, HealthKit automatically controls the accessory

Developing NativeHealthKit Accessories

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT Specifications

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT SpecificationsBest practices

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT SpecificationsBest practices Implement optional fields within the services, e.g. the heart rate field within the bloodpressure service saved as its own data point in HealthKit

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT SpecificationsBest practices Implement optional fields within the services, e.g. the heart rate field within the bloodpressure service saved as its own data point in HealthKit Implement supported metadata, e.g. energy expended stored as metadata along withthe heart rate measurement in HealthKit

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT SpecificationsBest practices Implement optional fields within the services, e.g. the heart rate field within the bloodpressure service saved as its own data point in HealthKit Implement supported metadata, e.g. energy expended stored as metadata along withthe heart rate measurement in HealthKit Implement optional characteristics, e.g. sensor contact to help identify valid data

Developing NativeHealthKit AccessoriesAdhere to Bluetooth Low Energy GATT SpecificationsBest practices Implement optional fields within the services, e.g. the heart rate field within the bloodpressure service saved as its own data point in HealthKit Implement supported metadata, e.g. energy expended stored as metadata along withthe heart rate measurement in HealthKit Implement optional characteristics, e.g. sensor contact to help identify valid data Implement optional services, e.g. battery Service

Developing Other Accessories

Developing Other AccessoriesCustom solutions can contribute to HealthKit

Developing Other AccessoriesCustom solutions can contribute to HealthKitUse any service that makes sense for your accessory. That might include theExternalAccessory framework, CoreBluetooth, USB, or Wi-Fi

Developing Other AccessoriesCustom solutions can contribute to HealthKitUse any service that makes sense for your accessory. That might include theExternalAccessory framework, CoreBluetooth, USB, or Wi-FiThen use the HealthKit framework APIs from within your app to add your data

Developing Other AccessoriesCustom solutions can contribute to HealthKitUse any service that makes sense for your accessory. That might include theExternalAccessory framework, CoreBluetooth, USB, or Wi-FiThen use the HealthKit framework APIs from within your app to add your dataWe hope these custom solutions will join in

HealthKit Software Support

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];.HKQuantityType *heartRateType [HKObjectType HeartRate];

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];.HKQuantityType *heartRateType [HKObjectType HeartRate];

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];.HKQuantityType *heartRateType [HKObjectType HeartRate];HKObserverQuery *heartRateQuery [[HKObserverQuery alloc] initWithSampleType:heartRateType predicate:nilupdateHandler: (HKObserverQuery *query,void ( completion)(void), NSError *error) {!}];

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];.HKQuantityType *heartRateType [HKObjectType HeartRate];HKObserverQuery *heartRateQuery [[HKObserverQuery alloc] initWithSampleType:heartRateType predicate:nilupdateHandler: (HKObserverQuery *query,void ( completion)(void), NSError *error) {if (error nil) {// Use HealthKit to fetch the new sample(s) from the database.[self fetchNewSamples];}}];

HealthKit Software Support@property (nonatomic) HKHealthStore *healthStore;[self setHealthStore:[[HKHealthStore alloc] init]];.HKQuantityType *heartRateType [HKObjectType HeartRate];HKObserverQuery *heartRateQuery [[HKObserverQuery alloc] initWithSampleType:heartRateType predicate:nilupdateHandler: (HKObserverQuery *query,void ( completion)(void), NSError *error) {if (error nil) {// Use HealthKit to fetch the new sample(s) from the database.[self fetchNewSamples];}}];[self.healthStore executeQuery:heartRateQuery];

DemoHeart rate monitorJorge MoriñigoSoftware Engineer, HealthKit team

Related Sessions HealthandFitnessGetTogether Introducing HealthKitMissionTuesday 10:15AMFolsomTuesday 4:30PM

HomeKit AccessoriesKevin McLaughlinWireless Software Engineering

HomeKit

HomeKitBring exciting new accessories to our users

HomeKitBring exciting new accessories to our usersProvide consistent user experience

HomeKitBring exciting new accessories to our usersProvide consistent user experienceLearn about APIs at HomeKit session

HomeKit Accessory Protocol

HomeKit Accessory ProtocolHomeKitAccessoryProtocol

HomeKit Accessory ProtocolHomeKitAccessoryProtocol“HAP”

HomeKit Accessory ProtocolConnecting accessories to HomeKit

HomeKit Accessory ProtocolConnecting accessories to HomeKitTransports Bluetooth Low Energy IP

HomeKit Accessory ProtocolConnecting accessories to HomeKitTransports Bluetooth Low Energy IPSecurity Bi-directional authentication Per-session encryption

HomeKit Accessory ProtocolConnecting accessories to HomeKitTransports Bluetooth Low Energy IPSecurity Bi-directional authentication Per-session encryptionCommon functionality definitions Services Characteristics

HomeKit Accessory ProfilesServicesCharacteristics Garage door openers Power state Lights Lock state Door locks Target state Thermostats Brightness IP camera controls Model number Switches Current temperature Custom Custom

HomeKit Accessory ProfilesServicesCharacteristics Garage door openers Power state Lights Lock state Door locks Target state Thermostats Brightness IP camera controls Model number Switches Current temperature Custom Custom

HomeKit Accessory Protocol Layers

HomeKit Accessory Protocol LayersBluetooth LEIP

HomeKit Accessory Protocol LayersL2CAPTCPBluetooth LEIP

HomeKit Accessory Protocol LayersAttribute Protocol (ATT)HTTPL2CAPTCPBluetooth LEIP

HomeKit Accessory Protocol LayersGeneric AttributeProfile (GATT)JSONAttribute Protocol (ATT)HTTPL2CAPTCPBluetooth LEIP

HomeKit Accessory Protocol LayersHomeKit Accessory ProtocolGeneric AttributeProfile (GATT)JSONAttribute Protocol (ATT)HTTPL2CAPTCPBluetooth LEIP

HomeKit Accessory Protocol LayersHomeKitHomeKit Accessory ProtocolGeneric AttributeProfile (GATT)JSONAttribute Protocol (ATT)HTTPL2CAPTCPBluetooth LEIP

HomeKit Accessory Protocol LayersHomeKitHomeKit Accessory ProtocolGeneric AttributeProfile (GATT)EncryptionBoundaryJSONAttribute Protocol (ATT)HTTPL2CAPTCPBluetooth LEIP

Garage Door OpenerServices and characteristics example

Garage Door OpenerServices and characteristics exampleaccessory : {

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {characteristic : “target-state”

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {characteristic : “target-state”characteristic : “current-state”

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {characteristic : “target-state”characteristic : “current-state”characteristic : “obstruction-detected”}

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {characteristic : “target-state”characteristic : “current-state”characteristic : “obstruction-detected”}service3 : “public.hap.lightbulb” {

Garage Door OpenerServices and characteristics exampleaccessory : {service1 : “public.hap.accessory-information” {characteristic : “serial-number”characteristic : “identify”}service2 : “public.hap.garage-door-opener” {characteristic : “target-state”characteristic : “current-state”characteristic : “obstruction-detected”}service3 : “public.hap.lightbulb” {characteristic : “on”}}

IP Details

IP DetailsRemote access through HomeKit

IP DetailsRemote access through HomeKitBonjour for accessory discovery

IP DetailsRemote access through HomeKitBonjour for accessory discoveryA single IP accessory may present multiple “accessories” Enables bridges Bridge is responsible for translating to and from HAP

IP DetailsRemote access through HomeKitBonjour for accessory discoveryA single IP accessory may present multiple “accessories” Enables bridges Bridge is responsible for translating to and from HAPRESTful API to interact with accessories, services, and characteristics

Bluetooth Low Energy Details

Bluetooth Low Energy DetailsRemote access through HomeKit

Bluetooth Low Energy DetailsRemote access through HomeKitApple-defined advertisement data for HAP

Bluetooth Low Energy DetailsRemote access through HomeKitApple-defined advertisement data for HAPAccessories are not identifiable from their advertisement data

Bluetooth Low Energy DetailsRemote access through HomeKitApple-defined advertisement data for HAPAccessories are not identifiable from their advertisement dataHAP security instead of Bluetooth Low Energy pairing

Protocol SecurityEnd-to-end encryptionInitial setup secured directly between iOS and accessoryPerfect forward secrecyStandard cryptography

Security Details!AlgorithmDescription!SecureRemote Password (SRP)Encrypts and authenticates initial pairing key exchange!Ed25519Long-term keys for pairing and authentication!Curve25519Encrypts initial authentication for each session!Per-session ephemeral encryption key derivationHKDF-SHA-512!ChaCha20-Poly1305Encrypts and authenticates HAP data!Defined in pairing specificationSupport available at HomeKit lab and through MFi program

Next Steps

Next StepsMFi program Access to HomeKit specifications forprotocol, pairing, and profiles Development and certification tool Available soon

Next StepsMFi program Access to HomeKit specifications forprotocol, pairing, and profiles Development and certification tool Available soonLearn HomeKit APIs Attend HomeKit session and lab

AirPlay

AirPlayAudio handling changes Accessory side skew compensation Buffer underrun handling

AirPlayAudio handling changes Accessory side skew compensation Buffer underrun handlingNew reference platform BSD on Raspberry Pi

iAP2 and ExternalAccessory Framework

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessories

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessoriesAccess to playback queue

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessoriesAccess to playback queuePlay all tracks

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessoriesAccess to playback queuePlay all tracksSeek to specific time in music track

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessoriesAccess to playback queuePlay all tracksSeek to specific time in music trackGet non-localized bundle identifier for media apps

iAP2 and ExternalAccessory FrameworkMedia playback enhancements for accessoriesAccess to playback queuePlay all tracksSeek to specific time in music trackGet non-localized bundle identifier for media appsGet progress information during media library synchronization

iAP2 and ExternalAccessory FrameworkAdditional enhancements for accessories

iAP2 and ExternalAccessory FrameworkAdditional enhancements for accessoriesSimplified time synchronization

iAP2 and ExternalAccessory FrameworkAdditional enhancements for accessoriesSimplified time synchronizationGet detailed charge state information

iAP2 and ExternalAccessory FrameworkAdditional enhancements for accessoriesSimplified time synchronizationGet detailed charge state informationSmaller footprint link layer reference code

iAP2 and ExternalAccessory FrameworkAdditional enhancements for accessoriesSimplified time synchronizationGet detailed charge state informationSmaller footprint link layer reference codeMultiple apps can open sessions for the same External Accessory protocolsimultaneously

Wireless Accessory Configuration

Wireless Accessory ConfigurationConfigure Wi-Fi accessories from within your appImport External Accessory frameworkImplement EAWiFiUnconfiguredAccessoryBrowserDelegate protocolInstantiate EAWiFiUnconfiguredAccessoryBrowser

Wireless Accessory ConfigurationSearch for unconfigured Wi-Fi accessoriesSearch for all unconfigured Wi-Fi accessories[browser edicate:nil];or filter for a subset of accessories[browser edicate:[NSPredicate predicateWithFormat:@"name ‘Amalgamated Audio’"]];

Wireless Accessory ConfigurationDelegate callbacksNew accessories were found- yBrowser*)browser Previously found accessory is no longer available- yBrowser*)browser esState of the browser has changed- yBrowser*)browser State)state

Wireless Accessory ConfigurationUser selects an accessory

Wireless Accessory ConfigurationUser selects an accessoryBegin configuring the accessory[browser rationUIOnViewController:self];

Wireless Accessory ConfigurationUser configures Wi-Fi accessory

Wireless Accessory ConfigurationUser configures Wi-Fi accessory

Wireless Accessory ConfigurationUser configures Wi-Fi accessory

Wireless Accessory ConfigurationConfiguration complete

SummaryHealthKitHomeKitMedia playback enhancements for accessoriesApp-driven Wireless Accessory Configuration

ReferencesMFi //developer.apple.com/ibeacon/Bluetooth Accessory Design Guidelines for Apple Productshttp://developer.apple.com/bluetooth/Case Design Guidelines for Apple Deviceshttp://developer.apple.com/resources/cases/

More InformationStephen ChickiPhone Evangelistchick@apple.comCraig KeithleyMFi and I/O Technologies Evangelistkeithley@apple.comMark TozerDesktop Technologies Evangelisttozer@apple.comApple Developer Forumshttp://devforums.apple.com

Related Sessions What’sNewinCoreLocation IntroducingHomeKit AdoptingAirPrint DesigningforGameControllers Introducing HealthKitMissionTuesday 10:15AMMarinaTuesday 2:00PMMarinaTuesday 4:30PMPacific HeightsFriday 9:00AMMissionFriday 10:15AM

Labs AccessoriesandI/OTechnologiesLab I/OTechnologiesLab AccessoriesandI/OTechnologiesLab HomeKitLab HealthKitLab I/O Technologies LabCore OS Lab ATuesday 9:00AMCore OS Lab ATuesday 11:30AMCore OS Lab AThursday 11:30AMCore OS Lab AThursday 12:45PMServices Lab AThursday 12:45PMServices Lab BFriday 9:00AM

Core Bluetooth Bluetooth Design Guidelines Apple Notification Center Service (ANCS) ! Notification Center Bluetooth Design Guidelines Hearing aid audio transport ! Core Audio MFi Program . Save and access health and fitness data. HealthKit Sneak Peek New framework in iOS 8 Save and access health an