0
votes

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

1
Do you want a list of available Bluetooth devices? or you need to check for a designated device?Tarek Hallak
I have device list. Once discovered my peripheral getting closed that time am trying to connect.Ganesh

1 Answers

1
votes

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 .