Android Pairing Issues
See original GitHub issueVersion
- react-native-ble-manager v6.0.0
- react-native v0.47.1
- iOS/Android 6.0.1 (Android) 10.3.3 (iOS)
Expected behaviour
Writing to a characteristic requiring authentication should trigger a pairing request and a promise rejection on authentication failure.
On authentication failure, subsequent writes should error with a valid message.
Actual behaviour
On iOS everything works well:
A pairing prompt is presented upon trying to write to a characteristic requiring authentication (good?). If an invalid passkey is provided, or if cancel is pressed, write then rejects with an Encryption is insufficient.
error (good?). Subsequent writes fail with Authentication is insufficient.
error (good?).
If a valid passkey is entered, subsequent writes resolve (good?).
On Android:
A pairing prompt is presented upon trying to write to a characteristic requiring authentication (good?). If an invalid passkey is provided, or if cancel is pressed, write does not reject (bad?). Subsequent writes fail with You're already writing
error (bad?).
If a valid passkey is entered, subsequent writes reject with You're already writing
(bad?).
I added some breakpoints to the Android source code. gatt.writeCharacteristic(characteristic)
succeeds but onCharacteristicWrite
never gets called. writeCallback
does not get set to null.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
I’m interested in this issue as well. I also suffer a lot when handling secure BLE + Android platform.
@marcosinigaglia I think a reliable way to dealing with this is to bridge the
createBond
API to JavaScript, let the app itself control whether to use any Bluetooth secure feature.With this API, app can make sure the secure BLE link is setup then proceed following characteristics read/write.
I think this is quite important and I will try to implement this when I’m available.
BTW, @mateusz- I’m also wondering why the Android didn’t fire any error when accessing a characteristic requiring auth. It seems that Android simply ignore the write command without complaining. Is this issue happens on certain device or all devices?
I got the same error message “You’re already writing” on android when I hit a button which writes data to a bluetooth characteristic repeatedly as fast as possible. I found this snippet in the
write(...)
method of Peripheral class:When I commented it out, my problem gone. Is it needed to wait for the success of the previous written to write again?