building a mobile location aware system with beacons

32
Building a Mobile Location Aware System with Beacons Jonathan LeBlanc (@jcleblanc) Head of Global Developer Advocacy at PayPal + Braintree

Upload: jonathan-leblanc

Post on 15-Jul-2015

1.304 views

Category:

Technology


2 download

TRANSCRIPT

Building a Mobile Location Aware System with Beacons

Jonathan LeBlanc (@jcleblanc) Head of Global Developer Advocacy at PayPal + Braintree

twitter: @jcleblanc | hashtag: #OSCON

Purpose of a Beacon

Being Location Aware

twitter: @jcleblanc | hashtag: #OSCON

Real World Use Case

twitter: @jcleblanc | hashtag: #OSCON

Central Device

Beacon Hardware

IP Address Endpoint

How it Works

twitter: @jcleblanc | hashtag: #OSCON

twitter: @jcleblanc | hashtag: #OSCON

Estimote: $99 / 3, temp + motion

Beacon Comparison

Bluecat: Trial, AA batteries

Gimbal Tag: $5, small & deployable

Kontakt.io: $81 / 3, battery life

•  UUID (16 bytes): Differentiates Large Group

•  Major (2 bytes): Beacon Subset

•  Minor (2 bytes): Individual Beacon

•  Tx Power: Proximity from beacon

Beacon Advertisement & ID

twitter: @jcleblanc | hashtag: #OSCON

twitter: @jcleblanc | hashtag: #OSCON

Don’t be Creepy

twitter: @jcleblanc | hashtag: #OSCON

Deploy Considerations

Battery Life vs Range

twitter: @jcleblanc | hashtag: #OSCON

Battery Replacement

twitter: @jcleblanc | hashtag: #OSCON

Signal Interference

twitter: @jcleblanc | hashtag: #OSCON

•  Microwave ovens

•  Direct Satellite Service (DSS)

•  Certain external electrical sources

•  2.4 GHz or 5 GHz phones

•  Video transmitters/receivers that operate in the 2.4

GHz or 5 GHz bandwidth

•  Wireless speakers that operate in the 2.4 GHz or 5

GHz band

•  Certain external monitors and LCD displays

•  Any other wireless devices that operate in the 2.4

GHz or 5 GHz bandwidth

twitter: @jcleblanc | hashtag: #OSCON

Signal Degradation

twitter: @jcleblanc | hashtag: #OSCON

Low Interference Medium Interference

High Interference Very High Interference

Wood

Synthetic Material

Glass  

Water

Bricks

Marble  

Plaster

Concrete

Bulletproof Glass  

Metal  

twitter: @jcleblanc | hashtag: #OSCON

Attaching to a Beacon

<uses-permission android:name=

"android.permission.BLUETOOTH"/>

<uses-permission android:name=

"android.permission.BLUETOOTH_ADMIN"/>

<service android:name=

”com.estimote.sdk.service.BeaconService"

android:exported="false"/>

AndroidManifest.xml

twitter: @jcleblanc | hashtag: #OSCON

Adjusting Beacon Settings Estimote Site and App

twitter: @jcleblanc | hashtag: #OSCON

connection = new BeaconConnection(this, beacon, new

BeaconConnection.ConnectionCallback(){

@Override public void onAuthenticated(){ ... }

@Override public void onAuthenticationError(){ ... }

@Override public void onDisconnected(){ ... }

});

connection.authenticate();

connection.close();

The Beacon Connection

twitter: @jcleblanc | hashtag: #OSCON

//update the beacon UUID and Major

connection.edit()

.set(connection.major(), newMajor)

.commit(new BeaconConnection.WriteCallback(){

@Override public void onSuccess(){}

@Override public void

onError(EstimoteDeviceException exception){}

});

Adjusting Beacon Settings

twitter: @jcleblanc | hashtag: #OSCON

•  AdvertisingInterval

•  BroadcastingPower

•  Major

•  Minor

•  ProximityUuid

Updatable Settings

twitter: @jcleblanc | hashtag: #OSCON

The Android Emulator

twitter: @jcleblanc | hashtag: #OSCON

twitter: @jcleblanc | hashtag: #OSCON

Virtual Machine Software +

USB BLE adapter

http://chrislarson.me/blog/emulate-android-and-bluetooth-le-hardware.html

Emulating Android & BLE

twitter: @jcleblanc | hashtag: #OSCON

Collecting Range Data

•  getProximityUUID: Proximity UUID of the Beacon

•  getMajor: Major version of the beacon •  getMinor: Minor version of the beacon

•  getMeasuredPower: Beacon measured power

(in dBm)

•  getMacAddress: Beacon MAC address

•  getName: Display friendly beacon name •  getRssi: Received Signal Strength Indication

The Beacon Object

twitter: @jcleblanc | hashtag: #OSCON

private static final Region ALL_BEACONS =

new Region("regionId", null, null, null);

private BeaconManager beaconManager = new

BeaconManager(this);

Setting the Beacon Manager

twitter: @jcleblanc | hashtag: #OSCON

beaconManager.setRangingListener(new BeaconManager.RangingListener() { @Override public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {

for (Beacon rangedBeacon : beacons) { double currentDistance = Utils.computeAccuracy(rangedBeacon); … }

} });

Setting the Listener

twitter: @jcleblanc | hashtag: #OSCON

beaconManager.connect(

new BeaconManager.ServiceReadyCallback(){

@Override public void onServiceReady(){

try{

beaconManager.startRanging(ALL_BEACONS);

} catch (RemoteException e) {

Log.e(TAG, "Cannot start ranging", e);

}

}

});

Getting Beacon Range

twitter: @jcleblanc | hashtag: #OSCON

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

Estimote Javadocs http://estimote.github.io/Android-SDK/JavaDocs/

AltBeacon http://altbeacon.org/examples/

twitter: @jcleblanc | hashtag: #OSCON

Beacon Wrap-up

twitter: @jcleblanc | hashtag: #OSCON

Thank You! http://slideshare.net/jcleblanc

Jonathan LeBlanc (@jcleblanc) Head of Global Developer Advocacy at PayPal + Braintree