似乎无法得到核心蓝牙的工作

我似乎无法获得核心蓝牙在我的iPad上工作。

ViewController.h

@interface ViewController : UIViewController <CBCentralManagerDelegate, CBPeripheralDelegate> { CBCentralManager *manager; } @end 

ViewController.m

 #import "ViewController.h" @interface ViewController () @property (strong, nonatomic) IBOutlet UITextView *textField; @end @implementation ViewController @synthesize textField; - (void)viewDidLoad { [super viewDidLoad]; manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)action:(id)sender { textField.text = @""; if (manager.state == CBCentralManagerStatePoweredOn) { textField.text = @"Scanning..."; NSLog(@"scanning"); [manager scanForPeripheralsWithServices:nil options:nil]; } else { textField.text = @"Error"; } } - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { NSLog(@"2"); textField.text = [NSString stringWithFormat:@"%@%@\n", textField.text, peripheral.name]; } - (void)centralManagerDidUpdateState:(CBCentralManager *)central { NSLog(@"d"); } @end 

2永远不会被logging,设备永远不会被检测到。 我确定在我的设置中启用了蓝牙。

代码有什么问题? 难道只是没有发现适用的设备? 我可以在蓝牙设置中发现我的iMac。

此外,核心蓝牙(运行在蓝牙LE设备上)是否能检测到非蓝牙LE设备? 如无线耳机?

核心蓝牙仅适用于低能耗蓝牙,您所拥有的代码只能在外设模式下发现外围蓝牙设备,如BLE标签,心率监测器,传感器或iOS 6设备 。

所以不,你不能通过这种方式检测你的iMac(OS X仍然没有通过核心蓝牙的外设模式)或无线耳机。 或者有任何其他方式与官方的SDK。