SlideShare a Scribd company logo
Practical Core Bluetooth
in IoT & Wearable projects
Shuichi Tsutsumi @shu223
AltConf 2016 - San Francisco
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
iOS-10-Sampler
https://github.com/shu223
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Overview
• Basics of Core Bluetooth
• Practical Core Bluetooth
Based on my experience!
Bluetooth Low Energy?
Bluetooth Low Energy (BLE)
Bluetooth Low Energy (BLE)
• Wireless technology
Bluetooth Low Energy (BLE)
• Wireless technology
- no network infrastructure required
Bluetooth Low Energy (BLE)
• Wireless technology
- no network infrastructure required
Wi-Fi
Bluetooth Low Energy (BLE)
• Wireless technology
- no network infrastructure required
BLE
• Low energy
• Low energy
• NOT compatible with Classic BT
• Low energy
• NOT compatible with Classic BT
• Uses 2.4 GHz radio frequencies
• Low energy
• NOT compatible with Classic BT
• Uses 2.4 GHz radio frequencies
• Marketed by the Bluetooth SIG
• Low energy
• NOT compatible with Classic BT
• Uses 2.4 GHz radio frequencies
• Marketed by the Bluetooth SIG
• etc…
• Low energy
• NOT compatible with Classic BT
• Uses 2.4 GHz radio frequencies
• Marketed by the Bluetooth SIG
• etc…
The most important thing
for
iOS developers
The API ‘Core Bluetooth’
is open for developers
The API ‘Core Bluetooth’
is open for developers
• API for Classic BT is NOT open.
- Requires MFi certification.
BLE is almost the ONLY way
to enable iOS apps to communicate
with external hardware
without infrastructure or MFi.
Basics of
Core Bluetooth
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Moff Band Moff App
Moff Band Moff App
BLE Connection
Moff Band Moff App
BLE Connection
Sensors
- Gyroscope
- Accelerometer
Moff Band Moff App
Sensor Data
BLE Connection
Sensors
- Gyroscope
- Accelerometer
Moff Band Moff App
Sensor Data
BLE Connection
Sensors
- Gyroscope
- Accelerometer
Analyze sensor data
Moff Band Moff App
Sensor Data
BLE Connection
Sensors
- Gyroscope
- Accelerometer
Analyze sensor data
Recognize
- Gesture
- Posture
Moff Band Moff App
Sensor Data
BLE Connection
Sensors
- Gyroscope
- Accelerometer
Analyze sensor data
Recognize
- Gesture
- Posture
Play sounds
Sensor Data
BLE Connection
How is sensor data sent with Core Bluetooth?
Step 1. Scan
Step 1. Scan: Search for nearby BLE devices
Step 1. Scan: Search for nearby BLE devices
Step 1. Scan
Advertise
: Search for nearby BLE devices
Scan
Step 1. Scan
Advertise
: Search for nearby BLE devices
Scan
Step 1. Scan
Advertise
: Search for nearby BLE devices
centralManager.scanForPeripheralsWithServices(nil, options: nil)
Scan
Step 1. Scan
Advertise
Discover
: Search for nearby BLE devices
Scan
Step 1. Scan
Advertise
Discover
: Search for nearby BLE devices
func centralManager(central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(“Discovered a BLE device!”)
}
Scan
Step 1. Scan
Advertise
Discover
: Search for nearby BLE devices
func centralManager(central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(“Discovered a BLE device!”)
}
Central
Scan
Step 1. Scan
Advertise
Discover
: Search for nearby BLE devices
func centralManager(central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(“Discovered a BLE device!”)
}
Peripheral Central
Step 2. Connect
Connect
Step 2. Connect
Connect
Step 2. Connect
centralManager.connectPeripheral(peripheral, options: nil)
Connect
Step 2. Connect
centralManager.connectPeripheral(peripheral, options: nil)
func centralManager(central: CBCentralManager,
didConnectPeripheral peripheral: CBPeripheral)
{
print(“Connected!”)
}
Step 3. Subscribe
Step 3. Subscribe: Ready to receive data
Step 3. Subscribe: Ready to receive data
GATT = Generic Attribute Profile
Moff Service
xx Service
Step 3. Subscribe: Ready to receive data
GATT = Generic Attribute Profile
Moff Service
xx Service
Button Characteristic
xx Characteristic
Sensor Characteristic
Step 3. Subscribe: Ready to receive data
GATT = Generic Attribute Profile
Moff Service
xx Service
Button Characteristic
xx Characteristic
Sensor Characteristic
Subscribe
(Request to be notified)
Step 3. Subscribe: Ready to receive data
GATT = Generic Attribute Profile
Moff Service
xx Service
Button Characteristic
xx Characteristic
Sensor Characteristic
Subscribe
(Request to be notified)
Step 3. Subscribe: Ready to receive data
GATT = Generic Attribute Profile
peripheral.setNotifyValue(true, forCharacteristic: c)
Step 4. Notify
Moff Service
Sensor Characteristic
xxxx Characteristic
Step 4. Notify
Moff Service
Sensor Characteristic
xxxx Characteristic
Update the value
Step 4. Notify
Notify
subscribers
Moff Service
Sensor Characteristic
xxxx Characteristic
Update the value
Step 4. Notify
Notify
subscribers
Moff Service
Sensor Characteristic
xxxx Characteristic
Update the value
func peripheral(peripheral: CBPeripheral,
didUpdateValueForCharacteristic characteristic: CBCharacteristic,
error: NSError?)
{
print(“Received sensor data!”)
}
Step 4. Notify
Notify
subscribers
Moff Service
Sensor Characteristic
xxxx Characteristic
Update the value
func peripheral(peripheral: CBPeripheral,
didUpdateValueForCharacteristic characteristic: CBCharacteristic,
error: NSError?)
{
print(“Received sensor data!”)
}
Hardware Side?
Hardware Side?
I’m sorry, I don’t know…
BLE
BLE
iOS Engineer
BLE
iOS Engineer
BLE
Firmware Engineer iOS Engineer
BLE
Firmware Engineer iOS Engineer
Hardware Projects
I’ve worked on
as an iOS engineer
Wheelchair ‘WHILL’
Wheelchair ‘WHILL’
Wearable Walkie-Talkie
‘BONX’
Wearable Walkie-Talkie
‘BONX’
Wearable Walkie-Talkie
‘BONX’
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Group conversation system with VoIP
Group conversation system with VoIP
- Detects the human voice
Group conversation system with VoIP
- Detects the human voice
- Cuts out all background noise
Group conversation system with VoIP
- Detects the human voice
- Cuts out all background noise
→ Can be used even in areas with poor coverage!
BLE for BONX
BLE for BONX
BLE for BONX
BLE for BONX
IoT for Cars ‘SmartDrive’
Printable Open-Source Humanoid “PLEN2”
Music for the Deaf
Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
Music for the Deaf
Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
iPhone
Music for the Deaf
Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
Electronic Stimulation DeviceiPhone
Music for the Deaf
Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
Commands
Electronic Stimulation DeviceiPhone
Music for the Deaf
Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
Practical Core Bluetooth
Defining GATT
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send sensor data
Foo Service
Sensor Data Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Bar Service
xx Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: acc x, acc y, acc z, gyro x, gyro y, gyro z (2bytes for each)
xx Characteristic
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
Button interactions
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
Button interactions
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
Button interactions
GATT to send button interactions
Foo Service
Button Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Notify
Value: 0x01 or 0x00
Button interactions
0x01: Pushed
0x00: Released
GATT for remote control
Foo Service
Remote Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: Horizontal (-100 ~ 100), Vertical (-100 ~ 100)
GATT for remote control
Foo Service
Remote Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: Horizontal (-100 ~ 100), Vertical (-100 ~ 100)
GATT for remote control
Foo Service
Remote Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: Horizontal (-100 ~ 100), Vertical (-100 ~ 100)
values
GATT for remote control
Foo Service
Remote Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: Horizontal (-100 ~ 100), Vertical (-100 ~ 100)
values
GATT for remote control
Foo Service
Remote Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: Horizontal (-100 ~ 100), Vertical (-100 ~ 100)
values
GATT for generic commands
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
4 Commands:
- Change the pulse frequency
- Change the electric current
- Right channels on/off
- Left channels on/off
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
4 Commands:
- Change the pulse frequency
- Change the electric current
- Right channels on/off
- Left channels on/off
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
High-order 2 bits
- 00: Change the pulse frequency
- 01: Change the electric current
- 10: Left channels on/off
- 11: Right channels on/off
GATT for generic commands
Electronic Stimulation Control Characteristic
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Properties: Write
Value: 1 byte
High-order 2 bits
- 00: Change the pulse frequency
- 01: Change the electric current
- 10: Left channels on/off
- 11: Right channels on/off
How to define GATT
How to define GATT
1. Create UUID for the service & characteristic
How to define GATT
1. Create UUID for the service & characteristic
$ uuidgen
CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
How to define GATT
1. Create UUID for the service & characteristic
2. Define the properties (Read, Notify, Write, etc.)
$ uuidgen
CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
How to define GATT
1. Create UUID for the service & characteristic
2. Define the properties (Read, Notify, Write, etc.)
Peripheral → Central: Notify 

