SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
A BRIEF INTRODUCTION TO BLUETOOTH
LOW ENERGY (BLE) ON IOS
Cocoaheads Denver - July 9, 2019
- Matt Whitlock
@mattwhitlockco
mattwhitlock@phaeron.com
DEMO
https://github.com/mattwhitlock/BLEScannerDemo
BLE vs Bluetooth Classic
BLE is Bluetooth in a marketing sense only, implementation is totally
unrelated

Can be connectionless - invisible to user

Low power
BLE 4.0-4.2
BLE was introduced as Bluetooth Smart in Bluetooth 4.0

Data packets were limited to 20 bytes until 4.2 with packet length
extension which allows 244 bytes

Very low speed (~100kbps / ~250kbps)
BLE 5.0
Very little hardware/software support, but improving

Bluetooth Smart branding dropped

~2x data rate

LE Long Range (~4x)

LE Advertising Extensions (Larger advertising packets possible)
iOS BLE Support
Most current devices support Bluetooth 4.2

>= iOS 9.3

>= iPhone 6

>= iPad Air 2, iPad mini 4 (2015+)

Notable Exceptions:

iPhone 5s - 4.0

iPod touch 7G - 4.1

iPod touch 6G - 4.0

2019 iPads, iPhone 8, X, Xr, Xs, Xs Max Support Bluetooth 5.0
Resources
Bluetooth Low Energy: The Developer’s Handbook - Robin Heydon, Prentice Hall 2013

Bluetooth SIG

https://www.bluetooth.com/

Bluetooth 4.2 standard

https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=441541

TI BLE-Stack User’s Guide for Bluetooth 4.2

http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_50_00_58/docs/blestack/ble_user_guide/html/ble-stack-3.x/
index.html

Apple Documentation

https://developer.apple.com/documentation/corebluetooth

https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/
AboutCoreBluetooth/Introduction.html#//apple_ref/doc/uid/TP40013257-CH1-SW1
Tools
BLE Sniffing Hardware/Software

Xcode Bluetooth Explorer

nRF52 DK - https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK

TI CC2540 - http://www.ti.com/product/CC2540

Bluegiga BLED112

Apps

nRF Connect

LightBlue
BLE FUNDAMENTALS
BLE Fundamentals
BLE is Hierarchical

BLE is Asynchronous

BLE does nothing without you telling it to

Core Bluetooth doesn’t give you anything but the basic building
blocks.
BLE Fundamentals - Hierarchical
Source: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/
Conceptual/CoreBluetooth_concepts/CoreBluetoothOverview/CoreBluetoothOverview.html
BLE Fundamentals
Central / Peripheral

Central scans / listens / commands

Peripheral advertises / responds to commands

Advertising and Scanning are core concepts.

Client / Server

Server has data

Client wants data
BLE Fundamentals - Security
Key exchange is broken in 4.0, 4.1, 4.2

Additional key exchange methodologies needed, relying on CMAC
which is not in CommonCrypto or Security framework

This is very difficult to do properly. Hire a BLE security expert to
define key exchange and to do security testing.
BLE Fundamentals - Protocol Stack
Source: http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_00_00_22/docs/blestack/html/ble-stack/index.html
Not quite right;
GAP is above GATT.
BLE Fundamentals - Protocols
Logical Link Control and Adaptation Protocol (L2CAP)

Allows segmentation and reassembly of packets (i.e. > 20B limit)

Security Manager (SM)

Attribute Protocol (AP / ATT)

All services above GATT (including GAP) use Attribute Protocol
BLE Fundamentals - Attributes
Attributes Defined by the Attribute Protocol (ATT / AP)

Defines Profiles / Services / Characteristics / Descriptors

All identified by UUID

Profiles

Generic Attribute Profile (GATT)

Defines how services, characteristics, descriptors can be discovered/used

Generic Access Profile (GAP)

