0% found this document useful (0 votes)
48 views22 pages

Core Bluetooth: Toantv - Ios Team

This document provides an overview of Core Bluetooth and how to use it to communicate with Bluetooth Low Energy (BLE) devices. It discusses how to import and declare the necessary classes, scan for devices, connect to a device, get services and characteristics, set up notifications, and handle characteristic value changes. The document also mentions implementing delegate methods and using UUIDs to identify services and characteristics when working with BLE devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views22 pages

Core Bluetooth: Toantv - Ios Team

This document provides an overview of Core Bluetooth and how to use it to communicate with Bluetooth Low Energy (BLE) devices. It discusses how to import and declare the necessary classes, scan for devices, connect to a device, get services and characteristics, set up notifications, and handle characteristic value changes. The document also mentions implementing delegate methods and using UUIDs to identify services and characteristics when working with BLE devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Core Bluetooth

ToanTV - iOS Team


Contents

1. Introduction to BLE
2. Introduction to Core Bluetooth
3. Demo
4. Q&A
What is BLE?

• Low power – can last months or even years on a single


battery
• Standard – Bluetooth 4.o
• Low cost – small, chip and simple
Why BLE?

• Heart rate monitor


• Sensors
• iBeacons(Proximity)
• Internet of things
Why BLE?
Why BLE?
1. Introduction to BLE
2. Introduction to Core Bluetooth
3. Demo
4. Q&A
Import
● Unlike beacons, which use Core Location, if you are
communicating to a BLE device, you will use
CoreBluetooth.
Delegates
• Eventually you are going to want to get callbacks from
some functionality. There are two delegates to implement:
CBCentralManagerDelegate, and CBPeripheralDelegate.
Declare Manager and Peripheral
● The CBCentralManager install will be what you use to
find, connect, and manage BLE devices. Once you are
connected, and are working with a specific service, the
peripheral will help you iterate characteristics and
interacting with them.
UUID and Service Name
● You will need UUID for the BLE service, and a UUID
for the specific characteristic. In some cases, you will
need additional UUIDs. They get used repeatedly
throughout the code, so having constants for them will
keep the code cleaner, and easier to maintain.
Instantiate Manager
• One-liner to create an instance of CBCentralManager. It
takes the delegate as an argument, and options, which in
most cases are not needed.
Scan for Devices
● Once the CBCentralManager instance is finished
creating, it will call centralManagerDidUpdateState on the
delegate class. From there, if Bluetooth is available (as in
"turned on"), you can start scanning for devices.
Connect to a Device
● When you find the device you
are interested in interacting
with, you will want to connect
to it. This is the only place
where the device name shows
up in the code, but I still like to
declare it as a constant with
the UUIDs.
Get Services
● Once you are connected to a device, you can get a list of
services on that device.
Get Characteristics
● Once you get a list of the
services offered by the
device, you will want to get
a list of the characteristics.
You can get crazy here, or
limit listing of characteristics
to just a specific service.
Setup Notifications
● There are different ways to approach getting data from
the BLE device. One approach would be to read changes
incrementally. Another approach, the approach I used in
my application, would be to have the BLE device notify
you whenever a characteristic value has changed.
Changes Are Coming
● Any characteristic changes
you have setup to receive
notifications for will call this
delegate method. You will
want to be sure and filter
them out to take the
appropriate action for the
specific change.
Disconnect and Try Again
● This is an optional step, but hey, let us be good
programmers and clean up after ourselves. Also a good
place to start scanning all over again.
1. Introduction to BLE
2. Introduction to Core Bluetooth
3. Demo
4. Q&A
DEMO

You might also like