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

Suddenly I'm seeing spontaneous disconnects in my iOS 7 app from my nRF51822 peripheral

Suddenly my app, running on iOS 7, is reporting lots of spontaneous disconnects by the peripheral device, an nRF51822, indicating a timeout:

didDisconnectPeripheral: Peripheral with UUID = 2F82C038-59AF-FA33-1963-644155D9CD09 disconnected, error = Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x176d88c0 {NSLocalizedDescription=The connection has timed out unexpectedly.}

Also seeing lots of cases of service discovery reporting unknown error: didDiscoverServices: Error code was Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x16d48850 {NSLocalizedDescription=Unknown error.},

This is a recent phenomenon, and I'm looking for some way of finding out what caused Core Bluetooth to report these. In the case of the timeout, what timed out? I assume this is coming from the interaction going on between CB and the peripheral, and CB possibly didn't get a response it was expecting? In the case of the service discovery error, it would help to know more about what CB is reporting with the unknown error code. Is there any way to get some additional feedback from CB? This is more a question for Apple and has been posted on the CB forum there, but maybe someone here has some insights.

Parents
  • This error is just a general connection timeout error, which can be caused by a lot of factors. First of all, I'd recommend you to make sure that app_error_handler does not contain a reset, since this will easily mask errors that could be returned by the softdevice.

    Secondly, it would be interesting to know if there is anything in particular that is happening when you see this kind of problems. Is it close to some specific time (5 s, 10 s, 30 s or similar) after connection, or is it just random?

    Third, this can happen if your clock source is not precise enough. What kind of low-frequency clock do you use?

    The only change I've noticed from iOS 6 to 7 affecting applications is that iOS no longer seems to downgrade a write to a write without response, but instead just fails to transmit the data. This can be a problem if you have a characteristic that have the Write Without Response property, but your app tries to do a normal Write. In this case, it seems to me that iOS 6 will "downgrade" the Write to a Write Without Response, while iOS 7 will just not transfer the data. This should however not cause a disconnection.

Reply
  • This error is just a general connection timeout error, which can be caused by a lot of factors. First of all, I'd recommend you to make sure that app_error_handler does not contain a reset, since this will easily mask errors that could be returned by the softdevice.

    Secondly, it would be interesting to know if there is anything in particular that is happening when you see this kind of problems. Is it close to some specific time (5 s, 10 s, 30 s or similar) after connection, or is it just random?

    Third, this can happen if your clock source is not precise enough. What kind of low-frequency clock do you use?

    The only change I've noticed from iOS 6 to 7 affecting applications is that iOS no longer seems to downgrade a write to a write without response, but instead just fails to transmit the data. This can be a problem if you have a characteristic that have the Write Without Response property, but your app tries to do a normal Write. In this case, it seems to me that iOS 6 will "downgrade" the Write to a Write Without Response, while iOS 7 will just not transfer the data. This should however not cause a disconnection.

Children
No Data
Related