building a mobile location aware system with beacons

Post on 16-Apr-2017

1.295 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Tim Messerschmidt Head of Developer Relations, International

Braintree_PayPal

@Braintree_Dev / @SeraAndroid

Building a Mobile Location Aware System with Beacons

#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

A Beacon’s Purpose

@Braintree_Dev / @SeraAndroid#OSCON

Location Awareness

@Braintree_Dev / @SeraAndroid#OSCON

Source: http://communityhealthmaps.nlm.nih.gov/2014/07/07/how-accurate-is-the-gps-on-my-smart-phone-part-2

GPS 3m

A-GPS 8m

WiFi 75m

Cellular 600m

Leveraging Your Phone’s Hardware

@Braintree_Dev / @SeraAndroid#OSCON

GPS vs Bluetooth Smart

@Braintree_Dev / @SeraAndroid#OSCON

Bluetooth vs Bluetooth Smart

@Braintree_Dev / @SeraAndroid#OSCON

Triangulation

Beacon

Beacon

Beacon

PositionMeasuring Angles From a Fixed Location

@Braintree_Dev / @SeraAndroid#OSCON

Trilateration

Beacon

BeaconBeacon

PositionMeasuring Distances From a Fixed Location

@Braintree_Dev / @SeraAndroid#OSCON

Applying This to the real world

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

Behind the Magic

Beacon Device

Advertisement

@Braintree_Dev / @SeraAndroid#OSCON

Behind the Magic

Beacon Device Endpoint

@Braintree_Dev / @SeraAndroid#OSCON

Popular Beacon Choices

Estimote 99 $ / 3

Gimbal 5 $

Bluecats 29 $

Kontakt.io 81 $ / 3

@Braintree_Dev / @SeraAndroid#OSCON

Advertising Beacons

UUID (16 Bytes): Large Beacon Group Major (2 Bytes): The Beacon Subset Minor (2 Bytes): The individual Beacon Tx Power: translates into distance

@Braintree_Dev / @SeraAndroid#OSCON

Avoid Being creepy

@Braintree_Dev / @SeraAndroid#OSCON

Deploying Beacons

@Braintree_Dev / @SeraAndroid#OSCON

Range vs. Battery

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

Replacing Batteries

@Braintree_Dev / @SeraAndroid#OSCON

SiGnal Interference

@Braintree_Dev / @SeraAndroid#OSCON

Confounding Factors

Microwave ovens Direct Satellite Services External electrical Sources Monitors and LCD Displays Anything that uses 2.4 or 5 GHz

@Braintree_Dev / @SeraAndroid#OSCON

SiGnal degradation

@Braintree_Dev / @SeraAndroid#OSCON

reddit.com/r/gifs/comments/2qv6xv/visualization_of_wifi_signal_strength_in_a_room

@Braintree_Dev / @SeraAndroid#OSCON

Low Interference

Wood Glass Synthetic Material

Medium Interference

Water Bricks Marble

Very High Interference

Metal

High Interference

Plaster Concrete bulletproof Glass

@Braintree_Dev / @SeraAndroid#OSCON

Attaching to a Beacon

@Braintree_Dev / @SeraAndroid#OSCON

dependencies { compile 'com.estimote:sdk:0.9.1@aar' }

Resolving The Dependency

Source: http://github.com/Estimote/Android-SDK

@Braintree_Dev / @SeraAndroid#OSCON

getMacAddress() getMajor() getMinor() getMeasuredPower()

The Estimote Beacon Object

Source: http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Beacon.html

getName() getProximityUUID() getRssi()

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application { private static final String ESTIMOTE_APP_ID = "FROM THE ESTIMOTE CLOUD"; private static final String ESTIMOTE_APP_TOKEN = "FROM THE ESTIMOTE CLOUD"; @Override public void onCreate() { super.onCreate(); EstimoteSDK.initialize(this, ESTIMOTE_APP_ID, ESTIMOTE_APP_TOKEN); EstimoteSDK.enableDebugLogging(true); } }

Initializing the SDK

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application implements BeaconManager.ServiceReadyCallback { private static final String ESTIMOTE_APP_ID = "FROM THE ESTIMOTE CLOUD"; private static final String ESTIMOTE_APP_TOKEN = "FROM THE ESTIMOTE CLOUD"; private BeaconManager beaconManager; @Override public void onCreate() { super.onCreate(); … beaconManager = new BeaconManager(this); beaconManager.connect(this); } @Override public void onServiceReady() { final Region regionOne = new Region("First region", UUID.fromString("Beacon UUID"), 22504, 44870); beaconManager.startMonitoring(regionOne); } }

