蓝牙bleonCharacteristicChanged不调用的问题
前言
在学的时候用的大佬开源的程序,发现onCharacteristicChanged一直没有调用
大佬的文章1程序 https://www.jianshu.com/p/d991f0fdec63
2入门相关 https://zhuanlan.zhihu.com/p/56887613
首先是注册notify回调的问题
3 https://blog.csdn.net/jdfkldjlkjdl/article/details/103925128
然后就是UUID了,文章1里注册notify的uuid不知道为什么有问题。
mBluetoothGatt.setCharacteristicNotification(mBluetoothGatt
.getService(notify_UUID_service).getCharacteristic(notify_UUID_chara),true);
这里的notify_UUID_chara和notify_UUID_service是软件获取的,不知道为什么notify的不对,wirte的就是对的。这个程序连接服务时显示一串uuid信息,和write服务一样的uuid就是正确的notify的uuid。
mBluetoothGatt.setCharacteristicNotification(mBluetoothGatt
.getService(UUID.fromString(nos)).getCharacteristic(UUID.fromString(noc)), true);
修改uuid正确就行了。