iOS蓝牙无法正常工作

时间:2015-10-23 22:08:54

标签: ios objective-c iphone bluetooth

我的目的是检查我的设备(iPhone 6)蓝牙是否正常工作。为此,我尝试了以下代码。但是当我尝试使用失败的蓝牙设备时,它并没有调用委托。我有理由,因为蓝牙不起作用,这就是代表没有接到电话的原因。但我如何判断,蓝牙无法用于iPhone或蓝牙有一些问题。

-(void)callBluetooth
{
    start = [NSDate date];

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerOptionShowPowerAlertKey, nil];

    ce = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
}

#pragma mark - Bluetooth Delegate

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

    if (central.state == CBCentralManagerStatePoweredOff) {
        status = CASE_STATUS_SKIPPED;
    }
    else if(!(central.state == CBCentralManagerStateUnsupported) && central.state == CBCentralManagerStatePoweredOn){
        if ([central respondsToSelector:@selector(scanForPeripheralsWithServices:options:)]) {
            status = CASE_STATUS_PASS;
        }
        else{
            status = CASE_STATUS_FAIL;
        }

    }
    else{
        status = CASE_STATUS_FAIL;
    }
    [self performSelector:@selector(callDelegate) withObject:nil afterDelay:1];

}

0 个答案:

没有答案