Skip to content
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

[Android] "Error, gatt is null" during nextCommand processing leaves callback unfulfilled #1291

Open
polovi opened this issue Nov 26, 2024 · 1 comment

Comments

@polovi
Copy link

polovi commented Nov 26, 2024

Describe the bug
"Error, gatt is null" during nextCommand processing leaves callback unfulfilled. Whole commandQueue is cleared. There is no response back to react-native that some error happen during processing.

if (gatt == null) {
Log.d(BleManager.LOG_TAG, "Error, gatt is null");
commandQueue.clear();
commandQueueBusy = false;
return;
}

To Reproduce
Hard to reproduce, we have a device that for some reason sometimes ends up in a strange state and breaks bluetooth communication. If this error can happen, it should be handled better.

Expected behavior
Errors should be handled inside commands and properly reported back through their callback.

Version:

  • react-native-ble-manager version: 11.5.7

Additional context

2024-11-26 17:42:01.157 17752-17823 RNBleManager            com.rnapp                  D  Connect to: FB:83:98:81:E6:0D
2024-11-26 17:42:01.161 17752-17752 RNBleManager            com.rnapp                  I  DiscoverPeripheral: null
2024-11-26 17:42:01.213 17752-17752 RNBleManager            com.rnapp                  D  Is Or Greater than M $mBluetoothDevice
2024-11-26 17:42:01.238 17752-18853 RNBleManager            com.rnapp                  D  onConnectionStateChange to 2 on peripheral: FB:83:98:81:E6:0D with status 0
2024-11-26 17:42:01.249 17752-17752 RNBleManager            com.rnapp                  D  Peripheral event (BleManagerConnectPeripheral):FB:83:98:81:E6:0D
2024-11-26 17:42:01.249 17752-17752 RNBleManager            com.rnapp                  D  Connected to: FB:83:98:81:E6:0D
2024-11-26 17:42:01.453 17752-17765 RNBleManager            com.rnapp                  D  onConnectionStateChange to 0 on peripheral: FB:83:98:81:E6:0D with status 0
2024-11-26 17:42:01.504 17752-17752 RNBleManager            com.rnapp                  D  Peripheral event (BleManagerDisconnectPeripheral):FB:83:98:81:E6:0D
2024-11-26 17:42:02.596 17752-17823 RNBleManager            com.rnapp                  D  Retrieve services from: FB:83:98:81:E6:0D
2024-11-26 17:42:02.603 17752-17823 RNBleManager            com.rnapp                  D  Error, gatt is null
@matt-42
Copy link

matt-42 commented Dec 10, 2024

Same problem here, it seems that the commands are already handling the gatt == null errors but these lines prevent them to actually deal with the error.
These lines were introduced 4 years ago by @dbarth to serialize the commands:
435ac0c

Removing those two lines fixed the issue for me. I'm posting a PR, can anyone review it ?
#1297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants