我知道如何scanForPeripheralsWithServices
使用它的回调来接收新的可用外围设备通知didDiscoverPeripheral
来填充UITableView
列表。
但是,当未连接的蓝牙设备不再可用时,如何接收通知?
/****************************************************************************/
/* Discovery */
/****************************************************************************/
- (void) startScanningForUUIDString:(NSString *)uuidString
{
NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:uuidString], nil];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[centralManager scanForPeripheralsWithServices:uuidArray options:options];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
if (![foundPeripherals containsObject:peripheral]) {
[foundPeripherals addObject:peripheral];
[discoveryDelegate discoveryDidRefresh];
}
}