nRF SDK Version 16.0.0
nRF52840
iOS version 15.2
I'm having an issue with my iPhone displaying incorrect characteristic data after doing a DFU to my nRF device, re-connecting, and reading the DIS service characteristics. I understand the iPhone having a caching issue, particularly when a change is made to a service or a new service is added but this is not the case. And of course when I reboot my iPhone, the data is read and displayed properly. We tried the trick of changing the BLE address after the device boots back up and this does fix the issue but consider this a 'hack' and not an optimal solution to this issue. I've read through similar posts on DevZone regarding this same problem but have found nothing that has solved my issue.
We are not using bonding and I dont initialize the Peer Manager in my project. Is Peer Manager necessary for sd_ble_gatts_service_changed() to work properly?
I did notice early on that my NRF_SDH_BLE_SERVICE_CHANGED setting in sdk_config.h was set to 0 but I now have it set to 1 in the new image that we are sending over DFU. Note that the pre-DFU image on the device was built with this setting set to 0. Not sure if this matters or not.
I found that I'm always getting an error when calling sd_ble_gatts_service_changed(conn_handle, 0x00, 0xFFFF) no matter what I pass in for the handles. I've tried a starting handle of 0 and 0x0C which is supposedly greater than the service changed cccd handle but seem to always get a return code of 0x3003 (BLE_ERROR_INVALID_ATTR_HANDLE). Ive tried callling sd_ble_gatts_service_changed in the Connection Event when the phone first connects and even later in the NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event but always the same error code.
So the big questions are, how do I get my iPhone to do a full service discovery everytime it connects to my device? What is the proper way to use sd_ble_gatts_service_changed() so that it works and returns SUCCESS?
Thanks for the help