20
Core Bluetooth CocoaHeads Sthlm 2014 Edward Patel teaser

Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Core BluetoothCocoaHeads Sthlm 2014

Edward Patel

teaser

Page 2: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Me

• I work at

• Love programming

• Love gadgets

• Love programming gadgets

Page 3: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Bluetooth Low Energy

Page 4: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

WWDC’13 Keynote• Anki DRIVE

Page 5: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac
Page 6: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Bluetooth Low Energy

• Invented by researchers at Nokia

• For small things

• Run a long time on a coin-cell battery

• Look for “Internet-of-Things”

Page 7: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

iOS

• Introduced in iOS 5

• Extended in iOS 6 (can become a “Peripheral”)

• Cleaning API in iOS 7 + better caching andhandling including backgrounding.

Page 8: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Framework

Core Bluetooth Framework ReferenceThe Core Bluetooth framework provides the classes needed for your iOS and Mac apps to communicate with devices that are equipped with Bluetooth low energy wireless technology.

 

Protocol ReferencesCBCentralManagerDelegateCBPeripheralDelegateCBPeripheralManagerDelegate

Class ReferencesCBATTRequestCBCentralCBCentralManagerCBCharacteristicCBDescriptorCBMutableCharacteristicCBMutableDescriptorCBMutableServiceCBPeripheralCBPeripheralManagerCBServiceCBUUID

Other ReferencesCore Bluetooth Constants

Page 9: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

There are only two hard things in Computer Science:

cache invalidation naming things

off-by-one errors

Page 10: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

PeripheralCentral

has datawants data

(server)(client)

Naming things...

advertise

Page 11: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Service

Characteristic

Characteristic

Service

Characteristic

Characteristic

Peripheral

Page 12: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Characteristic

• Can be read, and writable

• Can be integers, strings etc

• Can be “Notifiable”

Page 13: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

GATT

• A kind of contract known in advance

• Defines a number of UUID’s for Services and Characteristics and value types.

• There are standardized ones,i.e Heart rate monitors

• You can define your own

Service

Characteristic

Characteristic

Service

Characteristic

Characteristic

Generic Attribute Profile

Page 14: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

https://developer.bluetooth.org/gatt/

Find the standardized?

Page 15: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

UUID’s

• Standardized by Bluetooth SIG are short, 16 bit

• Free are long, 128 bits

“0CDA25F083E54CBCB7C97FB2AC3DC476”

“180D”

Heart rate monitor service

Your own message service

Page 16: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Discover Peripherals with Services

Connect to Peripheral

Discover Services for Peripheral

Discover Characteristics for Service

Workflow of a Central in iOS

Create a CBCentralManager

Page 17: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Where to start?

• LightBlue - Bluetooth Low Energy

• TI BLE Multitool

Download some apps from App Store

Do it now!

Page 18: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Get some hardware?

• SensorTag (6 sensors)

• Arduino Shields, i.e. Tinyduino or BLE Shield

• BLE Mini by RedBearLabs

• BLE-112 Evaluation board

• Gimbal iBeacon

• Or just use two iPhones

Page 19: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Get some sample code?

• HiBeacons by Nick Toumpelis (a Spotifier)

• Temperature Sensor by Apple

• Also, checkout WWDC videos

Page 20: Core Bluetooth - Mementionmemention.com/CHCoreBluetooth.pdf · Core Bluetooth CocoaHeads Sthlm 2014 ... The Core Bluetooth framework provides the classes needed for your iOS and Mac

Thanks!