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…
Author
Released
4/5/2018- 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
Duration
Views
Related Courses
-
Introduction
-
Welcome1m 10s
-
Exercise files33s
-
-
1. BLE Basics
-
BLE overview1m 29s
-
BLE communication workflow1m 18s
-
SensorTag overview1m 38s
-
-
2. Scanning, Connecting, and Discovering
-
Bluetooth project setup4m 30s
-
Scan for peripherals4m 54s
-
Connect to peripheral3m 13s
-
-
3. Writing to a Characteristic
-
Adding additional features10m 43s
-
4. An App as a Peripheral
-
Central app on Mac4m 19s
-
Peripheral iOS app7m 47s
-
Creating a characteristic2m 42s
-
Central read requests4m 6s
-
Central write requests4m 21s
-
-
Conclusion
-
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.
CancelTake 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.
Share this video
Embed this video
Video: Scan by service UUID