Central → Peripheral: Write
$ uuidgen
CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
How to define GATT
1. Create UUID for the service & characteristic
2. Define the properties (Read, Notify, Write, etc.)
Peripheral → Central: Notify 

Central → Peripheral: Write
3. Define the value format
$ uuidgen
CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
How to define GATT
1. Create UUID for the service & characteristic
2. Define the properties (Read, Notify, Write, etc.)
Peripheral → Central: Notify 

Central → Peripheral: Write
3. Define the value format
Usually limited to 20 bytes
$ uuidgen
CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
Reference:
GATT profiles by Bluetooth SIG
Defining background
behaviors
Background behaviors on iOS
• Very limited
- Listening to music
- Getting location data
- Downloading data
Imagine
If BLE didn’t work in the
background…
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
You would have to always keep the app
in the foreground, while snowboarding!
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
You would have to launch the app
whenever you go driving!
What functions can be used
in the background?
What functions can be used
in the background?
• Scanning peripherals
What functions can be used
in the background?
• Scanning peripherals
• Connecting with peripherals
What functions can be used
in the background?
• Scanning peripherals
• Connecting with peripherals
• Reading characteristics’ value
What functions can be used
in the background?
• Scanning peripherals
• Connecting with peripherals
• Reading characteristics’ value
• Writing characteristics’ value
What functions can be used
in the background?
• Scanning peripherals
• Connecting with peripherals
• Reading characteristics’ value
• Writing characteristics’ value
• Receiving notifications
What functions can be used
in the background?
• Scanning peripherals
• Connecting with peripherals
• Reading characteristics’ value
• Writing characteristics’ value
• Receiving notifications
Almost all functions can be used
even in the background!
How to support
background mode
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Just check this box!
Limitations
Limitations
• Longer intervals for scanning
Limitations
• Longer intervals for scanning
• Must explicitly specify one or more services to scan
Limitations
• Longer intervals for scanning
• Must explicitly specify one or more services to scan
• CBCentralManagerOptionShowPowerAlertKey option is
ignored
Limitations
• Longer intervals for scanning
• Must explicitly specify one or more services to scan
• CBCentralManagerOptionShowPowerAlertKey option is
ignored
Resources
- Core Bluetooth Programming Guide
- Core Bluetooth Framework Reference (also in headers)
If the app in the background
is killed by the system…
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
State Preservation and Restoration
State Preservation and Restoration
The system takes over the BLE tasks
even after the app is killed.
State Preservation and Restoration
The system takes over the BLE tasks
even after the app is killed.
- Preserves the state of the app’s central managers and
continues the BLE tasks on their behalf.
State Preservation and Restoration
The system takes over the BLE tasks
even after the app is killed.
- Preserves the state of the app’s central managers and
continues the BLE tasks on their behalf.
- Relaunches the app into the background and calls the
corresponding delegate method.
State Preservation and Restoration
The system takes over the BLE tasks
even after the app is killed.
- Preserves the state of the app’s central managers and
continues the BLE tasks on their behalf.
- Relaunches the app into the background and calls the
corresponding delegate method.
→ The app can handle BLE events!
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
• The app is killed by the system
• The app is killed by the system
• The user pushes the button on the
peripheral device
• The app is killed by the system
• The user pushes the button on the
peripheral device
• The system receives the notification
• The app is killed by the system
• The user pushes the button on the
peripheral device
• The system receives the notification
• The app is relaunched in the BG and the
delegate method is called.
func peripheral(peripheral: CBPeripheral,
didUpdateValueForCharacteristic characteristic: CBCharacteristic,
error: NSError?)
{
print(“Received the characteristic data!”)
}
• The app is killed by the system
• The user pushes the button on the
peripheral device
• The system receives the notification
• The app is relaunched in the BG and the
delegate method is called.
func peripheral(peripheral: CBPeripheral,
didUpdateValueForCharacteristic characteristic: CBCharacteristic,
error: NSError?)
{
print(“Received the characteristic data!”)
}
• The app is killed by the system
• The user pushes the button on the
peripheral device
• The system receives the notification
• The app is relaunched in the BG and the
delegate method is called.
The app can process the button interaction!
Implementation
Implementation
• Add an option when initializing the
CBCentralManager object.
let options = [
CBCentralManagerOptionRestoreIdentifierKey: "somekey"
]
centralManager = CBCentralManager(
delegate: self,
queue: queue,
options: options)
Implementation
• Implement the delegate method which is called when
the app is restored.
func centralManager(central: CBCentralManager,
willRestoreState dict: [String : AnyObject])
{
print("Restored")
}
Testing the restoration
Testing the restoration
• Kill the app as if it was killed by the iOS
kill(getpid(), SIGKILL);
How to test
without HW prototypes
Did the HW prototypes exist when develop the apps?
Projects HW prototypes existed?
Moff YES
WHILL NO
BONX NO
SmartDrive YES
PLEN2 NO
Music for the Deaf NO
Development Kit
Development Kit
BLE Module
Development Kit
BLE Module
Display
Development Kit
BLE Module
Display
USB interface
Development Kit
BLE Module
Display
USB interface
Battery box
Development Kit
Can start development without
creating a circuit ourselves
BLE Module
Display
USB interface
Battery box
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Development Kit
Development Kit App
Development Kit App
BLE
Horizontal (-100~100) / Vertical (-100~100)
Development Kit App
BLE
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Emulator App
Emulator App
• Develop another iOS app as the
alternative to the peripheral
device
Emulator App
• Develop another iOS app as the
alternative to the peripheral
device
• Use CBPeripheralManager
Emulator App
• Develop another iOS app as the
alternative to the peripheral
device
• Use CBPeripheralManager
• Easier for iOS engineers
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
=
Multi-Function Control
• Single Tap
• Double Tap
• Long Press
• Very Long Press
=
Troubleshooting
Can’t find the peripheral
Scan
?
Can’t connect
Find
Can’t connect
Connect
×
• Connection dropped
• Connection dropped
• Can’t discover services or characteristics
• Connection dropped
• Can’t discover services or characteristics
• Fail to write
• Connection dropped
• Can’t discover services or characteristics
• Fail to write
• Incorrect characteristic values
• Connection dropped
• Can’t discover services or characteristics
• Fail to write
• Incorrect characteristic values
• Incorrect behaviors in the background
• Connection dropped
• Can’t discover services or characteristics
• Fail to write
• Incorrect characteristic values
• Incorrect behaviors in the background
• etc…
Identify which side
the problem is on
Is the problem on the central side or on the peripheral side?
→ Compare with another iOS app like ‘LightBlue’
Can’t find the peripheral
• Scanning, but can’t find the peripheral device
Can’t find the peripheral
• Scanning, but can’t find the peripheral device
Scan
Can’t find the peripheral
• Scanning, but can’t find the peripheral device
Scan
but ‘didDiscover’
method isn’t called
Can’t find the peripheral
• Scan with another iOS app
Scan
Can’t find the peripheral
• Scan with another iOS app
Scan
Discovered peripherals
Can’t connect, etc.
Connect
Can’t connect, etc.
Connect
Services & Characteristics
Other debugging tools
Bluetooth Explorer
macOS app made by Apple
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Low Energy Devices
Low Energy Devices
Scan, Connect
Low Energy Devices
Scan, Connect
Details of services and characteristics
Low Energy Devices
Scan, Connect
Details of services and characteristics
Write, Read, Subscribe
func centralManager(
central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(advertisementData)
}
func centralManager(
central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(advertisementData)
}
Filtered by iOS!
func centralManager(
central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(advertisementData)
}
Filtered by iOS!
→ Can’t see all of the advertisement data
func centralManager(
central: CBCentralManager,
didDiscoverPeripheral peripheral: CBPeripheral,
advertisementData: [String : AnyObject],
RSSI: NSNumber!)
{
print(advertisementData)
}
Filtered by iOS!
→ Can’t see all of the advertisement data
e.g. Can’t see the ‘Manufacture Data’ field of iBeacon
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Not filtered →Can see the ‘Manufacture Data’ field of iBeacon
Packet Logger
macOS app made by Apple
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
How to get
How to get
Download ‘Hardware IO Tools for Xcode’
How to get
Download ‘Hardware IO Tools for Xcode’
How to get
Download ‘Hardware IO Tools for Xcode’
How to get
Download ‘Hardware IO Tools for Xcode’
App Review
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
MSRP $13,995
Costing too much
Not enough devices when submitting
Videos for review
Videos for review
• Show how the app works with the peripheral device
Videos for review
• Show how the app works with the peripheral device
• Not need to be cool!
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
• Shoot with iPhone
• Shoot with iPhone
• Edit with iMovie
Recap
Recap
• What is Bluetooth Low Energy?
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
- Defining GATT
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
- Defining GATT
- Defining background behaviors
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
- Defining GATT
- Defining background behaviors
- Testing without HW prototypes
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
- Defining GATT
- Defining background behaviors
- Testing without HW prototypes
- Troubleshooting
Recap
• What is Bluetooth Low Energy?
• Basics of Core Bluetooth with an actual product
• Practical Core Bluetooth with specific examples
- Defining GATT
- Defining background behaviors
- Testing without HW prototypes
- Troubleshooting
- App Review
Core Bluetooth
in iOS 10
Nothing special
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
CBManager
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
func centralManagerDidUpdateState(_ central: CBCentralManager) {
print("state: (central.state)")
}
Initializer without arguments
private var centralManager: CBCentralManager!
override func viewDidLoad() {
super.viewDidLoad()
centralManager = CBCentralManager(delegate: self, queue: nil)
}
From
private let centralManager = CBCentralManager()
override func viewDidLoad() {
super.viewDidLoad()
centralManager.delegate = self
}
private var centralManager: CBCentralManager!
override func viewDidLoad() {
super.viewDidLoad()
centralManager = CBCentralManager(delegate: self, queue: nil)
}
From
To
Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016
Thank you!
Shuichi Tsutsumi - iOS Freelancer
• Twitter: @shu223
• GitHub: shu223
• Blog: https://medium.com/@shu223/
• Email: shuichi0526@gmail.com

More Related Content

Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016