/** * 用于实现 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) {    }}

BluetoothGattCallback的更多相关文章

  1. Android BLE 蓝牙编程(三)

    上节我们已经可以连接上蓝牙设备了. 本节我们就要获取手环的电池电量和计步啦. 在介绍这个之前我们需要先了解下什么是 服务 什么是 UUID 我们记得上节中我们item监听事件的回调的返回值是Bluet ...

  2. Android BLE 蓝牙编程(二)

    大家中秋快乐啊--哈哈,今天继续工程项目吧! 上篇我们已经实现了蓝牙设备的扫描,本篇我们来通过list展示扫描到的设备并 实现点击连接. 先贴出上篇的完整的MainActivity的方法: packa ...

  3. BLE教程 - 官方tutorial翻译

    关键术语和概念 1. Generic Attribute Profile(GATT)GATT配置文件是一个通用规范,用于在BLE链路上发送和接收被称为"属性"的数据块.目前所有的B ...

  4. BLE编程中关键步骤

    获取权限 <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permiss ...

  5. Android 蓝牙4.0 BLE

    Android ble (Bluetooth Low Energy) 蓝牙4.0,也就是说API level >= 18,且支持蓝牙4.0的手机才可以使用. BLE是蓝牙4.0的核心Profil ...

  6. Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现

    http://blog.csdn.net/wave_1102/article/details/39271693 分类: Android(105) 作者同类文章X Android4.3 规范了BLE的A ...

  7. Bluetooth Low Energy——蓝牙低功耗

    Android4.3(API级别18)引入内置平台支持BLE的central角色,同时提供API和app应用程序用来发现设备,查询服务,和读/写characteristics.与传统蓝牙(Classi ...

  8. Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)

    背景 在学习BLE的过程中,积累了一些心得的DEMO,放到Github,形成本文.感兴趣的同学可以下载到源代码. github: https://github.com/vir56k/bluetooth ...

  9. 蓝牙防丢器原理、实现与Android BLE接口编程

    本文是对已实现的蓝牙防丢器项目的总结,阐述蓝牙防丢器的原理.实现与android客户端的蓝牙BLE接口编程.在这里重点关注如何利用BLE接口来进行工程实现,对于BLE的协议.涉及到JNI的BLE接口内 ...

随机推荐

  1. 19.1-uC/OS-III内存管理应用

    一个处理器,在不断地分配和释放内存的过程中,一整块连续的内存被分散为很多离散的小块内存, 这些叫做内存碎片, 内存碎片过多会导致内存的浪费. uC/OS 的内存管理机制就是为了尽量减少内存碎片.大致的 ...

  2. nginx安装lua模块实现高并发

    nginx安装lua扩展模块 1.下载安装LuaJIT-2.0.4.tar.gz wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz tar ...

  3. hibernate重要知识点总结

    一.使用注解方式-----实体和表之间的映射 配置spring的applicationContext.xml文件: <bean id="sessionFactory" cla ...

  4. 0003-20180422-自动化第三章-python基础学习笔记

    3章 内容回顾: 1. 计算机组成 2. 程序编译器 3. 变量 4. 条件 5. 循环 6. py2与py3区别 - 默认编码, - 除法, - input ,raw_input 7. 位,字节关系 ...

  5. win10安装JDK

    1.下载 首先,在官网下载 JDK:Oracle 官网 如上图所示,在 Oracle 官网下载 JDK,有一点需要注意,那就是在咱们下载合适的 JDK 之前,需要先点击“标记1”所在的按钮,选择接受. ...

  6. Java课程总结

    预备作业一 简要内容:我期望的师生关系 预备作业二 简要内容:学习基础和C语言基础调查 预备作业三 简要内容:Linux安装及学习 第一周作业 简要内容:Java入门 第二周作业 简要内容:学习基本数 ...

  7. DataGridView 访问任意行不崩溃

    int index= this.dataGridView1.rows.Add(); 先执行这行代码,然后访问任意行,不崩溃, 赋值不存在的行,只是不显示,或者无值. 什么原理呢? 一些其他 priva ...

  8. SpringDataJpa开发环境的搭建以及使用

    一.所需工具 安装jdk.IntelliJ IDEA和mysql数据库. 二.SpringDataJpa快速起步 开发环境的搭建: ①.在IDEA软件上添加依赖包:在http://mvnreposit ...

  9. C#异步编程基础入门总结

    1.前言 *.NET Framework提供了执行异步操作的三种模式: 异步编程模型(APM)模式(也称为IAsyncResult的模式),其中异步操作要求Begin和End方法(例如,BeginWr ...

  10. springMVC学习路线3-整合spring(annotion方式)

    个人认为使用框架并不是很难,关键要理解其思想,这对于我们提高编程水平很有帮助.不过,如果用都不会,谈思想就变成纸上谈兵了!!!先技术,再思想.实践出真知. 1.基本概念 1.1 Spring   Sp ...