我正在开发一个模块,在这个模块中,我需要获得所有的蓝光设备并连接所选设备。我正在使用这个
blueManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
NSString *messtoshow;
switch (central.state) {
case CBCentralManagerStateUnknown:
{
messtoshow=[NSString stringWithFormat:@"State unknown, update imminent."];
break;
}
case CBCentralManagerStateResetting:
{
messtoshow=[NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."];
break;
}
case CBCentralManagerStateUnsupported:
{
messtoshow=[NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"];
break;
}
case CBCentralManagerStateUnauthorized:
{
messtoshow=[NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"];
break;
}
case CBCentralManagerStatePoweredOff:
{
messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered off."];
break;
}
case CBCentralManagerStatePoweredOn:
{
messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered on and available to use."];
[self.blueManager scanForPeripheralsWithServices:nil options:nil];
CBUUID *deviceInfoUUID = [CBUUID UUIDWithString:@"180A"];
NSLog(@"connected devices ios 8 code%@ ",[blueManager retrieveConnectedPeripheralsWithServices:@[deviceInfoUUID]]);
}
我的蓝牙已打开并连接到两个设备,我可以从设置中看到,但我没有得到任何设备。我已经签到了
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {}
方法,但它没有调用。我知道有两个BLE设备已连接到我的设备