SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
YmsCoreBluetooth
A block-based API for Core Bluetooth
YmsCoreBluetooth
Core Bluetooth
▸ Bluetooth 4.0 Low Energy (BLE) API
▸ Released 2012 (iOS 5, macOS 10.10)
▸ Delegate-based
▸ Many updates, but very few API changes
▸ Established BLE as the standard Personal Area Network
(PAN) for mobile
Gadgets!
TI SensorTag
Mid-2013
YmsCoreBluetooth
TI SensorTag
▸ IR Temperature Sensor
▸ Humidity Sensor
▸ Gyroscope
▸ Accelerometer
▸ Magnetometer
▸ Barometric Pressure Sensor
▸ Temperature Sensor
▸ Battery/voltage Sensor
▸ Push Buttons
BLE!
Core Bluetooth!
Using the Core Bluetooth
API felt kinda awkward.
YmsCoreBluetooth
Programming the SensorTag with Core Bluetooth
▸ Delegation pattern for CBCentralManager and CBPeripheral
was clumsy to use
▸ 8 sensors = 8 services
▸ Each service had at least two characteristics
▸ Control, Data
▸ A lot of state to keep track of in different places
In 2013, ObjC blocks were
a thing. Why not use them
here?
History
YmsCoreBluetooth
▸ Inspired by AFNetworking
▸ Use Obj-C block to process response from a BLE request
▸ Captures state
▸ In-line syntax describes control flow in “one place”
▸ Released late 2013 on GitHub
▸ https://github.com/kickingvegas/YmsCoreBluetooth
Design Goals
YmsCoreBluetooth Design Goals
▸ Get a BLE app up and running fast
▸ Be ready to use in a production app
▸ Use SensorTag as reference model to sanity check above
Design Goals
API Design
▸ Wrapper classes around each Core Bluetooth class
▸ YMSCBCentralManager
▸ YMSCBPeripheral
▸ YMSCBService
▸ YMSCBCharacteristic
▸ YMSCBDescriptor
▸ Subclass off appropriate YMSCB* to personalize
YMSCBCentralManager
CBCentralManager
Design Goals
Hierarchical Object Operation
▸ Core Bluetooth API designed operations in terms of 

sender sends message to receiver with matching delegate
response
▸ CBCentralManager connects to CBPeripheral
▸ CBPeripheral discovers its CBServices
▸ CBPeripheral discovers the CBCharacteristics for a CBService
▸ CBPeripheral writes to CBCharacteristic
▸ High cognitive load
Design Goals
Hierarchical Object Operation
▸ YmsCoreBluetooth API designed operations in terms of 

sending a command to an object
▸ [YMSCBPeripheral connectWithOptions:withBlock:]
▸ [YMSCBPeripheral discoverServices:withBlock:]
▸ [YMSCBService discoverCharacteristics:withBlock:]
▸ [YMSCBCharacteristic writeValue:withBlock:]
Where are we now
YmsCoreBluetooth in the Wild
▸ First released on GitHub late 2013
▸ Last update 2015
▸ As of 4/12/17
▸ 498 stars
▸ 128 forks
Coming Real Soon
YmsCoreBluetooth Updates Coming!
▸ Improved YMSCBPeripheral collection handling
▸ Improved BLE scanning API
▸ Improved YMSCBCharacteristic subscription API
▸ Dependency Injection Everywhere
▸ Testability
▸ Decouple from Core Bluetooth objects
▸ Obj-C Nullability & Generics
▸ May 2017
github.com/

kickingvegas/

