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

iOS 8 disconnection: Code=6 "The connection has timed out unexpectedly."

I have a BLE peripheral application based on the nRF51822, running Soft Device S110 with SDK 8.1.0. The centrals are mobile apps, one on Android 5.0, one on iOS 8.4.1.

The Android app works fine. The iOS does not. It will spontaneously disconnect some time after connection. The time between connection and this disconnection is random. I've measured from 40s to 4m30s.

This question is similar but was never answered: devzone.nordicsemi.com/.../

My board has a 32.768 kHz crystal, one of these: www.digikey.co.uk/.../en

I start the soft device like this:

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);

There's no assert on the module side. In my app_error_handler() I put an assert LED on and sit there for 10s before resetting, and I'm not seeing that happen at all. All the app is doing with the BLE connection is writing some firmware logging messages to the mobile app UI using the Nordic UART service. Just a few writes to that one characteristic in quick succession every few minutes.

I've tested this on two of my current batch of prototype boards and seen the same issue on both.

Any ideas?

EDIT:

Rolling back through previous commits in my firmware, the change that introduced this problem was one where I cut out a lot of the printf() statements in my code that end up as a write to a BLE characteristic. It's doing fewer of these that's the problem, not doing more of them. It seems I need to write a new value to a characteristic every so often (say, every 30s) in order to keep the connection alive for iOS, but not for Android. Why is this?

EDIT:

I originally said I was on iOS 8.1.0. In fact, I'm on iOS 8.4.1.

EDIT:

Moving to iOS 9.0 has not fixed this. Here's the trace from the device manager:

0x8D 0xD0 0xBB 0x43 0x80 0x0B 0xE1 0xCE 0x6E 0x6A 0x2B 0xD2 0xCA 0x10 0xE2 0xA8 0x20 
[DM]: >> BLE_GAP_EVT_CONN_SEC_UPDATE, Mode 0x01, Level 0x02
[DM]: --> gatts_context_apply
[DM]:[CI 0x00]: State 0x8A, Size 0x0000001A
[DM]: Setting stored context.
[DM]: Notifying application of event 0x15
[DM]: Disconnect Reason 0x0008
[DM]: --> device_context_store
[DM]:[DI 00]:[CI 00]: -> No update in bonding information.
[DM]: --> gatts_context_store
[DM]:[0x00]: No change in GATTS Context information.
[DM]:[0x00]: Resetting GATTS for active instance.
[DM]: Notifying application of event 0x12
[DM]:[CI 0x00]: Freeing connection instance
[DM]:[00]: Freed connection instance.
[DM]: Initializing Connection Instance 0x00000000.

0x08 is BLE_HCI_CONNECTION_TIMEOUT. Now what?

EDIT:

Here are two Wireshark captures, one for the bonding and one for the subsequent reconnection. In the reconnection one, the last packet captured is after about 22 seconds but the module sat there supposedly in a connection for a minute or so after that before my debug LEDs on the device and my logging in the iOS app both told me the connection was broken.

bonding.pcapng

reconnection.pcapng

Related