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

Service Changed Characteristic not enabled on iOS

Hi,

My current project make use of pairing/bonding and at certain times I change the attribute table. To notify the central device about this change I have added the Service Changed Characteristic. It works good on Android after enabling notifications from the characteristic. However on iOS I cannot see the Service Changed Characteristic (iOS filter these out according to their guidelines), and I always receive error: NRF_ERROR_INVALID_STATE when I try to send I notification to an iOS device. I  seems like iOS is not enabling notifications on the Service Changed characteristic.

Is there something more to be done in order to make iOS enable notification for the Service Changed Characteristic?

I send the notification from the BLE_GAP_EVT_CONN_SEC_UPDATE event:

        err_code = sd_ble_gatts_service_changed(
            p_ble_evt->evt.gap_evt.conn_handle,
            system_service_get_service_handle(),
            0xFFFF
        );

        if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_INFO("Failed to send service changed indication!, err_code: %d", err_code);
        }

Edit:

After pairing I can send a Service Changed Notification. When the device eventually get disconnected after pairing/bonding I reconnect and after that the nRF52832 can no longer send Service Changed Notifications (NRF_ERROR_INVALID_STATE). Do I need to restore the CCCDs or what is happening here?

Parents Reply
  • Hi Vidar,

    It seems like that the case, I moved the call sd_ble_gatts_service_changed from the event BLE_GAP_EVT_CONN_SEC_UPDATE to BLE_GAP_EVT_CONN_PARAM_UPDATE which comes after roughly 20 seconds after connection. Then it works without issues.

    Any advice how to handle this? Putting the call in BLE_GAP_EVT_CONN_PARAM_UPDATE seems abit strange.

    Edit:

    You can use the PM API to manage SC indications to bonded peers.

    When you say PM API to manage SC indications, do you mean pm_local_database_has_changed()?

    Also I'm using SDK v15.0

Children
Related