遇到的坑
无法接收到蓝牙消息
在选定了Characteristic之后,通过BluetoothGatt.setCharacteristicNotification()设置结果虽然返回true但是无效;原因是没有修改Characteristic的Descriptor;
以下解决方案转自:https://blog.csdn.net/x283930450/article/details/80674263
/**
* Enables or disables notification on a give characteristic.
*
* @param characteristic Characteristic to act on.
* @param enabled If true, enable notification. False otherwise.
*/
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
boolean enabled) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
// mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
boolean isEnableNotification =<