public class Utils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Utils.Proximity
Defines distance relationship between beacon and the device.
|
static interface |
Utils.RestartCompletedListener
Interface used to notify called that Bluetooth stack has been restarted.
|
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static Beacon |
beaconFromLeScan(android.bluetooth.BluetoothDevice device,
int rssi,
ScanRecord scanRecord)
Parses
scanRecord to look for manufacturer specific data, verifies that
and constructs Beacon . |
static double |
computeAccuracy(Beacon beacon)
Returns distance in meters based on beacon's RSSI and measured transmitPower.
|
static double |
computeAccuracy(ConfigurableDevicesScanner.ScanResultItem resultItem) |
static double |
computeAccuracy(Eddystone eddystone) |
static double |
computeAccuracy(EstimoteLocation location) |
static Utils.Proximity |
computeProximity(Beacon beacon) |
static Utils.Proximity |
computeProximity(ConfigurableDevicesScanner.ScanResultItem scanResultItem) |
static Utils.Proximity |
computeProximity(Eddystone eddystone) |
static Utils.Proximity |
computeProximity(EstimoteLocation location) |
static Utils.Proximity |
computeProximity(Nearable nearable) |
static boolean |
isBeaconInRegion(Beacon beacon,
Region region)
Returns true if beacon matches the region.
|
static java.lang.String |
normalizeProximityUUID(java.lang.String proximityUUID)
Normalizes location UUID by making it lowercase and in format
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
|
static int |
parseInt(java.lang.String numberAsString)
Parses string to integer.
|
static Utils.Proximity |
proximityFromAccuracy(double accuracy)
Computes
Utils.Proximity based on distance in meters. |
static void |
restartBluetooth(android.content.Context context,
Utils.RestartCompletedListener listener)
Restarts Bluetooth stack on the device.
|
static byte[] |
revertBytes(byte[] bytes)
Reverts given byte array.
|
public static Beacon beaconFromLeScan(android.bluetooth.BluetoothDevice device, int rssi, ScanRecord scanRecord)
scanRecord
to look for manufacturer specific data, verifies that
and constructs Beacon
.device
- Bluetooth device found by BluetoothAdapter
.scanRecord
- Bluetooth advertisement data.rssi
- Current RSSI between devices.Beacon
or null if scanRecord
could not have been parsed.public static java.lang.String normalizeProximityUUID(java.lang.String proximityUUID)
public static boolean isBeaconInRegion(Beacon beacon, Region region)
public static double computeAccuracy(Beacon beacon)
public static double computeAccuracy(Eddystone eddystone)
public static double computeAccuracy(ConfigurableDevicesScanner.ScanResultItem resultItem)
public static double computeAccuracy(EstimoteLocation location)
public static Utils.Proximity proximityFromAccuracy(double accuracy)
Utils.Proximity
based on distance in meters. Current distance ranges:
accuracy
- Distance in meters.public static Utils.Proximity computeProximity(ConfigurableDevicesScanner.ScanResultItem scanResultItem)
public static Utils.Proximity computeProximity(Beacon beacon)
public static Utils.Proximity computeProximity(Eddystone eddystone)
public static Utils.Proximity computeProximity(EstimoteLocation location)
public static Utils.Proximity computeProximity(Nearable nearable)
public static int parseInt(java.lang.String numberAsString)
numberAsString
- String to be parsed.public static void restartBluetooth(android.content.Context context, Utils.RestartCompletedListener listener)
Never invoke this method without user's explicit consent that Bluetooth on the device is going to be restarted.
context
- Context.listener
- Listener to be invoked when Bluetooth stack is restarted.public static byte[] revertBytes(byte[] bytes)
bytes
- to revert