iOS: 12 Device: iPhone 6 ( but seems irrelevant )

I'm experiencing following problem while interacting with CBPeripheral. Device (peripheral) randomly disconnects after long periods of time. Prior to disconnection, app is successfully performing writes / didWrite / didRead sequences for long periods (10min - 1h - even 2h at times) -> then it suddenly stops working.

last action on app side:

[peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse]; 
(LOG: "write (17 bytes. device: connected. QueuedItems: 0)")

no further activity, shortly followed by 'didDisconnect' callback from CBCentralManager. No CBPeripheral delegate methods are called (didWrite etc..)

I've read through a lot of related topics, but nothing obvious comes up.

CBCentral init:

self.bleQueue = dispatch_queue_create("bleQueue", DISPATCH_QUEUE_SERIAL);
NSMutableDictionary *options = [NSMutableDictionary new];
options[CBCentralManagerOptionShowPowerAlertKey] = @NO;
options[CBCentralManagerOptionRestoreIdentifierKey] = self.restoreIdentifier;
self.manager = [[CBCentralManager alloc] initWithDelegate:self queue:self.bleQueue options:options];


strong reference, delegate set when connected, all writes done from another dedicated queue (dispatch_queue_create("peripheralQueue", DISPATCH_QUEUE_SERIAL);). Writing data only after previous transmission was confirmed by 'didWrite'etc.. Otherwise data is queued etc..

Other considerations: - fair amount of processing done by app ( heavy usage of GCD ) - constant data exchange across BLE ( 1Hz ) - app is in background


  • CBCentral has it's own queue. Another queue is used to send data to CBPeripheral - should be ok ( both serial / background) ?
  • What could be a reason for didWrite callback not to fire ( either success or error)?
  • Can system suspend BLE temporarily for whatever reason?
  • I guess this could as well be over-use of BLE (long uninterrupted connection) but then this does not seem to be an issue on Android devices etc)

0 Answers