Android asking for pairing after DFU

Using SDK 15.3 on the embedded side and Android 10 I think it is on the mobile side.

We've implemented whitelists and hanging onto the bonding information on the embedded side.  The idea is that once the mobile side is talking to us we only want to talk to that particular device until we explicitly change to another one.

This works fine across power cycles on both sides.  Once paired and bonded and everything, the mobile side and embedded side exist in married bliss.

Now, pull up nRF connect and run a DFU on the embedded side. Once the embedded side comes back (and it is keeping all the bonding information and whitelists and all that across this as far as I can tell), Android wants to pair again...

I just don't understand why this is.  We've got the bonding information both sides as far as I know. Why does the Android side really want to pair again?  Am I missing something on the embedded side?

Parents
  • Hello,

    So it is after the update is complete, and you try to connect to it again like it was before (in the married bliss) that it wants to pair again, is that correct? 

    Do you see whether the peripheral device has changed anything? Or did you try to debug the applciation? Is the bonding data still present on the peripheral? Does the peripheral use the same Bluetooth LE address as before the DFU update took place?

    Best regards,

    Edvin

  • yes, after the DFU has completed. Everything should be the same as before the update as all that information is being saved as far as I know...  Power cycles of either side of that prior to DFU does not cause this repairing request so I'm pretty sure it's being saved.

    Android itself is popping a "you want to pair?" message.

  • Are you reproducing this on a DK or custom HW? If custom, can you try to reproduce it on a DK? And does it only happen on a certain Android version (10) or on any android version? And have you tried iOS? Is there some way for me to replicate this issue on a DK with a phone? Preferably iOS, but I can try to get hold of an Android if I need to. 

    From the logs, you are saying that on line 52, when it says "applied whitelist with addr_cnt=1 irk_cnt=1", it will still go through the pairing process? Is there anything in the logs saying when you need to pair or not?

    BR,
    Edvin

  • This is full custom hardware; I rarely use a dev kit from anyone as they are so limiting to what I do. Reproducing it on the DK would be difficult as there is so much code there that assumes custom hardware.  Also we've seen this over 5 or 6 products all with the same basic code base.

    As to Android version, We've seen it on 10 and 11 (these logs were produced with an 11 connection). Never tried it on iOS as we don't have the app we use with it on iOS and it's rather difficult to get the connection to begin with without the app.  We can try it at some point here tho as that would be something instructive I think.

    Line 52 is saying that, when it comes back from POR, that there whitelist is still intact in flash storage.  That implies to me that any bonding information kept in the same basic storage place would be still intact.  I will have to verify that with your code suggestion the next time I get a chance.

    Line 54 has what I assume is step 3 pairing requests and whatnot coming through. Ignore anything labeled "RFID:"  It's about 5 seconds later (line around 188) where we see the bonding completion....

    The upshot is that these logs aren't as informative as they could possibly be.  I don't have an air sniffer at present to see the traffic here, which would be far more informative, and for that I apologize.

  • I understand. 

    Well, sometimes a custom log can give some insight in whats going on, but it is not always conclusive. 

    For the iOS part, if you are using the standard bootloader from the nRF5 SDK (without too much modifications), you should be able to use the nRF Connect for iOS app to perform the update, and then try to connect to it afterwards, to see if it also requires to re-bond. This is just for debugging purposes, to see whether this issue is limited to Android, or on all platforms. Perhaps it can narrow down possible reasons for this behavior.

    Best regards,

    Edvin

  • iOS: my engineers are reporting that iOS does not have this problem..  

    They did run into a services cache problem on that platform, but that's another problem (see https://developer.apple.com/forums/thread/76339)

  • As it is mentioned in that ticket, you need to enable the SERVICE_CHANGED in sdk_config.h of your application. Ironically, adding it later wouldn't help, but if you add it in your initial application, that should solve that. So for the phones that have already cached the services, First forget the device from the iPhone's bluetooth menu, then turn off bluetooth from the phone's settings (Settings menu, not the "drag up from bottom menu"). Wait for about 15 seconds, and turn bluetooth back on. Then it should be forgotten. Then, if you have the service changed service enabled, then the peer manager will use this to tell the phone to do a new service discovery if it has new services.

    Now, regarding our issue:

    I need you to check the number of peers in the peer manager (using the snippets in my answer from 13th of june. 

    Does this also happen if you use the "normal" bootloader and e.g. the ble_app_buttonless_dfu example to perform the update? Did you test this? If you test this with ble_app_buttonless_dfu, there is a setting in sdk_config.h called NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS. Leave this set to 0, because this does a couple of things. Then try to open ble_dfu_unbonded.c, and set:

        add_char_params.cccd_write_access = SEC_JUST_WORKS;
        add_char_params.write_access      = SEC_JUST_WORKS;
        add_char_params.read_access       = SEC_OPEN;

    in ble_dfu_buttonless_char_add(). That should trigger the pairing/bonding in the app, and then you can perform a DFU and try to connect again. Does that trigger the issue where you need to bond again?

    NB: This example already have the NRF_SDH_BLE_SERVICE_CHANGED set to 1.

    Best regards,

    Edvin

Reply
  • As it is mentioned in that ticket, you need to enable the SERVICE_CHANGED in sdk_config.h of your application. Ironically, adding it later wouldn't help, but if you add it in your initial application, that should solve that. So for the phones that have already cached the services, First forget the device from the iPhone's bluetooth menu, then turn off bluetooth from the phone's settings (Settings menu, not the "drag up from bottom menu"). Wait for about 15 seconds, and turn bluetooth back on. Then it should be forgotten. Then, if you have the service changed service enabled, then the peer manager will use this to tell the phone to do a new service discovery if it has new services.

    Now, regarding our issue:

    I need you to check the number of peers in the peer manager (using the snippets in my answer from 13th of june. 

    Does this also happen if you use the "normal" bootloader and e.g. the ble_app_buttonless_dfu example to perform the update? Did you test this? If you test this with ble_app_buttonless_dfu, there is a setting in sdk_config.h called NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS. Leave this set to 0, because this does a couple of things. Then try to open ble_dfu_unbonded.c, and set:

        add_char_params.cccd_write_access = SEC_JUST_WORKS;
        add_char_params.write_access      = SEC_JUST_WORKS;
        add_char_params.read_access       = SEC_OPEN;

    in ble_dfu_buttonless_char_add(). That should trigger the pairing/bonding in the app, and then you can perform a DFU and try to connect again. Does that trigger the issue where you need to bond again?

    NB: This example already have the NRF_SDH_BLE_SERVICE_CHANGED set to 1.

    Best regards,

    Edvin

Children
No Data
Related