Android-DFU-Library: `PlatformException` -> Code: 133, DFU FAILED: GATT ERROR
Hi @philips77, I am trying to use the nordic_dfu flutter library to perform DFU for my nrf51/52 devices. I understand this might not be the right place to raise such an issue but please know that I already tried raising it on the Flutter library repo (https://github.com/juliansteenbakker/nordic_dfu/issues/100) but I did not get any response over there hence I’m raising an issue over here in a hope that I get some direction.
I’m using the latest version of the library i.e. 6.0.1 which internally uses version 2.3.0 of this Android library.
Here are the details of the issue:
I am getting this error every time I try to start DFU for my BLE device. Could you please help?
Note: The bootloader (DFU mode) is getting started but the firmware transfer doesn’t take place. It just goes to the
Disconnectingstate after starting bootloader, stays there for about 10 retries, and then fails with the error below.
I/DfuBaseService(12367): DFU service destroyed
E/flutter (12367): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(133, DFU FAILED: GATT ERROR, Address: C3:CE:FE:CF:F5:E9, Error Type: 1, null)
E/flutter (12367): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter (12367): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter (12367): <asynchronous suspension>
E/flutter (12367):
Version info
- Library version:
6.0.1 - Flutter version:
3.13.0-0.2.pre - Android Version:
13 (API 33) - Android Kotlin Version:
1.8.22 - Android BLE DFU Library Version (used by the flutter library internally):
2.3.0
Complete Logs
D/BluetoothAdapter(12367): isLeEnabled(): ON
D/BluetoothLeScanner(12367): onScannerRegistered() - status=0 scannerId=5 mScannerId=0
D/BluetoothAdapter(12367): isLeEnabled(): ON
I/DfuBaseService(12367): DFU service created. Version: 2.3.0
I/DfuBaseService(12367): Starting DFU service in foreground
I/DfuBaseService(12367): Connecting to the device...
D/BluetoothGatt(12367): connect() - device: C3:CE:FE:CF:F5:E9, auto: false
D/BluetoothGatt(12367): registerApp()
D/BluetoothGatt(12367): registerApp() - UUID=832eaa21-d03a-411a-b24d-471893d93208
D/BluetoothGatt(12367): onClientRegistered() - status=0 clientIf=7
D/BluetoothGatt(12367): onClientConnectionState() - status=0 clientIf=7 device=C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Connected to GATT server
I/DfuBaseService(12367): Waiting 1600 ms for a possible Service Changed indication...
D/BluetoothGatt(12367): discoverServices() - device: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Attempting to start service discovery... succeed
D/BluetoothGatt(12367): onSearchComplete() = Device=C3:CE:FE:CF:F5:E9 Status=0
I/DfuBaseService(12367): Services discovered
I/DfuImpl (12367): Buttonless service without bond sharing found -> SDK 13 or newer
W/DfuImpl (12367): Device is paired! Use Buttonless DFU with Bond Sharing instead (SDK 14 or newer)
I/DfuImpl (12367): Enabling indications...
D/BluetoothGatt(12367): setCharacteristicNotification() - uuid: 8ec90003-f315-4f60-9fb8-838830daea50 enable: true
I/DfuImpl (12367): Sending Enter Bootloader (Op Code = 1)
I/DfuImpl (12367): Response received (Op Code = 1, Status = 1)
I/DfuBaseService(12367): Disconnecting from the device...
D/BluetoothGatt(12367): cancelOpen() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): onClientConnectionState() - status=0 clientIf=7 device=C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Disconnected from GATT server
I/DfuImpl (12367): Device disconnected
W/m.exampleapp.stg(12367): Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (unsupported, reflection, allowed)
D/BluetoothGatt(12367): refresh() - device: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Refreshing result: true
I/DfuBaseService(12367): Cleaning up...
D/BluetoothGatt(12367): cancelOpen() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): close()
D/BluetoothGatt(12367): unregisterApp() - mClientIf=7
I/DfuImpl (12367): Restarting to bootloader mode
D/BluetoothAdapter(12367): isLeEnabled(): ON
D/BluetoothLeScanner(12367): onScannerRegistered() - status=0 scannerId=5 mScannerId=0
D/BluetoothAdapter(12367): isLeEnabled(): ON
I/DfuImpl (12367): Scanning for new address finished with: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Starting DFU service in foreground
I/DfuBaseService(12367): Connecting to the device...
D/BluetoothGatt(12367): connect() - device: C3:CE:FE:CF:F5:E9, auto: false
D/BluetoothGatt(12367): registerApp()
D/BluetoothGatt(12367): registerApp() - UUID=864511eb-3ac0-4b8b-935a-797b07ccb485
D/BluetoothGatt(12367): onClientRegistered() - status=0 clientIf=7
D/BluetoothGatt(12367): onClientConnectionState() - status=0 clientIf=7 device=C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Connected to GATT server
I/DfuBaseService(12367): Waiting 1600 ms for a possible Service Changed indication...
D/BluetoothGatt(12367): discoverServices() - device: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Attempting to start service discovery... succeed
D/BluetoothGatt(12367): onConnectionUpdated() - Device=C3:CE:FE:CF:F5:E9 interval=6 latency=0 timeout=500 status=8
D/BluetoothGatt(12367): onConnectionUpdated() - Device=C3:CE:FE:CF:F5:E9 interval=6 latency=0 timeout=500 status=8
D/BluetoothGatt(12367): onClientConnectionState() - status=8 clientIf=6 device=C3:CE:FE:CF:F5:E9
D/FlutterBluePlugin(12367): [onConnectionStateChange] status: 8 newState: 0
D/BluetoothGatt(12367): onClientConnectionState() - status=8 clientIf=7 device=C3:CE:FE:CF:F5:E9
W/DfuBaseService(12367): Target device disconnected with status: 8
I/DfuBaseService(12367): Connection error after: 4087 ms
E/DfuBaseService(12367): An error occurred while connecting to the device: 8
I/DfuBaseService(12367): Attempt: 1
D/BluetoothGatt(12367): refresh() - device: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Refreshing result: true
I/DfuBaseService(12367): Cleaning up...
D/BluetoothGatt(12367): cancelOpen() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): close()
D/BluetoothGatt(12367): unregisterApp() - mClientIf=7
I/DfuBaseService(12367): Restarting the service
I/DfuBaseService(12367): Action received: android.bluetooth.device.action.ACL_DISCONNECTED
I/DfuBaseService(12367): Starting DFU service in foreground
I/DfuBaseService(12367): Connecting to the device...
D/BluetoothGatt(12367): connect() - device: C3:CE:FE:CF:F5:E9, auto: false
D/BluetoothGatt(12367): registerApp()
D/BluetoothGatt(12367): registerApp() - UUID=24d78135-cd9e-4560-b438-004d1494b7f8
D/BluetoothGatt(12367): onClientRegistered() - status=0 clientIf=7
I/TRuntime.CctTransportBackend(12367): Making request to: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog
D/TrafficStats(12367): tagSocket(79) with statsTag=0xffffffff, statsUid=-1
D/BluetoothGatt(12367): onClientConnectionState() - status=133 clientIf=7 device=C3:CE:FE:CF:F5:E9
E/DfuBaseService(12367): Connection state change error: 133 newState: 0
I/DfuBaseService(12367): Connection error after: 30025 ms
E/DfuBaseService(12367): Device not reachable. Check if the device with address C3:CE:FE:CF:F5:E9 is in range, is advertising and is connectable
I/DfuBaseService(12367): Attempt: 2
D/BluetoothGatt(12367): refresh() - device: C3:CE:FE:CF:F5:E9
I/DfuBaseService(12367): Refreshing result: true
I/DfuBaseService(12367): Cleaning up...
D/BluetoothGatt(12367): cancelOpen() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): close()
D/BluetoothGatt(12367): unregisterApp() - mClientIf=7
I/DfuBaseService(12367): Restarting the service
I/DfuBaseService(12367): Starting DFU service in foreground
I/DfuBaseService(12367): Connecting to the device...
D/BluetoothGatt(12367): connect() - device: C3:CE:FE:CF:F5:E9, auto: false
D/BluetoothGatt(12367): registerApp()
D/BluetoothGatt(12367): registerApp() - UUID=d2d67250-f09c-426c-bd10-7c280f09bfd3
D/BluetoothGatt(12367): onClientRegistered() - status=0 clientIf=7
I/TRuntime.CctTransportBackend(12367): Status Code: 200
D/BluetoothGatt(12367): onClientConnectionState() - status=133 clientIf=7 device=C3:CE:FE:CF:F5:E9
E/DfuBaseService(12367): Connection state change error: 133 newState: 0
I/DfuBaseService(12367): Connection error after: 30023 ms
E/DfuBaseService(12367): Device not reachable. Check if the device with address C3:CE:FE:CF:F5:E9 is in range, is advertising and is connectable
I/DfuBaseService(12367): Attempt: 3
I/DfuBaseService(12367): Cleaning up...
D/BluetoothGatt(12367): cancelOpen() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): close()
D/BluetoothGatt(12367): unregisterApp() - mClientIf=7
I/DfuBaseService(12367): DFU service destroyed
E/flutter (12367): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(133, DFU FAILED: GATT ERROR, Address: C3:CE:FE:CF:F5:E9, Error Type: 1, null)
E/flutter (12367): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter (12367): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter (12367): <asynchronous suspension>
E/flutter (12367):
D/BluetoothGatt(12367): refresh() - device: C3:CE:FE:CF:F5:E9
D/clearGattCache(12367): CLEAR GATT CACHE: true
D/BluetoothGatt(12367): onClientConnectionState() - status=0 clientIf=6 device=C3:CE:FE:CF:F5:E9
D/FlutterBluePlugin(12367): [onConnectionStateChange] status: 0 newState: 2
D/BluetoothGatt(12367): discoverServices() - device: C3:CE:FE:CF:F5:E9
D/BluetoothGatt(12367): onConnectionUpdated() - Device=C3:CE:FE:CF:F5:E9 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(12367): onSearchComplete() = Device=C3:CE:FE:CF:F5:E9 Status=0
D/FlutterBluePlugin(12367): [onServicesDiscovered] count: 5 status: 0
Additional info
In the logs, it shows that Device not reachable. Check if the device with address C3:CE:FE:CF:F5:E9 is in range, is advertising and is connectable but I can check in the nRFConnect app that while the device is in bootloader state, the MAC address is incremented by 1 i.e. it is C3:CE:FE:CF:F5:EA now and the library is not able to search for it on its own, it’s still searching for the non-bootloader MAC address.
Any ideas about this? What can we do here? Should the library automatically search for a +1 MAC address?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (9 by maintainers)
Same here on Android 13, version 2.3.0, but I’m using it under React Native .
You are correct! In the nRF DFU app, if I set the reboot time to 0ms, DFU doesn’t work but it starts working perfectly fine for the duration of 1000ms
Thank you very much @philips77 You saved a lot of time and effort 😃
I’m closing this ticket now. Thank you for your time and effort 🙌
Ok, looking at the logs again I found this:
After sending ‘jump to bootloader’ command the library started scanning and almost 100 ms after that it found the device still advertising with the original device. It did not timeout to the old address, but rather such address was scanned. Consider using
setRebootTime(long)to delay scan. Perhaps the device indeed needs some more time to restart? If you don’t have such API in your Flutter or ReactNative wrappers, you’ll have to add this functionality to the them.But before you do that, you may test using nRF DFU app. In Settings you may set the Reboot Time and check whether with 500 ms or 1 sec it works for you.