Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More

35
St. Pölten University of Applied Sciences Platzhalter für möglichen Bildeinsatz Bluetooth Beacons Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 Creators Update & More Version 2.0 – June 21 st , 2017 Andreas Jakl, Twitter: @ andijakl, Blog: andreasjakl.com Lecturer, Digital Healthcare, FH St. Pölten Platzhalter für möglichen Bildeinsatz

Transcript of Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More

St. Pölten University of Applied Sciences

Platzhalter für möglichen

Bildeinsatz

Bluetooth Beacons

Bluetooth 5, iBeacon, Eddystone, Arduino,

Windows 10 Creators Update & More

Version 2.0 – June 21st, 2017Andreas Jakl, Twitter: @andijakl, Blog: andreasjakl.comLecturer, Digital Healthcare, FH St. Pölten

Platzhalter für möglichen

Bildeinsatz

BLUETOOTH BEACON OVERVIEW

Bluetooth & The Very Latest Windows – Andreas Jakl

Bluetooth & The Very Latest Windows – Andreas Jakl

Transmit small packets of data

e.g., ID & transmission power

Up to ~70m

No back communication channel

Wake up listening device.

Notification / app launch based on ID.

Calculate distance through signal power.

Your App

Bluetooth & The Very Latest Windows – Andreas Jakl

Battery

1-4 years

Bluetooth chipset

Beacon Use Cases

Bluetooth & The Very Latest Windows – Andreas Jakl

Indoor navigation & localization

- Industry (e.g., maintenance)

- Airports, shopping malls

- Automated check-ins

Augment shopping experience

- Ads relevant to location, coupons

- Open customer card when

approaching cash register

Museums & Events

- Location info

- Welcome note

Asset tracking

- Security monitoring: tool

not allowed to leave room

- Locate (misplaced) tools

Public transport

departure information

Bluetooth & The Very Latest Windows – Andreas Jakl

GPS

▪ Worldwide, outdoors

▪ Uni-directional

▪ Localization

Beacons

▪ Also indoors, 0-70 m

▪ Uni-directional

▪ Proximity information

NFC

▪ Contact

▪ Bi-directional

▪ Pay, Access, Trigger

Now with iPhone support!

Bluetooth LE ->

▪ New

▪ 2x Bandwidth (2 Mbps) without increased energy consumption

▪ 4x Range (allows whole home wireless)

▪ 8x Broadcasting Message Capacity

▪ Beacon frame size: 31 bytes -> 255 bytes

▪ Bluetooth 4 LE = feature within Bluetooth 5

▪ Bluetooth LE / Smart is no more!

▪ Backwards Compatible

Bluetooth & The Very Latest Windows – Andreas Jakl

Samsung Galaxy S8

Bluetooth & The Very Latest Windows – Andreas Jakl

0.00

1,000.00

2,000.00

3,000.00

4,000.00

5,000.00

6,000.00

2016 2017 2018 2019 2020 2021

Bluetooth enabled device shipments (in Millions)

Cellular PCs/Peripherals Mobile Devices Networking Connected Home Smart Home Automotive Wearables and Healthcare Devices Beacons

Source: Bluetooth e-Guide “Rethinking the future: Bluetooth 5,

beacon technology and the Internet of Things”, https://www.bluetooth.com/bluetooth-5-guide

Based on ABI Research

8.2 Million

beacons

565.3 Million

beacons

BEACON FLAVORS

iBeacons, Eddystone, Web Blueooth, Physical Web & more!

Bluetooth & The Very Latest Windows – Andreas Jakl

iBeacon™ & Eddystone™

iBeacon

UUID, major &

minor ID

Proprietary specification

https://developer.apple.com/ibeacon/

Bluetooth & The Very Latest Windows – Andreas Jakl

Eddystone

Beacon

Eddystone-UIDBeacon ID, Tx power

level

Eddystone-TLMBattery, temperature,

sent frames, time

running

Eddystone-URLURL, Tx power level

Open beacon format from Google

https://github.com/google/eddystone