Monitoring a Single Beacon

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application implements BeaconManager.ServiceReadyCallback { private static final String ESTIMOTE_APP_ID = "FROM THE ESTIMOTE CLOUD"; private static final String ESTIMOTE_APP_TOKEN = "FROM THE ESTIMOTE CLOUD"; private BeaconManager beaconManager; @Override public void onCreate() { super.onCreate(); … beaconManager = new BeaconManager(this); beaconManager.connect(this); } @Override public void onServiceReady() { final Region regionOne = new Region("First region", UUID.fromString("Beacon UUID"), null, null); beaconManager.startMonitoring(regionOne); } }

Monitoring multiple BeaconS

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application implements BeaconManager.ServiceReadyCallback, BeaconManager.MonitoringListener { @Override public void onServiceReady() { final Region regionOne = new Region("First region", UUID.fromString("Beacon UUID"), null, null); beaconManager.startMonitoring(regionOne); } @Override public void onEnteredRegion(Region region, List<Beacon> list) { // Interact with the region final String regionId = region.getIdentifier(); … } @Override public void onExitedRegion(Region region) { // Notify the user that he left the region } }

Interacting with Regions

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application implements BeaconManager.ServiceReadyCallback, BeaconManager.RangingListener { private static final String ESTIMOTE_APP_ID = "FROM THE ESTIMOTE CLOUD"; private static final String ESTIMOTE_APP_TOKEN = "FROM THE ESTIMOTE CLOUD"; private BeaconManager beaconManager; @Override public void onServiceReady() { final Region regionOne = new Region("First region", UUID.fromString("Beacon UUID"), null, null); beaconManager.startRanging(regionOne); } @Override public void onBeaconsDiscovered(Region region, List<Beacon> list) { final Beacon closestBeacon = list.get(0); // Interact with the beacon } }

Ranging Beacons

@Braintree_Dev / @SeraAndroid#OSCON

public class BeaconApplication extends Application implements BeaconConnection.ConnectionCallback, BeaconConnection.WriteCallback { private void configureBeacon(Beacon beacon) { final BeaconConnection connection = new BeaconConnection(this, beacon, this); connection.authenticate(); connection.edit() .set(connection.major(), 11) .set(connection.minor(), 3) .commit(this); connection.close(); }

// Implement the two interfaces for successful authentication and writing the configuration …}

Configuring Beacons

@Braintree_Dev / @SeraAndroid

Distance vs Signal Strength

Source: http://developer.estimote.com/android/tutorial/part-3-ranging-beacons

0

25

50

75

100

1m 2m 4m 8m

@Braintree_Dev / @SeraAndroid#OSCON

Important: While received signal strength, proximity zone and accuracy values can theoretically be used to derive a distance estimation, in practice this is far from trivial and requires complex mathematical models to account for fluctuations in the signal strength.

Long story short: do not expect distance estimations from beacons.

Measuring Distance

Source: http://developer.estimote.com/android/tutorial/part-3-ranging-beacons

@Braintree_Dev / @SeraAndroid#OSCON

immediate (strong signal) near (medium signal) far (weak signal) unknown (very weak signal)

Measuring Distance

Source: http://developer.estimote.com/android/tutorial/part-3-ranging-beacons

@Braintree_Dev / @SeraAndroid#OSCON

immediate (strong signal) - NFC near (medium signal) - Beacons far (weak signal) - Beacons unknown (very weak signal)

Measuring Distance

Source: http://developer.estimote.com/android/tutorial/part-3-ranging-beacons

@Braintree_Dev / @SeraAndroid#OSCON

computeAccuracy() computeProximity() isBeaconInRegion() proximityFromAccuracy()

The Utils Class

Source: http://estimote.github.io/Android-SDK/JavaDocs/com/estimote/sdk/Utils.html

@Braintree_Dev / @SeraAndroid#OSCON

Ranging vs Monitoring

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

@Braintree_Dev / @SeraAndroid#OSCON

Testing BLE on Android

@Braintree_Dev / @SeraAndroid#OSCON

BLE & Android’s Emulator

Virtual Machine + USB BLE Adapter chrislarson.me/blog/emulate-android-and-bluetooth-le-hardware.html

@Braintree_Dev / @SeraAndroid#OSCON

Altbeacon

@Braintree_Dev / @SeraAndroid#OSCON

Eddystone vs iBeacon

@Braintree_Dev / @SeraAndroid#OSCON

reference Material

Beacon vs BLE: link-labs.com/bluetooth-vs-bluetooth-low-energy ALTBEACON: altbeacon.org iBeacon Specification: developer.apple.com/ibeacon Estimote JavaDoc: estimote.github.io/Android-SDK/JavaDocs Eddystone: github.com/google/eddystone

@SeraAndroid tim@getbraintree.com

slideshare.net/paypal braintreepayments.com/developers

Thank you!

top related