96: Discovering Core Bluetooth

Published: Dec. 16, 2015, 5:45 p.m.

Darryl and Nolan take a journey of exploration through the world of Bluetooth and Core Bluetooth.\n\nTweet Shoutouts\n\n@iOhYesPodcast ep.94 you guys talked about the struggle to make income as an indie dev. Is it possible for a newb dev to go indie in 2016?— Kyle Lee (@Kilo_Loco) December 9, 2015\n\n\n\n\niOhYes: 95 - Great non technical episode of @iOhYesPodcast with @jaimeejaimee I'll start my #tinychallenges in Jan https://t.co/rR2W5udvGb— You can call me Joe (@mokagio) December 10, 2015\n\n\n\n\n.@iOhYesPodcast Got to listen to the podcast on my way to the tvOS tech talk. Love the tiny challenges concept. @jaimeejaimee— Jeremiah Jessel (@JCubedApps) December 10, 2015\n\n\n\n\n@iOhYesPodcast Sorry to keep you gentlemen in suspense. Ep #93 was great \u2014 motivation, conference philosophy, and plenty of tips!— Greg Heo (@gregheo) December 11, 2015\n\n\n\n\n@iOhYesPodcast @dh_thomas Thanks for the ep #95 pick! I enjoyed the non-tech talk \u2014 like refactoring your life rather than your code ;)— Greg Heo (@gregheo) December 11, 2015\n\n\n\n\n@jaimeejaimee @iOhYesPodcast great interview! Thank you Jaimee for being so open about your life, I know I learned from #tinychallenges— Dale Fairclough (@faircoder) December 12, 2015\n\n\n\n\n\nDiscussion - News we missed\n\n\nSwift is Open Source!\n\n\nApple starting to accept pull requests (notably the removal of C-style for loops)\nDocs are also open, and a call has been made for translations\n\n\nApple to remove headphone jacks??\n\n\nAudio over Lightning?\nBluetooth\n\n\n\n\n\nDiscussion - Core Bluetooth\n\n\nBluetooth\u2019s Background\n\n\nInvented by Ericsson in 1994 as a wireless alternative to RS-232 serial interfaces\nIEEE 802.15.1 (Bluetooth) part of IEEE 802.15 (Personal Area Network: PAN) within IEEE 802 (Local and Metropolitan Area Networking, LAN & MAN) Wikipedia Link\nThe name is a nod to King Harald "Bl\xe5tand" Gormsson (Bluetooth is an anglicanized version of "Bl\xe5tand"). King Bluetooth is said to have united the Danish tribes into a single kingdom.\nThe logo is a bind rune forming the initials H. B. (sort-of)\n\n\nVersions\n\n\n1.2\n\n\n1 Mbps data rate, > 80 kbps application throughput\nProbably the first version considered \u201cviable.\u201d\n\n\n2.0 + EDR\n\n\n3 Mbps data rate, > 80 kbps application throughput\n\n\n3.0 + HS\n\n\n24 Mbps data rate, but not really: The connection is negotiated over a BT link, but 802.11 is used for data transfer\n\n\n4.0 (Classic and HS) & 4.0 LE (Branded as Bluetooth Smart)\n\n\n24 Mbps data rate, but not really: See 3.0 + HS and LE has extremely low throughput by design (like less than 100 kbps)\nBluetooth LE\n\n\nTotally new protocol specifically designed for low energy consumption and simplified communications\nPeripheral devices can implement just LE, just Classic or both\n\n\n\n\n\n\nBluetooth LE and Core Bluetooth\n\n\nCore Bluetooth provides a layer of abstraction over the GATT profile (Generic Attribute Profile)\nPeripherals are \u201cservers\u201d\nCentrals are \u201cclients\u201d\nPeripherals serve one or more Service(s)\nServices have Characteristics (can be thought of as attributes or properties)\nCharacteristics have a value, which may be readable, writable or notifiable\n\n\nUsing CBCentralManager\n\n\nInstantiate the manager and then check for availability (implement the -centralManagerDidUpdateState: delegate method and check for PoweredOn state\nScan for services with service UUIDs you provide using -scanForPeripheralsWithServices:options:\nWhen peripherals are discovered, the -centralManager:didDiscoverPeripheral:advertisementData:RSSI: delegate method will be called\n\n\nConnect to a peripheral using -connectPeripheral:options:, which in turn will call the delegate\u2019s -centralManager:didConnectPeripheral: method.\nAt this point, you can start using the peripheral directly. (And get responses through the CBPeripheralDelegate protocol)\nDiscover services with -discoverServices:, which will result in the delegate\u2019s -peripheral:didDiscoverServices: method being called\nSimilarly, discover characteristics of a service using -discoverCharacteristics:forService:, from which you can expect a -peripheral:didDiscoverCharacteristicsForService:error: message\nDepending on the peripheral\u2019s configuration, values for a characteristic can be read, written to or monitored for changes (notified)\nCharacteristic values are expected to be small. (Like 20 bytes or smaller.) If you need to send larger payloads, it\u2019s possible to roll-your-own streaming protocol atop characteristics.\n\n\nI don\u2019t really recommend this, but it\u2019s a fairly common approach\nI suspect some of this comes from the legacy of BT being treated as a dumb serial link\nApple has recognized this trend and in recent versions of iOS/OS X, they have tried to accommodate higher throughput by negotiating higher MTUs when possible. They even demonstrate how this can be done in one of their WWDC sessions.\n\n\n\n\n\nPicks\n\nNolan\n\n\nStar Wars Trilogy: Despecialized Edition\nStar Wars Machete Order\n\n\n\nDarryl\n\n\nWWDC 2012 Session 703 - Core Bluetooth 101\nWWDC 2012 Session 705 - Advanced Core Bluetooth\nWWDC 2012 Session 701 - iOS Accessories\nWWDC 2013 Session 703 - Core Bluetooth\nWWDC 2013 Session 307 - What's New in Core Location\nWWDC 2014 Session 708 - Taking Core Location Indoors\nWWDC 2014 Session 713 - What's New in iOS Notifications