Defines how devices can discover and connect with each other
BLE Fundamentals - Attribute Permissions
Permissions defined at the Attribute layer

Pertains to Services and Characteristics

Readable, Writable, Readable and Writable

When an attribute is read/written, then check is done for
Authentication and Authorization
BLE Fundamentals - Profiles
Generic Attribute Profile (GATT)

Defines how services, characteristics, descriptors can be
discovered/used

Generic Access Profile (GAP)

Defines how devices can discover and connect with each other

Advertising, Discover, Pair, Bond, Security, etc.
BLE Fundamentals - Services
Some defined by BLE Specification - https://www.bluetooth.com/specifications/
gatt/services/

Generic Access Service 0x1800

Battery Service 0x180F

Heart Rate Service 0x180D

etc.

Usually a custom Service is defined for the product

Essentially built on top of GATT
BLE Fundamentals - Characteristics
Data that is part of a service, typically a single value or control point

Device Name, Appearance, Peripheral Preferred Connection
Parameters are characteristics of Generic Access service.

Battery Level characteristic is part of Battery service

Heart Rate Measurement, Body Sensor Location, Heart Rate
Control Point characteristics are part of Heart Rate service

Usually many custom Characteristics are defined for the product
BLE Fundamentals - Operations
Read

Write

Notify / Indicate

Essentially a subscription or signing up for notification

Notification can be lost (think UDP or a broadcast)

Indication requires attribute confirmation (think TCP)
BLE Fundamentals - Connections
Advertising - Connectionless

A lot can be done with no connection
and just advertising packet

Read - only from Central perspective

Beacons use this

Connect

May or may not require user
interaction (depends on capabilities
matrix) Source: https://www.electronicdesign.com/communications/
ble-v42-creating-faster-more-secure-power-efficient-designs-
part-3
BLE Fundamentals - Connections
Pair

Required for encrypted characteristics

Authentication / Authorization / Shared secrets (Short-term / Long-term key
exchange)

Bond

Devices state / agree that they are saving keys in security database.

Very Rare

Issues around this on iOS
BLE Fundamentals - Byte Order
iOS uses Little Endian byte order

BLE Sends LSB first

Some devices use Big Endian byte order

Example: Value is 0x01234567 89ABCDEF





APPLE CORE BLUETOOTH
General iOS Process
Check Permissions (new in iOS 13)

NSBluetoothPeripheralUsageDescription in Info.plist - supposed to be required in iOS 10+

Check for Bluetooth Enabled

Scan

Connect

Discover Services/Characteristics

Pair / Bond (optional)

Interact
Frameworks
Core Bluetooth

Bluejay - https://github.com/steamclock/bluejay

RxBluetoothKit - https://github.com/Polidea/RxBluetoothKit

BlueCap - https://github.com/troystribling/BlueCap
Core Bluetooth
Core Bluetooth is the Framework for BLE on all Apple devices 

Incomplete but decent implementation of BLE capabilities.

Android can be more complete and have more control, but is
inconsistent device to device.

Can be Central or Peripheral
Core Bluetooth Classes to act as Central
CBCentralManager - “used to manage discovered or connected remote peripheral devices
(represented by CBPeripheral objects), including scanning for, discovering, and connecting
to advertising peripherals.”

CBCentralManagerDelegate
CBPeripheral - “represents remote peripheral devices that your app—by means of a central
manager (an instance of CBCentralManager)—has discovered advertising or is currently
connected to.”

CBPeripheralDelegate
Can act as a Peripheral by using CBPeripheralManager / CBCentral classes
Core Bluetooth Classes to act as Central - 2
These are the big ones.

CBPeripheral represents the Peripheral so most actions done with
this class.

CBPeripheralDelegate - “monitor the discovery, exploration, and
interaction of a remote peripheral’s services and properties.“
CORE BLUETOOTH CLASS DETAILS -
CENTRAL
CBCentralManager
Initializing

