Reputation: 99
I am trying to build an app to get data from accelerometer through BLE.
As per the android developer site I am using function setCharacteristicNotification(characteristic, true)
to start data streaming from BLE device.
But when callingsetCharacteristicNotification(characteristic, false)
to stop data streaming, it works sometime and sometime not.
I couldn't figure out what is going wrong, as I m doing everything according to information given in Android Developer Site
Can Anyone please give exact process how to stop data streaming i.e. how to successfully setCharacteristicNotification(characteristic, false)
.
Thanks in advance.
Upvotes: 0
Views: 929
Reputation: 18452
The setCharacteristicNotification
method only tells the Bluetooth stack in Android if it should forward notifications/indications to your app. You also need to write the configuration to the Client Characteristic Configuration descriptor. See Why does setCharacteristicNotification() not actually enable notifications?, and use https://developer.android.com/reference/android/bluetooth/BluetoothGattDescriptor.html#DISABLE_NOTIFICATION_VALUE.
Upvotes: 2