SlideShare a Scribd company logo
1 of 259
Download to read offline
Practical Core Bluetooth
in IoT & Wearable projects
Shuichi Tsutsumi @shu223
AltConf 2016 - San Francisco
iOS-10-Sampler
https://github.com/shu223
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
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’
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…
You would have to always keep the app
in the foreground, while snowboarding!
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
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…
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!
• 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
Development Kit
Development Kit App
Development Kit App
BLE
Horizontal (-100~100) / Vertical (-100~100)
Development Kit App
BLE
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
=
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
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
Not filtered →Can see the ‘Manufacture Data’ field of iBeacon
Packet Logger
macOS app made by Apple
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
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!
• 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
CBManager
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
Thank you!
Shuichi Tsutsumi - iOS Freelancer
• Twitter: @shu223
• GitHub: shu223
• Blog: https://medium.com/@shu223/
• Email: shuichi0526@gmail.com

More Related Content

Viewers also liked

How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!
How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!
How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!Evan Stone
 
How to teach grammar from examples ( Inductive .Approach ).
How to teach grammar from examples ( Inductive .Approach ).How to teach grammar from examples ( Inductive .Approach ).
How to teach grammar from examples ( Inductive .Approach ).Shalem Limón
 
How to teach grammar (Inductive teaching)
How to teach grammar (Inductive teaching)How to teach grammar (Inductive teaching)
How to teach grammar (Inductive teaching)Saul Hernandez
 
Linkedin & OAuth
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuthUmang Goyal
 
Basics of English Grammar
Basics of English GrammarBasics of English Grammar
Basics of English GrammarRahul Jose
 
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...Amélie Gyrard
 
LinkedIn OAuth: Zero To Hero
LinkedIn OAuth: Zero To HeroLinkedIn OAuth: Zero To Hero
LinkedIn OAuth: Zero To HeroTaylor Singletary
 
The Greater Dublin Area (GDA region)
The Greater Dublin Area (GDA region)The Greater Dublin Area (GDA region)
The Greater Dublin Area (GDA region)Aisling O Connor
 
Tech Comms Text Nf
Tech Comms Text NfTech Comms Text Nf
Tech Comms Text NfJohn_Wilson
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsA B Shinde
 
IEEE IOT PROJECT TITLE 2015-16
IEEE IOT PROJECT TITLE 2015-16IEEE IOT PROJECT TITLE 2015-16
IEEE IOT PROJECT TITLE 2015-16Spiro Vellore
 
API提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpAPI提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpTatsuo Kudo
 
12 verb tenses in English grammar with examples 12 English tenses PDF
12 verb tenses in English grammar with examples 12 English tenses PDF12 verb tenses in English grammar with examples 12 English tenses PDF
12 verb tenses in English grammar with examples 12 English tenses PDFlearningenglishvocabularygrammar.com
 
Grammar Translation Method
Grammar Translation MethodGrammar Translation Method
Grammar Translation MethodMarisol Smith
 
Basics of English Grammar
Basics of English GrammarBasics of English Grammar
Basics of English GrammarKarina Salcedo
 

Viewers also liked (20)

How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!
How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!
How Hot is My Coffee? Sensors, Core Bluetooth, and Swift!
 
Hassle-free IoT projects with DeviceHive — Artyom Sorokin (Tech Stage)
Hassle-free IoT projects with DeviceHive — Artyom Sorokin (Tech Stage)Hassle-free IoT projects with DeviceHive — Artyom Sorokin (Tech Stage)
Hassle-free IoT projects with DeviceHive — Artyom Sorokin (Tech Stage)
 
How to teach grammar from examples ( Inductive .Approach ).
How to teach grammar from examples ( Inductive .Approach ).How to teach grammar from examples ( Inductive .Approach ).
How to teach grammar from examples ( Inductive .Approach ).
 
How to teach grammar (Inductive teaching)
How to teach grammar (Inductive teaching)How to teach grammar (Inductive teaching)
How to teach grammar (Inductive teaching)
 
OAuth2 and LinkedIn
OAuth2 and LinkedInOAuth2 and LinkedIn
OAuth2 and LinkedIn
 
Linkedin & OAuth
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuth
 
Basics of English Grammar
Basics of English GrammarBasics of English Grammar
Basics of English Grammar
 
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...
Assisting IoT Projects and Developers in Designing Interoperable Semantic Web...
 
LinkedIn OAuth: Zero To Hero
LinkedIn OAuth: Zero To HeroLinkedIn OAuth: Zero To Hero
LinkedIn OAuth: Zero To Hero
 
The Greater Dublin Area (GDA region)
The Greater Dublin Area (GDA region)The Greater Dublin Area (GDA region)
The Greater Dublin Area (GDA region)
 
Tech Comms Text Nf
Tech Comms Text NfTech Comms Text Nf
Tech Comms Text Nf
 
Grammar: Use of Hyphens In Medical Writing
Grammar: Use of Hyphens In Medical WritingGrammar: Use of Hyphens In Medical Writing
Grammar: Use of Hyphens In Medical Writing
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC Tools
 
IEEE IOT PROJECT TITLE 2015-16
IEEE IOT PROJECT TITLE 2015-16IEEE IOT PROJECT TITLE 2015-16
IEEE IOT PROJECT TITLE 2015-16
 
Slideshare Doc
Slideshare DocSlideshare Doc
Slideshare Doc
 
API提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpAPI提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijp
 
Client-Side Deep Learning
Client-Side Deep LearningClient-Side Deep Learning
Client-Side Deep Learning
 
12 verb tenses in English grammar with examples 12 English tenses PDF
12 verb tenses in English grammar with examples 12 English tenses PDF12 verb tenses in English grammar with examples 12 English tenses PDF
12 verb tenses in English grammar with examples 12 English tenses PDF
 
Grammar Translation Method
Grammar Translation MethodGrammar Translation Method
Grammar Translation Method
 
Basics of English Grammar
Basics of English GrammarBasics of English Grammar
Basics of English Grammar
 

Similar to Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016

PicoScenes Tutorial @ CPS-IOT Week 2022
PicoScenes Tutorial @ CPS-IOT Week 2022PicoScenes Tutorial @ CPS-IOT Week 2022
PicoScenes Tutorial @ CPS-IOT Week 2022Zhiping Jiang
 
DEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the aptDEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the aptFelipe Prado
 
Core bluetooth @ cocohead
Core bluetooth @ cocoheadCore bluetooth @ cocohead
Core bluetooth @ cocoheadKai-Yuan Cheng
 
Ble boise codecamp
Ble boise codecampBle boise codecamp
Ble boise codecampChip Keyes
 
Hack your business android+beacons+big data
Hack your business  android+beacons+big dataHack your business  android+beacons+big data
Hack your business android+beacons+big dataTushar Choudhary
 
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...Maksim Shudrak
 
Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2Jeff Sipko
 
Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?Nelson Brito
 
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suroDevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suroGaurav "GP" Pal
 
Kavya racharla ndh-naropanth_fin
Kavya racharla ndh-naropanth_finKavya racharla ndh-naropanth_fin
Kavya racharla ndh-naropanth_finPacSecJP
 
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...Pierluigi Casale
 
Controlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesControlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesKeerati Torach
 
Canopy unconference preso
Canopy unconference presoCanopy unconference preso
Canopy unconference presogregulator
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Daniel Luxemburg
 
Building the IOT Platform as a Service
Building the IOT Platform as a ServiceBuilding the IOT Platform as a Service
Building the IOT Platform as a ServiceJesus Rodriguez
 
Defcon 22-cesar-cerrudo-hacking-traffic-control-systems
Defcon 22-cesar-cerrudo-hacking-traffic-control-systemsDefcon 22-cesar-cerrudo-hacking-traffic-control-systems
Defcon 22-cesar-cerrudo-hacking-traffic-control-systemsPriyanka Aash
 
