Most visited

Recently visited

Added in API level 18

BluetoothGattCallback

public abstract class BluetoothGattCallback
extends Object

java.lang.Object
   ↳ android.bluetooth.BluetoothGattCallback


这个抽象类用于实现 BluetoothGatt回调。

Summary

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

From class java.lang.Object

Public constructors

BluetoothGattCallback

Added in API level 18
BluetoothGattCallback ()

Public methods

onCharacteristicChanged

Added in API level 18
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.

onCharacteristicRead

Added in API level 18
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.

onCharacteristicWrite

Added in API level 18
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.

onConnectionStateChange

Added in API level 18
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

onDescriptorRead

Added in API level 18
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

onDescriptorWrite

Added in API level 18
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.

onMtuChanged

Added in API level 21
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

onReadRemoteRssi

Added in API level 18
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

onReliableWriteCompleted

Added in API level 18
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

onServicesDiscovered

Added in API level 18
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.

Hooray!