init(delegate: CBCentralManagerDelegate?, queue: DispatchQueue?, options: [String : Any]?)

Scanning

func scanForPeripherals(withServices: [CBUUID]?, options: [String : Any]?)

func stopScan() 

Connections

func connect(CBPeripheral, options: [String : Any]?)

func cancelPeripheralConnection(CBPeripheral)

func retrieveConnectedPeripherals(withServices: [CBUUID]) -> [CBPeripheral]

func retrievePeripherals(withIdentifiers: [UUID]) -> [CBPeripheral]
CBCentralManagerDelegate
Scanning

func centralManager(CBCentralManager, didDiscover: CBPeripheral, advertisementData: [String :
Any], rssi: NSNumber)

Monitor Connections

func centralManager(CBCentralManager, didConnect: CBPeripheral)

func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?)

func centralManager(CBCentralManager, didFailToConnect: CBPeripheral, error: Error?)

State

func centralManagerDidUpdateState(CBCentralManager)

func centralManager(CBCentralManager, willRestoreState: [String : Any])
CBPeripheral
Properties

var name: String?

var delegate: CBPeripheralDelegate?

Discovery

func discoverServices([CBUUID]?)

func discoverIncludedServices([CBUUID]?, for: CBService)

var services: [CBService]?

func discoverCharacteristics([CBUUID]?, for: CBService)

func discoverDescriptors(for: CBCharacteristic)
CBPeripheral - 2
Read/Write/Notification

func readValue(for: CBCharacteristic)

func readValue(for: CBDescriptor)

func writeValue(Data, for: CBCharacteristic, type: CBCharacteristicWriteType)

func setNotifyValue(Bool, for: CBCharacteristic)

Supports Notifications and Indications

State

var state: CBPeripheralState

func readRSSI()
CBPeripheralDelegate
Discovery

func peripheral(CBPeripheral, didDiscoverServices: Error?)

func peripheral(CBPeripheral, didDiscoverIncludedServicesFor: CBService, error: Error?)

func peripheral(CBPeripheral, didDiscoverCharacteristicsFor: CBService, error: Error?)

func peripheral(CBPeripheral, didDiscoverDescriptorsFor: CBCharacteristic, error: Error?)

State

func peripheral(CBPeripheral, didReadRSSI: NSNumber, error: Error?)

func peripheralDidUpdateName(CBPeripheral)

func peripheral(CBPeripheral, didModifyServices: [CBService])
CBPeripheralDelegate - 2
Read/Write/Notification

func peripheral(CBPeripheral, didUpdateValueFor: CBCharacteristic, error:
Error?)

func peripheral(CBPeripheral, didUpdateValueFor: CBDescriptor, error: Error?)

func peripheral(CBPeripheral, didWriteValueFor: CBCharacteristic, error: Error?)

func peripheral(CBPeripheral, didWriteValueFor: CBDescriptor, error: Error?)

func peripheral(CBPeripheral, didUpdateNotificationStateFor:
CBCharacteristic, error: Error?)
QUESTIONS?

Más contenido relacionado

La actualidad más candente

Cloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisCloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisYue Chen
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google GuiceKnoldus Inc.
 
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016DataStax
 
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3I Putu Hariyadi
 
CredHub and Secure Credential Management
CredHub and Secure Credential ManagementCredHub and Secure Credential Management
CredHub and Secure Credential ManagementVMware Tanzu
 
Binlog Servers 구축사례
Binlog Servers 구축사례Binlog Servers 구축사례
Binlog Servers 구축사례I Goo Lee
 
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis ToolWebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis ToolJeffrey West
 
Migrating and Running DBs on Amazon RDS for Oracle
Migrating and Running DBs on Amazon RDS for OracleMigrating and Running DBs on Amazon RDS for Oracle
Migrating and Running DBs on Amazon RDS for OracleMaris Elsins
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법Ji-Woong Choi
 
