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.

Two issues about DFU library.

See original GitHub issue

We find two issues in the DFU library and also find the solution. Maybe Nordic can review and join them if they are actually useful.

  1. During our testing, we find out dfu library will be hanged up if the mobile phone turn off Bluetooth during OTA. After the mobile phone turn on Bluetooth, dfu library still can’t back to normal status. dfu will keep hanging up status unless app restarts.

After our testing, we find if we add “mLock.notifyAll()” code in the mBluetoothStateBroadcastReceiver below. This question will be solved.

private final BroadcastReceiver mBluetoothStateBroadcastReceiver = new BroadcastReceiver() {
	@Override
	public void onReceive(final Context context, final Intent intent) {
		final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
		final int previousState = intent.getIntExtra(BluetoothAdapter.EXTRA_PREVIOUS_STATE, BluetoothAdapter.STATE_ON);
		logw("Action received: android.bluetooth.adapter.action.STATE_CHANGED [state: " + state + ", previous state: " + previousState + "]");
		if (previousState == BluetoothAdapter.STATE_ON
				&& (state == BluetoothAdapter.STATE_TURNING_OFF || state == BluetoothAdapter.STATE_OFF)) {
			sendLogBroadcast(LOG_LEVEL_WARNING, "Bluetooth adapter disabled");
			mConnectionState = STATE_DISCONNECTED;
			if (mDfuServiceImpl != null)
				mDfuServiceImpl.getGattCallback().onDisconnected();

			// Notify waiting thread
			synchronized (mLock) {
				mLock.notifyAll();
			}
		}
	}
};
  1. In the Nordic BLE library, connectGatt command have different parameters in different android version, like below (I remove some log information):
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
		final int preferredPhy = connectRequest.getPreferredPhy();
		bluetoothGatt = device.connectGatt(context, false, gattCallback,
				BluetoothDevice.TRANSPORT_LE, preferredPhy/*, handler*/);
	} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
		bluetoothGatt = device.connectGatt(context, false, gattCallback,
				BluetoothDevice.TRANSPORT_LE);
	} else {
		bluetoothGatt = device.connectGatt(context, false, gattCallback);
	}

But in the DFU library, connectGatt command only use one method.

   final BluetoothGatt gatt = device.connectGatt(this, false, mGattCallback);

During out testing, some Android mobile sometimes can’t connect successfully if we only use the DFU connectGatt command. (Like HTC U11). Maybe you can review it and consider to alert these parts.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
philips77commented, Jul 28, 2020

Released.

2reactions
philips77commented, Jul 27, 2020

Thank you for your contribution! I’ll fix the issues soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · NordicSemiconductor/Android-DFU-Library - GitHub
Issues list ; Nordic Uart services integration in Android DFU Library Source Code: #368 opened on Oct 12 ; Unable to write Op...
Read more >
Android DFU library not working for Samsung phones on ...
Recently we found that Samsung phones running on Android 10 have a problem with DFU both on our app and when using the...
Read more >
NordicDFU - Swift Package Index
OTA DFU Library for Mac and iOS, compatible with nRF5x SoCs ... There are 10 open issues and 2 open pull requests. The...
Read more >
Bluetooth in DFU mode: connection always fails for some ...
So, here is my description on the github issue : I've been struggling with this the last two days and I can't find...
Read more >
USB device firmware update (DFU) for Kinetis MCUs - NXP
The USB DFU bootloader is able to enumerate in two ways: ... If using CW10.x, build each library individually (bsp_m52259evb, psp_m52259evb, etc) as...
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