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.

[Version 1.2] BleManagerGattCallback.nextRequest stucks after onBonded

See original GitHub issue

Hi,

I ran into the mentioned issue using version 1.2.0 of the library. The app is running on a Nexus 5 with Android 8.1. I’m trying to connect to a nRF52840 dongle, then bond. After bonding I want to change MTU size and write some characteristics on the device.

The flow in details:

  • after device discovery, I call BleManager.connect(BluetoothDevice)
  • in my BleManagerGattCallback.initGatt implementation, I push a single bond request (Request.createBond()) into the requests queue
  • BleManageCallbacks.onBondingRequired(BluetoothDevice) is invoked, Android pops up the Pairing notification, where I choose to pair. In the nRF Connect app, I also confirm that the pins match.
  • BleManagerCallbacks.onBonded(BluetoothDevice) is invoked. In my implementation I enqueue a new MTU change request here: enqueue(Request.newMtuRequest(128))

The request never gets processed since the BleManager.BleManagerGattCallback.mOperationInProgress flag is still true.

I actually checked out the source of the library and modified the BleManager implementation to reset the mOperationInProgress flag to false on successful bonding in the BroadcastReceiver’s BOND_BONDED case:

                                        Logger.i(mLogSession, "Device bonded");
					mGattCallback.mOperationInProgress = false; // added this line
					mCallbacks.onBonded(device);
					// If the device started to pair just after the connection was established the services were not discovered.
					if (mBluetoothGatt.getServices().isEmpty()) {
						mHandler.post(() -> {
							Logger.v(mLogSession, "Discovering Services...");
							Logger.d(mLogSession, "gatt.discoverServices()");
							mBluetoothGatt.discoverServices();
						});
						return;
					}
					break;

With the modifications above I managed to run the MTU change and other requests after bonding.

Is my solution valid or did I do something wrong in my intitial flow?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sztomekcommented, Oct 31, 2018

Hi again,

Just checked the latest version (2.0.0-beta7) and the scenario I have described earlier works just fine. So I assume this ticket can be closed.

Thanks!

1reaction
stefnotchcommented, Mar 5, 2021

Looks like version 2 is out now. Should this ticket be closed now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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