Bluetooth LE: User Experience with iOS

Preview:

Citation preview

1

2

Bluetooth LE:User experience with iOS

Serhii SuprunGlobalLogic Lviv iOS TechTalk16.11.2016

3

Confidential

Radio transmit technology based on 2.4 to 2.485 GHzProtocols Initiated in 1989 (1.1 in 2002 and 5.0 in june 2016)Dr. Nils Rydbeck CTO at Ericsson Mobile and Dr. Johan Ullman Runes

What is Bluetooth ?

4

Confidential

Runes

ᚼ and ᛒScandinavian runes

5

Confidential

LE == Low Energy ?

Up to 4-5 years of work on one battery

- 1 Mbit/s (radio)

- 270 Kbit/s (application limit)

- 26 kbit/s (iOS-iOS my tests)

6

Confidential

CentralClient

Peripheral

Server

iOS?

Who is who?

7

Confidential

Device to CBPeripheral magic

CoreBluetooth

8

Confidential

Red pill

9

Confidential

Identifiers

Everything is uuid

128 bit (289ed316-defc-48de-8a74-2c9e854e5ab3)

16 bit ( 0xFE8B)

10

Confidential

Discovery UUID is everything

func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil)func stopScan()

optional func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber)

CBCentralManager

CBCentralManagerDelegate

11

Confidential

Connect: 1 connect CBCentralManager

func connect(_ peripheral: CBPeripheral, options: [String : Any]? = nil)func cancelPeripheralConnection(_ peripheral: CBPeripheral)

optional func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral)

CBCentralManagerDelegate

12

Confidential

Connect: 2 services

CBPeripheral

func discoverServices(_ serviceUUIDs: [CBUUID]?)

optional func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?)

CBPeripheralDelegate

13

Confidential

Connect: 3 characteristic

CBPeripheral

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

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

CBPeripheralDelegate

14

Confidential

Connect: 3 characteristic

CBPeripheral

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

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

CBPeripheralDelegate

15

Confidential

Data transfer

CBPeripheral

func readValue(for characteristic: CBCharacteristic)func writeValue(_ data: Data, for characteristic: CBCharacteristic, type: CBCharacteristicWriteType)

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

CBPeripheralDelegate

16

Confidential

Transfer speedPacketsConnection Interval Min ≥ 20 ms

Default MTU: 23 bytes

23*50 = 1150 bytes per second9200 bit per second

Max MTU: 512 bytes512*50 = 25600 bytes per second204800 bit per seconds (200 kbit/s)

128 kbit - low quality audio stream

17

Confidential

Under the hood

18

Confidential

iphone 6 to iphone 5s

average

bytestime interval (second) bytes/sec

82939 25.147522 3298.09831882939 24.842042 3338.65468982939 24.637974 3366.30763682939 24.557985 3377.27219982939 24.590379 3372.823168 bytes/sec kbit/s kbyte/s82939 25.016174 3315.415059 3344.761845 26.75809476 3.266368989

iphone 5s to iphone 687771 27.235893 3222.622442

average87771 26.602149 3299.39509887771 26.506242 3311.33323287771 26.216806 3347.89066287771 26.595411 3300.231006 bytes/sec kbit/s kbyte/s87771 26.41587 3322.661718 3300.689026 26.40551221 3.223329127

Experiments

19

Confidential

Time between chunks

20

Confidential

Problemaz - Pairing - Rename- Speed?

New in iOS 10?

21

Confidential

Linkshttps://en.wikipedia.org/wiki/Bluetoothhttps://developer.apple.com/videos/play/wwdc2013/703/https://developer.apple.com/videos/play/wwdc2012/703/https://developer.apple.com/videos/play/wwdc2012/705/https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdfhttps://www.google.com

22

Confidential

Questions please

Thanks

23

Thank you

Recommended