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

ANCS Sample doesn't work after rebooting iOS Device

I'm testing ble_app_ancs experimental sample.

It seems working first connection. But after rebooting iOS Device, or Turn Off/On bluetooth function on iOS Device, ANCS does't work.

After delete bonding both evaluation board and iOS Device, it works again. Is there any infomation about this issue?

Testing Environment

iOS Device iPod touch 5th Gen. iOS 7.0.3 iPhone 5 iOS 7.0.3

BLE Board nrf6310 Rev 1.4 nrf6350 Rev 2.0 PCA10004 Rev 2.1.0 Softdevice 6.0.0-5beta

Parents
  • Hi Ole,

    I found that I had to keep my code mentioned above:

    case BLE_GAP_EVT_CONN_PARAM_UPDATE:
    case BLE_GAP_EVT_AUTH_STATUS:
    apple_notification_setup();
    break;
    

    and, add the following:

    ble_ancs_c_t * timer_p_ancs;
    
    void timer_service_discovery(void)
    {
        service_disc_req_send(timer_p_ancs);
    }
    
    static void event_discover_rsp(ble_ancs_c_t * p_ancs, const ble_evt_t * p_ble_evt)
    {
        if (p_ble_evt->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS)
        {
            // ignore failure - retry in one second
            //handle_discovery_failure(p_ancs, p_ble_evt->evt.gattc_evt.gatt_status);
    
            timer_p_ancs = p_ancs;
            // call function timer_service_discovery in 1000ms, don't repeat
            start_new_timer(timer_service_discovery, 1000, false);
    ...
    
    

    This seems to allow notifications after bluetooth has been turned off and on, AND after the iPhone has been turned off and on.

    Please let me know if you think this is a suitable work-around, or what needs changing and where about in the source.

    Thank you for all your help so far, Paul.

Reply
  • Hi Ole,

    I found that I had to keep my code mentioned above:

    case BLE_GAP_EVT_CONN_PARAM_UPDATE:
    case BLE_GAP_EVT_AUTH_STATUS:
    apple_notification_setup();
    break;
    

    and, add the following:

    ble_ancs_c_t * timer_p_ancs;
    
    void timer_service_discovery(void)
    {
        service_disc_req_send(timer_p_ancs);
    }
    
    static void event_discover_rsp(ble_ancs_c_t * p_ancs, const ble_evt_t * p_ble_evt)
    {
        if (p_ble_evt->evt.gattc_evt.gatt_status != BLE_GATT_STATUS_SUCCESS)
        {
            // ignore failure - retry in one second
            //handle_discovery_failure(p_ancs, p_ble_evt->evt.gattc_evt.gatt_status);
    
            timer_p_ancs = p_ancs;
            // call function timer_service_discovery in 1000ms, don't repeat
            start_new_timer(timer_service_discovery, 1000, false);
    ...
    
    

    This seems to allow notifications after bluetooth has been turned off and on, AND after the iPhone has been turned off and on.

    Please let me know if you think this is a suitable work-around, or what needs changing and where about in the source.

    Thank you for all your help so far, Paul.

Children
  • This doesn't seem too bad, but I would consider to just retry a limited number of times, to limit current consumption in case the service is actually not there.

    Also, I can't really give a proper verification of the code, so I suggest that you test this thoroughly yourself, to be confident that it works as expected.

  • Hi Paul/Ole,

    Not sure if I correctly understood here. Are you saying that with ONLY the following change:

    case BLE_GAP_EVT_CONN_PARAM_UPDATE: // <- this line case BLE_GAP_EVT_AUTH_STATUS: apple_notification_setup(); break;

    we can workaround the problem of not getting notifications after turning OFF and ON again the Bluetooth on iPhone? Or we also need the whitelisting? If that's the case could you please elaborate more?

    Thanks

  • Fabio: no, it required BOTH snippets in this post. i.e. also the bit adding the retry timer to event_discover_rsp. You will need to do this differently as you do not have my 'start_new_timer' function, but perhaps you can use Nordics app_timer or write your own timer to call the function after 1 second. I don't think I needed whitelisting (if I remember correctly).

  • Thanks Paul! Sorry, just got confused because some posts above I read the following: "I have changed the following code in on_ble_evt from: .... This causes alerts to work after Bluetooth is turned off (on the iPhone) and back on again.

    However, alerts still do not work after the iPhone has been turned off and back on again!"

    It didn't seem right and in fact none of the 2 problems was fixed with only that simple change... :)

    I'll try your complete fix. Thanks again!

    Ole: Do you have any particular suggestions on how to use only Nordic functions for the timer (code snippets would be very much appreciated of course :D)?

    Thanks.

Related