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

  • I'm not able to replicate this problem. What do you do with the Development Kit when turning off Bluetooth on the iOS device?

    Also, which SDK version are you working with?

    Edit: I've now managed to reproduce this problem, and it turns out that this is actually a problem with Apple's implementation. There are two facets to it:

    1. CCCD values are apparently lost when Bluetooth is turned off and on. You can verify this by reading out the CCCDs on reconnection, and see that they are 0.

    When this happens, the Peripheral does not get any new notifications before it re-writes CCCD values, which isn't usually done except when initially bonding. This is a spec violation, and has been reported to Apple.

    1. When booting, the iOS device will connect to Peripheral devices before having populated the GATT Table fully. This means that when the iOS device is turned off and on, the Peripheral device may not actually see the ANCS. I haven't gotten around to verify this properly, but if you register for Service Changed indication, it could be that you'll get one when the service is added. This would have to be done before the iOS device is turned off. An alternative is to retry service discovery some time after connection if you didn't find it initially.
  • Nori, did you find a solution to this?

    I have noticed the same problem (using sdk 5.0.0 - i don't think ancs code changed in 5.1.0).

    The sequence of events is this:

    1. erase flash, program soft device, program ancs example
    2. on iphone, make sure bluetooth is on, select 'ANCS' device, and pair.
    3. dev board led's show advertising stops, and connetion on.
    4. send an SMS to the iphone (with another phone), iphone gets text and notification.
    5. devboard says 'Social' and 'Added 00000000'
    6. clear the notification on the iPhone.
    7. devboard says 'Social' and 'Removed 00000000'
    8. in iPhone settings, turn bluetooth off.
    9. devboard leds show connection 'off' and advertising starts.
    10. on the iPhone, turn bluetooth back on
    11. devboard leds show advertising stops, and connection back 'on'
    12. send another SMS to the iphone (with another phone), iphone gets text and notification.
    13. no message on devboard this time.

    As Nori said, selecting the ANCS device in iPhone bluetooth settings, and then clicking 'Forget device' will erase the bond in the iPhone, and reconnecting will create a new bond and everything will work. It only seems to be re-using an existing bond that causes notifications not to work.

  • I edited my answer above, as I've now managed to reproduce this. Please take a look.

  • Hi Ole,

    thank you for your swift response!

    Do you know if/when there may be a work-around?

    When investigating, I thought I may have found the cause slightly earlier on in the chain of events.

    I noticed that in the function ble_ancs_c_on_bondmgmr_evt, when the initial bond is made then event BLE_BONDMNGR_EVT_NEW_BOND occurs.

    However, after Bluetooth is turned off (on the iPhone) and back on again, there is no event BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL.

    I would have expected the second event to fire after connecting to a previously bonded iPhone.

    This can be easily checked by setting a breakpoint after the second event.

  • I haven't heard anything back from Apple regarding this, and the issue is just marked as Open, but as I said, you can work around it by writing the CCCDs on reconnection.

    Regarding the BLE_BONDMNGR_EVT_CONN_TO_BONDED_CENTRAL event, beware that with the current bond manager, you will unfortunately not get this event if you don't use whitelisting when advertising. This is a limitation that will most likely be fixed in a future SDK version.

Related