繁体   English   中英

如何在蓝牙打开的情况下检测Iphone / Ipad设备?

[英]How to detect Iphone/Ipad devices with bluetooth ON?

我正在使用BluetoothManager.framework

我有用于检测iphone / ipad蓝牙设备的示例示例。 但是此示例应用程序未检测到我的设备。

以下是示例代码和网址的链接:

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框架时可能会更好,尤其是它不是私有的。 使用蓝牙,您必须创建一个CBCentralManager实例。 比您必须实现CBCentralManagerDelegate协议和CBPeripheralDelegate协议。 您可以通过询问CBCentralManager状态来测试您的硬件是否支持蓝牙4.0。 例如:CBCentralMangerStateUnsupported表示您的硬件不支持BT 4.0。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM