【发布时间】:2013-06-09 15:33:04
【问题描述】:
我知道如何使用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];
}
}
【问题讨论】:
标签: iphone ios core-bluetooth bluetooth-lowenergy