Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
Core BluetoothCocoaHeads Sthlm 2014
Edward Patel
teaser
Me
• I work at
• Love programming
• Love gadgets
• Love programming gadgets
Bluetooth Low Energy
WWDC’13 Keynote• Anki DRIVE
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”
iOS
• Introduced in iOS 5
• Extended in iOS 6 (can become a “Peripheral”)
• Cleaning API in iOS 7 + better caching andhandling including backgrounding.
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
There are only two hard things in Computer Science:
cache invalidation naming things
off-by-one errors
PeripheralCentral
has datawants data
(server)(client)
Naming things...
advertise
Service
Characteristic
Characteristic
Service
Characteristic
Characteristic
Peripheral
Characteristic
• Can be read, and writable
• Can be integers, strings etc
• Can be “Notifiable”
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
https://developer.bluetooth.org/gatt/
Find the standardized?
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
Discover Peripherals with Services
Connect to Peripheral
Discover Services for Peripheral
Discover Characteristics for Service
Workflow of a Central in iOS
Create a CBCentralManager
Where to start?
• LightBlue - Bluetooth Low Energy
• TI BLE Multitool
Download some apps from App Store
Do it now!
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
Get some sample code?
• HiBeacons by Nick Toumpelis (a Spotifier)
• Temperature Sensor by Apple
• Also, checkout WWDC videos
Thanks!