Once a Bluetooth LE device is discovered through scanning, the app needs to determine if is interested in the device and its services. If so, it needs to connect to the device. The steps to this process are handled by both the Core Bluetooth classes combined with the functionality in the app’s callback function implementation.
- [Instructor] When we've determined the…peripheral we'd like to connect to…there's a few things we need to do.…First, we need to store a copy of the peripheral locally…to keep it in scope.…Then we call connect on the central,…passing in that peripheral.…When we get the didConnect call back,…we can discover the services…of that peripheral and move on.…We also want to handle the case for DidDisconnectPeripheral…and have our central begin scanning again.…So the current state of our code…is that we're scanning for peripherals…and when we find one we check its name.…
If its name matches the sensor tag…that we're interested in…we want to stop scanning and connect to that peripheral.…We can connect to it by adding the line,…central.connect, and pass in the peripheral.…This is what we'll add on line 25.…For the options we don't need to specify anything…and it's an optional so we'll pass in nil.…In the case when we were trying to discover a peripheral…we handed the callback didDiscover.…In the case when we're trying to connect to a central…
- Bluetooth Low Energy (BLE) basics
- Core Bluetooth key classes
- Scanning for peripherals
- Discovering services and characteristics
- Writing to a characteristic
- Reconnecting to peripherals
- Apps as peripherals
Skill Level Intermediate
1. BLE Basics
2. Scanning, Connecting, and Discovering
3. Writing to a Characteristic
Adding additional features10m 43s
4. An App as a Peripheral
Next steps1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.