If we call setCharacteristicNotification on a character, not giving Remote Notification on value Change? How to enable the remote Notification on a Central Device in Bluetooth LE ?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
TO enable Remote Notification on Android,
setCharacteristicNotification(characteristic, enable) is not enough.
Need to write the descriptor for the characteristic. Peripheral has to enable characteristic notification while creating the characteristic.
Once the Notify is enabled , it will have a descriptor with handle 0x2902 . so we need to write BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE to the descriptor. First Convert 0x2902 to 128 bit UUID, it will be like this 00002902-0000-1000-8000-00805f9b34fb (Base Bluetooth UUID is 0000xxxx-0000-1000-8000-00805f9b34fb).
i also receive null value when call descrpitor.setValue, so i just turn it on when discovering service and finally it works very well:
to notify master device that some characteristic is change, call this function on your pheripheral:
in your master device: enable setCharacteristicNotification after discover the service:
now you can check your characteristic value is change, for example onCharacteristicRead function :
To enable notification you should do as following.
of which definition is as following.
Still if remote notification does not work, try to read characteristics only after enabling notifications for the same.
Reading characteristics is as