This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sd_ble_gap_address_get returns different addr for app and DFU

Hi, when calling sd_ble_gap_address_get from APP i get 0xXXXXXXXX4F and when i call it from DFU i get 0xXXXXXXXX50(X beeing the same), why is this? Is it a feature or a bug?

  • Hi

    It's basicly a feature that was added a few versions back in the SDK. The magic happens at line 1071 of the file dfu_transport_ble.c in the SDK 9.0.0:

        // Increase the BLE address by one when advertising openly.
        addr.addr[0] += 1;
    

    The bluetooth address is increased by 1 in DFU when no peer data could be loaded from the memory section where the application could write it's peer data to be used by the bootloader.

    The only reason i can imagine is, that it is because Android devices have some issues when a device changes it's BLE services. The Android BLE stack caches the discovered services and it doesn't clear this cache even when the SERVICE_CHANGED notification is sent.

    I personaly don't like this "fix", because it confuses our Update-Client in some cases. So we disabled this change of the bluetooth address. To be able to handle the Android issue with service changes we ensure that the DFU service is the first in the service list in the application. So the handles are equal in applicaiton and bootloader and Android can access the characteristics without any issues.

    Regards Adrian

Related