0

我正在尝试制作一个简单的程序,它只列出每个连接的蓝牙设备的名称。我不断收到此错误

 "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
4

1 回答 1

1

iPhone 4不支持蓝牙低功耗。它受iPhone 4S或更新版本、iPad 3或更新版本和iPad Mini
的支持 您确定您正在寻找与“经典”蓝牙一起使用或仅适用于“经典”蓝牙的低功耗蓝牙(也称为“智能蓝牙”)CoreBluetooth.framework,哪个适用于ExternalAccessory.framework

于 2013-07-29T20:00:39.553 回答