RMAN in 12c: The Next Generation (PPT)
RMAN in 12c: The Next Generation (PPT)RMAN in 12c: The Next Generation (PPT)
RMAN in 12c: The Next Generation (PPT)Gustavo Rene Antunez
 
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...Nelson Calero
 
MariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseMariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseSeveralnines
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Stamatis Zampetakis
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesSreenivas Makam
 
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Artem Chebotko
 
Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Vinay Kumar Chella
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistenceJanakiram MSV
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseSandesh Rao
 
Fatkulin hotsos 2014
Fatkulin hotsos 2014Fatkulin hotsos 2014
Fatkulin hotsos 2014Enkitec
 

La actualidad más candente (20)

Cloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and AnalysisCloudera Impala Source Code Explanation and Analysis
Cloudera Impala Source Code Explanation and Analysis
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google Guice
 
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
Troubleshooting Cassandra (J.B. Langston, DataStax) | C* Summit 2016
 
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3
Import DEVNET Associate OVA sebagai VM pada Proxmox VE 6.3
 
CredHub and Secure Credential Management
CredHub and Secure Credential ManagementCredHub and Secure Credential Management
CredHub and Secure Credential Management
 
Binlog Servers 구축사례
Binlog Servers 구축사례Binlog Servers 구축사례
Binlog Servers 구축사례
 
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis ToolWebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool
WebLogic's ClassLoaders, Filtering ClassLoader and ClassLoader Analysis Tool
 
Migrating and Running DBs on Amazon RDS for Oracle
Migrating and Running DBs on Amazon RDS for OracleMigrating and Running DBs on Amazon RDS for Oracle
Migrating and Running DBs on Amazon RDS for Oracle
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
 
RMAN in 12c: The Next Generation (PPT)
RMAN in 12c: The Next Generation (PPT)RMAN in 12c: The Next Generation (PPT)
RMAN in 12c: The Next Generation (PPT)
 
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
Automate Oracle database patches and upgrades using Fleet Provisioning and Pa...
 
MariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseMariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash Course
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
Using the Chebotko Method to Design Sound and Scalable Data Models for Apache...
 
Become an AWS IAM Policy Ninja
Become an AWS IAM Policy NinjaBecome an AWS IAM Policy Ninja
Become an AWS IAM Policy Ninja
 
Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistence
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous Database
 
Fatkulin hotsos 2014
Fatkulin hotsos 2014Fatkulin hotsos 2014
Fatkulin hotsos 2014
 

Similar a A Brief Introduction to Bluetooth Low Energy (BLE) on iOS

How to use Bluetooth® Smart to control your embedded device with a mobile device
How to use Bluetooth® Smart to control your embedded device with a mobile deviceHow to use Bluetooth® Smart to control your embedded device with a mobile device
How to use Bluetooth® Smart to control your embedded device with a mobile deviceAnaren, Inc.
 
(Sacon) Sumanth Naropanth - IoT network & ecosystem security attacks & secur...
(Sacon) Sumanth Naropanth  - IoT network & ecosystem security attacks & secur...(Sacon) Sumanth Naropanth  - IoT network & ecosystem security attacks & secur...
(Sacon) Sumanth Naropanth - IoT network & ecosystem security attacks & secur...Priyanka Aash
 
Bluetooth 4.0 specification
Bluetooth 4.0 specificationBluetooth 4.0 specification
Bluetooth 4.0 specificationabhiamanchopra
 
Softimize - Connecting Devices to Gateways
Softimize - Connecting Devices to GatewaysSoftimize - Connecting Devices to Gateways
Softimize - Connecting Devices to GatewaysYael Malki
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01nagapriyanka
 
Control Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable MobileControl Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable MobileSamiul Hoque
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01ramaswamireddy challa
 
Eyeball AnyConnect™ Gateway Administration Guide
Eyeball AnyConnect™ Gateway Administration GuideEyeball AnyConnect™ Gateway Administration Guide
Eyeball AnyConnect™ Gateway Administration GuideEyeball Networks
 
