ios- cbcentralManager state unknown and CoreBluetooth[WARNING] <CBConcreteCentralManager> is not powered on

穿精又带淫゛_ 提交于 2019-12-11 04:21:16

问题


I am working on CoreBluetooth framework. I ran the famous temperatureSensor application but when i run it on simulator I get the following warning:

 CoreBluetooth[WARNING] <CBConcreteCentralManager: 0x713b550> is not powered on

and I checked the state of CBCentralManager it is Unknown. Following is the code:

(void) startScanningForUUIDString:(NSString *)uuidString {
    centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

    if ([centralManager state] == CBCentralManagerStatePoweredOff) NSLog(@"CBCentralManagerStatePoweredOff");
    if ([centralManager state] == CBCentralManagerStatePoweredOn) NSLog(@"CBCentralManagerStatePoweredOn");
    if ([centralManager state] == CBCentralManagerStateResetting) NSLog(@"CBCentralManagerStateResetting");
    if ([centralManager state] == CBCentralManagerStateUnauthorized) NSLog(@"CBCentralManagerStateUnauthorized");
    if ([centralManager state] == CBCentralManagerStateUnknown) NSLog(@"CBCentralManagerStateUnknown");
    if ([centralManager state] == CBCentralManagerStateUnsupported) NSLog(@"CBCentralManagerStateUnsupported");
    NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:uuidString], nil];

    NSLog(@"%@", uuidArray);
    NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
    [centralManager scanForPeripheralsWithServices:uuidArray options:options];
}

How do I solve it?


回答1:


Seems like the bluetooth device is not connected or not detected. You will need to connect an external USB BLE dongle to be able to use it with the simulator even though your machine might be BTLE capable. This application note from Apple might be helful



来源:https://stackoverflow.com/questions/14722092/ios-cbcentralmanager-state-unknown-and-corebluetoothwarning-cbconcretecentra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!