This talk got delivered at OSCON EU 2015. It covers the usage of Bluetooth LE Beacons in order to allow for real world interaction with users that you normally deal with through an API.
08448380779 Call Girls In Civil Lines Women Seeking Men
Â
Building a Mobile Location Aware System with Beacons
1. Tim Messerschmidt
Head of Developer Relations, International
Braintree_PayPal
@Braintree_Dev / @SeraAndroid
Building a Mobile Location Aware
System with Beacons
#OSCON
14. @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
24. @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
28. @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
29. @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
30. @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
31. @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
32. @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
33. @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
34. @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
35. @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
45. @Braintree_Dev / @SeraAndroid#OSCON
BLE & Androidâs Emulator
Virtual Machine + USB BLE Adapter
chrislarson.me/blog/emulate-android-and-bluetooth-le-hardware.html