我试图实现使用IOS 5.0.1 iPhone 4S的蓝牙设备发现。 我使用的是私有的框架BluetoothManager。
我的代码是:
- (IBAction)searchForDevices:(id)sender
{
[self.indicator setHidden:NO];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bluetoothAvailabilityChanged:) name:@"BluetoothAvailabilityChangedNotification" object:nil];
btCont = [BluetoothManager sharedInstance];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDiscovered:) name:@"BluetoothDeviceDiscoveredNotification" object:nil];
}
- (void)bluetoothAvailabilityChanged:(NSNotification *)notification
{
self.label.text = @"Availability changed!";
[btCont setDeviceScanningEnabled:YES];
}
- (void)deviceDiscovered:(BluetoothDevice *)device
{
[self.indicator setHidden:YES];
self.label.text = device.address;
我的蓝牙耳机发现。 deviceDiscovered回调函数被调用,但device.address不包含蓝牙设备的MAC地址。 该应用程序崩溃。 此外,device.name返回的通知(BluetoothDeviceDiscoveredNotification),而不是发现的设备名称的名称。
任何建议,我怎么能找回我的蓝牙耳机这种方式的MAC地址?
谢谢!