iphone - 如何检测蓝牙开启的Iphone/Ipad设备?

标签 iphone objective-c ios5 bluetooth

我正在使用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/

相关文章:

ios - 调用了 viewWillAppear 但在 pushViewController 之后未调用 viewDidAppear

iPhone 将我网站上的日期转换为电话号码——我该如何防止这种情况发生?

iphone - 如何在ios5中将NSString转换为JSON格式?

ios - UIView 层次结构中的顶级 View

iphone - 如果我使用@property,还需要声明实例变量吗?

ios - 为什么当应用程序从后台返回时不会调用 viewWillAppear?

objective-c - 复制 NSDate 对象并释放

objective-c - 如何判断 NSString 中是否存在 "."?

iphone - AVAudioPlayer 在 iOS sdk 的振动模式下播放一点点

iphone - GTM OAuth iOS5 保留访问 token