1

CBCenteralManager我在viewdidload主队列中初始化。第一次调用更新状态方法并开始扫描蓝牙设备,但didDiscoverPeripheral:从未调用委托方法。

代码是:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.CM = [[CBCentralManager alloc]initWithDelegate:self queue:nil];
}

-(void)centralManagerDidUpdateState:(CBCentralManager *)central{

    if (central.state == CBCentralManagerStatePoweredOn) {

        [self.CM scanForPeripheralsWithServices:nil options:nil];

    }
}

- (void)centralManager:(CBCentralManager *)central   didDiscoverPeripheral(CBPeripheral*)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {   
}
-(void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals{

}
-(void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals{

}
-(void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{

}
-(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{

}
-(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{

}
4

0 回答 0