Eddystone-EIDEphemeral Identifier,

Tx power level

LOW LEVEL BEACON INFO

Arduino / Genuino 101

Bluetooth & The Very Latest Windows – Andreas Jakl

Bluetooth & The Very Latest Windows – Andreas Jakl

Arduino / Genuino 101

Integrated

Bluetooth

Bluetooth & The Very Latest Windows – Andreas Jakl

1. Install Curie Board and

CurieBLE Library

Warning: Windows Store version of Arduino IDE does not install all the necessary drivers for Intel Curie boards. Use standalone IDE from https://www.arduino.cc/ instead.

Bluetooth & The Very Latest Windows – Andreas Jakl

2. Open CurieBLE > Central >

Scan example

Bluetooth & The Very Latest Windows – Andreas Jakl

3. Extend code to print

manufacturer data

Bluetooth & The Very Latest Windows – Andreas Jakl

4. Run and test

FEAA = Eddystone service UUID

4C = Apple Manufacturer ID

iBeacon UUID

https://play.google.com/store/apps/details?id=net.alea.beaconsimulator

BEACON APP DEVELOPMENT

Windows 10

Bluetooth & The Very Latest Windows – Andreas Jakl

Universal Beacon Library

https://github.com/andijakl/universal-beacon

Parse & create

Beacon frames

Assigns received

frames to individual

beacons

Fully documented.

Includes Windows 10 example app.Open Source license

Bluetooth & The Very Latest Windows – Andreas Jakl

Windows 10 Example

_beaconManager = new BeaconManager();_watcher = new BluetoothLEAdvertisementWatcher();_watcher.Received += WatcherOnReceived;_watcher.Start();

1 Initialize Beacon scanning

API documentation: bit.ly/ProximityAPI

private async void WatcherOnReceived(BluetoothLEAdvertisementWatcher sender,BluetoothLEAdvertisementReceivedEventArgs eventArgs)

{await _dispatcher.RunAsync(CoreDispatcherPriority.Normal,

() => _beaconManager.ReceivedAdvertisement(eventArgs));}

2 Beacon advertisement frame received callback

Bluetooth & The Very Latest Windows – Andreas Jakl

Example

foreach (var bluetoothBeacon in _beaconManager.BluetoothBeacons.ToList()){

Debug.WriteLine("Beacon: " + bluetoothBeacon.BluetoothAddressAsString);Debug.WriteLine("Type: " + bluetoothBeacon.BeaconType);

foreach (var beaconFrame in bluetoothBeacon.BeaconFrames.ToList()){

// Print a small sample of the available data parsed by the libraryif (beaconFrame is UrlEddystoneFrame){

Debug.WriteLine("Eddystone URL Frame");Debug.WriteLine("URL: " + ((UrlEddystoneFrame) beaconFrame).CompleteUrl);

} // ...

}}

3 Access Beacon Info

Bluetooth & The Very Latest Windows – Andreas Jakl

Bluetooth Beacon Interactor

Bluetooth & The Very Latest Windows – Andreas Jakl

Windows 10 Library Example App = Free Bluetooth Beacon Interactor

https://www.microsoft.com/store/apps/9NBLGGH1Z24K

(Also available on HoloLens!)

Buying Bluetooth Beacons

Bluetooth & The Very Latest Windows – Andreas Jakl

Starting at $60 (3 pcs)

BLUETOOTH GATT

Communication Without Pairing

Bluetooth & The Very Latest Windows – Andreas Jakl

Bluetooth Advertising

Bluetooth & The Very Latest Windows – Andreas Jakl

Peripheral

Device(e.g., beacon)

GAP = Generic Access Profile: makes devices visible, defines device interactions

Central

Device(e.g., phone)

Central

Device

Central

Device

Central

Device

Peripheral is broadcasting.

Beacons: advertising package contains all data

(= 31 bytes for Bluetooth LE < 5)

Bluetooth Communication

Bluetooth & The Very Latest Windows – Andreas Jakl

Central /

