【问题标题】:Is it possible to connect iPhone4S to MBA via CoreBluetooth?是否可以通过 CoreBluetooth 将 iPhone4S 连接到 MBA?
【发布时间】:2012-02-08 17:26:09
【问题描述】:

我正在尝试通过蓝牙在 iOS 和 OSX 之间发送/接收数据。

因为 GameKit 不支持 OSX,我需要使用其他选项。 iPhone4S 和最新的 Mac Book Air 支持蓝牙 4.0, 所以我认为可以在这些设备之间建立连接。

但我下面的示例代码不起作用,需要您的帮助。 虽然我只是创建了 CBCentralManager 并开始扫描设备(手头有两个 iPhone4S 和 MBA), – centralManager:didDiscoverPeripheral:advertisementData:RSSI: 从未被调用...

- (void)start {
    self.mgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil] autorelease];
    NSDictionary * opts = [NSDictionary dictionaryWithObjectsAndKeys:
                                            [NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
    [self.mgr scanForPeripheralsWithServices:nil options:opts];
}

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
    // not called this delegate method...
}

我的代码有什么问题?我错过了什么吗?

【问题讨论】:

    标签: objective-c macos ios5 core-bluetooth


    【解决方案1】:

    从 iOS 7.0 和 OS X Mavericks 开始,我相信这是可能的。查看两个操作系统的最新 CoreBluetooth 文档。

    【讨论】:

      【解决方案2】:

      对于 iOS 5.x,您不能。但随着 iOS 6.x(尤其是 CBPeripheralManager)中增强了 CoreBluetooth 框架,两个 BLE 设备之间的数据传输成为可能。

      Apple 刚刚发布了最新的sample code

      【讨论】:

        【解决方案3】:

        我认为德莫特没有给我们一个正确的完整答案。

        您应该查看Apple technical note,它清楚地说明您可以通过 MBP 使用 Bluetooth LE aka CoreBluetooth API,但您必须插入 Bluetooth LE USB 适配器

        【讨论】:

          【解决方案4】:

          不,恐怕 CoreBluetooth 仅适用于低功耗设备(手表、健康监视器等...) 无法使用此蓝牙配置文件将两个低功耗“主机”设备连接在一起。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2019-11-04
            • 2015-02-14
            • 2012-02-09
            • 1970-01-01
            • 1970-01-01
            • 2017-08-10
            • 1970-01-01
            相关资源
            最近更新 更多