question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android Pairing Issues

See original GitHub issue

Version

  • 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:closed
  • Created 6 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
whitedogg13commented, Sep 9, 2017

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?

1reaction
dreamlovercommented, Apr 27, 2019

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:

if (writeCallback != null) {
	callback.invoke("You're already writing");
}

When I commented it out, my problem gone. Is it needed to wait for the success of the previous written to write again?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Bluetooth problems on Android - Google Support
Step 1: Check Bluetooth basics · Turn Bluetooth off and then on again. Learn how to turn Bluetooth on and off. · Confirm...
Read more >
12 Quick Ways to Fix Bluetooth Problems on Android Devices
1. Try to Connect With a Different Device · 2. Turn Off Bluetooth and Then Turn It On Again · 3. Unpair the...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
1. Make sure Bluetooth is turned on · 2. Determine which pairing process your device employs · 3. Turn on discoverable mode ·...
Read more >
[Working] 5 Ways to Fix Bluetooth Not Working on Android Issue
Fix Bluetooth Not Working on Android Issue · 1. Restart Your Phone · 2. Forget Device and Pair · 3. Check Bluetooth Device...
Read more >
How To Fix Android Bluetooth Problems - Technobezz
Start by restarting your phone. A restart fixes simple errors and helps your phone start afresh. Switch on Bluetooth by pulling down your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found