CBCentralManager未检测到附近的设备

时间:2014-10-28 11:28:27

标签: ios objective-c bluetooth cbcentralmanager

CBCentralManager未检测到附近的蓝牙设备。

- (void)viewDidLoad
{
    [super viewDidLoad];

    _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

    _data = [[NSMutableData alloc] init];
}

- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
    if (central.state == CBCentralManagerStatePoweredOn) {
        NSDictionary *options = @{CBCentralManagerScanOptionAllowDuplicatesKey: @NO};
        [_centralManager scanForPeripheralsWithServices:nil options:options];


        NSLog(@"Scanning started");
    }
    if (central.state == CBCentralManagerStateUnknown) {
        NSLog(@"CBCentralManagerStateUnknown");
    }
    if (central.state == CBCentralManagerStateResetting) {
        NSLog(@"CBCentralManagerStateResetting");
    }
    if (central.state == CBCentralManagerStateUnsupported) {
        NSLog(@"CBCentralManagerStateUnsupported");
    }
    if(central.state == CBCentralManagerStateUnauthorized) {
        NSLog(@"CBCentralManagerStateUnauthorized");
    }
    if(central.state == CBCentralManagerStatePoweredOff)
    {
        NSLog(@"CBCentralManagerStatePoweredOff");
    }
}

我已检查过状态CBCentralManagerStatePoweredOn

之后它不会调用委托方法。

0 个答案:

没有答案