您的位置:首页 > 移动开发 > Android开发

低功耗蓝牙(BLE)之概念理解

2016-04-11 23:46 363 查看


如上图所示:

Android中进行蓝牙开发需要使用到的类的执行过程是:

使用BluetoothAdapter.startLeScan来扫描低功耗蓝牙设备

在扫描到设备的回调函数中会得到BluetoothDevice对象,并使用BluetoothAdapter.stopLeScan停止扫描

使用BluetoothDevice.connectGatt来获取到BluetoothGatt对象

执行BluetoothGatt.discoverServices,这个方法是异步操作,在回调函数onServicesDiscovered中得到status,通过判断status是否等于BluetoothGatt.GATT_SUCCESS来判断查找Service是否成功

如果成功了,则通过BluetoothGatt.getService来获取BluetoothGattService

接着通过BluetoothGattService.getCharacteristic获取BluetoothGattCharacteristic

然后通过BluetoothGattCharacteristic.getDescriptor获取BluetoothGattDescriptor
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 蓝牙 BLE