Package com.estimote.sdk
Interface Summary 接口概要 | |
Callback to be invoked when any error happened while performing low energy scanning. 当进行低功耗浏览发生任何错误会被触发的回调 | |
Callback to be invoked when beacons are discovered in a region. 当beacons在一个区域被发现时被触发的回调 | |
Callback to be invoked when beacons are ranged. 当beacons被测距时触发的回调 | |
Callback to inform client when service is ready to use. 当服务准备好时通知客户端的回调函数 | |
Interface used to notify called that Bluetooth stack has been restarted. 当蓝牙栈已经被重启时用来通知的所调用的接口 |
Class Summary 类概要 | |
Immutable representations of single beacon. 不变的单个beacon的呈现 | |
This is a class that clients should use to interact with iBeacons. 这是一个客户端应该用来和iBeacons交互的类 | |
Defines a region based on device's proximity to a beacon. 定义一个基于beacon设备精度的区域 | |
Grab bag of utilities. 混杂的实用工具 |
Enum Summary 枚举概要 | |
Describes current location relationship with region bounds. 描述当前位置和区域边界的关联 | |
Defines distance relationship between beacon and the device. 定义beacon和设备的距离关系 |
Package com.estimote.sdk.connection
Interface Summary | |
Callback used to indicate state of the connection to the beacon. 用来指向beacon连接状态的回调函数 | |
Callback used to indicate status of updating beacon characteristic. 用来指向更新beacon特征的回调函数 |
Class Summary | |
Establishes connection to the beacon and reads its characteristics. 建立和beacon的连接并且读取它的特征 | |
Value object for beacon's characteristics (battery level, broadcasting power, advertising interval, software and hardware version). 包含Beacon特征值的对象(电池等级,广播能量,广告间隔,软件和硬件版本) |
Package com.estimote.sdk.service
SDK classes for Androidservice that is responsible for interacting with beacons.
Android 服务的SDK类需要负责和beacons交互。
See:
Description
Class Summary | |
Don't use this class directly, use it via BeaconManager. 不要直接用这个类,应该通过BeaconManager使用它。 | |
Data object for results from Monitoring. 监测结果的数据对象 | |
Data object for results from ranging. 测距结果的数据对象 | |
Data object containing values for setting scan periods. 包含设置扫描周期的数据对象 |
Package com.estimote.sdk.service Description
SDK classes for Android service that isresponsible for interacting with beacons.
Do not use those classes directly.Use BeaconManager instead.
In your AndroidManifest.xml declare service:
在你的 AndroidManifest.xml声明服务:
<serviceandroid:name="com.estimote.sdk.service.BeaconService"
android:exported="false"/>
and add neededBluetooth permissions:
并且添加需要的蓝牙许可:
<uses-permissionandroid:name="android.permission.BLUETOOTH"/>
<uses-permissionandroid:name="android.permission.BLUETOOTH_ADMIN"/>
Package com.estimote.sdk.utils
Class Summary | |
L stands for logging. L可以替代日志 |
com.estimote.sdk
Class Beacon
java.lang.Object
com.estimote.sdk.Beacon
All Implemented Interfaces:
public class Beacon
extends Object
implements Parcelable
Immutable representations of single beacon.
单个beacon不变的呈现形式
Two beacons are considered equal if their proximity UUID, majorand minor are equal.
假如两个beacon的UUID,major和minor相同的话,它们被认为是等同的。
This mimics CLBeacon
fromiOS.
这个模仿IOS的CLBeacon
嵌套类概述 |
Nested classes/interfaces inherited from interface android.os.Parcelable 嵌套的类继承自android.os.Parcelable |
Field Summary 字段概要 | |
|
Fields inherited from interface android.os.Parcelable |
Constructor Summary 构造函数概要 | |
Beacon |
Method Summary | |
| |
| |
| getMajor |
| |
| getMinor |
getName | |
| getRssi |
| hashCode |
toString | |
| writeToParcel |
Methods inherited from class java.lang.Object |
clone |
CREATOR
public static final Parcelable.Creator<Beacon> CREATOR
Beacon
public Beacon(String proximityUUID,
String name,
String macAddress,
int major,
int minor,
int measuredPower,
int rssi)
getProximityUUID
public String getProximityUUID()
Returns:
ProximityUUID of the beacon in format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (alllowercases).
返回:
以XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX(全部小写)Beacon的UUID
getName
public String getName()
Returns:
Devicefriendly name (this name is advertised by the beacon).
返回:
设备友好的名字(这个名字被beacon广告)
getMacAddress
public String getMacAddress()
Returns:
MACaddress of the beacon.
返回:
Beacon的MAC地址
getMajor
public int getMajor()
Returns:
Majorversion of the beacon.
返回:
Beacon的主要版本
getMinor
public int getMinor()
Returns:
Minorversion of the beacon.
返回:
Beacon的次要版本
getMeasuredPower
public int getMeasuredPower()
Returns:
Measuredpower of the beacon (in dBm).
返回:
Beacon的实测功率(dBM)
getRssi
public int getRssi()
Returns:
ReceivedSignal Strength Indication at the moment of scanning.
返回:
在扫描时刻接收到的型号强度。
toString
public String toString()
Overrides:
equals
public boolean equals(Object o)
Overrides:
hashCode
public int hashCode()
Overrides:
describeContents
public int describeContents()
Specifiedby:
describeContents ininterface Parcelable
writeToParcel
public void writeToParcel(Parcel dest,
int flags)
Specifiedby:
writeToParcel ininterface Parcelable
com.estimote.sdk
Class BeaconManager
java.lang.Object
com.estimote.sdk.BeaconManager
public class BeaconManager
extends Object
This is a class that clients should use to interact withiBeacons. All name conventions come from iOS and Estimote iOS library. Itallows to:
这是一个客户端应该用来和iBeacons交互的类。所有命名约束来自IOS和EstimoteIOS库。他允许:
- range beacons (scan beacons and optionally filter them by their values)
- 测距beacons(扫描beacons并且根据它们的值可选地过滤)
- monitor beacons (track beacons in order to get events that device has entered or leaved regions of interest)
- 监测beacons(为了得到设备进入或离开特定区域的事件而跟踪beacons)
Typical use for ranging:
private static final String ESTIMOTE_PROXIMITY_UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";
private static final Region ALL_ESTIMOTE_BEACONS = new Region("rid", ESTIMOTE_PROXIMITY_UUID, null, null)
BeaconManager beaconManager = new BeaconManager(context);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override public void onBeaconsDiscovered(Region region, final List beacons) {
Log.d(TAG, "Ranged beacons: " + beacons);
}
});
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);
}
}
});
// When no longer needed. Note that ranging will stop.
beaconManager.disconnect();
It is a good practice to have only one instance of BeaconManager
perapplication stored in your Application
subclass.
最好在你的应用子类中只有一个BeaconManager实例。
This is wrapper around BeaconService
thatclients should use as implementation details of service can be changed in time.
它是一个BaconService的包装材料,服务的实现细节改变时,客户应该及时用。
Some methods throw RemoteException
.This can happen if service call happened and hosting process no longer exists(only if service is remote process).
有些方法会抛RemoteException错误。当服务呼叫发生并且当前进程不再存在时可能发生(仅当服务室远程进程时)
Nested Class Summary | |
| BeaconManager.ErrorListener 当电量低并且发生错误时触发的回调函数。 |
| BeaconManager.MonitoringListener 当beacons被发现在一个区域中时调用 |
| BeaconManager.RangingListener 当beacons被测距时被调用 |
| BeaconManager.ServiceReadyCallback 当服务准备用时被调用来通知客户 |
Constructor Summary | |
BeaconManager |
Method Summary | |
| checkPermissionsAndService 检查蓝牙权限和BeaconService是否在AndroidMainfest.XML中给出 |
| connect 连接到BeaconService |
| disconnect 从BeaconService中断开 |
| hasBluetooth 假如设备支持BLE的话返回true |
| isBluetoothEnabled 假如设备打开蓝牙返回true |
| setBackgroundScanPeriod 改变监测进行时默认的扫描周期 |
| setErrorListener 设置新的错误监听 |
| setForegroundScanPeriod 改变测距进行时默认的扫描周期 |
| setMonitoringListener 设置新的监视监听者。 |
| setRangingListener 设置新的测距监听者。 |
| startMonitoring |
| startRanging 开始对给出的区域进行测距修正 |
| stopMonitoring |
| stopRanging |
Methods inherited from class java.lang.Object |
clone |
Constructor Detail |
BeaconManager
public BeaconManager(Context context)
Constructs BeaconManager
instance.It's good practice to have only one per application stored in yourApplication
subclass.
Parameters:
context
-Context to wire up BeaconManager
.
Method Detail |
hasBluetooth
public boolean hasBluetooth()
Returnstrue if device supports Bluetooth Low Energy.
isBluetoothEnabled
public boolean isBluetoothEnabled()
Returnstrue if Bluetooth is enabled on the device. If not, you should ask user toenable it via:
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
checkPermissionsAndService
public boolean checkPermissionsAndService()
Checksif required Bluetooth permissions are set (android.permission.BLUETOOTH andandroid.permission.BLUETOOTH_ADMIN) along with BeaconService
inAndroidManifest.xml.
Returns:
True ifpermissions and service is declared in AndroidManifest.xml.
connect
public void connect(BeaconManager.ServiceReadyCallback callback)
Connectsto BeaconService
.
Parameters:
callback
-Callback to be invoked when connection is made to service.
disconnect
public void disconnect()
Disconnectsfrom BeaconService
.If there were any ranging or monitoring in progress, they will be stopped. Thisshould be typically called in onDestroy method.
从BeaconService中断开。假如它们在进程中测距或监听,它们会被停止。一般会调用onDestroy函数。
setRangingListener
public void setRangingListener(BeaconManager.RangingListener listener)
Sets newranging listener. Old one will be discarded.旧的会被忽略
Parameters:
listener
- Newlistener.
setMonitoringListener
public void setMonitoringListener(BeaconManager.MonitoringListener listener)
Sets newmonitoring listener. Old one will be discarded.
Parameters:
listener
- Newlistener.
setErrorListener
public void setErrorListener(BeaconManager.ErrorListener listener)
Sets newerror listener. Old one will be discarded.
Parameters:
listener
- Newerror listener.
setForegroundScanPeriod
public void setForegroundScanPeriod(long scanPeriodMillis,
long waitTimeMillis)
Changesdefaults scanning periods when ranging is performed. Default values:scanPeriod=1s, waitTime=0s
默认值为:scanPerid=1s,waitTime=0s
Parameters:
scanPeriodMillis
- Howlong to perform Bluetooth Low Energy scanning?
ScanPeridMillis-多久进行一次BLE扫描
waitTimeMillis
- Howlong to wait until performing next scanning?
WaitTimeMillis-当下一次扫描前等待多久
setBackgroundScanPeriod
public void setBackgroundScanPeriod(long scanPeriodMillis,
long waitTimeMillis)
Changesdefaults scanning periods when monitoring is performed. Default values:scanPeriod=5s, waitTime=25s
Parameters:
scanPeriodMillis
- Howlong to perform Bluetooth Low Energy scanning?
waitTimeMillis
- Howlong to wait until performing next scanning?
startRanging
public void startRanging(Region region)
throws RemoteException
Startsranging given range. Ranging results will be delivered to listener registeredviasetRangingListener(RangingListener)
.If given region is already ranged, this is no-op.
开始对给出的区域进行测距。测距结果会传递给通过setRandingListener(RangingListener)注册的接口。假如给定的区域已经被测距了,这会是空操作。
Parameters:
region
- Regionto range.
Throws:
RemoteException - Ifcommunication with service failed.
stopRanging
public void stopRanging(Region region)
throws RemoteException
Throws:
startMonitoring
public void startMonitoring(Region region)
throws RemoteException
Throws:
stopMonitoring
public void stopMonitoring(Region region)
throws RemoteException
Throws:
com.estimote.sdk
Interface BeaconManager.ErrorListener
Enclosing class:
public static interface BeaconManager.ErrorListener
Callback to be invoked when any error happened while performinglow energy scanning.
Method Summary | |
|
在BeaconService类中以ERROR_前缀定义的错误标识。 |
Method Detail |
onError
void onError(Integer errorId)
Erroridentifiers are defined in BeaconService
class with ERROR_ prefix.
com.estimote.sdk
Interface BeaconManager.MonitoringListener
Enclosing class:
public static interface BeaconManager.MonitoringListener
Callback to be invoked when beacons are discovered in a region.
Method Summary | |
|
|
|
|
Method Detail |
onEnteredRegion
void onEnteredRegion(Region region,
List<Beacon> beacons)
Parameters:
region
- Regionthat was monitored.
被监测的区域
beacons
- Listof beacons that triggered onEnteredRegion event. This list may not reflect allbeacons around that are matching given region.
触发onEnteredRegion事件的beacons列表。这个列表可能不会反应所有的在匹配区域中的beacons
onExitedRegion
void onExitedRegion(Region region)
com.estimote.sdk
Interface BeaconManager.RangingListener
Enclosing class:
public static interface BeaconManager.RangingListener
Callback to be invoked when beacons are ranged.
Method Summary | |
|
告诉监听者beacons当前在范围中。 |
Method Detail |
onBeaconsDiscovered
void onBeaconsDiscovered(Region region,
List<Beacon> beacons)
Tellslistener what beacons are currently in range. The list of beacons can be empty.List of beacons is sorted by accuracy.
Beacons的列表可能是空的。Beacons的列表以精确度排序。
Parameters:
region
- Regionthat was used for ranging.
beacons
- Listof beacons sorted by accuracy.
com.estimote.sdk
Interface BeaconManager.ServiceReadyCallback
Enclosing class:
public static interface BeaconManager.ServiceReadyCallback
Callback to inform client when service is ready to use.
Method Summary | |
|
Method Detail |
onServiceReady
void onServiceReady()
com.estimote.sdk
Class Region
java.lang.Object
com.estimote.sdk.Region
All Implemented Interfaces:
public class Region
extends Object
implements Parcelable
Defines a region based on device's proximity to a beacon. Regionis defined by proximity UUID, major and minor numbers of targeting beacons. Allof those can be nulls which means wildcard on that field.
定义一个基于设备和一个beacon相邻距离的区域。区域以UUID,major和minor匹配多个目标beacons定义。所有都可以为空,这意味着匹配所有的地点。
Region's identifier is introduced similarly to CLBeaconRegion
'sidentifier to uniquely identify region. You can use this identifier in the appto differentiate regions.
区域的标识和CLBeaconRegion的标识符相似,用来唯一的识别区域。你可以在app中用这个标识去区别区域。
This mimics CLBeaconRegion
fromiOS.
Nested Class Summary | |
|
描述当前位置和区域边界的关系。 |
Nested classes/interfaces inherited from interface android.os.Parcelable |
Field Summary | |
|
Fields inherited from interface android.os.Parcelable |
Constructor Summary | |
|
Method Summary | |
| |
| |
| |
| |
|
|
| |
|
|
Methods inherited from class java.lang.Object |
|
Field Detail |
CREATOR
public static final Parcelable.Creator<Region> CREATOR
Constructor Detail |
Region
public Region(String identifier,
String proximityUUID,
Integer major,
Integer minor)
Parameters:
identifier
- Aunique identifier for a region. Cannot be null.
proximityUUID
-Proximity UUID of beacons. Can be null. Null indicates all proximity UUIDs.
major
- Majorversion of the beacons. Can be null. Null indicates all major versions.
minor
- Minorversion of the beacons. Can be null. Null indicates all minor versions.
Method Detail |
getIdentifier
public String getIdentifier()
Returns:
Region'sunique identifier. Cannot be null.
区域的唯一标识,不能为空
getProximityUUID
public String getProximityUUID()
Returns:
ProximityUUID of targeting beacons.
目标beacons的UUID
getMajor
public Integer getMajor()
Returns:
Majorversion of targeting beacons.
getMinor
public Integer getMinor()
Returns:
Minorversion of targeting beacons.
toString
public String toString()
Overrides:
equals
public boolean equals(Object o)
Overrides:
hashCode
public int hashCode()
Overrides:
describeContents
public int describeContents()
Specifiedby:
describeContents
ininterface Parcelable
writeToParcel
public void writeToParcel(Parcel dest,
int flags)
Specifiedby:
writeToParcel
ininterface Parcelable
com.estimote.sdk
Enum Region.State
java.lang.Object
java.lang.Enum<Region.State>
com.estimote.sdk.Region.State
All Implemented Interfaces:
Serializable, Comparable<Region.State>
Enclosing class:
public static enum Region.State
extends Enum<Region.State>
Describes current location relationship with region bounds.
在给定区域的内部 | |
在给定区域的外部 |
Method Summary | |
|
用指定名字返回枚举常量。 |
|
返回一个包含枚举类型的常量数组,以它们声明的顺序。 |
Methods inherited from class java.lang.Enum |
|
Methods inherited from class java.lang.Object |
INSIDE
public static final Region.State INSIDE
Insidegiven region.
OUTSIDE
public static final Region.State OUTSIDE
Outsidegiven region.
Method Detail |
values
public static Region.State[] values()
Returnsan array containing the constants of this enum type, in the order they aredeclared. This method may be used to iterate over the constants as follows:
for (Region.State c : Region.State.values())
System.out.println(c);
Returns:
an arraycontaining the constants of this enum type, in the order they are declared
valueOf
public static Region.State valueOf(String name)
Returnsthe enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enumconstant in this type. (Extraneous whitespace characters are not permitted.)
这个字符串必须完全匹配一个用来声明这种类型的枚举常量的标志。(无关的空格串不被允许)
Parameters:
name
- thename of the enum constant to be returned.
Returns:
the enumconstant with the specified name
Throws:
IllegalArgumentException
- ifthis enum type has no constant with the specified name
假如没有枚举常量和指定名字匹配。
NullPointerException
- if theargument is null
假如参数为空
com.estimote.sdk
Class Utils
java.lang.Object
com.estimote.sdk.Utils
public class Utils
extends Object
Grab bag of utilities.
Nested Class Summary | |
|
定义beacon和设备的距离关系。 |
|
当蓝牙栈被重启时来通知的接口 |
Constructor Summary | |
|
Method Summary | |
|
分析scanRecord去查找厂商特定的数据,验证它并构造Beacon。 |
|
基于beacon的RSSI值和实测功率返回以米为单位的距离。 |
|
|
|
假如beacon匹配区域返回true。 |
|
从区域中将整形转化成无符号16位整形。 |
|
同过将UUID全部小写并且以”XXXXXXX-XXX..”的形式将UUID正常化 |
|
将字符串转化成整形 |
|
基于以米为单位的距离计算邻近关系。 |
|
重启设备的蓝牙栈。 |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
Utils
public Utils()
Method Detail |
beaconFromLeScan
public static Beacon beaconFromLeScan(BluetoothDevice device,
int rssi,
byte[] scanRecord)
Parses scanRecord
to lookfor manufacturer specific data, verifies that and constructs Beacon
.
Parameters:
device
-Bluetooth device found by BluetoothAdapter
.
通过BluetoothAdapter发现的蓝牙设备
scanRecord
-Bluetooth advertisement data.
蓝牙广播的数据
rssi
-Current RSSI between devices.
设备间当前的rssi。
Returns:
Constructed Beacon
or null if scanRecord
couldnot have been parsed.
构造Beacon或者当scanRecord不能被转换时为空。
normalizeProximityUUID
public static String normalizeProximityUUID(String proximityUUID)
Normalizesproximity UUID by making it lowercase and in formatXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX. Validates if there are 32 characters (notcounting dashes).
isBeaconInRegion
public static boolean isBeaconInRegion(Beacon beacon,
Region region)
Returnstrue if beacon matches the region. That is region's proximity UUID, major,minor matches beacon's ones. Or if region uses wildcard for any of thoseproperties.
当beacon匹配区域的时候返回真。这意味着区域的UUID,major,minor匹配beacon,或者区域用那些属性的通配符。
computeAccuracy
public static double computeAccuracy(Beacon beacon)
Returnsdistance in meters based on beacon's RSSI and measured power. Returns -1 whencannot compute accuracy.
proximityFromAccuracy
public static Utils.Proximity proximityFromAccuracy(double accuracy)
Computes Utils.Proximity
based on distance in meters. Currentdistance ranges:
· immediate: 0 - 0.5m
· near: 0.5m - 3.0m
· far: 3.0m - ...
Parameters:
accuracy
-Distance in meters.
Returns:
Proximitybetween device and beacon.
computeProximity
public static Utils.Proximity computeProximity(Beacon beacon)
parseInt
public static int parseInt(String numberAsString)
Parsesstring to integer. If string cannot be parsed, returns 0.
Parameters:
numberAsString
- Stringto be parsed.
Returns:
Integervalue or 0 if string cannot be parsed.
normalize16BitUnsignedInt
public static int normalize16BitUnsignedInt(int value)
Normalizesinteger to be unsigned 16-bit integer from range (1, 65535).
Parameters:
value
- Aninteger value.
Returns:
Normalizedunsigned 16-bit integer.
restartBluetooth
public static void restartBluetooth(Context context,
Utils.RestartCompletedListener listener)
RestartsBluetooth stack on the device.
Never invokethis method without user's explicit consent that Bluetooth on the device isgoing to be restarted.
Parameters:
context
-Context.
listener
-Listener to be invoked when Bluetooth stack is restarted.
com.estimote.sdk
Enum Utils.Proximity
java.lang.Object
java.lang.Enum<Utils.Proximity>
com.estimote.sdk.Utils.Proximity
All Implemented Interfaces:
Serializable, Comparable<Utils.Proximity>
Enclosing class:
public static enum Utils.Proximity
extends Enum<Utils.Proximity>
Defines distance relationship between beacon and the device.
Enum Constant Summary | |
| |
| |
| |
|
Method Summary | |
|
|
|
|
Methods inherited from class java.lang.Enum |
|
Methods inherited from class java.lang.Object |
Enum Constant Detail |
UNKNOWN
public static final Utils.Proximity UNKNOWN
Proximitycould not be determined.
IMMEDIATE
public static final Utils.Proximity IMMEDIATE
Immediatevicinity.
紧邻
NEAR
public static final Utils.Proximity NEAR
Relativelyclose.
相对近
FAR
public static final Utils.Proximity FAR
Faraway.
很远
Method Detail |
values
public static Utils.Proximity[] values()
Returnsan array containing the constants of this enum type, in the order they aredeclared. This method may be used to iterate over the constants as follows:
for (Utils.Proximity c : Utils.Proximity.values())
System.out.println(c);
Returns:
an arraycontaining the constants of this enum type, in the order they are declared
valueOf
public static Utils.Proximity valueOf(String name)
Returnsthe enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enumconstant in this type. (Extraneous whitespace characters are not permitted.)
Parameters:
name
- thename of the enum constant to be returned.
Returns:
the enumconstant with the specified name
Throws:
IllegalArgumentException
- ifthis enum type has no constant with the specified name
NullPointerException
- if theargument is null
com.estimote.sdk
Interface Utils.RestartCompletedListener
Enclosing class:
public static interface Utils.RestartCompletedListener
Interface used to notify called that Bluetooth stack has beenrestarted.
Method Summary | |
|
Method Detail |
onRestartCompleted
void onRestartCompleted()
com.estimote.sdk.connection
Interface BeaconConnection.ConnectionCallback
Enclosing class:
public static interface BeaconConnection.ConnectionCallback
Callback used to indicate state of the connection to the beacon.
指定和beacon连接状态的回调函数
Method Summary | |
|
当和beacon的连接建立时调用 |
|
当和beacon的验证出现错误时调用错误 |
|
当和beacon的连接断开时。 |
Method Detail |
onAuthenticated
void onAuthenticated(BeaconConnection.BeaconCharacteristics characteristics)
Invokedwhen connection to beacon is established.
Parameters:
characteristics
-Beacon's characteristics.
Beacon的特征
onAuthenticationError
void onAuthenticationError()
Invokedwhen there was a problem within authentication to the beacon.
onDisconnected
void onDisconnected()
Connectionwas closed to the beacon. Can happen when beacon is out of range.
com.estimote.sdk.connection
Interface BeaconConnection.WriteCallback
Enclosing class:
public static interface BeaconConnection.WriteCallback
Callback used to indicate status of updating beaconcharacteristic.
指向更新beacon 特征状态调用的回调函数
Method Summary | |
|
|
|
Method Detail |
onSuccess
void onSuccess()
onError
void onError()
com.estimote.sdk.connection
Class BeaconConnection
java.lang.Object
com.estimote.sdk.connection.BeaconConnection
public class BeaconConnection
extends Object
Establishes connection to the beacon and reads itscharacteristics.
建立和beacon的连接并且读取它的特征。
Exposes methods to change beacon's UUID, major, minor,advertising interval and broadcasting power values. You can only change thosevalues only if there is established connection to beacon.
用来改变beacon的UUID,major,minor,广播间隔和广播功率值得暴露函数。只有当连接到beacon时你才能改变那些值。
It is very important to close()
connection when it is not needed.
当不需要时关闭连接很重要。
Usage:
用法:
BeaconConnection connection = new BeaconConnection(context, beacon, new BeaconConnection.ConnectionCallback() {
@Override public void onAuthenticated(BeaconConnection.BeaconCharacteristics chars) {
Log.d(TAG, "Authenticated to beacon: " + chars);
}
@Override public void onAuthenticationError() {
Log.d(TAG, "Authentication Error");
}
@Override public void onDisconnected() {
Log.d(TAG, "Disconnected");
}
});
connection.authenticate();
// Interact with beacon.
// You can update characteristics via
// connection.write* methods
connection.close();
Nested Class Summary | |
|
Beacon特征的值对象(电池等级,广播能量,广播间隔,软件和硬件版本) |
|
|
|
|
Field Summary | |
允许的广播功率值。 |
Constructor Summary | |
|
Method Summary | |
|
开始和设备建立连接流,10秒超时。 |
|
关闭连接,或者取消正在连接的工作流。 |
|
当和beacon的连接成功建立时返回真。 |
|
改变beacon的广播间隔。 |
|
改变beacon的广播功率。 |
|
改变beacon的major值。 |
|
改变beacon的minor值。 |
|
改变beacon的UUID值。 |
Methods inherited from class java.lang.Object |
|
Field Detail |
ALLOWED_POWER_LEVELS
public static Set<Integer> ALLOWED_POWER_LEVELS
Allowedvalues of broadcasting power. Higher value means larger broadcasting power.
Constructor Detail |
BeaconConnection
public BeaconConnection(Context context,
Beacon beacon,
BeaconConnection.ConnectionCallback connectionCallback)
Method Detail |
authenticate
public void authenticate()
Startsconnection flow to device with 10s timeout.
close
public void close()
Closesconnection to beacon or cancels in-flight connection flow.
isConnected
public boolean isConnected()
Returnstrue if connection is successfully established with the beacon.
writeProximityUuid
public void writeProximityUuid(String proximityUuid,
BeaconConnection.WriteCallback writeCallback)
Changesproximity UUID of the beacon.
Parameters:
proximityUuid
- Stringrepresentation of the UUID (16 bytes encoded as hex with or without dashes).(16位16进制编码带或者不带破折号)
writeCallback
-Callback to be invoked when write is completed.
writeAdvertisingInterval
public void writeAdvertisingInterval(int intervalMillis,
BeaconConnection.WriteCallback writeCallback)
Changesadvertising interval of the beacon. Interval value will be normalized to fitthe range (50 - 2000 ms).间隔值会正常话去适应区域(50-2000毫秒)
Parameters:
intervalMillis
-Advertising interval in milliseconds.
writeCallback
-Callback to be invoked when write is completed.
当写完时调用
writeBroadcastingPower
public void writeBroadcastingPower(int powerDBM,
BeaconConnection.WriteCallback writeCallback)
Changesbroadcasting power of the beacon. Allowed values: -30, -20, -16, -12, -8, -4,0, 4. Larger value means stronger power.
允许的值:-30,-20,-16,-12,-8,-4,0,4。更大的值意味刚多的能量。
Parameters:
powerDBM
-Broadcasting power to be set.
设置的广播功率
writeCallback
-Callback to be invoked when write is completed.
SeeAlso:
writeMajor
public void writeMajor(int major,
BeaconConnection.WriteCallback writeCallback)
Changesmajor value of the beacon. Major value will be normalized to fit the range (1,65535).
Parameters:
major
- Majorvalue to be set.
writeCallback
-Callback to be invoked when write is completed.
writeMinor
public void writeMinor(int minor,
BeaconConnection.WriteCallback writeCallback)
Changesminor value of the beacon. Minor value will be normalized to fit the range (1,65535).
Parameters:
minor
- Minorvalue to be set.
writeCallback
-Callback to be invoked when write is completed.
com.estimote.sdk.connection
Class BeaconConnection.BeaconCharacteristics
java.lang.Object
com.estimote.sdk.connection.BeaconConnection.BeaconCharacteristics
Enclosing class:
public static class BeaconConnection.BeaconCharacteristics
extends Object
Value object for beacon's characteristics (battery level,broadcasting power, advertising interval, software and hardware version).
Those values can be read via BeaconConnection.authenticate()
and are delivered asynchronously inConnectionCallback#onAuthenticated(BeaconCharacteristics)
.
这些值可以通过BeaconConnection.authenticate()读取并且同时传递给inConnectionCallback#onAuthenticated(BeaconCharacteristics)
Constructor Summary | |
|
Method Summary | |
返回毫秒单位的广播间隔 | |
返回当前的电池等级 | |
返回广播功率 | |
返回硬件的版本 | |
返回操作系统版本 | |
返回可读的特征描述 |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
BeaconConnection.BeaconCharacteristics
public BeaconConnection.BeaconCharacteristics(EstimoteService estimoteService,
VersionService versionService)
Method Detail |
getBatteryPercent
public Integer getBatteryPercent()
ReturnsBattery level in percent.
getBroadcastingPower
public Byte getBroadcastingPower()
ReturnsBroadcasting power. @see BeaconConnection#ALLOWED_POWER_LEVELS
getAdvertisingIntervalMillis
public Integer getAdvertisingIntervalMillis()
ReturnsAdvertising interval in milliseconds.
getSoftwareVersion
public String getSoftwareVersion()
ReturnsVersion of operating system.
getHardwareVersion
public String getHardwareVersion()
ReturnsRevision of hardware.
toString
public String toString()
Humanreadable description of the characteriscts.
Overrides:
com.estimote.sdk.service
Class BeaconService
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.app.Service
com.estimote.sdk.service.BeaconService
All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2
public class BeaconService
extends Service
Don't use this class directly, use it via BeaconManager
.
Field Summary | |
|
当蓝牙服务因为某些原因不详开启低功耗扫描时发生 |
|
服务发送错误。 |
|
服务发送监测结果。 |
|
服务发送测距结果。 |
|
服务注册可以接收到错误的错误监听者 |
|
当app在前景时设置监测的扫描周期。 |
|
。。。测距周期 |
|
服务开始监测区域。 |
|
服务开始测距区域 |
|
服务开始停止监测区域。 |
|
|
Fields inherited from class android.app.Service |
|
Fields inherited from interface android.content.ComponentCallbacks2 |
|
Constructor Summary | |
Method Summary | |
|
|
| |
|
|
|
|
Methods inherited from class android.app.Service |
|
Methods inherited from class android.content.Context |
|
Methods inherited from class java.lang.Object |
|
Field Detail |
MSG_START_RANGING
public static final int MSG_START_RANGING
Servicestarts ranging region. Message contains Region
.
消息包含Region
SeeAlso:
MSG_STOP_RANGING
public static final int MSG_STOP_RANGING
Servicestops ranging region. Message contains String
(region id).
SeeAlso:
MSG_RANGING_RESPONSE
public static final int MSG_RANGING_RESPONSE
Servicesends ranging results. Message contains RangingResult
.
SeeAlso:
MSG_START_MONITORING
public static final int MSG_START_MONITORING
Servicestarts monitoring region. Message contains Region
.
SeeAlso:
MSG_STOP_MONITORING
public static final int MSG_STOP_MONITORING
Servicestops monitoring region. Message contains String
(region id).
SeeAlso:
MSG_MONITORING_RESPONSE
public static final int MSG_MONITORING_RESPONSE
Servicesends monitoring results. Message contains MonitoringResult
.
SeeAlso:
MSG_REGISTER_ERROR_LISTENER
public static final int MSG_REGISTER_ERROR_LISTENER
Serviceregisters error listener where errors can be send.
SeeAlso:
MSG_ERROR_RESPONSE
public static final int MSG_ERROR_RESPONSE
Servicesends error. Message contains Integer
as error id.
SeeAlso:
MSG_SET_FOREGROUND_SCAN_PERIOD
public static final int MSG_SET_FOREGROUND_SCAN_PERIOD
Setsscan periods for ranging, that is when app is in foreground. Message contains ScanPeriodData
.
SeeAlso:
MSG_SET_BACKGROUND_SCAN_PERIOD
public static final int MSG_SET_BACKGROUND_SCAN_PERIOD
Setsscan periods for monitoring, that is when app is in foreground. Messagecontains ScanPeriodData
.
SeeAlso:
ERROR_COULD_NOT_START_LOW_ENERGY_SCANNING
public static final int ERROR_COULD_NOT_START_LOW_ENERGY_SCANNING
Happenswhen Bluetooth service for some reason does not want to start low energyscanning. It is good indicator to restart Bluetooth stack.
SeeAlso:
Utils.restartBluetooth(Context,com.estimote.sdk.Utils.RestartCompletedListener)
, Constant Field Values
Constructor Detail |
BeaconService
public BeaconService()
Method Detail |
onCreate
public void onCreate()
Overrides:
onDestroy
public void onDestroy()
Overrides:
onBind
public IBinder onBind(Intent intent)
Specifiedby:
startMonitoring
public void startMonitoring(com.estimote.sdk.service.MonitoringRegion monitoringRegion)
stopMonitoring
public void stopMonitoring(String regionId)
com.estimote.sdk.service
Class MonitoringResult
java.lang.Object
com.estimote.sdk.service.MonitoringResult
All Implemented Interfaces:
public class MonitoringResult
extends Object
implements Parcelable
Data object for results from ranging.
测距的数据结果对象
Nested Class Summary |
Nested classes/interfaces inherited from interface android.os.Parcelable |
Field Summary | |
触发进入状态的beacons集合 | |
| |
这些结果对应的区域。 | |
我们是进入还是离开区域 |
Fields inherited from interface android.os.Parcelable |
Constructor Summary | |
|
Method Summary | |
| |
| |
|
|
| |
|
|
Methods inherited from class java.lang.Object |
|
Field Detail |
region
public final Region region
Regionfor which these results are for.
state
public final Region.State state
Did weenter or exit the region?
beacons
public final List<Beacon> beacons
Collectionof beacons that triggered ENTER state.
CREATOR
public static final Parcelable.Creator<MonitoringResult> CREATOR
Constructor Detail |
MonitoringResult
public MonitoringResult(Region region,
Region.State state,
Collection<Beacon> beacons)
Method Detail |
equals
public boolean equals(Object o)
Overrides:
hashCode
public int hashCode()
Overrides:
toString
public String toString()
Overrides:
describeContents
public int describeContents()
Specifiedby:
describeContents
ininterface Parcelable
writeToParcel
public void writeToParcel(Parcel dest,
int flags)
Specifiedby:
writeToParcel
ininterface Parcelable
com.estimote.sdk.service
Class RangingResult
java.lang.Object
com.estimote.sdk.service.RangingResult
All Implemented Interfaces:
public final class RangingResult
extends Object
implements Parcelable
Data object for results from ranging. Consists of range forwhich scanning was made and collection of found beacons in the range.Collection of beacons is sorted by its accuracy.
测距的数据结果对象。由测距组成,开始扫描和在区域内找到的beacons的对象组成。Beacons集合以精确度排序。
Nested Class Summary |
Nested classes/interfaces inherited from interface android.os.Parcelable |
Field Summary | |
| |
| |
|
Fields inherited from interface android.os.Parcelable |
Constructor Summary | |
|
Method Summary | |
| |
| |
|
|
| |
|
|
Methods inherited from class java.lang.Object |
|
Field Detail |
region
public final Region region
Regionfor which these results are for.
beacons
public final List<Beacon> beacons
Collectionof ranged beacons.
CREATOR
public static final Parcelable.Creator<RangingResult> CREATOR
Constructor Detail |
RangingResult
public RangingResult(Region region,
Collection<Beacon> beacons)
Method Detail |
equals
public boolean equals(Object o)
Overrides:
hashCode
public int hashCode()
Overrides:
toString
public String toString()
Overrides:
describeContents
public int describeContents()
Specifiedby:
describeContents
ininterface Parcelable
writeToParcel
public void writeToParcel(Parcel dest,
int flags)
Specifiedby:
writeToParcel
ininterface Parcelable
com.estimote.sdk.service
Class ScanPeriodData
java.lang.Object
com.estimote.sdk.service.ScanPeriodData
All Implemented Interfaces:
public final class ScanPeriodData
extends Object
implements Parcelable
Data object containing values for setting scan periods.
包含设置扫描周期的数据对象
Nested Class Summary |
Nested classes/interfaces inherited from interface android.os.Parcelable |
Field Summary | |
| |
|
|
|
|
Fields inherited from interface android.os.Parcelable |
Constructor Summary | |
|
Method Summary | |
| |
| |
|
|
| |
|
|
Methods inherited from class java.lang.Object |
|
Field Detail |
scanPeriodMillis
public final long scanPeriodMillis
How longwe perform low energy scanning and restarting the scan.
waitTimeMillis
public final long waitTimeMillis
How longwe wait before starting a new low energy scan.
CREATOR
public static final Parcelable.Creator<ScanPeriodData> CREATOR
Constructor Detail |
ScanPeriodData
public ScanPeriodData(long scanPeriodMillis,
long waitTimeMillis)
Method Detail |
equals
public boolean equals(Object o)
Overrides:
hashCode
public int hashCode()
Overrides:
toString
public String toString()
Overrides:
describeContents
public int describeContents()
Specifiedby:
describeContents
ininterface Parcelable
writeToParcel
public void writeToParcel(Parcel dest,
int flags)
Specifiedby:
writeToParcel
ininterface Parcelable
com.estimote.sdk.utils
Class L
java.lang.Object
com.estimote.sdk.utils.L
public class L
extends Object
L stands for logging.
Constructor Summary | |
|
Method Summary | |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
|
Methods inherited from class java.lang.Object |
|
Constructor Detail |
L
public L()
Method Detail |
enableDebugLogging
public static void enableDebugLogging(boolean enableDebugLogging)
Enablesdebug logging of the Estimote SDK.
允许调试EstimoteSDK的日志
Parameters:
enableDebugLogging
-Whether enable debug logging.
enableCrashlyticsLogging
public static void enableCrashlyticsLogging(boolean enableCrashlytics)
v
public static void v(String msg)
d
public static void d(String msg)
i
public static void i(String msg)
w
public static void w(String msg)
e
public static void e(String msg)
e
public static void e(String msg,
Throwable e)
wtf
public static void wtf(String msg)
wtf
public static void wtf(String msg,
Exception exception)