CBConcreteCentralManager未启动错误

时间:2013-06-06 04:40:55

标签: ios objective-c bluetooth

我正在尝试创建一个简单的程序,只列出每个连接的蓝牙设备的名称。我一直收到这个错误

 "CBConcreteCentralManager: (some memory address) is not powered on". 

我在iPhone 4上启用了蓝牙功能我正在测试它。我在这里做错了什么?

@interface ViewController ()

@property (strong, nonatomic) CBCentralManager *centralManager;

@end

@implementation ViewController

- (void)viewDidLoad{

    [super viewDidLoad];
    self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];
    [self.centralManager retrieveConnectedPeripherals];

}

- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals{
    for (CBPeripheral *a in peripherals){ //print all of the names
        NSLog(a.name);
    }
}

- (void)centralManagerDidUpdateState:(CBCentralManager *)central{
    NSLog([NSString stringWithFormat:@"%d", [central state]]); //prints 2, which is CBCentralManagerStateUnsupported
}

//irrelevant methods not shown

@end

1 个答案:

答案 0 :(得分:1)

iPhone 4 不支持 Bluetooth Low-Energy 。它受到 iPhone 4S 或更新版本以及 iPad 3 或更新版本以及 iPad Mini 的支持 你确定你正在寻找蓝牙低功耗(也就是“客户观点的智能蓝牙”),它与CoreBluetooth.framework或juste一起使用“经典”蓝牙,可与之配合使用ExternalAccessory.framework