我正在使用BluetoothManager.framework
我有用于检测 iphone/ipad 蓝牙设备的示例。但这个示例应用程序没有检测到我的设备。
下面是示例代码和 url 的链接:
http://www.pocketmagic.net/2012/07/bluetooth-and-ios-use-bluetooth-in-your-iphone-apps/#.URnZy-hhNDQ
BluetoothManager *btManager;
- (IBAction)scanButtonAction
{
if ([btManager enabled])
{
// start scan
[btManager setDeviceScanningEnabled:YES];
}
else
{
showMessage(@"Error", @"Turn Bluetooth on first!");
}
}
- (IBAction)bluetoothON
{
NSLog(@"bluetoothON called.");
[btManager setPowered:YES];
[btManager setEnabled:YES];
}
- (IBAction)bluetoothOFF
{
NSLog(@"bluetoothOFF called.");
[btManager setEnabled:NO];
[btManager setPowered:NO];
}
任何检测蓝牙设备的建议或示例将不胜感激。
最佳答案
您的蓝牙设备使用哪种蓝牙?蓝牙4.0?如果是的话,当您使用 CoreBluetooth 框架时可能会更好,尤其是它不是私有(private)的。 使用蓝牙,您必须创建一个 CBCentralManager 实例。您必须实现 CBCentralManagerDelegate 协议(protocol)和 CBPeripheralDelegate 协议(protocol)。您可以通过询问 CBCentralManager 状态来测试您的硬件是否支持蓝牙 4.0。例如:CBCentralMangerStateUnsupported 表示您的硬件不支持 BT 4.0。
关于iphone - 如何检测蓝牙开启的Iphone/Ipad设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14832358/