- (NSArray *)retrieveConnectedPeripherals {
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[cbCentralManager retrieveConnectedPeripherals];
retrieveConnectedPeripheralsSema = dispatch_semaphore_create(0);
dispatch_semaphore_wait(retrieveConnectedPeripheralsSema, DISPATCH_TIME_FOREVER);
dispatch_release(retrieveConnectedPeripheralsSema);
});
return connectedPeripherals;
}
- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals {
connectedPeripherals = peripherals;
dispatch_semaphore_signal(retrieveConnectedPeripheralsSema);
}