Lukas Apa - Hacking Robots Before SkyNet
Lukas Apa - Hacking Robots Before SkyNet Lukas Apa - Hacking Robots Before SkyNet
Lukas Apa - Hacking Robots Before SkyNet NoNameCon
 

Similar to Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016 (20)

PicoScenes Tutorial @ CPS-IOT Week 2022
PicoScenes Tutorial @ CPS-IOT Week 2022PicoScenes Tutorial @ CPS-IOT Week 2022
PicoScenes Tutorial @ CPS-IOT Week 2022
 
DEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the aptDEFCON 23 - Ian Latter - remote access the apt
DEFCON 23 - Ian Latter - remote access the apt
 
Core bluetooth @ cocohead
Core bluetooth @ cocoheadCore bluetooth @ cocohead
Core bluetooth @ cocohead
 
JAM805 - Beyond the Device
JAM805 -  Beyond the DeviceJAM805 -  Beyond the Device
JAM805 - Beyond the Device
 
Ble boise codecamp
Ble boise codecampBle boise codecamp
Ble boise codecamp
 
Hack your business android+beacons+big data
Hack your business  android+beacons+big dataHack your business  android+beacons+big data
Hack your business android+beacons+big data
 
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
Fuzzing malware for fun & profit. Applying Coverage-Guided Fuzzing to Find Bu...
 
Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2
 
Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?
 
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suroDevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
 
Kavya racharla ndh-naropanth_fin
Kavya racharla ndh-naropanth_finKavya racharla ndh-naropanth_fin
Kavya racharla ndh-naropanth_fin
 
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...
BeaStreamer: a new platform for Multi-Sensors Data Acquisition in Wearable Co...
 
Controlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesControlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy Devices
 
Canopy unconference preso
Canopy unconference presoCanopy unconference preso
Canopy unconference preso
 
Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)Getting Started with iBeacons (Designers of Things 2014)
Getting Started with iBeacons (Designers of Things 2014)
 
Bluetooth [in]security
Bluetooth [in]securityBluetooth [in]security
Bluetooth [in]security
 
Bluetooth insecurity
Bluetooth insecurity Bluetooth insecurity
Bluetooth insecurity
 
Building the IOT Platform as a Service
Building the IOT Platform as a ServiceBuilding the IOT Platform as a Service
Building the IOT Platform as a Service
 
Defcon 22-cesar-cerrudo-hacking-traffic-control-systems
Defcon 22-cesar-cerrudo-hacking-traffic-control-systemsDefcon 22-cesar-cerrudo-hacking-traffic-control-systems
Defcon 22-cesar-cerrudo-hacking-traffic-control-systems
 
Lukas Apa - Hacking Robots Before SkyNet
Lukas Apa - Hacking Robots Before SkyNet Lukas Apa - Hacking Robots Before SkyNet
Lukas Apa - Hacking Robots Before SkyNet
 

More from Shuichi Tsutsumi

Core MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyoCore MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyoShuichi Tsutsumi
 
エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略Shuichi Tsutsumi
 
UIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconfUIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconfShuichi Tsutsumi
 
UIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfUIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfShuichi Tsutsumi
 
飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDCShuichi Tsutsumi
 
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDevShuichi Tsutsumi
 
オープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyoオープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyoShuichi Tsutsumi
 
Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9Shuichi Tsutsumi
 
Core Graphics on watchOS 2
Core Graphics on watchOS 2Core Graphics on watchOS 2
Core Graphics on watchOS 2Shuichi Tsutsumi
 
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜Shuichi Tsutsumi
 
iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編Shuichi Tsutsumi
 
UI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つUI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つShuichi Tsutsumi
 
watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話Shuichi Tsutsumi
 
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜Shuichi Tsutsumi
 
