在CBCentralManager委托方法中,didDiscoverPeripheral:从未调用过

时间:2014-04-02 10:27:10

标签: ios objective-c bluetooth-lowenergy core-bluetooth ios-bluetooth

我初始化主队列中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{

}

0 个答案:

没有答案