NordicSemiconductor / Android-DFU-Library

Device Firmware Update library and Android app
http://www.nordicsemi.com/dfu
BSD 3-Clause "New" or "Revised" License
763 stars 269 forks source link

Error DFU CHARACTERISTICS NOT FOUND stops BluetoothLeScanner after the result error #388

Closed mgoyenavitio closed 1 year ago

mgoyenavitio commented 1 year ago

DFU Bootloader version (please complete the following information):

Device information (please complete the following information):

Your question

When we try to do a DFU Update on a device that doesn't support DFU the error stops scanning of BLE adapter. It does it a few seconds after and without any reason. In case of another error or when DFU is completed with success the scan doesn't stop. It seems that the scan is stopped before the DFUService is destroyed and in this case it does it afterwards. This a problem for us because just after the error we start scan, which you are stopping again by yourself.

Logs

Here there are logs also from my APP. As you can see at the end, 8 seconds after it stops scan:

13:11:27.879 DfuBaseService     I  DFU service created. Version: 2.3.0
13:11:27.890 DfuBaseService     W  Foreground service disabled. Android Oreo or newer may kill a background service few moments the application.
                                              Consider enabling foreground service using DfuServiceInitiator#setForeground(boolean)
13:11:28.000 DfuBaseService     I  Connecting to the device...
13:11:28.002 BluetoothAdapter   I  STATE_ON
13:11:28.005 BluetoothGatt      D  connect() - device: D0:DD:08:18:65:46, auto: false
13:11:28.005 BluetoothGatt      D  registerApp()
13:11:28.006 BluetoothGatt      D  registerApp() - UUID=5b268a53-2343-40d7-9578-065cbe36b645
13:11:28.010 BluetoothGatt      D  onClientRegistered() - status=0 clientIf=6
13:11:29.187 DfuBaseService     I  Action received: android.bluetooth.device.action.ACL_CONNECTED
13:11:29.188 BluetoothGatt      D  onClientConnectionState() - status=0 clientIf=6 device=D0:DD:08:18:65:46
13:11:29.200 DfuBaseService     I  Connected to GATT server
13:11:29.205 BluetoothGatt      D  discoverServices() - device: D0:DD:08:18:65:46
13:11:29.209 DfuBaseService     I  Attempting to start service discovery... succeed
13:11:29.658 BluetoothGatt      D  onConnectionUpdated() - Device=D0:DD:08:18:65:46 interval=6 latency=0 timeout=500 status=0
13:11:29.786 BluetoothGatt      D  onSearchComplete() = Device=D0:DD:08:18:65:46 Status=0
13:11:29.786 DfuBaseService     I  Services discovered
13:11:29.790 DfuBaseService     W  DFU Service not found.
13:11:29.791 DfuBaseService     I  Disconnecting from the device...
13:11:29.792 BluetoothGatt      D  cancelOpen() - device: D0:DD:08:18:65:46
13:11:29.792 VITURE_SDK         D  DFU: onDeviceDisconnecting: D0:DD:08:18:65:46
13:11:29.797 BluetoothGatt      D  onClientConnectionState() - status=0 clientIf=6 device=D0:DD:08:18:65:46
13:11:29.805 DfuBaseService     I  Disconnected from GATT server
13:11:29.806 itio.viture.app    W  Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (unsupported, reflection, allowed)
13:11:29.806 BluetoothGatt      D  refresh() - device: D0:DD:08:18:65:46
13:11:29.808 DfuBaseService     I  Refreshing result: true
13:11:29.809 DfuBaseService     I  Cleaning up...
13:11:29.809 BluetoothGatt      D  cancelOpen() - device: D0:DD:08:18:65:46
13:11:29.813 BluetoothGatt      D  close()
13:11:29.819 BluetoothGatt      D  unregisterApp() - mClientIf=6
13:11:30.425 VITURE_SDK         D  DFU: onDeviceDisconnected: D0:DD:08:18:65:46
13:11:30.426 VITURE_SDK         D  DFU: onError: D0:DD:08:18:65:46
13:11:30.426 VITURE_SDK         D  Error performing update: DFU CHARACTERISTICS NOT FOUND
13:11:30.427 MAIN ACTIVITY      D  Error during DFU update, please retry.
13:11:30.431 DfuBaseService     I  DFU service destroyed
13:11:38.007 BluetoothAdapter   I  STATE_ON
13:11:38.007 BluetoothLeScanner D  Stop Scan with callback
philips77 commented 1 year ago

Hello, sorry for replying so late.

The library only starts or stops scans when it needs to (when switching to a bootloader). It cannot stop another scan, initiated by some other part of your app.

It must be either your app or the system.