How to Troubleshoot Apps for the Modern Connected Worker
Bw13 session2 app_dev_presenter_final
1. Bluetooth SIG Proprietary and Confidential 1Bluetooth SIG Proprietary and Confidential 1
Click to edit Master title style
Click to edit Master subtitle style
Appcessories
Bridging the Digital to the Physical
2. Bluetooth SIG Proprietary and Confidential 2Bluetooth SIG Proprietary and Confidential 2
What’s In It For Me?
• Understand the opportunity
– Great potential for growth and monetization with
appcessories
– Bluetooth technology‟s role
• What a sample Bluetooth implementation
looks like
– From „profiles‟ and use cases to code
• Where to find more resources
– Hint: developer.bluetooth.org
3. Bluetooth SIG Proprietary and Confidential 3Bluetooth SIG Proprietary and Confidential 3
Digital and Physical Worlds Collide!
4. Bluetooth SIG Proprietary and Confidential 4Bluetooth SIG Proprietary and Confidential 4
Appcessories = Application + Accessory
They are complementary devices that enable people
to interact with technology like never before by
creating physical experiences to strengthen the digital
experience
What Is An Appcessory?
MobiPlex - SwingTIP
What makes Bluetooth a good fit
for Appcessories?
Performance
THE Standard for device
connectivity
5. Bluetooth SIG Proprietary and Confidential 5Bluetooth SIG Proprietary and Confidential 5
1,000,000,000 Devices*
Why Should I Care?
1,000,000,000x Applications
* 2012 ANALYSIS OF THE BLUETOOTH MARKET AND INDUSTRY, ABI Research
6. Bluetooth SIG Proprietary and Confidential 6Bluetooth SIG Proprietary and Confidential 6
Let Me Share a Story…
7. Bluetooth SIG Proprietary and Confidential 7Bluetooth SIG Proprietary and Confidential 7
Bluetooth – Bridging the Gap
App for the
Phone
Sensor-based
device for the
Lock
For the
Connection
• Well defined specs and protocols
• Standard way to implement
solutions
8. Bluetooth SIG Proprietary and Confidential 8Bluetooth SIG Proprietary and Confidential 8
Smart Device Profiles – Defining the Use Cases
A Generic Attribute Profile
(GATT) is a description of how a
device functions for a given
scenario/use case
Generic Attribute Profile
Service
Value
Characteristic
Value
Value
Value
Characteristic
Value
Value
First thing we need to do is to define the
use cases…
9. Bluetooth SIG Proprietary and Confidential 9Bluetooth SIG Proprietary and Confidential 9
Profile for the Lock Mechanism
What is your use case? Let’s focus on the
Password-enabled scenario
Admin User Lock
Turn ‘on’ PWD
PWD ‘on’ AK
Change PWD
Send Admin PWD
Admin PWD
Send Good/Bad
New User PWD
Send User PWD
Change AK
In this flow, we will assume that the Admin PWD given is correct
Encrypted
Encrypted
• We want an admin to be able to turn passwords on/off
• We want an admin to be able to send an ‘admin’ password, which can then be used to set the
‘user’ password
10. Bluetooth SIG Proprietary and Confidential 10Bluetooth SIG Proprietary and Confidential 10
Service Definition for the Lock Mechanism
High-level sample profile
Lock Mechanism Profile
Lock Service
Yes
Locked
…
Code Service
ON
Status
12345
User Code
54321
Admin Code
• Use case scenarios are
important to define
– Design decisions are important to your
scenario(s)
– Lock Service – is it simply a toggle?
– Code Service – are we covering all of the
right use cases?
• Quick word on Adopted
Profiles…
– Proximity is an example
– Contains a „link loss‟, an „immediate alert
level‟, and a „transmit power‟ service
– Can easily add those services to your
„custom‟ profile‟.
11. Bluetooth SIG Proprietary and Confidential 11Bluetooth SIG Proprietary and Confidential 11
Attribute Tables for Lock Mechanism
Handle Type Value Permissions
1 «Primary Service» «Code Service» --
2 «Status» {r/w, 3, «Value for Status»} Read/Write
3 «Value for Status» “ON” --
4 «User Code» {r/w, 5, «Value for Code»} Read/Write
5 «Value for Code» “12345” --
6 «Admin Code» {r/w, 7, «Value for Code»} Read/Write
7 «Value for Code» “54321” --
• Smart Device stores Service data in
an Attribute Table
– Implemented on the actual Smart Device to
store data
• Structure defined by GATT
– Every entry in the table is considered an
attribute
– Service, Characteristic, Value, etc
12. Bluetooth SIG Proprietary and Confidential 12Bluetooth SIG Proprietary and Confidential 12
Smart Ready Platforms and Profiles
When creating apps for modern
smartphone platforms, many
Bluetooth details are abstracted away
by the underlying SDK
• In many cases, still requires
knowledge of the profile.
• Each platform has their own
SDK and are a bit different
– Microsoft, Apple, Blackberry, Google
• Refer to the SDK docs of the
platform you are targeting
Generic Attribute Profile
Service
Value
Characteristic
Value
Value
Value
Characteristic
Value
Value
13. Bluetooth SIG Proprietary and Confidential 13Bluetooth SIG Proprietary and Confidential 13
• Smart Device Discovery
Typical Bluetooth Application Flow
Smart Device Advertises Itself
Smart Ready Hub Scans for Advertisements
Smart Ready Hub requests a
Connection
Smart Device accepts Connection
request
• Smart Device Connection to Smart Ready Hub
14. Bluetooth SIG Proprietary and Confidential 14Bluetooth SIG Proprietary and Confidential 14
• Interacting with Services
Typical Bluetooth Application Flow
– Smart Ready Hub can look at
services and the values they contain
in Smart Devices
– Smart Ready Hub can send
commands to the Smart Device
services
– Smart Ready Hub can receive
commands and updates from the
Smart Device
• Requires the services to be configured
properly on the Smart Device
15. Bluetooth SIG Proprietary and Confidential 15Bluetooth SIG Proprietary and Confidential 15
Lockitron – Not Just a Story
• Turn your mobile phone into a
key.
• Send permanent or temporary
virtual keys to family, friends and
house guests.
• Your mobile phone can be better
than a key – keep it in your
pocket.
Keyless entry with your phone
– Bluetooth low energy – “…the only wireless technology we can keep on for extended
periods and is integrated directly into mobile phones.”
– “With Bluetooth low energy, we can carry out commands without the user tapping the
app.”
Cameron Robertson, Founder
16. Bluetooth SIG Proprietary and Confidential 16Bluetooth SIG Proprietary and Confidential 16
Bridging the Digital to the Physical
Internet
Connected
Native APIs
for
applications
®
17. Bluetooth SIG Proprietary and Confidential 17Bluetooth SIG Proprietary and Confidential 17
Implementation – Getting Started
• Texas Instruments CC2541
– Single-chip single-mode Bluetooth low energy
System-on-a-Chip
– Contains radio, MCU, stack, profiles, applications,
and on-chip peripherals – everything needed for
your product!
• CC2541 Sensor Tag Kit
– Fully working Bluetooth low energy peripheral
based on CC2541
– Contains sensors for temperature, humidity,
accelerometer, magnetometer
– Enables app developers to quickly develop
prototype Bluetooth low energy software
• CC2541 Mini Development Kit
– Includes CC2541 Keyfob, USB Dongle, and
Debugger
– Enables CC2541 embedded software development
18. Bluetooth SIG Proprietary and Confidential 18Bluetooth SIG Proprietary and Confidential 18
Implementation – TI iOS SensorTag App
• Targeting Smart Phone App Developers
• Limitless App Possibilities
– Health and fitness, medical, educational tools, toys,
remote controls, mobile phone accessories, and
proximity.
• The CC2541 SensorTag kit shortens the
design time for Bluetooth low energy
app development from months to hours
– No embedded software design knowledge required.
– The SensorTag includes all SW needed for App
development
– TI has a SensorTag App on the App Store providing
developers with easy access to the tools they need.
– iOS Example App Source Code available for
download at http://ti.com/sensortag
19. Bluetooth SIG Proprietary and Confidential 19Bluetooth SIG Proprietary and Confidential 19
Implementation – Developing for iOS
• Development done using Xcode
• Xcode runs on OSX [Mountain] Lion
• Xcode and simulator is free
– BLE requires physical iOS device
• Physical device download requires Apple Developer Account
– Costs 99$ per year at developer.apple.com/programs/ios
20. Bluetooth SIG Proprietary and Confidential 20Bluetooth SIG Proprietary and Confidential 20
Implementation – iOS Source Code
• The communication is asynchronous
between app and iOS’s CoreBluetooth API
• We issue commands to CBCentralManager
and CBPeripheral
– [BLEUtility writeCharacteristic ...]
– [peripheral writeValue:data ... ];
• Then act as delegate for CBCentralManager
– centralManagerDidUpdateState
– didDiscoverPeripheral
– didConnectPeripheral
• And for CBPeripheral
– didDiscoverServices
– didUpdateValueForCharacteristic
– didWriteValueForCharacteristic
• Delegates implement callbacks according to
a protocol. A design pattern used in iOS.
21. Bluetooth SIG Proprietary and Confidential 21Bluetooth SIG Proprietary and Confidential 21
Implementation – Developing for CC2541
• TI provides license-free Bluetooth low energy qualified
protocol stack and profiles
• Application development using C using IAR Embedded
Workbench
• Operating system abstraction layer (OSAL) with
priorized event handler, memory management, task
messaging, and NV drivers
• Sample applications included with SDK
– Standard profile applications such as Proximity, Heart Rate Sensor,
Glucose Sensor, etc...
– Custom profile applications such as SensorTag, Generic Peripheral,
Generic Central
• Additional Features
– Over-the-Air Firmware Updates
– Boot Image Manager- run multiple firmware images on one chip
– Hardware Abstraction Layer (HAL) drivers for on-chip peripherals including
SPI, UART, I2C, ADC, Timers
22. Bluetooth SIG Proprietary and Confidential 22Bluetooth SIG Proprietary and Confidential 22
Resources on the Portal
• Knowledge Center
– White papers
– Training Videos
• Development Resources
– Quick Start Kit
– Platform availability for Smart and
Smart Ready
– Recorded webinars on
development topics
– Links to SIG tools (PTS, etc.)
• Forums
• GATT specifications
http://developer.bluetooth.org
23. Bluetooth SIG Proprietary and Confidential 23Bluetooth SIG Proprietary and Confidential 23
Coming Soon – New Developer Resources
• Bluetooth Quick Start Kit v2
– Fundamentals for device makers new to
Bluetooth Low Energy
• GATT, GAP, ATT, adopted profiles, etc.
– Sample application
• “Hello Bluetooth”
– iOS, Android, Windows 8
• Bluetooth Application
Accelerators v1
– Accelerator for application developers
– Educational content
• Setting up your environment
• Tutorial/code walkthrough
– Fully commented sample code
• iOS initially http://developer.bluetooth.org
24. Bluetooth SIG Proprietary and Confidential 24Bluetooth SIG Proprietary and Confidential 24
Appcessories – Join the Movement
• Appcessory market is mainstream
– Great potential for growth and monetization
• Bluetooth can help you bridge the digital to
the physical
– Bluetooth is the a defacto standard
• Grab a development kit and start today