Bluetooth technology introduction and ecosystem
Bluetooth technology introduction and ecosystem Bluetooth technology introduction and ecosystem
Bluetooth technology introduction and ecosystem NiclasGranqvist
 
JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)SMIJava
 
ArcSight Connector Appliance 6.4 Patch 1 Release Notes
ArcSight Connector Appliance 6.4 Patch 1 Release NotesArcSight Connector Appliance 6.4 Patch 1 Release Notes
ArcSight Connector Appliance 6.4 Patch 1 Release NotesProtect724tk
 
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730Netgear Italia
 
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...degarden
 
F5 BigIP LTM Initial, Build, Install and Licensing.
F5 BigIP LTM Initial, Build, Install and Licensing.F5 BigIP LTM Initial, Build, Install and Licensing.
F5 BigIP LTM Initial, Build, Install and Licensing.Kapil Sabharwal
 
Bluetooth low energy- Kashyap Velpuru
Bluetooth low energy- Kashyap VelpuruBluetooth low energy- Kashyap Velpuru
Bluetooth low energy- Kashyap Velpurukashyap velpuru
 
BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth Zach Dennis
 

Similar a A Brief Introduction to Bluetooth Low Energy (BLE) on iOS (20)

N045057376
N045057376N045057376
N045057376
 
How to use Bluetooth® Smart to control your embedded device with a mobile device
How to use Bluetooth® Smart to control your embedded device with a mobile deviceHow to use Bluetooth® Smart to control your embedded device with a mobile device
How to use Bluetooth® Smart to control your embedded device with a mobile device
 
CompTIA Security Plus Overview
CompTIA Security Plus OverviewCompTIA Security Plus Overview
CompTIA Security Plus Overview
 
CompTIA Security Plus Mini Bootcamp Session
CompTIA Security Plus Mini Bootcamp Session  CompTIA Security Plus Mini Bootcamp Session
CompTIA Security Plus Mini Bootcamp Session
 
(Sacon) Sumanth Naropanth - IoT network & ecosystem security attacks & secur...
(Sacon) Sumanth Naropanth  - IoT network & ecosystem security attacks & secur...(Sacon) Sumanth Naropanth  - IoT network & ecosystem security attacks & secur...
(Sacon) Sumanth Naropanth - IoT network & ecosystem security attacks & secur...
 
Calico architecture
Calico architectureCalico architecture
Calico architecture
 
Bluetooth 4.0 specification
Bluetooth 4.0 specificationBluetooth 4.0 specification
Bluetooth 4.0 specification
 
Softimize - Connecting Devices to Gateways
Softimize - Connecting Devices to GatewaysSoftimize - Connecting Devices to Gateways
Softimize - Connecting Devices to Gateways
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
 
Control Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable MobileControl Pc Via Bluetooth Enable Mobile
Control Pc Via Bluetooth Enable Mobile
 
Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01Controlpcviabluetoothenablemobile 091028150632-phpapp01
Controlpcviabluetoothenablemobile 091028150632-phpapp01
 
Eyeball AnyConnect™ Gateway Administration Guide
Eyeball AnyConnect™ Gateway Administration GuideEyeball AnyConnect™ Gateway Administration Guide
Eyeball AnyConnect™ Gateway Administration Guide
 
Bluetooth technology introduction and ecosystem
Bluetooth technology introduction and ecosystem Bluetooth technology introduction and ecosystem
Bluetooth technology introduction and ecosystem
 
JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)JSR 82 (bluetooth obex)
JSR 82 (bluetooth obex)
 
