iOS BLE peripheral connect-disconnect loop. Error Domain=CBErrorDomain Code=10
iOS BLE peripheral connect-disconnect loop. Error Domain=CBErrorDomain Code=10
- Subject: iOS BLE peripheral connect-disconnect loop. Error Domain=CBErrorDomain Code=10
- From: Andreas Luka de Reggi <email@hidden>
- Date: Tue, 22 Apr 2014 12:13:56 +0200
Hello all.
I am new to the list. I am seeking help and hope I am in the right place.
To describe our problem:
We are creating a BLE peripheral to connect to iOS devices.
Most of the time the connection runs smoothly, but on occasion there are issues with which I am banging my head against the wall for a while now.
The CBCentralManager is initiated as follows:
dispatch_queue_t centralQueue = dispatch_queue_create("com.myapp.blecentral.queue", DISPATCH_QUEUE_SERIAL);
NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey:@YES,
CBCentralManagerOptionRestoreIdentifierKey:@"com.myapp.blecentral"};
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:centralQueue options:options];
The usual connection procedure would be:
...
2014-04-22 11:32:27:138 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:32:27:852 MyApp[271:1803] < centralManager:didConnectPeripheral:
2014-04-22 11:32:27:858 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:32:28:472 MyApp[271:7307] < peripheral:didDiscoverServices:
2014-04-22 11:32:28:474 MyApp[271:7307] > discoverCharacteristics:sUUID:cUUIDs:
2014-04-22 11:32:28:922 MyApp[271:7307] < peripheral:didDiscoverCharacteristicsForService:error:
2014-04-22 11:32:28:924 MyApp[271:7307] > setNotificationForCharacteristic:sUUID:cUUID:enable:
2014-04-22 11:32:29:041 MyApp[271:7307] < peripheral:didUpdateValueForCharacteristic:error:
2014-04-22 11:32:29:044 MyApp[271:7307] > discoverCharacteristics:sUUID:cUUIDs:
2014-04-22 11:32:29:047 MyApp[271:7307] < peripheral:didUpdateNotificationStateForCharacteristic:error:
2014-04-22 11:32:29:048 MyApp[271:7307] < peripheral:didDiscoverCharacteristicsForService:error:
2014-04-22 11:32:29:049 MyApp[271:7307] > readCharacteristic:sUUID:cUUID:
2014-04-22 11:32:29:131 MyApp[271:7307] < peripheral:didUpdateValueForCharacteristic:error:
... and so on.
But sometimes:
...
2014-04-22 11:38:52:833 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:38:55:068 MyApp[271:7827] < centralManager:didConnectPeripheral:
2014-04-22 11:38:55:071 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:38:55:439 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error:
2014-04-22 11:38:55:440 MyApp[271:7827] Error Domain=CBErrorDomain Code=10 "The connection has failed unexpectedly." UserInfo=0x14d84060 {NSLocalizedDescription=The connection has failed unexpectedly.}
2014-04-22 11:38:55:443 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:38:57:145 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error:
2014-04-22 11:38:57:146 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:38:57:647 MyApp[271:7827] < centralManager:didConnectPeripheral:
2014-04-22 11:38:57:649 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:38:58:018 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error:
2014-04-22 11:38:58:018 MyApp[271:7827] Error Domain=CBErrorDomain Code=10 "The connection has failed unexpectedly." UserInfo=0x14e7fa90 {NSLocalizedDescription=The connection has failed unexpectedly.}
2014-04-22 11:38:58:021 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:38:58:285 MyApp[271:7827] < centralManager:didConnectPeripheral:
2014-04-22 11:38:58:288 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:38:58:677 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error: green
2014-04-22 11:38:58:678 MyApp[271:7827] Error Domain=CBErrorDomain Code=10 "The connection has failed unexpectedly." UserInfo=0x14e699f0 {NSLocalizedDescription=The connection has failed unexpectedly.}
2014-04-22 11:38:58:681 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:39:00:871 MyApp[271:7827] < centralManager:didConnectPeripheral:
2014-04-22 11:39:00:875 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:39:01:604 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error: green
2014-04-22 11:39:01:604 MyApp[271:7827] Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x14d7d310 {NSLocalizedDescription=The connection has timed out unexpectedly.}
2014-04-22 11:39:01:608 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:39:02:143 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error: green
2014-04-22 11:39:02:146 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:39:02:800 MyApp[271:7827] < centralManager:didConnectPeripheral:
2014-04-22 11:39:02:804 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:39:03:538 MyApp[271:7827] < centralManager:didDisconnectPeripheral:error:
2014-04-22 11:39:03:538 MyApp[271:7827] Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly." UserInfo=0x14d7f860 {NSLocalizedDescription=The connection has timed out unexpectedly.}
...
This can loop from 1 to n times before finally:
...
2014-04-22 11:39:03:541 MyApp[271:60b] > connectPeripheral:
2014-04-22 11:39:04:733 MyApp[271:730b] < centralManager:didConnectPeripheral:
2014-04-22 11:39:04:736 MyApp[271:60b] > discoverServices:sUUIDs:
2014-04-22 11:39:05:354 MyApp[271:730b] < peripheral:didDiscoverServices: green
2014-04-22 11:39:05:355 MyApp[271:730b] > discoverCharacteristics:sUUID:cUUIDs:
2014-04-22 11:39:05:804 MyApp[271:730b] < peripheral:didDiscoverCharacteristicsForService:error:
2014-04-22 11:39:05:806 MyApp[271:730b] > setNotificationForCharacteristic:sUUID:cUUID:enable:
2014-04-22 11:39:05:923 MyApp[271:730b] < peripheral:didUpdateValueForCharacteristic:error:
2014-04-22 11:39:05:926 MyApp[271:730b] > discoverCharacteristics:sUUID:cUUIDs:
2014-04-22 11:39:05:929 MyApp[271:730b] < peripheral:didUpdateNotificationStateForCharacteristic:error:
2014-04-22 11:39:05:930 MyApp[271:730b] < peripheral:didDiscoverCharacteristicsForService:error:
2014-04-22 11:39:05:930 MyApp[271:730b] > readCharacteristic:sUUID:cUUID:
2014-04-22 11:39:06:013 MyApp[271:730b] < peripheral:didUpdateValueForCharacteristic:error:
... connection succeeds.
Any help would be greatly appreciated.
Cheers,
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden