Reputation: 53
Am working on corebluetooth framework, I can able to discover and connect with the device if both the BLE is visible. Now i got an issue is am able to discover the device once discovered peripheral was switched off due to some reason now am trying to connect that device using
[centralManager connectPeripheral:activePeripheral options:nil];
this method, but the peripheral not available to connect, so i need to check before connection is peripheral available or not.
Thanks
Upvotes: 0
Views: 1676
Reputation: 7333
You have one method :
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
if you add the scanning option like :
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:@YES, CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[manager scanForPeripheralsWithServices:nil options:options];
then the above method will be called continuously to update state of the peripheral . Then you could watch for which peripheral the method is not called for some time then remove that peripheral from the list
Or second option is to scan it again just before the connecting to the peripheral .
Upvotes: 1