-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GATT notifications : use setCharacteristicNotification from Android 4.3 #307
base: master
Are you sure you want to change the base?
Conversation
…bscribe to notification from Android 4.3.
@fmhun The |
You are right ... I can't really explain what's happening but adding the I also removed |
I remember looking into this when originally working on the plugin, but it's been two years. Let me take a look. The Android example app has it call setCharacteristicNotification first. It's also only writing the descriptor if it's a heart beat UUID... Since this was originally developed for a heart rate related app, maybe my code only works for heart rate monitors. I'm surprised no one else has faced the issue... What type of device are you connecting to? |
Hi @randdusing, I don't think I'm the only one facing this issue, @kgillespieanaren reported the bug in issue #266. Sorry for having referenced the #294 it was a mistake ... I'm working with a custom and not commercialized BLE device. The device works perfectly on iOS with your plugin. |
AFAIK, There's potentially a race condition between when the android device writes to the ex.) Current workflow without this branch is outlined below. If a notification/indication is sent before step 2 or 3, I believe the Android device would ignore it; Resulting in behaviour witnessed above.
A better solution may involve:
Edit: https://stackoverflow.com/a/38807905/1404126:
|
Hi,
This pull request solve a critical bug in gatt notification. I experienced the issue #294 on Android 5.1 (Nexus 6) and Android 6.0 (Samsung S6).
In my case, the subscribe success callback was called first with the status
subscribed
but was never called with the statussubscribedResult
. After receiving the statussubscribed
, the subscribe error callback was called with anisDisconnected
error.The Android documentation (https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification) say that we must call the
BluetoothGatt#setCharacteristicNotification()
to enable/disable characteristic notification.This method call is missing in the
BluetoothLePlugin#subscribeAction()
andBluetoothLePlugin#unsubscribeAction()
methods.Note : The
BluetoothGatt#setCharacteristicNotification()
method is available in the SDK from jelly bean.