Android-DFU-Library
Android-DFU-Library copied to clipboard
Unable to write Op Code 3 (error 133), and dfu library is stuck in the disconnecting status
Information
This GitHub Issue page is for reporting issues or asking questions regarding the Android DFU library. For general DFU questions, SDK questions, etc, please check our DevZone.
Make sure you are using the latest version of the library:
Also, before creating a new issue, make sure similar issue isn't already opened in open or closed issues.
DFU Bootloader version (please complete the following information):
- nRF5 SDK version: [Unknown]
- Are you using bonding: [no]
- DFU Library version: [2.1.0]
Device information (please complete the following information):
- Device: [Samsung A136B]
- OS: [Android 12]
Your question
Step2 by Steps:
- Use the dfu library perform dfu
- Before the dfu progress finish, move the sensor device away to let the gatt connection disconnect from the phone.
- Then, check the phone dfu notification, I found that, the dfu notification is stuck, and show the "Disconnecting...".
- Check the logcat, the log "Disconnected from GATT server" was triggered before "Disconnecting from the device..."
And after dived into the dfu library source code, I finally found the root cause is that: the function com.vivalnk.no.nordicsemi.android.dfu.DfuProgressInfo.ProgressListener#updateProgressNotification is taken too much times(about 30~40ms), so before the library finish setProgress:
6.

the library had trigger the connection state change callback function:

Logs
2022-09-10 00:27:26.439 14101-24017/? E/DfuBaseService: Unable to write Op Code 3 (error 133)
2022-09-10 00:27:26.464 14101-14101/? I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
2022-09-10 00:27:26.479 14101-16657/? I/DfuBaseService: Disconnected from GATT server
2022-09-10 00:27:26.481 14101-24017/? I/DfuBaseService: Disconnecting from the device...
Current My Workaround
move the function updateProgressNotification to main thread:

I know it's a temporary cheap way to avoid this issue, may be you guys have another better way.