GATT Client(e.g., phone)

GATT = Generic Attribute Profile, data transfer through services and characteristics

Peripheral /

GATT Server(e.g. sensors, smart

home components)

Peripheral /

GATT Server

Peripheral /

GATT Server

Peripheral /

GATT Server

After established connection: 2-way

communication.

(connection != pairing)

Profiles / Services / Characteristics

▪ Profile

▪ Pre-defined collection of services

▪ E.g., heart rate profile, blood pressure profile

▪ https://www.bluetooth.com/specifications/adopted-

specifications#GATT

Bluetooth & The Very Latest Windows – Andreas Jakl

Profile

Profiles / Services / Characteristics

▪ Service

▪ Data broken up into logical entities

▪ E.g., heart rate service, battery service

▪ https://www.bluetooth.com/specifications/gatt/servic

es

Bluetooth & The Very Latest Windows – Andreas Jakl

Profile

Service

Service

Profiles / Services / Characteristics

▪ Characteristic

▪ Single data point

▪ E.g., Heart rate service

▪ Measurement

▪ Body sensor location

▪ Control point

▪ E.g., Battery service

▪ Battery level (read), percentage 0 – 100%

▪ Read & write access

Bluetooth & The Very Latest Windows – Andreas Jakl

Profile

Service

Characteristic

Characteristic

Characteristic

Service

Characteristic

Windows 10 Creators Update

Bluetooth & The Very Latest Windows – Andreas Jakl

https://blogs.windows.com/buildingapps/2017/01/13/new-bluetooth-features-in-creators-update-gatt-server-bluetooth-le/

NEW!

Support?

Bluetooth & The Very Latest Windows – Andreas Jakl

var localAdapter = await BluetoothAdapter.GetDefaultAsync();

Debug.WriteLine("Low energy supported? -> " + localAdapter.IsLowEnergySupported);

Debug.WriteLine("Central role supported? -> " + localAdapter.IsCentralRoleSupported);

Debug.WriteLine("Peripheral role supported? -> " + localAdapter.IsPeripheralRoleSupported);

Support?

Bluetooth & The Very Latest Windows – Andreas Jakl

var localAdapter = await BluetoothAdapter.GetDefaultAsync();

Debug.WriteLine("Low energy supported? -> " + localAdapter.IsLowEnergySupported);

Debug.WriteLine("Central role supported? -> " + localAdapter.IsCentralRoleSupported);

Debug.WriteLine("Peripheral role supported? -> " + localAdapter.IsPeripheralRoleSupported);New APIs!

Read Battery Level of Bluetooth Beacon

Bluetooth & The Very Latest Windows – Andreas Jakl

using (var bluetoothLeDevice =await BluetoothLEDevice.FromBluetoothAddressAsync(bluetoothAddress))

Access Bluetooth device1

Query GATT services2

var gattServices = await bluetoothLeDevice.GetGattServicesAsync();

00001800-0000-1000-8000-00805f9b34fb

00001801-0000-1000-8000-00805f9b34fb

0000180a-0000-1000-8000-00805f9b34fb

0000180f-0000-1000-8000-00805f9b34fb

[…]

https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.battery_service.xml

foreach (var curService in gattServices.Services) {

var gattCharacteristics = await curService.GetCharacteristicsAsync();

Read Battery Level of Bluetooth Beacon

Bluetooth & The Very Latest Windows – Andreas Jakl

Query characteristics3

Characteristic Handle: 20

UUID: 00002a19-0000-1000-8000-00805f9b34fb

https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml

Read Battery Level of Bluetooth Beacon

Bluetooth & The Very Latest Windows – Andreas Jakl

Process characteristics4

foreach (var curCharacteristic in gattCharacteristics.Characteristics) {

if (curCharacteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Read))

{var result = await curCharacteristic.ReadValueAsync();

64 (Hex) -> 100% (Decimal)

THANK YOU!

Andreas Jakl

@andijakl

andreasjakl.com

Bluetooth & The Very Latest Windows – Andreas Jakl