Android   电子/物联      Android蓝牙开发   
文章目录  [隐藏]

1.准备

1)初始化Manager

2)判断可用状态

3)开启硬件

2.扫描方式1

1)扫描回调

2)执行扫描

2.扫描方式2

1)广播接收器

2)广播过滤器

3)启动广播

3.连接

1)连接回调-GATT连接

2)连接设备

3)断开设备

4.获取蓝牙设备提供的服务

1)开放设备的服务

2)获取服务列表

执行上一步后,gatt对象回调BluetoothGattCallback中的onServicesDiscovered方法。

5.读写BluetoothGattCharacteristic

1)读

执行上一步后,gatt对象回调 BluetoothGattCallback 中的 onCharacteristicRead 方法。

2)更新

执行上一步后,gatt对象回调 BluetoothGattCallback 中的 onCharacteristicWrite 方法。

3)开启设备的通知功能

ServiceUUID:00000001-0000-1000-8000-00805f9b34fb
CharacteristicUUID:00000003-0000-1000-8000-00805f9b34fb
DescriptorUUID:00002902-0000-1000-8000-00805f9b34fb


当蓝牙设备有交互,BluetoothGattCallback的onCharacteristicChanged方法会响应。

承接App定制、企业web站点、办公系统软件 设计开发,外包项目,毕设