macos - Core Bluetooth 和 IOBluetooth 有什么区别

标签 macos bluetooth core-bluetooth iobluetooth

此问题已在 Stack Overflow in 2013 上被问到, 但它需要更新。自 macOS 10.13 以来,macOS 的 Core Bluetooth 功能已更改,以使其更符合 iOS。

这个问题的答案是

CoreBluetooth is an iOS framework for Bluetooth LE communication. IOBluetooth is an OS X framework

这不再是真的了,Core Bluetooth 不是 独有的 iOS 框架,尽管 IOBluetooth 是 macOS 独有的

CoreBluetooth is for accessing Bluetooth Low Energy APIs. and IOBluetooth is for Bluetooth Classic Interface

这也不正确,因为 Core Bluetooth 并非专用于 BLE。

CoreBluetooth 文档指出:

Communicate with Bluetooth low energy and BR/EDR (“Classic”) Devices.

这看起来很简单; Core Bluetooth 用于蓝牙通信,包括 BLE 和 Classic。

IOBluetooth 文档指出:

Gain user-space access to Bluetooth devices.

但这并不是特别有启发性。

在 macOS 10.13+ 上的 CoreBluetooth 时代,IOBluetooth 与 macOS 上的 CoreBluetooth 的主要现代用例是什么?

最佳答案

CoreBluetooth 支持 BLE、GATT over BR/EDR 和 L2CAP。尽管它是摘要,但它不支持大多数经典配置文件。特别是,它支持 GATT over BR/EDR。它不支持其他协议(protocol)。 (根据我的经验,GATT over BR/EDR 非常罕见。我从未遇到过真正支持它的设备。)它不支持 SDP,不能用于发现大多数经典设备。

IOBluetooth 支持各种经典协议(protocol),包括 SDP、RFCOMM 和 L2CAP。它支持音频和 HCI 设备。据我所知,它并不直接支持 BLE;为此,它嵌入了 CoreBluetooth。 (我相信它可以对 BLE 进行一些非常低级别的发现,但这不是您想要使用的。)

我认为这在 10.13 中没有根本改变。最大的变化(我认为主要是为了支持 Catalyst)是 Core Bluetooth 在平台之间变得更加统一。我不认为这从根本上改变了框架的用途。

关于macos - Core Bluetooth 和 IOBluetooth 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68793810/

相关文章:

iphone - 是否可以以编程方式访问 CoreBluetooth 记录的错误代码?

iOS 蓝牙 retrievePeripherals 导致 EXC_BAD_ACCESS 崩溃

macos - 在Mac OS X上使用AudioUnit检测扬声器/耳机

macos - 在 Mac OS X 上停止 mongod 的干净方法是什么?

java - 深度 sleep 连接蓝牙设备失败

java - Android 蓝牙 - 检测与设备的断开连接

node.js - 使用 Homebrew 安装 Node 版本后如何更改它?

macos - Mac OS X Mavericks 上为 "/etc/sudoers is world writable"

android - 如何获得蓝牙低功耗设备的 RSSI 值?

ios - 代理在 BLE 身份验证上不可用