WatchKitを実際にさわってみてわかったこと
WatchKitを実際にさわってみてわかったことWatchKitを実際にさわってみてわかったこと
WatchKitを実際にさわってみてわかったことShuichi Tsutsumi
 
おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」Shuichi Tsutsumi
 
iOSエンジニア in ハードウェア・プロジェクト
iOSエンジニア in ハードウェア・プロジェクトiOSエンジニア in ハードウェア・プロジェクト
iOSエンジニア in ハードウェア・プロジェクトShuichi Tsutsumi
 

More from Shuichi Tsutsumi (20)

Core MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyoCore MLのアップデートを3倍楽しむ方法 #wwdctokyo
Core MLのアップデートを3倍楽しむ方法 #wwdctokyo
 
エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略エンジニアという仕事を楽しみ続けるためのキャリア戦略
エンジニアという仕事を楽しみ続けるためのキャリア戦略
 
Depth in Depth #iOSDC
Depth in Depth #iOSDCDepth in Depth #iOSDC
Depth in Depth #iOSDC
 
UIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconfUIImageView vs Metal [日本語版] #tryswiftconf
UIImageView vs Metal [日本語版] #tryswiftconf
 
UIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconfUIImageView vs Metal #tryswiftconf
UIImageView vs Metal #tryswiftconf
 
飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC飛び道具ではないMetal #iOSDC
飛び道具ではないMetal #iOSDC
 
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDev
 
オープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyoオープンソースエコシステム #demodaytokyo
オープンソースエコシステム #demodaytokyo
 
Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9Core Image Tips & Tricks in iOS 9
Core Image Tips & Tricks in iOS 9
 
Core Graphics on watchOS 2
Core Graphics on watchOS 2Core Graphics on watchOS 2
Core Graphics on watchOS 2
 
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
Audio Unit Extensions 〜オーディオエフェクトのアプリ間共有〜
 
iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編iOS 9 の新機能 Core Image 編
iOS 9 の新機能 Core Image 編
 
UI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つUI/UX に影響の大きい watchOS 2 の新機能 3つ
UI/UX に影響の大きい watchOS 2 の新機能 3つ
 
watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話watchOS 2 新機能の細かい話
watchOS 2 新機能の細かい話
 
Apple Watch 間通信
Apple Watch 間通信Apple Watch 間通信
Apple Watch 間通信
 
OpenCV 3.0 on iOS
OpenCV 3.0 on iOSOpenCV 3.0 on iOS
OpenCV 3.0 on iOS
 
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
殺しても死なないアプリ 〜Core Bluetooth の「状態の保存と復元」機能〜
 
WatchKitを実際にさわってみてわかったこと
WatchKitを実際にさわってみてわかったことWatchKitを実際にさわってみてわかったこと
WatchKitを実際にさわってみてわかったこと
 
おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」
 
iOSエンジニア in ハードウェア・プロジェクト
iOSエンジニア in ハードウェア・プロジェクトiOSエンジニア in ハードウェア・プロジェクト
iOSエンジニア in ハードウェア・プロジェクト
 