YmsCoreBluetooth
twitter: cy_choi
Deep Core Bluetooth
Learning stuff the hard way
HMM… THAT’S FUNNY, IT
WORKS FOR ME.
Any developer writing a Core Bluetooth app
Deep Core Bluetooth
Learning 1: Your app
doesn’t have direct access
to the hardware
CBCentralManager
CBPeripheral
App A
BLE Peripheral
CBCentralManager
CBPeripheral
App A
BT Server
BLE Peripheral
BLE HW
CBCentralManager
CBPeripheral
CBCentralManager
CBPeripheral
App A
BT Server
BLE Peripheral
BLE HW
CBCentralManager
CBPeripheral
CBCentralManager
CBPeripheral
App A
CBCentralManager
CBPeripheral
CBCentralManager
CBPeripheral
App B
BT Server
BLE Peripheral
BLE HW
Deep Core Bluetooth
Learning 1: Your app doesn’t have direct access to the hardware
▸ CBPeripheral connection is a logical connection
▸ BT Server manages the physical connection to an actual BLE
peripheral
▸ Core Bluetooth state restoration works because of this
▸ Core Bluetooth background execution is decoupled from the
app state
Learning 2: Unpaired
CBPeripheral identifiers
are cached values
BLE Peripheral BT Server App
advertising MAC: 1235
didDiscoverPeripheral: FRED
advertising MAC: 1235
didDiscoverPeripheral: FRED
Map MAC to Identifier
Map MAC to Identifier
Map MAC to Identifier Full
advertising MAC: 1235
didDiscoverPeripheral: JANE
Deep Core Bluetooth
Learning 2: Unpaired CBPeripheral Identifiers are Cached
▸ There is a fixed size table for mapping MAC addresses to
CBPeripheral identifiers in BT Server
▸ When this table is full, an identifier will be invalidated
▸ To test an identifier, you must call 

[CBCentralManager retrievePeripheralsWithIdentifiers:]
▸ iOS 10 made this table really big
Learning 3: If BT Server resets
when your backgrounded BLE app
is not running, you won’t hear of it.
BLE Peripheral BT Server App
connectPeripheral:
connectPeripheral:
didConnectPeripheral: didConnectPeripheral:
Resets!
App terminated 

in background
centralManagerDidUpdateState:
Deep Core Bluetooth
Learning 3: If BT Server resets when your background app is not running, you won’t hear of it
▸ Core Bluetooth background execution is reliant on BT Server
always running perfectly
▸ If BT Server resets and your app that supports background
execution is not running, you will not receive the
centralManagerDidUpdateState: message
Learning 4: BLE state
restoration is a lot of work
Text
Learning 4: BLE state restoration is a lot of work
▸ Restore ServiceUUIDs that were scanned for
▸ You must restore your scan handler
▸ Restore Peripherals that central manager was trying to connect to or had
already connected to
▸ You must restore your connection and discovery handlers
▸ Restore Characteristics the central manager was subscribed to
▸ You must restore your notification handlers
▸ Run-time state you keep for a connected peripheral must be restored too!
Deep Core Bluetooth
Core Bluetooth Abstracts BLE
▸ Core Bluetooth is an abstraction API on top of the BLE
protocol
▸ Mimics BLE link-layer transactions
▸ Exercises only a sub-set of BLE protocol
▸ Your central never has direct communication with your
peripheral
We ❤ Core Bluetooth

Más contenido relacionado

La actualidad más candente

State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DC
Puppet
 

La actualidad más candente (20)

Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)
 
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
 
Jenkins Docker
Jenkins DockerJenkins Docker
Jenkins Docker
 
How Atlassian's Build Engineering Team Has Scaled to 150k Builds Per Month an...
How Atlassian's Build Engineering Team Has Scaled to 150k Builds Per Month an...How Atlassian's Build Engineering Team Has Scaled to 150k Builds Per Month an...
How Atlassian's Build Engineering Team Has Scaled to 150k Builds Per Month an...
 
Game of Codes: the Battle for CI
Game of Codes: the Battle for CIGame of Codes: the Battle for CI
Game of Codes: the Battle for CI
 
Hello elixir (and otp)
Hello elixir (and otp)Hello elixir (and otp)
Hello elixir (and otp)
 
How to setup jenkins
How to setup jenkinsHow to setup jenkins
How to setup jenkins
 
Security in serverless world
Security in serverless worldSecurity in serverless world
Security in serverless world
 
DevOps with Serverless
DevOps with ServerlessDevOps with Serverless
DevOps with Serverless
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
 
There is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless ArchitectureThere is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless Architecture
 
AtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration trainingAtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration training
 
mykola marzhan - jenkins on aws spot instance
mykola marzhan - jenkins on aws spot instancemykola marzhan - jenkins on aws spot instance
mykola marzhan - jenkins on aws spot instance
 
Tech trends 2018 2019
Tech trends 2018 2019Tech trends 2018 2019
Tech trends 2018 2019
 
fmcsadmin 1.0.0
fmcsadmin 1.0.0fmcsadmin 1.0.0
fmcsadmin 1.0.0
 
State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DC
 
Selenium Grid
Selenium GridSelenium Grid
Selenium Grid
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Docker, Continuous Integration, and You
Docker, Continuous Integration, and YouDocker, Continuous Integration, and You
Docker, Continuous Integration, and You
 
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
 

