SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Downloaden Sie, um offline zu lesen
Building iOS apps using
"Bluetooth Low Energy"
Shuichi Tsutsumi @shu223
July 25, 2016 Azrieli College, Jerusalem
July 26, 2016 Google Campus - Tel Aviv, Israel
July 27, 2016 SigmaLabs - Tel Aviv, Israel
July 28, 2016 Birzeit University - Palestine
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Overview
• Basics of BLE
• Practical Tips to build apps using BLE
with Japanse Products
Bluetooth Low Energy?
Bluetooth Low Energy (BLE)
• Wireless technology
- no network infrastructure required
Wi-FiBLE
• 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 iOS 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.
konashi moff band sensortag
External HW
• Simple
→ Small, Low cost & Long life
Smart Phone
• High Performance
• Internet Connection
• Easy to program
• etc…
Communicate
with BLE
Basics of BLE
Building iOS apps using "Bluetooth Low Energy"
(Demo)
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 to the app?
Scan
Step 1. Scan
Advertise
: Search for nearby BLE devices
centralManager.scanForPeripheralsWithServices(nil, options: nil)
Peripheral Central
Connect
Step 2. Connect
centralManager.connectPeripheral(peripheral, options: nil)
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
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?
I’m sorry, I don’t know…
BLE
Firmware Engineer iOS Engineer
Japanese
Hardware Products
I’ve worked on
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
Building iOS apps using "Bluetooth Low Energy"
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
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
Commands
Electronic Stimulation DeviceiPhone
Building iOS apps using "Bluetooth Low Energy"
Practical Tips
to build apps using BLE
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 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)
values
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 in iOS?
• Scanning peripherals
• Connecting with peripherals
• Reading characteristics’ value
• Writing characteristics’ value
• Receiving notifications
Almost all functions can be used
even in the background!
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…
Building iOS apps using "Bluetooth Low Energy"
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 callback method.
→ The app can handle BLE events!
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!
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
Can start development without
creating a circuit ourselves
BLE Module
Display
USB interface
Battery box
Horizontal (-100~100) / Vertical (-100~100)
Development Kit App
BLE
Building iOS apps using "Bluetooth Low Energy"
Emulator App
• Develop another iOS app as the
alternative to the peripheral
device
• Easier for iOS engineers
Multi-Function Control
• Single Tap
• Double Tap
• Long Press
• Very Long Press
=
App Review
Costing too much
MSRP $13,995
Not enough devices when submitting
Videos for review
• Show how the app works with the peripheral device
• Not need to be cool!
• Shoot with iPhone
• Edit with iMovie
Recap
• What is Bluetooth Low Energy?
• Basics of BLE with ‘Moff’.
• Japanese Hardware Products I’ve worked on
• Practical Tips to build apps using BLE
- Defining GATT
- Defining background behaviors
- Testing without HW prototypes
- App Review
Thank you!
Shuichi Tsutsumi - iOS Freelancer
• Twitter: @shu223
• GitHub: shu223
• Email: shuichi0526@gmail.com

Weitere ähnliche Inhalte

Ähnlich wie Building iOS apps using "Bluetooth Low Energy"

NUS-ISS Learning Day 2019-Building IoT solutions with the Pi
NUS-ISS Learning Day 2019-Building IoT solutions with the PiNUS-ISS Learning Day 2019-Building IoT solutions with the Pi
NUS-ISS Learning Day 2019-Building IoT solutions with the PiNUS-ISS
 
IRJET- A Raspberry Pi based Speaker Recognition System for Access Control
IRJET- A Raspberry Pi based Speaker Recognition System for Access ControlIRJET- A Raspberry Pi based Speaker Recognition System for Access Control
IRJET- A Raspberry Pi based Speaker Recognition System for Access ControlIRJET Journal
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumAnton Sirota
 
Manual POPP-HUB-V2 (POP-011801)
Manual POPP-HUB-V2 (POP-011801)Manual POPP-HUB-V2 (POP-011801)
Manual POPP-HUB-V2 (POP-011801)Domotica daVinci
 
Track 3 session 4 - st dev con 2016 - sensortile
Track 3   session 4 - st dev con 2016 - sensortileTrack 3   session 4 - st dev con 2016 - sensortile
Track 3 session 4 - st dev con 2016 - sensortileST_World
 
2015 01 24 Coding4Fun at Tajamar
2015 01 24 Coding4Fun at Tajamar2015 01 24 Coding4Fun at Tajamar
2015 01 24 Coding4Fun at TajamarBruno Capuano
 
Controlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesControlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesKeerati Torach
 
IRJET- Smart Mirror using Voice Interface
IRJET- Smart Mirror using Voice InterfaceIRJET- Smart Mirror using Voice Interface
IRJET- Smart Mirror using Voice InterfaceIRJET Journal
 
AT&T WNY Hackathon / Buffalo Open Data
AT&T WNY Hackathon / Buffalo Open DataAT&T WNY Hackathon / Buffalo Open Data
AT&T WNY Hackathon / Buffalo Open DataTim Poulsen
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"DataArt
 
Building and selecting hardware for connected devices, use case - BLE devices
Building and selecting hardware for connected devices, use case - BLE devicesBuilding and selecting hardware for connected devices, use case - BLE devices
Building and selecting hardware for connected devices, use case - BLE devicesPavel Stessin
 
THE THIRD EYE-Presentation
THE THIRD EYE-PresentationTHE THIRD EYE-Presentation
THE THIRD EYE-PresentationRomil Shah
 
Wecon HMI PI Series Q&A
Wecon HMI PI Series Q&AWecon HMI PI Series Q&A
Wecon HMI PI Series Q&ALily Zheng
 
Choosing_(and_Implem..
Choosing_(and_Implem..Choosing_(and_Implem..
Choosing_(and_Implem..webhostingguy
 

Ähnlich wie Building iOS apps using "Bluetooth Low Energy" (20)

NUS-ISS Learning Day 2019-Building IoT solutions with the Pi
NUS-ISS Learning Day 2019-Building IoT solutions with the PiNUS-ISS Learning Day 2019-Building IoT solutions with the Pi
NUS-ISS Learning Day 2019-Building IoT solutions with the Pi
 
IRJET- A Raspberry Pi based Speaker Recognition System for Access Control
IRJET- A Raspberry Pi based Speaker Recognition System for Access ControlIRJET- A Raspberry Pi based Speaker Recognition System for Access Control
IRJET- A Raspberry Pi based Speaker Recognition System for Access Control
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on Appium
 
Nt1320 Unit 6
Nt1320 Unit 6Nt1320 Unit 6
Nt1320 Unit 6
 
Manual POPP-HUB-V2 (POP-011801)
Manual POPP-HUB-V2 (POP-011801)Manual POPP-HUB-V2 (POP-011801)
Manual POPP-HUB-V2 (POP-011801)
 
Track 3 session 4 - st dev con 2016 - sensortile
Track 3   session 4 - st dev con 2016 - sensortileTrack 3   session 4 - st dev con 2016 - sensortile
Track 3 session 4 - st dev con 2016 - sensortile
 
2015 01 24 Coding4Fun at Tajamar
2015 01 24 Coding4Fun at Tajamar2015 01 24 Coding4Fun at Tajamar
2015 01 24 Coding4Fun at Tajamar
 
Controlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy DevicesControlling Bluetooth Low Energy Devices
Controlling Bluetooth Low Energy Devices
 
SensiBLE presentation
SensiBLE presentationSensiBLE presentation
SensiBLE presentation
 
JAM805 - Beyond the Device
JAM805 -  Beyond the DeviceJAM805 -  Beyond the Device
JAM805 - Beyond the Device
 
IRJET- Smart Mirror using Voice Interface
IRJET- Smart Mirror using Voice InterfaceIRJET- Smart Mirror using Voice Interface
IRJET- Smart Mirror using Voice Interface
 
Selfie booth ppt
Selfie booth pptSelfie booth ppt
Selfie booth ppt
 
AT&T WNY Hackathon / Buffalo Open Data
AT&T WNY Hackathon / Buffalo Open DataAT&T WNY Hackathon / Buffalo Open Data
AT&T WNY Hackathon / Buffalo Open Data
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
Comfort click bos
Comfort click bosComfort click bos
Comfort click bos
 
Building and selecting hardware for connected devices, use case - BLE devices
Building and selecting hardware for connected devices, use case - BLE devicesBuilding and selecting hardware for connected devices, use case - BLE devices
Building and selecting hardware for connected devices, use case - BLE devices
 
THE THIRD EYE-Presentation
THE THIRD EYE-PresentationTHE THIRD EYE-Presentation
THE THIRD EYE-Presentation
 
Wecon HMI PI Series Q&A
Wecon HMI PI Series Q&AWecon HMI PI Series Q&A
Wecon HMI PI Series Q&A
 
IoT
IoTIoT
IoT
 
Choosing_(and_Implem..
Choosing_(and_Implem..Choosing_(and_Implem..
Choosing_(and_Implem..
 

Mehr von 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
 

Mehr von 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
 
Client-Side Deep Learning
Client-Side Deep LearningClient-Side Deep Learning
Client-Side Deep Learning
 
オープンソースエコシステム #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を実際にさわってみてわかったこと
 
おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」おもしろく働くための「わらしべ長者方式」
おもしろく働くための「わらしべ長者方式」
 

Building iOS apps using "Bluetooth Low Energy"

  • 1. Building iOS apps using "Bluetooth Low Energy" Shuichi Tsutsumi @shu223 July 25, 2016 Azrieli College, Jerusalem July 26, 2016 Google Campus - Tel Aviv, Israel July 27, 2016 SigmaLabs - Tel Aviv, Israel July 28, 2016 Birzeit University - Palestine
  • 4. Overview • Basics of BLE • Practical Tips to build apps using BLE with Japanse Products
  • 6. Bluetooth Low Energy (BLE) • Wireless technology - no network infrastructure required Wi-FiBLE
  • 7. • Low energy • NOT compatible with Classic BT • Uses 2.4 GHz radio frequencies • Marketed by the Bluetooth SIG • etc…
  • 8. The most important thing (for iOS developers)
  • 9. The iOS API ‘Core Bluetooth’ is open for developers • API for Classic BT is NOT open. - Requires MFi certification.
  • 10. BLE is almost the ONLY way to enable iOS apps to communicate with external hardware without infrastructure or MFi.
  • 11. konashi moff band sensortag External HW • Simple → Small, Low cost & Long life Smart Phone • High Performance • Internet Connection • Easy to program • etc… Communicate with BLE
  • 15. Moff Band Moff App Sensor Data BLE Connection Sensors - Gyroscope - Accelerometer Analyze sensor data Recognize - Gesture - Posture Play sounds
  • 16. Sensor Data BLE Connection How is sensor data sent to the app?
  • 17. Scan Step 1. Scan Advertise : Search for nearby BLE devices centralManager.scanForPeripheralsWithServices(nil, options: nil) Peripheral Central
  • 19. 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)
  • 20. 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!”) }
  • 21. Hardware Side? I’m sorry, I don’t know…
  • 33. Group conversation system with VoIP - Detects the human voice - Cuts out all background noise → Can be used even in areas with poor coverage!
  • 35. IoT for Cars ‘SmartDrive’
  • 37. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY
  • 38. Music for the Deaf Daito Manabe/Motoi Ishibashi/Teruoka Masaki/Shuichi Tsutsumi x SOUL FAMILY Commands Electronic Stimulation DeviceiPhone
  • 40. Practical Tips to build apps using BLE
  • 42. 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
  • 43. 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
  • 44. 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
  • 45. 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
  • 48. Background behaviors on iOS • Very limited - Listening to music - Getting location data - Downloading data
  • 50. If BLE didn’t work in the background…
  • 51. You would have to always keep the app in the foreground, while snowboarding!
  • 52. You would have to launch the app whenever you go driving!
  • 53. What functions can be used in the background in iOS? • Scanning peripherals • Connecting with peripherals • Reading characteristics’ value • Writing characteristics’ value • Receiving notifications Almost all functions can be used even in the background!
  • 54. 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)
  • 55. If the app in the background is killed by the system…
  • 57. 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 callback method. → The app can handle BLE events!
  • 58. 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!
  • 59. How to test without HW prototypes
  • 60. 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
  • 61. Development Kit Can start development without creating a circuit ourselves BLE Module Display USB interface Battery box
  • 62. Horizontal (-100~100) / Vertical (-100~100) Development Kit App BLE
  • 64. Emulator App • Develop another iOS app as the alternative to the peripheral device • Easier for iOS engineers
  • 65. Multi-Function Control • Single Tap • Double Tap • Long Press • Very Long Press =
  • 67. Costing too much MSRP $13,995 Not enough devices when submitting
  • 68. Videos for review • Show how the app works with the peripheral device • Not need to be cool!
  • 69. • Shoot with iPhone • Edit with iMovie
  • 70. Recap • What is Bluetooth Low Energy? • Basics of BLE with ‘Moff’. • Japanese Hardware Products I’ve worked on • Practical Tips to build apps using BLE - Defining GATT - Defining background behaviors - Testing without HW prototypes - App Review
  • 71. Thank you! Shuichi Tsutsumi - iOS Freelancer • Twitter: @shu223 • GitHub: shu223 • Email: shuichi0526@gmail.com