Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E/DfuBaseService: Connection state change error: 133 newState: 0 #250

Closed
nathanlin109 opened this issue Jun 18, 2020 · 6 comments
Closed

Comments

@nathanlin109
Copy link

nathanlin109 commented Jun 18, 2020

Sorry for submitting a new issue, but I encountered another issue and reopened my issue from earlier, and I'm not sure if you saw it. Also, should DfuTarg advertise with the same MAC address as the device's address or should it be the device's address +1?

Any help would be appreciated.

I have created a working zip file to upgrade my device, and I followed these steps below:

  1. Scan for Bluetooth LE device
  2. Start DFU using DfuServiceInitiator
  3. Wait for complete or fail callbacks

I get this error below:

E/DfuBaseService: Connection state change error: 133 newState: 0
E/DfuBaseService: An error occurred while connecting to the device:133

DFU Bootloader version:

SDK version: 11.0
Bonding used: no
Library version: 1.10.3
Device information:

Device: Samsung Galaxy S9
OS: Android 10

Logs:

2020-06-15 16:51:31.691 8388-8423/org.aihealth.ineck E/DfuBaseService: Connection state change error: 133 newState: 0
2020-06-15 16:51:31.691 8388-8768/org.aihealth.ineck E/DfuBaseService: An error occurred while connecting to the device:133
2020-06-15 16:51:31.693 8388-8768/org.aihealth.ineck D/BluetoothGatt: refresh() - device: F2:DB:E7:CB:5D:08
2020-06-15 16:51:31.694 8388-8768/org.aihealth.ineck D/BluetoothGatt: close()
2020-06-15 16:51:31.696 8388-8768/org.aihealth.ineck D/BluetoothGatt: unregisterApp() - mClientIf=12
2020-06-15 16:51:33.725 8388-8768/org.aihealth.ineck D/BluetoothAdapter: STATE_ON
2020-06-15 16:51:33.728 8388-8768/org.aihealth.ineck D/BluetoothGatt: connect() - device: F2:DB:E7:CB:5D:08, auto: false
2020-06-15 16:51:33.728 8388-8768/org.aihealth.ineck D/BluetoothAdapter: isSecureModeEnabled
2020-06-15 16:51:33.728 8388-8768/org.aihealth.ineck D/BluetoothGatt: registerApp()
2020-06-15 16:51:33.728 8388-8768/org.aihealth.ineck D/BluetoothGatt: registerApp() - UUID=c6fa3279-14ae-4dd7-a48a-dc5e8718464c
2020-06-15 16:51:33.732 8388-8423/org.aihealth.ineck D/BluetoothGatt: onClientRegistered() - status=0 clientIf=12
2020-06-15 16:51:38.752 8388-8423/org.aihealth.ineck D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=12 device=F2:DB:E7:CB:5D:08
2020-06-15 16:51:38.760 8388-8423/org.aihealth.ineck E/DfuBaseService: Connection state change error: 133 newState: 0
2020-06-15 16:51:38.761 8388-8768/org.aihealth.ineck E/DfuBaseService: An error occurred while connecting to the device:133
2020-06-15 16:51:38.763 8388-8768/org.aihealth.ineck D/BluetoothGatt: refresh() - device: F2:DB:E7:CB:5D:08
2020-06-15 16:51:38.765 8388-8768/org.aihealth.ineck D/BluetoothGatt: close()
2020-06-15 16:51:38.771 8388-8768/org.aihealth.ineck D/BluetoothGatt: unregisterApp() - mClientIf=12
2020-06-15 16:51:40.807 8388-8768/org.aihealth.ineck D/BluetoothAdapter: STATE_ON
2020-06-15 16:51:40.812 8388-8768/org.aihealth.ineck D/BluetoothGatt: connect() - device: F2:DB:E7:CB:5D:08, auto: false
2020-06-15 16:51:40.813 8388-8768/org.aihealth.ineck D/BluetoothAdapter: isSecureModeEnabled
2020-06-15 16:51:40.814 8388-8768/org.aihealth.ineck D/BluetoothGatt: registerApp()
2020-06-15 16:51:40.815 8388-8768/org.aihealth.ineck D/BluetoothGatt: registerApp() - UUID=5bc7b4fe-c9ea-4fd4-a2ed-c8ac47739cbe
2020-06-15 16:51:40.822 8388-8423/org.aihealth.ineck D/BluetoothGatt: onClientRegistered() - status=0 clientIf=12
2020-06-15 16:51:45.851 8388-8423/org.aihealth.ineck D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=12 device=F2:DB:E7:CB:5D:08
2020-06-15 16:51:45.856 8388-8423/org.aihealth.ineck E/DfuBaseService: Connection state change error: 133 newState: 0
2020-06-15 16:51:45.856 8388-8768/org.aihealth.ineck E/DfuBaseService: An error occurred while connecting to the device:133
@philips77
Copy link
Member

