public abstract class BluetoothGattCallback
extends Object
| java.lang.Object | |
| android.bluetooth.BluetoothGattCallback | |
这个抽象类用于实现 BluetoothGatt回调。
Public constructors |
|
|---|---|
BluetoothGattCallback() |
|
公共方法(Public methods) |
|
|---|---|
void |
onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) 由于远程特征通知而触发的回叫。 |
void |
onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) 回叫报告特征读取操作的结果。 |
void |
onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) 表示特征写入操作结果的回调。 |
void |
onConnectionStateChange(BluetoothGatt gatt, int status, int newState) 回叫指示GATT客户端何时连接到远程GATT服务器/从远程GATT服务器断开连接。 |
void |
onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) 回调报告描述符读取操作的结果。 |
void |
onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) 回调,指示描述符写入操作的结果。 |
void |
onMtuChanged(BluetoothGatt gatt, int mtu, int status) 指示给定设备连接的MTU的回叫已更改。 |
void |
onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) 回拨报告远程设备连接的RSSI。 |
void |
onReliableWriteCompleted(BluetoothGatt gatt, int status) 当可靠的写入事务完成时调用回调。 |
void |
onServicesDiscovered(BluetoothGatt gatt, int status) 当远程设备的远程服务,特性和描述符列表已更新时(即发现新服务),调用回调。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
void onCharacteristicChanged (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
由于远程特征通知而触发的回叫。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client the characteristic is associated with |
characteristic |
BluetoothGattCharacteristic: Characteristic that has been updated as a result of a remote notification event. |
void onCharacteristicRead (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
回叫报告特征读取操作的结果。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked readCharacteristic(BluetoothGattCharacteristic) |
characteristic |
BluetoothGattCharacteristic: Characteristic that was read from the associated remote device. |
status |
int: GATT_SUCCESS if the read operation was completed successfully. |
void onCharacteristicWrite (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
表示特征写入操作结果的回调。
如果在进行可靠的写入事务时调用此回调,则该特性的值表示远程设备报告的值。 应用程序应将此值与要写入的期望值进行比较。 如果值不匹配,则应用程序必须中止可靠的写入事务。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked writeCharacteristic(BluetoothGattCharacteristic) |
characteristic |
BluetoothGattCharacteristic: Characteristic that was written to the associated remote device. |
status |
int: The result of the write operation GATT_SUCCESS if the operation succeeds. |
void onConnectionStateChange (BluetoothGatt gatt, int status, int newState)
回叫指示GATT客户端何时连接到远程GATT服务器/从远程GATT服务器断开连接。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client |
status |
int: Status of the connect or disconnect operation. GATT_SUCCESS if the operation succeeds. |
newState |
int: Returns the new connection state. Can be one of STATE_DISCONNECTED or STATE_CONNECTED |
void onDescriptorRead (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
回调报告描述符读取操作的结果。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked readDescriptor(BluetoothGattDescriptor) |
descriptor |
BluetoothGattDescriptor: Descriptor that was read from the associated remote device. |
status |
int: GATT_SUCCESS if the read operation was completed successfully |
void onDescriptorWrite (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
回调,指示描述符写入操作的结果。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked writeDescriptor(BluetoothGattDescriptor) |
descriptor |
BluetoothGattDescriptor: Descriptor that was writte to the associated remote device. |
status |
int: The result of the write operation GATT_SUCCESS if the operation succeeds. |
void onMtuChanged (BluetoothGatt gatt, int mtu, int status)
指示给定设备连接的MTU的回叫已更改。 此回调是为响应requestMtu(int)函数或响应连接事件而触发的。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked requestMtu(int) |
mtu |
int: The new MTU size |
status |
int: GATT_SUCCESS if the MTU has been changed successfully |
void onReadRemoteRssi (BluetoothGatt gatt, int rssi, int status)
回拨报告远程设备连接的RSSI。 这个回调是为了响应readRemoteRssi()函数而触发的。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked readRemoteRssi() |
rssi |
int: The RSSI value for the remote device |
status |
int: GATT_SUCCESS if the RSSI was read successfully |
void onReliableWriteCompleted (BluetoothGatt gatt, int status)
当可靠的写入事务完成时调用回调。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked executeReliableWrite() |
status |
int: GATT_SUCCESS if the reliable write transaction was executed successfully |
void onServicesDiscovered (BluetoothGatt gatt, int status)
当远程设备的远程服务,特性和描述符列表已更新时(即发现新服务),调用回调。
| 参数(Parameters) | |
|---|---|
gatt |
BluetoothGatt: GATT client invoked discoverServices() |
status |
int: GATT_SUCCESS if the remote device has been explored successfully. |