[英]ios- cbcentralManager state unknown and CoreBluetooth[WARNING] <CBConcreteCentralManager> is not powered on
I am working on CoreBluetooth framework. 我正在研究CoreBluetooth框架。 I ran the famous
temperatureSensor
application but when i run it on simulator I get the following warning: 我运行了著名的
temperatureSensor
应用程序,但是当我在模拟器上运行它时,出现以下警告:
CoreBluetooth[WARNING] <CBConcreteCentralManager: 0x713b550> is not powered on
and I checked the state of CBCentralManager
it is Unknown
. 我检查了
CBCentralManager
的状态为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? 我该如何解决?
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.
即使您的计算机可能具有BTLE功能,您也需要连接一个外部USB BLE加密狗才能将其与模拟器一起使用。 This application note from Apple might be helful
苹果公司的本应用笔记可能非常有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.