Error 133 is very common on Android. It's a generic BLE error. From the above log I conclude that your device does not behave correctly. It replies with something that is being rejected by the phone. Did you try another phone to check it?

@philips77 philips77 added the 133 label Jun 24, 2020
@nathanlin109
Copy link
Author

I got the DFU to work. I talked to my firmware team making the hardware, and they changed the MAC address of DfuTarg to be the same as the device itself. Before it was +1.

@philips77
Copy link
Member

Be careful, as services may be cached now. Make sure you have Service Changed characteristic enabled, otherwise you'll have problems on iOS (and perhaps Android future versions).

I'm closing the issue now. Feel free to open a new one if you have another issue.

@oliver-ep
Copy link

oliver-ep commented Jul 9, 2020

Hi I would like to recommend re-opening this issue. I could have created a new issue, but its the same issue without a resolve for me. @philips77 if you would rather, I can log this as a new issue.

I have the exact same issue as this - and I can conclude that it is not because of the phone. I think this is related, identical or the exact same experience that developers go through to other issues others have raised:
#245
#250
#255
Possilby #234 (but we're not using legacy DFU?)

and so it's worth addressing this with an updated sample code or documentation that prevents this behaviour so people don't need to go through multiple closed issues.

Here's what I did:

  1. Downloaded the nRF Tool box app from PlayStore and confirmed DFU is working with the hardware (phone and device).
  2. Cloned the nRF Tool box repo, ran it locally and confirmed DFU is working.
  3. Created a new project, referenced the same version of DFU in gradle
  4. Copy the implementation over from the cloned nRF Toolbox on DFU feature (Updated to Kotlin, targeting recent androids)
  5. Experience the error with channel needing to be setup for recent Android (RemoteServiceException: Bad notification for startForeground crash on >= Android 8.1 #192)
  6. Fix the issue with code like below (we're using Kotlin):
override fun onCreate(savedInstanceState: Bundle?) {
    // abbreviated
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            DfuServiceInitiator.createDfuNotificationChannel(this)
        }
    DfuServiceListenerHelper.registerProgressListener(this, dfuProgressListener)
  1. Experience the same bug as raised by @nathanlin109

In my case the device goes into bootloader mode, but then the connection seems to get an error.

I'm really lost as to how the same code as the repository, would create a difference? There must be somewhere that is configuring a different behaviour.

We're using the latest Android version, firmware and SDK.

Here's the relevant gradle dependency

implementation 'no.nordicsemi.android:log:2.2.0'
implementation 'no.nordicsemi.android.support.v18:scanner:1.4.3'
implementation 'no.nordicsemi.android:dfu:1.10.3' // The DFU Library is imported automatically from jcenter:
implementation 'no.nordicsemi.android:ble-common:2.2.0' // The BLE Common Library depends on BLE Library. It is enough to include the first one.

As mentioned in #255

Regarding error 133. This is a very common error thrown for any reason. I would recommend:

Trying other phone.
In nRF Connect app, connect to your device and select "Refresh services", or "Refresh device cache". Then try again.

This did not work for me, it's consistently happening.

here's the log from nRF toolbox clone - a successful update:

D/ViewRootImpl@562cad5[DfuActivity]: ViewPostIme pointer 0
D/ViewRootImpl@562cad5[DfuActivity]: ViewPostIme pointer 1
I/DfuBaseService: DFU service created. Version: 1.10.3
I/DfuBaseService: Starting DFU service in foreground
I/DfuBaseService: Connecting to the device...
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=e8a71895-ac6f-45a7-b749-be1f87d9a336
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=11 device=E2:83:BD:2F:9B:57
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_CONNECTED
I/DfuBaseService: Connected to GATT server
D/BluetoothGatt: discoverServices() - device: E2:83:BD:2F:9B:57
I/DfuBaseService: Attempting to start service discovery... succeed
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:57 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onSearchComplete() = Device=E2:83:BD:2F:9B:57 Status=0
I/DfuBaseService: Services discovered
I/DfuImpl: Buttonless service without bond sharing found -> SDK 13 or newer
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:57 interval=36 latency=0 timeout=500 status=0
I/DfuImpl: Enabling indications...
D/BluetoothGatt: setCharacteristicNotification() - uuid: 8ec90003-f315-4f60-9fb8-838830daea50 enable: true
I/DfuImpl: Sending Enter Bootloader (Op Code = 1)
I/DfuImpl: Response received (Op Code = 1, Status = 1)
D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=E2:83:BD:2F:9B:57
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
W/DfuBaseService: Target device disconnected with status: 8
W/roid.nrftoolbo: Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (greylist, reflection, allowed)
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
I/DfuBaseService: Refreshing result: true
I/DfuBaseService: Cleaning up...
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
I/DfuImpl: Restarting to bootloader mode
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Start Scan with callback
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=11 mScannerId=0
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan with callback
I/DfuImpl: Scanning for new address finished with: E2:83:BD:2F:9B:58
I/DfuBaseService: Starting DFU service in foreground
I/DfuBaseService: Connecting to the device...
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:58, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=1ac9c9e4-95b1-4cfd-897c-29ba6e4216f5
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=11 device=E2:83:BD:2F:9B:58
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_CONNECTED
I/DfuBaseService: Connected to GATT server
D/BluetoothGatt: discoverServices() - device: E2:83:BD:2F:9B:58
I/DfuBaseService: Attempting to start service discovery... succeed
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:58 interval=12 latency=0 timeout=600 status=0
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:58 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onSearchComplete() = Device=E2:83:BD:2F:9B:58 Status=0
I/DfuBaseService: Services discovered
W/DfuImpl: Secure DFU bootloader found
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:58 interval=12 latency=0 timeout=600 status=0
I/DfuImpl: Requesting MTU = 517
D/BluetoothGatt: configureMTU() - device: E2:83:BD:2F:9B:58 mtu: 517
D/BluetoothGatt: onConfigureMTU() - Device=E2:83:BD:2F:9B:58 mtu=247 status=0
I/DfuImpl: MTU changed to: 247
I/DfuImpl: Enabling notifications...
D/BluetoothGatt: setCharacteristicNotification() - uuid: 8ec90001-f315-4f60-9fb8-838830daea50 enable: true
I/DfuImpl: Setting object to Command (Op Code = 6, Type = 1)
I/DfuImpl: Command object info received (Max size = 512, Offset = 0, CRC = 00000000)
I/DfuImpl: Sending the number of packets before notifications (Op Code = 2, Value = 0)
I/DfuImpl: Creating Init packet object (Op Code = 1, Type = 1, Size = 141)
I/DfuImpl: Sending 141 bytes of init packet...
I/DfuImpl: Sending init packet (Value = 12-8A-01-0A-44-08-01-12-40-08-0A-10-34-1A-02-CB-01-20-00-28-00-30-00-38-DC-EB-07-42-24-08-03-12-20-70-E7-F5-DF-23-E2-70-AC-3D-64-CD-90-F4-A3-59-E6-8F-09-80-92-BD-CC-A9-29-13-64-7B-F4-A7-EA-72-7C-48-00-52-04-08-01-12-00-10-00-1A-40-0F-A6-1D-7A-78-3C-50-CA-56-25-F7-FF-A9-BA-3A-79-F0-6C-76-72-8B-BE-10-53-F1-BA-67-10-FF-DC-2D-18-BE-73-7B-18-22-5C-5A-B4-D4-E9-8C-7C-63-9D-89-94-14-F1-68-F9-01-57-28-7A-6B-25-90-43-90-BE-CD-07)
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 141, CRC = 2C9D1502)
I/DfuImpl: Executing init packet (Op Code = 4)
I/DfuImpl: Setting object to Data (Op Code = 6, Type = 2)
I/DfuImpl: Data object info received (Max size = 4096, Offset = 0, CRC = 00000000)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (1/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 4096, CRC = B05022DC)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (2/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 8192, CRC = 7B3CE15D)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (3/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 12288, CRC = 58AAB297)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (4/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
D/ViewRootImpl@562cad5[DfuActivity]: ViewPostIme pointer 0
D/ViewRootImpl@562cad5[DfuActivity]: ViewPostIme pointer 1
I/DfuImpl: Checksum received (Offset = 16384, CRC = D68CB804)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (5/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 20480, CRC = FF2A6CE2)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (6/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 24576, CRC = C5E45CBD)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (7/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 28672, CRC = 884E2260)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (8/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 32768, CRC = 9ADA133E)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (9/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 36864, CRC = 167AE64F)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (10/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 40960, CRC = 9C168C89)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (11/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 45056, CRC = 682520F5)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (12/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 49152, CRC = B2DA6782)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (13/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 53248, CRC = 3A078B3D)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (14/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 57344, CRC = 4D88D547)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (15/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 61440, CRC = C345E3EC)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (16/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 65536, CRC = A63E6647)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (17/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 69632, CRC = 072E01EB)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (18/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 73728, CRC = 229834D8)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (19/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 77824, CRC = BC5BDEB0)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (20/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 81920, CRC = 45B5DCA4)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (21/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 86016, CRC = AC2BEFEC)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (22/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 90112, CRC = 837DD55F)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (23/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 94208, CRC = E93ECDF5)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (24/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 98304, CRC = D63CE104)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (25/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 102400, CRC = EE57D156)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (26/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 106496, CRC = 2922647E)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (27/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 110592, CRC = DEF700A6)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (28/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 114688, CRC = 7AC69927)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (29/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 118784, CRC = 028F02A3)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (30/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 122880, CRC = 96509AA9)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 4096) (31/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 126976, CRC = 258E0B07)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Creating Data object (Op Code = 1, Type = 2, Size = 1500) (32/32)
I/DfuImpl: Uploading firmware...
I/DfuImpl: Sending Calculate Checksum command (Op Code = 3)
I/DfuImpl: Checksum received (Offset = 128476, CRC = 888EC9BE)
I/DfuImpl: Executing data object (Op Code = 4)
I/DfuImpl: Transfer of 128476 bytes has taken 27307 ms
D/BluetoothGatt: onClientConnectionState() - status=19 clientIf=11 device=E2:83:BD:2F:9B:58
I/DfuBaseService: Action received: android.bluetooth.device.action.ACL_DISCONNECTED
W/DfuBaseService: Target device disconnected with status: 19
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:58
I/DfuBaseService: Refreshing result: true
I/DfuBaseService: Cleaning up...
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
I/DfuBaseService: DFU service destroyed
D/ViewRootImpl@83b44e8[Toast]: setView = android.widget.LinearLayout@3ab3701 TM=true MM=false
V/Toast: Text: Bppl in android.widget.Toast$TN@66ee9a6
D/ViewRootImpl@83b44e8[Toast]: Relayout returned: old=(0,54,720,1436) new=(58,1217,662,1324) req=(604,107)0 dur=24 res=0x7 s={true 3694942208} ch=true
D/OpenGLRenderer: createReliableSurface : 0xe820e200, 0xdc3c5800
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/ViewRootImpl@83b44e8[Toast]: MSG_RESIZED: frame=(58,1217,662,1324) ci=(0,0,0,0) vi=(0,0,604,107) or=1
W/libEGL: EGLNativeWindowType 0xe820e208 disconnect failed
D/ViewRootImpl@83b44e8[Toast]: dispatchDetachedFromWindow
D/InputTransport: Input channel destroyed: '8697f2e', fd=83
D/ViewRootImpl@562cad5[DfuActivity]: MSG_RESIZED: frame=(0,0,720,1520) ci=(0,54,0,84) vi=(0,54,0,84) or=2
W/libEGL: EGLNativeWindowType 0xd769a148 disconnect failed
D/ViewRootImpl@562cad5[DfuActivity]: Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)8 dur=27 res=0x5 s={false 0} ch=true
D/ViewRootImpl@562cad5[DfuActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@4cf95f3[DfuActivity]
    getNavigationBarColor() -855310
D/ViewRootImpl@562cad5[DfuActivity]: stopped(true) old=false
D/InputTransport: Input channel destroyed: 'ClientS', fd=78

and here's the log from the new implementation - not a successful update.

I/DeviceInteractionActivity: DFU process started successfully
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=0d59be2d-a0e3-4e90-afc3-f8669d65a96b
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=11 device=E2:83:BD:2F:9B:57
E/DfuBaseService: Connection state change error: 133 newState: 0
E/DfuBaseService: An error occurred while connecting to the device:133
W/m.equivital.sd: Accessing hidden method Landroid/bluetooth/BluetoothGatt;->refresh()Z (greylist, reflection, allowed)
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=9a899bbe-3c0b-45a9-b7a6-65f26747bf22
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=11 device=E2:83:BD:2F:9B:57
D/BluetoothGatt: discoverServices() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:57 interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt: onSearchComplete() = Device=E2:83:BD:2F:9B:57 Status=0
I/DfuProgressListener: onDeviceConnected - Enter 
    onDeviceConnected - Exit 
I/DfuProgressListener: onDfuProcessStarting - Enter 
    onDfuProcessStarting - Exit 
D/BluetoothGatt: onConnectionUpdated() - Device=E2:83:BD:2F:9B:57 interval=36 latency=0 timeout=500 status=0
D/BluetoothGatt: setCharacteristicNotification() - uuid: 8ec90003-f315-4f60-9fb8-838830daea50 enable: true
I/DfuProgressListener: onEnablingDfuMode - Enter 
I/DfuProgressListener: onEnablingDfuMode - Exit 
D/BluetoothGatt: onClientConnectionState() - status=8 clientIf=11 device=E2:83:BD:2F:9B:57
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: STATE_ON
D/BluetoothAdapter: BLE support array set: 010011
D/BluetoothLeScanner: Start Scan with callback
D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=11 mScannerId=0
D/BluetoothAdapter: STATE_ON
D/BluetoothLeScanner: Stop Scan with callback
I/DfuProgressListener: onDeviceConnecting - Enter 
I/DfuProgressListener: onDeviceConnecting - Exit 
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=0375e883-03b3-4b85-98ca-bd7d8ac90f48
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=11 device=E2:83:BD:2F:9B:57
E/DfuBaseService: Connection state change error: 133 newState: 0
E/DfuBaseService: An error occurred while connecting to the device:133
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=94fcdbb0-ce63-43cb-a964-1e9d2666061a
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=11 device=E2:83:BD:2F:9B:57
E/DfuBaseService: Connection state change error: 133 newState: 0
E/DfuBaseService: An error occurred while connecting to the device:133
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11
D/BluetoothAdapter: STATE_ON
D/BluetoothGatt: connect() - device: E2:83:BD:2F:9B:57, auto: false
D/BluetoothAdapter: isSecureModeEnabled
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=e7ba0452-7eaa-4787-8d00-7d43359dd94b
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=11
D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=11 device=E2:83:BD:2F:9B:57
E/DfuBaseService: Connection state change error: 133 newState: 0
E/DfuBaseService: An error occurred while connecting to the device:133
D/BluetoothGatt: refresh() - device: E2:83:BD:2F:9B:57
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=11

The implementation is identical to the cloned repository, with the one exception that I hard-coded the .setPacketsReceiptNotificationsValue() (which was derived from nRFTool box implementation).

val starter : DfuServiceInitiator = DfuServiceInitiator(deviceId!!)
            .setDeviceName("Nordic_")
            .setKeepBond(false)
            .setForceDfu(false)
            .setPacketsReceiptNotificationsEnabled(false)
            .setPacketsReceiptNotificationsValue(12)
            .setPrepareDataObjectDelay(400)
            .setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(true)

starter.setZip(fileStreamUri!!) // can use file path if preferred
starter.start(this, DfuService::class.java)

When I run the above code, the device goes into bootloader mode (nice LED that tells me that) and, well it hangs with the above message.

If I run the nRF Toolbox clone, I get 100% success rate. I run the above code, it's a 100% failure rate so far (I've only started on this today!)

I'm using Samsung Galaxy A10, Android 10. I've tried 6 times with the refresh services strategy - and the 133 error seems to come through.

I'll switch to nRF Toolbox and it works without a hitch! What am I doing wrong?

@oliver-ep
Copy link

Hi,

Just a follow up.

I created a ticket, and I immediately found a resolve so I'm posting it here.

My issue, which wasn't to do with Legacy DFU or anything like that, was because I was working on an activity of a larger project - and my activity I was working on wasn't asking for Location Permission before the DFU process started.

The DFU Library must be using a privacy sensitive method to interact with the device after it turns the Nordic device into bootloader mode.

See more details here
https://devzone.nordicsemi.com/f/nordic-q-a/63623/android-ota-dfu-not-working-with-latest-sdk-dfu-library?ReplySortBy=CreatedDate&ReplySortOrder=Descending

@philips77
Copy link
Member

True. I should have mention this in the ReadMe. Unless bonding is used, and buttonless service with bond support, Location permission is required for scanning Bluetooth LE devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants