“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.

 

Parents
  •  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.

Reply
  •  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.

Children
Related