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
  • Hi Ole. John has answered questions 1 & 3, I'll answer # 2. The disconnect happens at random locations/times. Earlier today I had a disconnect occur in the midst of the connection attempt (Core Bluetooth told to connect, started that process but then disconnected). Here are the lines from our log file: 2013-10-21 09:32:34.604 HOBOmobile[164:4703] MXBLEDevice.m:(1182) connectPeripheral: Tell the Central Manager to connect to the target peripheral 2013-10-21 09:32:34.645 HOBOmobile[164:1f6f] MXBLEDevice.m:(1841) didConnectPeripheral: Connection to peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA successful 2013-10-21 09:32:34.647 HOBOmobile[164:1f6f] MXBLEDevice.m:(1844) didConnectPeripheral: Active peripheral is now = <CBPeripheral: 0x175c5800 identifier = D93F9E39-89AA-BC5F-B0FA-30745532D7EA, Name = "MX1101", state = connected> 2013-10-21 09:32:34.648 HOBOmobile[164:1f6f] MXBLEDevice.m:(1854) PID = 9218, is a supported Onset device, created MXLoggerMX1101 logger object 2013-10-21 09:32:35.068 HOBOmobile[164:1f6f] MXBLEDevice.m:(1880) didDisconnectPeripheral: Peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA disconnected, error = Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x175dcf00 {NSLocalizedDescription=The connection has timed out unexpectedly.} 2013-10-21 09:32:35.073 HOBOmobile[164:1f6f] MXBLEDevice.m:(1887) didDisconnectPeripheral: Unexpected disconnection detected - cleaning up

    In another test I encountered another disconnect that happened spontaneously after the connection was fully established and there had been some other communication with the peripheral. Suddenly, from the app's point of view, a spontaneous disconnect occurred. The last communication with the device happened at 11:14:36.839, then there was some idle time, then the disconnect. Here are the log lines for that one - the didDisconnectPeripheral method is the callback from Core Bluetooth:

    2013-10-21 11:14:51.881 HOBOmobile[188:1f0b] MXBLEDevice.m:(1880) didDisconnectPeripheral: Peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA disconnected, error = Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x16d9c820 {NSLocalizedDescription=Unknown error.} 2013-10-21 11:14:51.884 HOBOmobile[188:1f0b] MXBLEDevice.m:(1887) didDisconnectPeripheral: Unexpected disconnection detected - cleaning up

Reply
  • Hi Ole. John has answered questions 1 & 3, I'll answer # 2. The disconnect happens at random locations/times. Earlier today I had a disconnect occur in the midst of the connection attempt (Core Bluetooth told to connect, started that process but then disconnected). Here are the lines from our log file: 2013-10-21 09:32:34.604 HOBOmobile[164:4703] MXBLEDevice.m:(1182) connectPeripheral: Tell the Central Manager to connect to the target peripheral 2013-10-21 09:32:34.645 HOBOmobile[164:1f6f] MXBLEDevice.m:(1841) didConnectPeripheral: Connection to peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA successful 2013-10-21 09:32:34.647 HOBOmobile[164:1f6f] MXBLEDevice.m:(1844) didConnectPeripheral: Active peripheral is now = <CBPeripheral: 0x175c5800 identifier = D93F9E39-89AA-BC5F-B0FA-30745532D7EA, Name = "MX1101", state = connected> 2013-10-21 09:32:34.648 HOBOmobile[164:1f6f] MXBLEDevice.m:(1854) PID = 9218, is a supported Onset device, created MXLoggerMX1101 logger object 2013-10-21 09:32:35.068 HOBOmobile[164:1f6f] MXBLEDevice.m:(1880) didDisconnectPeripheral: Peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA disconnected, error = Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x175dcf00 {NSLocalizedDescription=The connection has timed out unexpectedly.} 2013-10-21 09:32:35.073 HOBOmobile[164:1f6f] MXBLEDevice.m:(1887) didDisconnectPeripheral: Unexpected disconnection detected - cleaning up

    In another test I encountered another disconnect that happened spontaneously after the connection was fully established and there had been some other communication with the peripheral. Suddenly, from the app's point of view, a spontaneous disconnect occurred. The last communication with the device happened at 11:14:36.839, then there was some idle time, then the disconnect. Here are the log lines for that one - the didDisconnectPeripheral method is the callback from Core Bluetooth:

    2013-10-21 11:14:51.881 HOBOmobile[188:1f0b] MXBLEDevice.m:(1880) didDisconnectPeripheral: Peripheral with UUID = D93F9E39-89AA-BC5F-B0FA-30745532D7EA disconnected, error = Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x16d9c820 {NSLocalizedDescription=Unknown error.} 2013-10-21 11:14:51.884 HOBOmobile[188:1f0b] MXBLEDevice.m:(1887) didDisconnectPeripheral: Unexpected disconnection detected - cleaning up

Children
Related