“The handle is invalid“ error thrown right at the end of firmware upgrade

We have written a Flutter app, which uses the Flutter-nRF-Connect-Device-Manager package to perform firmware upgrades on bluetooth devices that the app bonds with.

If iOS users pair and bond with our bluetooth device and then perform a firmware upgrade without restarting the app, an error is thrown saying "The handle is invalid". The error does not occur if users restart the app between bonding with the device and upgrading its firmware, however this is not a feasible solution to our problem as it would massively disrupt the user experience of our app.

I have performed the firmware upgrade using the example app of the package mentioned above with the same FirmwareUpgradeMode and estimatedSwapTime that our app uses (testAndConfirm and 90 seconds respectively) and I experience the same error.

I saw this thread, which seems related. The solution was to disconnect and reconnect to the bluetooth device, which is possible, but seems hacky. Especially as errors could potentially be thrown during the disconnection or reconnection step. I'm hoping for a cleaner solution than that.

Is this a known issue? Do you have guidance on how to stop this error being thrown please?

Thanks in advance for any help you can provide.

 

  • Thanks for your replies.

    You can do "test only" and then manually "confirm" after the swap is done.
    As an alternative you can also confirm from the application, if you prefer to do local tests.

    Those are promising suggestions. However, I would ideally like to get to the bottom of why test&confirm isn't working as expected, rather than avoid using it.

    What did you change in the application for this test DFU?

    By "application", do you mean the nRF Connect Device Manager app? If so, I didn't change anything. I just ran the upgrade as instructed and that "handle is invalid" error came out when I tried reconnecting to the device.

  • WesCJ said:
    Those are promising suggestions. However, I would ideally like to get to the bottom of why test&confirm isn't working as expected, rather than avoid using it.

    Agreed. Still, can you try the test only, just to debug this issue?

    WesCJ said:
    By "application", do you mean the nRF Connect Device Manager app? If so, I didn't change anything. I just ran the upgrade as instructed and that "handle is invalid" error came out when I tried reconnecting to the device.

    I mean the application running on the nRF Chip. If the hash of the nRF chip firmware is the same, DFU will be aborted.

  •  I was doing some more investigation into this issue today and I noticed that our firmware exposes a Service Changed characteristic under the "Generic Attribute" service.

    However, when I try to access that "Generic Attribute" service from inside the app code (see code below), I get null.

    Should the app be able to access this service? I'm wondering if the fact that the app can't access this service is the reason why the app isn't reacting to the Service Changed indications from that characteristic, resulting in the "handle is invalid" error.

  • Did you see my suggestion below?

    Sigurd Hellesvik said:
    Agreed. Still, can you try the test only, just to debug this issue?

    I suggest that you test this and let me know how this went before moving on to the attribute question

Related