Similar a SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth

Similar a SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth (20)

BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth
 
Where should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and moreWhere should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and more
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gateway
 
Why do we even have Kubernetes?
Why do we even have Kubernetes?Why do we even have Kubernetes?
Why do we even have Kubernetes?
 
Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"
 
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdfCloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
Cloud Native Data Warehouses - Intro to ClickHouse on Kubernetes-2021-07.pdf
 
Using eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster HealthUsing eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster Health
 
Introduction to Kubernetes with demo
Introduction to Kubernetes with demoIntroduction to Kubernetes with demo
Introduction to Kubernetes with demo
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
Keynote #Tech - Google : aperçu de la gestion des services distribués chez Go...
Keynote #Tech - Google : aperçu de la gestion des services distribués chez Go...Keynote #Tech - Google : aperçu de la gestion des services distribués chez Go...
Keynote #Tech - Google : aperçu de la gestion des services distribués chez Go...
 
Deploy Application on Kubernetes
Deploy Application on KubernetesDeploy Application on Kubernetes
Deploy Application on Kubernetes
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for Kubernetes
 
Kubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of Containers
 
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UIData Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
Data Warehouses in Kubernetes Visualized: the ClickHouse Kubernetes Operator UI
 
Ignacy Kowalczyk
Ignacy KowalczykIgnacy Kowalczyk
Ignacy Kowalczyk
 
Introduction to Kubernetes and GKE
Introduction to Kubernetes and GKEIntroduction to Kubernetes and GKE
Introduction to Kubernetes and GKE
 
Core Bluetooth and BLE 101
Core Bluetooth and BLE 101Core Bluetooth and BLE 101
Core Bluetooth and BLE 101
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
 
Docker and Cloud - Enables for DevOps - by ACA-IT
Docker and Cloud - Enables for DevOps - by ACA-ITDocker and Cloud - Enables for DevOps - by ACA-IT
Docker and Cloud - Enables for DevOps - by ACA-IT
 
'DOCKER' & CLOUD: ENABLERS For DEVOPS
'DOCKER' & CLOUD:  ENABLERS For DEVOPS'DOCKER' & CLOUD:  ENABLERS For DEVOPS
'DOCKER' & CLOUD: ENABLERS For DEVOPS
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 

SV iOS Meetup Slides: YmsCoreBluetooth and Deep Core Bluetooth

  • 2. YmsCoreBluetooth Core Bluetooth ▸ Bluetooth 4.0 Low Energy (BLE) API ▸ Released 2012 (iOS 5, macOS 10.10) ▸ Delegate-based ▸ Many updates, but very few API changes ▸ Established BLE as the standard Personal Area Network (PAN) for mobile
  • 5. YmsCoreBluetooth TI SensorTag ▸ IR Temperature Sensor ▸ Humidity Sensor ▸ Gyroscope ▸ Accelerometer ▸ Magnetometer ▸ Barometric Pressure Sensor ▸ Temperature Sensor ▸ Battery/voltage Sensor ▸ Push Buttons BLE! Core Bluetooth!
  • 6. Using the Core Bluetooth API felt kinda awkward.
  • 7. YmsCoreBluetooth Programming the SensorTag with Core Bluetooth ▸ Delegation pattern for CBCentralManager and CBPeripheral was clumsy to use ▸ 8 sensors = 8 services ▸ Each service had at least two characteristics ▸ Control, Data ▸ A lot of state to keep track of in different places
  • 8. In 2013, ObjC blocks were a thing. Why not use them here?
  • 9. History YmsCoreBluetooth ▸ Inspired by AFNetworking ▸ Use Obj-C block to process response from a BLE request ▸ Captures state ▸ In-line syntax describes control flow in “one place” ▸ Released late 2013 on GitHub ▸ https://github.com/kickingvegas/YmsCoreBluetooth
  • 10. Design Goals YmsCoreBluetooth Design Goals ▸ Get a BLE app up and running fast ▸ Be ready to use in a production app ▸ Use SensorTag as reference model to sanity check above
  • 11. Design Goals API Design ▸ Wrapper classes around each Core Bluetooth class ▸ YMSCBCentralManager ▸ YMSCBPeripheral ▸ YMSCBService ▸ YMSCBCharacteristic ▸ YMSCBDescriptor ▸ Subclass off appropriate YMSCB* to personalize YMSCBCentralManager CBCentralManager
  • 12. Design Goals Hierarchical Object Operation ▸ Core Bluetooth API designed operations in terms of 
 sender sends message to receiver with matching delegate response ▸ CBCentralManager connects to CBPeripheral ▸ CBPeripheral discovers its CBServices ▸ CBPeripheral discovers the CBCharacteristics for a CBService ▸ CBPeripheral writes to CBCharacteristic ▸ High cognitive load
  • 13. Design Goals Hierarchical Object Operation ▸ YmsCoreBluetooth API designed operations in terms of 
 sending a command to an object ▸ [YMSCBPeripheral connectWithOptions:withBlock:] ▸ [YMSCBPeripheral discoverServices:withBlock:] ▸ [YMSCBService discoverCharacteristics:withBlock:] ▸ [YMSCBCharacteristic writeValue:withBlock:]
  • 14. Where are we now YmsCoreBluetooth in the Wild ▸ First released on GitHub late 2013 ▸ Last update 2015 ▸ As of 4/12/17 ▸ 498 stars ▸ 128 forks
  • 15. Coming Real Soon YmsCoreBluetooth Updates Coming! ▸ Improved YMSCBPeripheral collection handling ▸ Improved BLE scanning API ▸ Improved YMSCBCharacteristic subscription API ▸ Dependency Injection Everywhere ▸ Testability ▸ Decouple from Core Bluetooth objects ▸ Obj-C Nullability & Generics ▸ May 2017
  • 17. Deep Core Bluetooth Learning stuff the hard way
  • 18. HMM… THAT’S FUNNY, IT WORKS FOR ME. Any developer writing a Core Bluetooth app Deep Core Bluetooth
  • 19. Learning 1: Your app doesn’t have direct access to the hardware
  • 24. Deep Core Bluetooth Learning 1: Your app doesn’t have direct access to the hardware ▸ CBPeripheral connection is a logical connection ▸ BT Server manages the physical connection to an actual BLE peripheral ▸ Core Bluetooth state restoration works because of this ▸ Core Bluetooth background execution is decoupled from the app state
  • 25. Learning 2: Unpaired CBPeripheral identifiers are cached values
  • 26. BLE Peripheral BT Server App advertising MAC: 1235 didDiscoverPeripheral: FRED advertising MAC: 1235 didDiscoverPeripheral: FRED Map MAC to Identifier Map MAC to Identifier Map MAC to Identifier Full advertising MAC: 1235 didDiscoverPeripheral: JANE
  • 27. Deep Core Bluetooth Learning 2: Unpaired CBPeripheral Identifiers are Cached ▸ There is a fixed size table for mapping MAC addresses to CBPeripheral identifiers in BT Server ▸ When this table is full, an identifier will be invalidated ▸ To test an identifier, you must call 
 [CBCentralManager retrievePeripheralsWithIdentifiers:] ▸ iOS 10 made this table really big
  • 28. Learning 3: If BT Server resets when your backgrounded BLE app is not running, you won’t hear of it.
  • 29. BLE Peripheral BT Server App connectPeripheral: connectPeripheral: didConnectPeripheral: didConnectPeripheral: Resets! App terminated 
 in background centralManagerDidUpdateState:
  • 30. Deep Core Bluetooth Learning 3: If BT Server resets when your background app is not running, you won’t hear of it ▸ Core Bluetooth background execution is reliant on BT Server always running perfectly ▸ If BT Server resets and your app that supports background execution is not running, you will not receive the centralManagerDidUpdateState: message
  • 31. Learning 4: BLE state restoration is a lot of work
  • 32. Text Learning 4: BLE state restoration is a lot of work ▸ Restore ServiceUUIDs that were scanned for ▸ You must restore your scan handler ▸ Restore Peripherals that central manager was trying to connect to or had already connected to ▸ You must restore your connection and discovery handlers ▸ Restore Characteristics the central manager was subscribed to ▸ You must restore your notification handlers ▸ Run-time state you keep for a connected peripheral must be restored too!
  • 33. Deep Core Bluetooth Core Bluetooth Abstracts BLE ▸ Core Bluetooth is an abstraction API on top of the BLE protocol ▸ Mimics BLE link-layer transactions ▸ Exercises only a sub-set of BLE protocol ▸ Your central never has direct communication with your peripheral
  • 34. We ❤ Core Bluetooth