/** * 用于实现 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) {    }}
05-11 16:15