Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!

456 views

Published on

Fitbit, Withings, Nest. The Internet of Things (IoT) innovation tidal wave has just begun, and those are just three of the more well-known players in the IoT and connected gadget landscape. It’s critical that iOS developers know how to connect and interact with BLE prototyping devices using the Core Bluetooth Framework provided by the iOS SDK. In this session, you’ll get the jump-start you need to begin creating engaging apps that bring these devices to life.

Published in: Technology
  • Be the first to comment

How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!

  1. 1. How Hot is My Coffee? Sensors, Core Bluetooth, and Swi8! Evan K. Stone Senior iOS Developer Cloud City Development // San Francisco
  2. 2. An integrated design and so-ware consultancy specializing in web and mobile apps
  3. 3. There is an explosion.
  4. 4. Not bombs.
  5. 5. Usually doesn’t hurt people.
  6. 6. Very o8en helps people.
  7. 7. This explosion is…
  8. 8. The Internet of Things
  9. 9. Connected devices
  10. 10. Nest. Fitbit. Polar.
  11. 11. Key technology behind it?
  12. 12. Bluetooth Low Energy
  13. 13. What is it?
  14. 14. Not Classic Bluetooth.
  15. 15. A lightweight subset
  16. 16. AKA “Bluetooth Smart”
  17. 17. Why do we care?
  18. 18. It’s exciSng!
  19. 19. It’s fun!
  20. 20. It can be rewarding.
  21. 21. Allows us to interact with physical devices
  22. 22. We can develop iOS apps that communicate with other things around us!
  23. 23. No cerSficaSon required!
  24. 24. Super Low Barrier for Entry.
  25. 25. TI SensorTag Ambient Light Digital Microphone MagneSc Sensor Humidity Accelerometer Gyroscope Magnetometer Ambient Temperature IR Temperature
  26. 26. $29
  27. 27. What does this mean for us?
  28. 28. The IoT Landscape is changing
  29. 29. Tons of innovaSon going on right now.
  30. 30. Startups
  31. 31. Incubators and Accelerators
  32. 32. They will need you.
  33. 33. Ge]ng started now will help you help them.
  34. 34. Side note:
  35. 35. What about iBeacons?
  36. 36. Subject of another talk!
  37. 37. iBeacons are BLE devices.
  38. 38. Behave differently
  39. 39. They are also fun to work with.
  40. 40. Are handled by a different framework!
  41. 41. Core LocaSon
  42. 42. Ge]ng back to BLE…
  43. 43. Acronym Time!
  44. 44. GAP Generic Access Profile
  45. 45. Defines how devices adver&se themselves and how they connect
  46. 46. Defines the concept of the Central and the Peripheral
  47. 47. GATT Generic Aaribute Profile
  48. 48. Defines the way devices transfer data back and forth
  49. 49. Introduces Services and CharacterisScs
  50. 50. You won’t be tested on the acronyms.
  51. 51. Just know they exist.
  52. 52. Roles
  53. 53. We are already used to Client and Server roles
  54. 54. In BLE we have the Central and Peripheral roles
  55. 55. Central
  56. 56. Wants data from a Peripheral
  57. 57. Generally this is your iOS device.
  58. 58. Peripheral
  59. 59. Supplies data.
  60. 60. A device like a heart rate monitor
  61. 61. Becomes an extension of our iOS device, giving it abiliSes it didn’t have previously
  62. 62. Side note:
  63. 63. An iOS device can be a Peripheral…
  64. 64. …but typically they act as a Central.
  65. 65. The Age of Discovery
  66. 66. For devices to communicate with each other, they must find each other.
  67. 67. AdverSsing and Discovery
  68. 68. The Peripheral AdverSses
  69. 69. The Central scans and listens
  70. 70. When it finds a Peripheral, the Central can ask to connect.
  71. 71. Kinda like a headhunter on LinkedIn.
  72. 72. Services and CharacterisScs
  73. 73. Services group data
  74. 74. Services contain CharacterisScs
  75. 75. Service Characteris2c Characteris2c Characteris2c
  76. 76. Central connects and discovers Services and CharacterisScs the peripheral offers
  77. 77. But how?
  78. 78. Core Bluetooth
  79. 79. Apple’s abstracSon over all that Bluetooth gobbledygook.
  80. 80. Encapsulates the funcSonality of the BLE enSSes in framework classes
  81. 81. Remember the four main players?
  82. 82. Central and Peripheral. Service and CharacterisSc.
  83. 83. Everything begins with a CB
  84. 84. Peripheral
  85. 85. CBPeripheral
  86. 86. Central
  87. 87. CBCentralManager
  88. 88. Service
  89. 89. CBService
  90. 90. CharacterisSc
  91. 91. CBCharacterisSc
  92. 92. Side note:
  93. 93. Caveat with Core Bluetooth development
  94. 94. iOS Simulator does not support BLE.
  95. 95. So you have to use a device.
  96. 96. Which devices support BLE?
  97. 97. iPhone 4s and later. iPad 3 and later.
  98. 98. Basic Workflow
  99. 99. Feels very client-server
  100. 100. That’s not an accident.
  101. 101. Workflow:
  102. 102. InstanSate a CBCentralManager
  103. 103. Tell CBCentralManager to scan for Peripherals with Services we want
  104. 104. When it finds a Peripheral, request to connect
  105. 105. A8er connecSng, find out more about the Peripheral
  106. 106. Read and set characterisScs
  107. 107. Rinse, Lather, Repeat…
  108. 108. Disconnect.
  109. 109. What makes this work?
  110. 110. Enter the UUID.
  111. 111. Enter the UUID.
  112. 112. Standard UUIDs have a 16-bit form.
  113. 113. 0x180A
  114. 114. Custom UUIDs have a 128-bit form.
  115. 115. F000AA00-0451-4000-B000-000000000000
  116. 116. What do we mean by Standard and Custom UUIDs?
  117. 117. For example…
  118. 118. Heart Rate Monitor Service 0x180D
  119. 119. Heart Rate Measurement CharacterisSc 0x2A37
  120. 120. ExciSng Reading! developer.bluetooth.org 🤓
  121. 121. Custom Service UUIDs Anything not listed on the standard list.
  122. 122. For example…
  123. 123. IR Temperature Sensor F000AA00-0451-4000-B000-000000000000
  124. 124. Where do I find these crazy numbers?
  125. 125. Typically on the vendor website
  126. 126. Or the hardware engineer on your team creates them!
  127. 127. Back to scanning…
  128. 128. CBCentralManager
  129. 129. Core Bluetooth relies heavily on delegates
  130. 130. CBCentralManagerDelegate
  131. 131. CBPeripheralDelegate
  132. 132. Demo Time! 🎉
  133. 133. How Hot is My Coffee?
  134. 134. Side note:
  135. 135. Backgrounding
  136. 136. Yes it’s possible!
  137. 137. Requires a flag in your Info.plist
  138. 138. key: UIBackgroundModes value: bluetooth-central
  139. 139. Devices
  140. 140. Many to choose from
  141. 141. New ones appear constantly
  142. 142. TI SensorTag hap://www.S.com/sensortag
  143. 143. LightBlue Bean/Bean+ haps://punchthrough.com/bean
  144. 144. Adafruit Feather 32u4 Bluefruit LE haps://www.adafruit.com/products/2829
  145. 145. TinyCircuits haps://Sny-circuits.com/
  146. 146. The IoT space is exploding!
  147. 147. More connected devices are being developed every day!
  148. 148. More connected apps are needed every day!
  149. 149. As an iOS developer, you can be on the cu]ng edge of this new fronSer!
  150. 150. Explore!
  151. 151. Experiment!
  152. 152. Connect and Communicate
  153. 153. Core Bluetooth.
  154. 154. Resources
  155. 155. Cloud City Development Blog hap://cloudcity.io/blog/2015/06/11/zero-to-ble-on-ios-part-one/ hap://cloudcity.io/blog/2015/10/15/developing-ios-app-using-ble-standard/ GitHub haps://github.com/cloudcity/BLECoffee haps://github.com/cloudcity/ZeroToBLE-Part2
  156. 156. Apple's Official Core Bluetooth Docs IntroducSon to Core Bluetooth Background OperaSon Best PracSces
  157. 157. Adafruit's IntroducSon to BLE haps://learn.adafruit.com/introducSon-to-bluetooth-low-energy/introducSon
  158. 158. Evan K. Stone web: h<p://www.cloudcity.io cloud city blog: h<p://blog.cloudcity.io blog: h<p://www.interac?velogic.net twi<er: @interac?vlogic

×