我是一名有用的助手,可以为您翻译以下内容:
我正在尝试在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地址吗?