ArcSight Connector Appliance 6.4 Patch 1 Release Notes
ArcSight Connector Appliance 6.4 Patch 1 Release NotesArcSight Connector Appliance 6.4 Patch 1 Release Notes
ArcSight Connector Appliance 6.4 Patch 1 Release Notes
 
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730
Webinar NETGEAR - Nuovi AP Professionali Prosafe WAC720 e WAC730
 
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...
Fingerprinting Bluetooth-Low-Energy Devices Based on the Generic Attribute Pr...
 
F5 BigIP LTM Initial, Build, Install and Licensing.
F5 BigIP LTM Initial, Build, Install and Licensing.F5 BigIP LTM Initial, Build, Install and Licensing.
F5 BigIP LTM Initial, Build, Install and Licensing.
 
Bluetooth low energy- Kashyap Velpuru
Bluetooth low energy- Kashyap VelpuruBluetooth low energy- Kashyap Velpuru
Bluetooth low energy- Kashyap Velpuru
 
BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth BTLE (Bluetooth Low Energy) and CoreBluetooth
BTLE (Bluetooth Low Energy) and CoreBluetooth
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

A Brief Introduction to Bluetooth Low Energy (BLE) on iOS

  • 1. A BRIEF INTRODUCTION TO BLUETOOTH LOW ENERGY (BLE) ON IOS Cocoaheads Denver - July 9, 2019 - Matt Whitlock @mattwhitlockco mattwhitlock@phaeron.com
  • 3. BLE vs Bluetooth Classic BLE is Bluetooth in a marketing sense only, implementation is totally unrelated Can be connectionless - invisible to user Low power
  • 4. BLE 4.0-4.2 BLE was introduced as Bluetooth Smart in Bluetooth 4.0 Data packets were limited to 20 bytes until 4.2 with packet length extension which allows 244 bytes Very low speed (~100kbps / ~250kbps)
  • 5. BLE 5.0 Very little hardware/software support, but improving Bluetooth Smart branding dropped ~2x data rate LE Long Range (~4x) LE Advertising Extensions (Larger advertising packets possible)
  • 6. iOS BLE Support Most current devices support Bluetooth 4.2 >= iOS 9.3 >= iPhone 6 >= iPad Air 2, iPad mini 4 (2015+) Notable Exceptions: iPhone 5s - 4.0 iPod touch 7G - 4.1 iPod touch 6G - 4.0 2019 iPads, iPhone 8, X, Xr, Xs, Xs Max Support Bluetooth 5.0
  • 7. Resources Bluetooth Low Energy: The Developer’s Handbook - Robin Heydon, Prentice Hall 2013 Bluetooth SIG https://www.bluetooth.com/ Bluetooth 4.2 standard https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=441541 TI BLE-Stack User’s Guide for Bluetooth 4.2 http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_50_00_58/docs/blestack/ble_user_guide/html/ble-stack-3.x/ index.html Apple Documentation https://developer.apple.com/documentation/corebluetooth https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/ AboutCoreBluetooth/Introduction.html#//apple_ref/doc/uid/TP40013257-CH1-SW1
  • 8. Tools BLE Sniffing Hardware/Software Xcode Bluetooth Explorer nRF52 DK - https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK TI CC2540 - http://www.ti.com/product/CC2540 Bluegiga BLED112 Apps nRF Connect LightBlue
  • 10. BLE Fundamentals BLE is Hierarchical BLE is Asynchronous BLE does nothing without you telling it to Core Bluetooth doesn’t give you anything but the basic building blocks.
  • 11. BLE Fundamentals - Hierarchical Source: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/ Conceptual/CoreBluetooth_concepts/CoreBluetoothOverview/CoreBluetoothOverview.html
  • 12. BLE Fundamentals Central / Peripheral Central scans / listens / commands Peripheral advertises / responds to commands Advertising and Scanning are core concepts. Client / Server Server has data Client wants data
  • 13. BLE Fundamentals - Security Key exchange is broken in 4.0, 4.1, 4.2 Additional key exchange methodologies needed, relying on CMAC which is not in CommonCrypto or Security framework This is very difficult to do properly. Hire a BLE security expert to define key exchange and to do security testing.
  • 14. BLE Fundamentals - Protocol Stack Source: http://dev.ti.com/tirex/content/simplelink_cc2640r2_sdk_1_00_00_22/docs/blestack/html/ble-stack/index.html Not quite right; GAP is above GATT.
  • 15. BLE Fundamentals - Protocols Logical Link Control and Adaptation Protocol (L2CAP) Allows segmentation and reassembly of packets (i.e. > 20B limit) Security Manager (SM) Attribute Protocol (AP / ATT) All services above GATT (including GAP) use Attribute Protocol
  • 16. BLE Fundamentals - Attributes Attributes Defined by the Attribute Protocol (ATT / AP) Defines Profiles / Services / Characteristics / Descriptors All identified by UUID Profiles Generic Attribute Profile (GATT) Defines how services, characteristics, descriptors can be discovered/used Generic Access Profile (GAP) Defines how devices can discover and connect with each other
  • 17. BLE Fundamentals - Attribute Permissions Permissions defined at the Attribute layer Pertains to Services and Characteristics Readable, Writable, Readable and Writable When an attribute is read/written, then check is done for Authentication and Authorization
  • 18. BLE Fundamentals - Profiles Generic Attribute Profile (GATT) Defines how services, characteristics, descriptors can be discovered/used Generic Access Profile (GAP) Defines how devices can discover and connect with each other Advertising, Discover, Pair, Bond, Security, etc.
  • 19. BLE Fundamentals - Services Some defined by BLE Specification - https://www.bluetooth.com/specifications/ gatt/services/ Generic Access Service 0x1800 Battery Service 0x180F Heart Rate Service 0x180D etc. Usually a custom Service is defined for the product Essentially built on top of GATT
  • 20. BLE Fundamentals - Characteristics Data that is part of a service, typically a single value or control point Device Name, Appearance, Peripheral Preferred Connection Parameters are characteristics of Generic Access service. Battery Level characteristic is part of Battery service Heart Rate Measurement, Body Sensor Location, Heart Rate Control Point characteristics are part of Heart Rate service Usually many custom Characteristics are defined for the product
  • 21. BLE Fundamentals - Operations Read Write Notify / Indicate Essentially a subscription or signing up for notification Notification can be lost (think UDP or a broadcast) Indication requires attribute confirmation (think TCP)
  • 22. BLE Fundamentals - Connections Advertising - Connectionless A lot can be done with no connection and just advertising packet Read - only from Central perspective Beacons use this Connect May or may not require user interaction (depends on capabilities matrix) Source: https://www.electronicdesign.com/communications/ ble-v42-creating-faster-more-secure-power-efficient-designs- part-3
  • 23. BLE Fundamentals - Connections Pair Required for encrypted characteristics Authentication / Authorization / Shared secrets (Short-term / Long-term key exchange) Bond Devices state / agree that they are saving keys in security database. Very Rare Issues around this on iOS
  • 24. BLE Fundamentals - Byte Order iOS uses Little Endian byte order BLE Sends LSB first Some devices use Big Endian byte order Example: Value is 0x01234567 89ABCDEF
 
 

  • 26. General iOS Process Check Permissions (new in iOS 13) NSBluetoothPeripheralUsageDescription in Info.plist - supposed to be required in iOS 10+ Check for Bluetooth Enabled Scan Connect Discover Services/Characteristics Pair / Bond (optional) Interact
  • 27. Frameworks Core Bluetooth Bluejay - https://github.com/steamclock/bluejay RxBluetoothKit - https://github.com/Polidea/RxBluetoothKit BlueCap - https://github.com/troystribling/BlueCap
  • 28. Core Bluetooth Core Bluetooth is the Framework for BLE on all Apple devices Incomplete but decent implementation of BLE capabilities. Android can be more complete and have more control, but is inconsistent device to device. Can be Central or Peripheral
  • 29. Core Bluetooth Classes to act as Central CBCentralManager - “used to manage discovered or connected remote peripheral devices (represented by CBPeripheral objects), including scanning for, discovering, and connecting to advertising peripherals.” CBCentralManagerDelegate CBPeripheral - “represents remote peripheral devices that your app—by means of a central manager (an instance of CBCentralManager)—has discovered advertising or is currently connected to.” CBPeripheralDelegate Can act as a Peripheral by using CBPeripheralManager / CBCentral classes
  • 30. Core Bluetooth Classes to act as Central - 2 These are the big ones. CBPeripheral represents the Peripheral so most actions done with this class. CBPeripheralDelegate - “monitor the discovery, exploration, and interaction of a remote peripheral’s services and properties.“
  • 31. CORE BLUETOOTH CLASS DETAILS - CENTRAL
  • 32. CBCentralManager Initializing init(delegate: CBCentralManagerDelegate?, queue: DispatchQueue?, options: [String : Any]?) Scanning func scanForPeripherals(withServices: [CBUUID]?, options: [String : Any]?) func stopScan() Connections func connect(CBPeripheral, options: [String : Any]?) func cancelPeripheralConnection(CBPeripheral) func retrieveConnectedPeripherals(withServices: [CBUUID]) -> [CBPeripheral] func retrievePeripherals(withIdentifiers: [UUID]) -> [CBPeripheral]
  • 33. CBCentralManagerDelegate Scanning func centralManager(CBCentralManager, didDiscover: CBPeripheral, advertisementData: [String : Any], rssi: NSNumber) Monitor Connections func centralManager(CBCentralManager, didConnect: CBPeripheral) func centralManager(CBCentralManager, didDisconnectPeripheral: CBPeripheral, error: Error?) func centralManager(CBCentralManager, didFailToConnect: CBPeripheral, error: Error?) State func centralManagerDidUpdateState(CBCentralManager) func centralManager(CBCentralManager, willRestoreState: [String : Any])
  • 34. CBPeripheral Properties var name: String? var delegate: CBPeripheralDelegate? Discovery func discoverServices([CBUUID]?) func discoverIncludedServices([CBUUID]?, for: CBService) var services: [CBService]? func discoverCharacteristics([CBUUID]?, for: CBService) func discoverDescriptors(for: CBCharacteristic)
  • 35. CBPeripheral - 2 Read/Write/Notification func readValue(for: CBCharacteristic) func readValue(for: CBDescriptor) func writeValue(Data, for: CBCharacteristic, type: CBCharacteristicWriteType) func setNotifyValue(Bool, for: CBCharacteristic) Supports Notifications and Indications State var state: CBPeripheralState func readRSSI()
  • 36. CBPeripheralDelegate Discovery func peripheral(CBPeripheral, didDiscoverServices: Error?) func peripheral(CBPeripheral, didDiscoverIncludedServicesFor: CBService, error: Error?) func peripheral(CBPeripheral, didDiscoverCharacteristicsFor: CBService, error: Error?) func peripheral(CBPeripheral, didDiscoverDescriptorsFor: CBCharacteristic, error: Error?) State func peripheral(CBPeripheral, didReadRSSI: NSNumber, error: Error?) func peripheralDidUpdateName(CBPeripheral) func peripheral(CBPeripheral, didModifyServices: [CBService])
  • 37. CBPeripheralDelegate - 2 Read/Write/Notification func peripheral(CBPeripheral, didUpdateValueFor: CBCharacteristic, error: Error?) func peripheral(CBPeripheral, didUpdateValueFor: CBDescriptor, error: Error?) func peripheral(CBPeripheral, didWriteValueFor: CBCharacteristic, error: Error?) func peripheral(CBPeripheral, didWriteValueFor: CBDescriptor, error: Error?) func peripheral(CBPeripheral, didUpdateNotificationStateFor: CBCharacteristic, error: Error?)