iPhone4S可以通过CoreBluetooth连接MBA吗?

发布于 2024-12-26 06:31:11 字数 933 浏览 6 评论 0原文

我正在尝试通过蓝牙在 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...
}

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

I'm trying to send/receive data between iOS and OSX via Bluetooth.

Because GameKit doesn't support OSX, I need to use other options.
iPhone4S and latest Mac Book Air support Bluetooth 4.0,
so I think it is possible to establish a connection between these devices.

But my sample codes below doesn't work and need your help.
Though I just create CBCentralManager and start to scan devices(having two iPhone4S and MBA at hand),
– centralManager:didDiscoverPeripheral:advertisementData:RSSI: is never called...

- (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...
}

What's wrong with my code? Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

鸢与 2025-01-02 06:31:11

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

No, im afraid CoreBluetooth is only for Low Energy devices (watches, health monitors etc...)
It is not possible to connect two Low Energy "Host" devices together using this Bluetooth Profile.

坦然微笑 2025-01-02 06:31:11

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

Apple 刚刚发布了最新的

For iOS 5.x you cannot. But as CoreBluetooth framework has been augmented in iOS 6.x (, especially the CBPeripheralManager), transferring data between two BLE devices is made possible.

Apple has just published the latest sample code.

过潦 2025-01-02 06:31:11

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

您应该检查此 Apple 技术说明,它清楚地解释了您可以通过 MBP 使用 Bluetooth LE 又名 CoreBluetooth API,但是您必须插入蓝牙 LE USB 适配器

I don't think Dermot gave us a correct full answer.

You should check on this Apple technical note, it clearly explains that you can use Bluetooth LE aka CoreBluetooth API through your MBP but you have to plug a Bluetooth LE USB adapter

陌路终见情 2025-01-02 06:31:11

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

As of iOS 7.0 and OS X Mavericks, I believe this is possible. Check the latest CoreBluetooth documentation for both operating systems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文