Given the nature of the growing number of Bluetooth LE devices, chances are we are only interested in a small group of them. We can, therefore, specify that our CBCentralManager instance only scan for devices that include the services the app is interested in. This can make our code cleaner and more efficient.
- [Instructor] Another way we can make…the connection more efficient in our app, is by…only scanning for peripherals that we're interested in.…We can limit this by specifying the services…we're interested in, for peripherals we want to scan.…You should still check to make sure…that the devices discovered,…match what you're looking for.…We've been doing this by checking the name…and making sure it contains sensor tag.…So when scan for peripherals,…we can pass in the services we're interested in,…just like we did on line 32…with retrieve connect the peripherals.…
So I'll simply copy and paste…this array of the single service that we're interested in…and paste it where we scanned for peripherals.…I'll also do this in the disconnect peripheral call for…scanning and replace the nil on line 58 with the same array.…Just as we want to re-scan when the peripheral disconnects,…we should also call that…when we fail to connect to a peripheral.…So on line 57, I'll override…the function did fail to connect to peripheral.…I'm going to use the same body as when the peripheral…
- 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.