Recently uploaded

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Recently uploaded (20)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Practical Core Bluetooth in IoT & Wearable projects @ AltConf 2016

  • 1. Practical Core Bluetooth in IoT & Wearable projects Shuichi Tsutsumi @shu223 AltConf 2016 - San Francisco
  • 2.
  • 3.
  • 4.
  • 6.
  • 7. Overview • Basics of Core Bluetooth • Practical Core Bluetooth Based on my experience!
  • 10. Bluetooth Low Energy (BLE) • Wireless technology
  • 11. Bluetooth Low Energy (BLE) • Wireless technology - no network infrastructure required
  • 12. Bluetooth Low Energy (BLE) • Wireless technology - no network infrastructure required Wi-Fi
  • 13. Bluetooth Low Energy (BLE) • Wireless technology - no network infrastructure required BLE
  • 15. • Low energy • NOT compatible with Classic BT
  • 16. • Low energy • NOT compatible with Classic BT • Uses 2.4 GHz radio frequencies
  • 17. • Low energy • NOT compatible with Classic BT • Uses 2.4 GHz radio frequencies • Marketed by the Bluetooth SIG
  • 18. • Low energy • NOT compatible with Classic BT • Uses 2.4 GHz radio frequencies • Marketed by the Bluetooth SIG • etc…
  • 19. • Low energy • NOT compatible with Classic BT • Uses 2.4 GHz radio frequencies • Marketed by the Bluetooth SIG • etc…
  • 20. The most important thing for iOS developers
  • 21. The API ‘Core Bluetooth’ is open for developers
  • 22. The API ‘Core Bluetooth’ is open for developers • API for Classic BT is NOT open. - Requires MFi certification.
  • 23. BLE is almost the ONLY way to enable iOS apps to communicate with external hardware without infrastructure or MFi.
  • 25.
  • 27. Moff Band Moff App BLE Connection
  • 28. Moff Band Moff App BLE Connection Sensors - Gyroscope - Accelerometer
  • 29. Moff Band Moff App Sensor Data BLE Connection Sensors - Gyroscope - Accelerometer
  • 30. Moff Band Moff App Sensor Data BLE Connection Sensors - Gyroscope - Accelerometer Analyze sensor data
  • 31. Moff Band Moff App Sensor Data BLE Connection Sensors - Gyroscope - Accelerometer Analyze sensor data Recognize - Gesture - Posture
  • 32. Moff Band Moff App Sensor Data BLE Connection Sensors - Gyroscope - Accelerometer Analyze sensor data Recognize - Gesture - Posture Play sounds
  • 33. Sensor Data BLE Connection How is sensor data sent with Core Bluetooth?
  • 35. Step 1. Scan: Search for nearby BLE devices
  • 36. Step 1. Scan: Search for nearby BLE devices
  • 37. Step 1. Scan Advertise : Search for nearby BLE devices
  • 38. Scan Step 1. Scan Advertise : Search for nearby BLE devices
  • 39. Scan Step 1. Scan Advertise : Search for nearby BLE devices centralManager.scanForPeripheralsWithServices(nil, options: nil)
  • 40. Scan Step 1. Scan Advertise Discover : Search for nearby BLE devices
  • 41. 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!”) }
  • 42. 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
  • 43. 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
  • 47. Connect Step 2. Connect centralManager.connectPeripheral(peripheral, options: nil) func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) { print(“Connected!”) }
  • 49. Step 3. Subscribe: Ready to receive data
  • 50. Step 3. Subscribe: Ready to receive data GATT = Generic Attribute Profile
  • 51. Moff Service xx Service Step 3. Subscribe: Ready to receive data GATT = Generic Attribute Profile
  • 52. Moff Service xx Service Button Characteristic xx Characteristic Sensor Characteristic Step 3. Subscribe: Ready to receive data GATT = Generic Attribute Profile
  • 53. 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
  • 54. 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)
  • 55. Step 4. Notify Moff Service Sensor Characteristic xxxx Characteristic
  • 56. Step 4. Notify Moff Service Sensor Characteristic xxxx Characteristic Update the value
  • 57. Step 4. Notify Notify subscribers Moff Service Sensor Characteristic xxxx Characteristic Update the value
  • 58. 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!”) }
  • 59. 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!”) }
  • 61. Hardware Side? I’m sorry, I don’t know…
  • 62. BLE
  • 67. Hardware Projects I’ve worked on as an iOS engineer
  • 73.
  • 75. Group conversation system with VoIP - Detects the human voice
  • 76. Group conversation system with VoIP - Detects the human voice - Cuts out all background noise
  • 77. Group conversation system with VoIP - Detects the human voice - Cuts out all background noise → Can be used even in areas with poor coverage!
  • 82. IoT for Cars ‘SmartDrive’
  • 84. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
  • 85. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY iPhone
  • 86. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY Electronic Stimulation DeviceiPhone
  • 87. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY Commands Electronic Stimulation DeviceiPhone
  • 88. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
  • 91. 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
  • 92. 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
  • 93. 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
  • 94. 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
  • 95. 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
  • 96. 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
  • 97. 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
  • 98. 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
  • 99. 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
  • 100. 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
  • 101. 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
  • 102. 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
  • 103. 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
  • 104. 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)
  • 105. 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)
  • 106. 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
  • 107. 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
  • 108. 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
  • 109. GATT for generic commands
  • 110. GATT for generic commands Electronic Stimulation Control Characteristic UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Properties: Write Value: 1 byte
  • 111. GATT for generic commands Electronic Stimulation Control Characteristic UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Properties: Write Value: 1 byte
  • 112. 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
  • 113. 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
  • 114. 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
  • 115. 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
  • 116. How to define GATT
  • 117. How to define GATT 1. Create UUID for the service & characteristic
  • 118. How to define GATT 1. Create UUID for the service & characteristic $ uuidgen CEEA31BC-BEAC-4A78-B7ED-FC96B6254D4C
  • 119. 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
  • 120. 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
  • 121. 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
  • 122. 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
  • 123. Reference: GATT profiles by Bluetooth SIG
  • 125. Background behaviors on iOS • Very limited - Listening to music - Getting location data - Downloading data
  • 127. If BLE didn’t work in the background…
  • 128.
  • 129. You would have to always keep the app in the foreground, while snowboarding!
  • 130.
  • 131. You would have to launch the app whenever you go driving!
  • 132. What functions can be used in the background?
  • 133. What functions can be used in the background? • Scanning peripherals
  • 134. What functions can be used in the background? • Scanning peripherals • Connecting with peripherals
  • 135. What functions can be used in the background? • Scanning peripherals • Connecting with peripherals • Reading characteristics’ value
  • 136. What functions can be used in the background? • Scanning peripherals • Connecting with peripherals • Reading characteristics’ value • Writing characteristics’ value
  • 137. What functions can be used in the background? • Scanning peripherals • Connecting with peripherals • Reading characteristics’ value • Writing characteristics’ value • Receiving notifications
  • 138. 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!
  • 140.
  • 144. Limitations • Longer intervals for scanning • Must explicitly specify one or more services to scan
  • 145. Limitations • Longer intervals for scanning • Must explicitly specify one or more services to scan • CBCentralManagerOptionShowPowerAlertKey option is ignored
  • 146. 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)
  • 147. If the app in the background is killed by the system…
  • 148.
  • 149. State Preservation and Restoration
  • 150. State Preservation and Restoration The system takes over the BLE tasks even after the app is killed.
  • 151. 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.
  • 152. 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.
  • 153. 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!
  • 154.
  • 155. • The app is killed by the system
  • 156. • The app is killed by the system • The user pushes the button on the peripheral device
  • 157. • The app is killed by the system • The user pushes the button on the peripheral device • The system receives the notification
  • 158. • 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.
  • 159. 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.
  • 160. 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!
  • 162. Implementation • Add an option when initializing the CBCentralManager object. let options = [ CBCentralManagerOptionRestoreIdentifierKey: "somekey" ] centralManager = CBCentralManager( delegate: self, queue: queue, options: options)
  • 163. Implementation • Implement the delegate method which is called when the app is restored. func centralManager(central: CBCentralManager, willRestoreState dict: [String : AnyObject]) { print("Restored") }
  • 165. Testing the restoration • Kill the app as if it was killed by the iOS kill(getpid(), SIGKILL);
  • 166. How to test without HW prototypes
  • 167. 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
  • 172. Development Kit BLE Module Display USB interface Battery box
  • 173. Development Kit Can start development without creating a circuit ourselves BLE Module Display USB interface Battery box
  • 174.
  • 178. Horizontal (-100~100) / Vertical (-100~100) Development Kit App BLE
  • 179.
  • 181. Emulator App • Develop another iOS app as the alternative to the peripheral device
  • 182. Emulator App • Develop another iOS app as the alternative to the peripheral device • Use CBPeripheralManager
  • 183. Emulator App • Develop another iOS app as the alternative to the peripheral device • Use CBPeripheralManager • Easier for iOS engineers
  • 184.
  • 185.
  • 186.
  • 187. =
  • 188. Multi-Function Control • Single Tap • Double Tap • Long Press • Very Long Press =
  • 190. Can’t find the peripheral Scan ?
  • 194. • Connection dropped • Can’t discover services or characteristics
  • 195. • Connection dropped • Can’t discover services or characteristics • Fail to write
  • 196. • Connection dropped • Can’t discover services or characteristics • Fail to write • Incorrect characteristic values
  • 197. • Connection dropped • Can’t discover services or characteristics • Fail to write • Incorrect characteristic values • Incorrect behaviors in the background
  • 198. • Connection dropped • Can’t discover services or characteristics • Fail to write • Incorrect characteristic values • Incorrect behaviors in the background • etc…
  • 199. 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’
  • 200. Can’t find the peripheral • Scanning, but can’t find the peripheral device
  • 201. Can’t find the peripheral • Scanning, but can’t find the peripheral device Scan
  • 202. Can’t find the peripheral • Scanning, but can’t find the peripheral device Scan but ‘didDiscover’ method isn’t called
  • 203. Can’t find the peripheral • Scan with another iOS app Scan
  • 204. Can’t find the peripheral • Scan with another iOS app Scan Discovered peripherals
  • 209.
  • 212. Low Energy Devices Scan, Connect Details of services and characteristics
  • 213. Low Energy Devices Scan, Connect Details of services and characteristics Write, Read, Subscribe
  • 214. func centralManager( central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber!) { print(advertisementData) }
  • 215. func centralManager( central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber!) { print(advertisementData) } Filtered by iOS!
  • 216. 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
  • 217. 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
  • 218.
  • 219. Not filtered →Can see the ‘Manufacture Data’ field of iBeacon
  • 220. Packet Logger macOS app made by Apple
  • 221.
  • 222.
  • 224. How to get Download ‘Hardware IO Tools for Xcode’
  • 225. How to get Download ‘Hardware IO Tools for Xcode’
  • 226. How to get Download ‘Hardware IO Tools for Xcode’
  • 227. How to get Download ‘Hardware IO Tools for Xcode’
  • 229.
  • 232. Not enough devices when submitting
  • 234. Videos for review • Show how the app works with the peripheral device
  • 235. Videos for review • Show how the app works with the peripheral device • Not need to be cool!
  • 236.
  • 237. • Shoot with iPhone
  • 238. • Shoot with iPhone • Edit with iMovie
  • 239. Recap
  • 240. Recap • What is Bluetooth Low Energy?
  • 241. Recap • What is Bluetooth Low Energy? • Basics of Core Bluetooth with an actual product
  • 242. Recap • What is Bluetooth Low Energy? • Basics of Core Bluetooth with an actual product • Practical Core Bluetooth with specific examples
  • 243. Recap • What is Bluetooth Low Energy? • Basics of Core Bluetooth with an actual product • Practical Core Bluetooth with specific examples - Defining GATT
  • 244. 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
  • 245. 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
  • 246. 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
  • 247. 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
  • 250.
  • 251.
  • 253.
  • 254. func centralManagerDidUpdateState(_ central: CBCentralManager) { print("state: (central.state)") }
  • 256. private var centralManager: CBCentralManager! override func viewDidLoad() { super.viewDidLoad() centralManager = CBCentralManager(delegate: self, queue: nil) } From
  • 257. 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
  • 258.
  • 259. Thank you! Shuichi Tsutsumi - iOS Freelancer • Twitter: @shu223 • GitHub: shu223 • Blog: https://medium.com/@shu223/ • Email: shuichi0526@gmail.com