问题
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