使用蓝牙通讯,有些手机型号会向智能设备发送命令时失败
解决方法:
再 onServicesDiscovered 方法中 添加
for(BluetoothGattDescriptor dp:characteristic.getDescriptors()){
dp.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(dp);
}
其中 ENABLE_NOTIFICATION_VALUE 表示用于启用客户端配置描述符的通知的值