BluetoothGattCallback

/**
* 用于实现 BluetoothGatt 的回调
*/
public abstract class BluetoothGattCallback {

/**
* GATT客户端连接或断开到远程的时候。
*
* @param gatt GATT客户端
* @param status 连接或者断开操作时的状态。
* {BluetoothGatt#GATT_SUCCESS} 如果操作成功。
* @param newState 返回新的连接状态。{BluetoothProfile#STATE_DISCONNECTED}或者
* {BluetoothProfile#STATE_CONNECTED}
*/
public void onConnectionStateChange(BluetoothGatt gatt, int status,
int newState) {
}

/**
* 远程服务列表时调用的回调函数,远程设备的 characteristics 和 descriptors 已经更新,
* 已经发现了新服务。
*
* @param gatt 调用了{BluetoothGatt#discoverServices}的GATT客户端
* @param status 如果远程设备已经成功探索,状态为{BluetoothGatt#GATT_SUCCESS}
*/
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
}

/**
* 报告一个 characteristic 读取操作的结果。
*
* @param gatt 调用了{BluetoothGatt#readCharacteristic}的GATT客户端
* @param characteristic 从关联的远程设备读取的 Characteristic
* @param status 如果读取操作成功完成,状态为{BluetoothGatt#GATT_SUCCESS}
*/
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
int status) {
}

/**
* characteristic写入操作结果的回调.
*
* <p>If this callback is invoked while a reliable write transaction is
* in progress, the value of the characteristic represents the value
* reported by the remote device. An application should compare this
* value to the desired value to be written. If the values don't match,
* the application must abort the reliable write transaction.
*
* @param gatt 调用了{BluetoothGatt#writeCharacteristic}的GATT客户端
* @param characteristic 写入关联的远程设备的 Characteristic
* @param status 写入操作的结果,如果操作成功,状态为{BluetoothGatt#GATT_SUCCESS}
*/
public void onCharacteristicWrite(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic, int status) {
}

/**
* 由于远程 characteristic 通知而触发的回调。
*
* @param gatt GATT client the characteristic is associated with
* @param characteristic 由于远程通知事件而更新的 Characteristic
*/
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
}

/**
* Callback reporting the result of a descriptor read operation.
*
* @param gatt GATT client invoked {@link BluetoothGatt#readDescriptor}
* @param descriptor Descriptor that was read from the associated
* remote device.
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation
* was completed successfully
*/
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
int status) {
}

/**
* Callback indicating the result of a descriptor write operation.
*
* @param gatt GATT client invoked {@link BluetoothGatt#writeDescriptor}
* @param descriptor Descriptor that was writte to the associated
* remote device.
* @param status The result of the write operation
* {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
*/
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
int status) {
}

/**
* Callback invoked when a reliable write transaction has been completed.
*
* @param gatt GATT client invoked {@link BluetoothGatt#executeReliableWrite}
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write
* transaction was executed successfully
*/
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
}

/**
* Callback reporting the RSSI for a remote device connection.
*
* This callback is triggered in response to the
* {@link BluetoothGatt#readRemoteRssi} function.
*
* @param gatt GATT client invoked {@link BluetoothGatt#readRemoteRssi}
* @param rssi The RSSI value for the remote device
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the RSSI was read successfully
*/
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
}

/**
* Callback indicating the MTU for a given device connection has changed.
*
* This callback is triggered in response to the
* {@link BluetoothGatt#requestMtu} function, or in response to a connection
* event.
*
* @param gatt GATT client invoked {@link BluetoothGatt#requestMtu}
* @param mtu The new MTU size
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the MTU has been changed successfully
*/
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
}
}

转载于:https://www.cnblogs.com/bky1225987336/p/8919853.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值