7. Type Function Name Function Description
String getMacAddress() Return MAC address of the beacon.
int getMajor() Return Major version of the beacon.
int getMeasuredPower() Return Measured power of the beacon (in dBm).
int getMinor() Return Minor version of the beacon.
String getName()
Return Device friendly name (this name is
advertised by the beacon).
String getProximityUUID()
Return Proximity UUID of the beacon in
format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
(all lowercases).
int getRssi()
Return Received Signal Strength Indication
at the moment of scanning.
com.estimote.sdk
Class Beacon
8. com.estimote.sdk.connection
Class BeaconConnection.BeaconCharacteristics
Type Function Name Function Description
Integer getAdvertisingIntervalMillis()
Returns Advertising interval in
milliseconds.
Integer getBatteryPercent()
Returns Battery level in
percent.
Byte getBroadcastingPower() Returns Broadcasting power.
String getHardwareVersion() Returns Revision of hardware.
String getSoftwareVersion()
Returns Version of operating
system.
9. com.estimote.sdk
Class Utils
Type Function Name
static double
computeAccuracy(Beacon beacon)
Returns distance in meters based on beacon's RSSI and measured power.
static boolean
isBeaconInRegion(Beacon beacon, Region region)
Returns true if beacon matches the region.
static void
restartBluetooth(Context context, Utils.RestartCompletedListener listener)
Restarts Bluetooth stack on the device.
10. com.estimote.sdk.connection
Class BeaconConnection
Function Name
void:writeAdvertisingInterval(int intervalMillis, BeaconConnection.WriteCallback writeCallback)
Changes advertising interval of the beacon.
void:writeBroadcastingPower(int powerDBM, BeaconConnection.WriteCallback writeCallback)
Changes broadcasting power of the beacon.
void:writeMajor(int major, BeaconConnection.WriteCallback writeCallback)
Changes major value of the beacon.
void:writeMinor(int minor, BeaconConnection.WriteCallback writeCallback)
Changes minor value of the beacon.
void:writeProximityUuid(String proximityUuid, BeaconConnection.WriteCallback writeCallback)
Changes proximity UUID of the beacon.
13. private static final String ESTIMOTE_PROXIMITY_UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";
private static final Region ALL_ESTIMOTE_BEACONS =
new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
private BeaconManager beaconManager = new BeaconManager(context);
// Should be invoked in #onCreate.
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
Log.d(TAG, "Ranged beacons: " + beacons);
}
});
// Should be invoked in #onStart.
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override public void onServiceReady() {
try {
beaconManager.startRanging(ALL_ESTIMOTE_BEACONS);
}
catch (RemoteException e) {
Log.e(TAG, "Cannot start ranging", e);
}
}
});
// Should be invoked in #onStop.
try {
beaconManager.stopRanging(ALL_ESTIMOTE_BEACONS);
}
catch (RemoteException e) {
Log.e(TAG, "Cannot stop but it does not matter now", e);
}
// When no longer needed. Should be invoked in #onDestroy.
beaconManager.disconnect();
快速上手操作iBeacon