如何在OS X上检查硬件BLE支持?

Tho*_*mas 7 macos bluetooth-lowenergy

我在这里读到,2011年中期的Apple电脑应该支持BLE(低功耗蓝牙).有没有办法(可能使用命令行)检查设备和操作系统是否支持BLE?

ric*_*cht 6

在Mac OS X终端应用程序中,您可以键入以下内容:

system_profiler -detailLevel full SPBluetoothDataType | grep "LMP Version"
Run Code Online (Sandbox Code Playgroud)

如果此命令输出> = '0x6'则支持蓝牙4.0,因此也支持BLE.


Tho*_*mas 2

显然,iOS 和 OSX 的 CBCentralManager api 是相同或非常相似的(不确定这是否是预期的,因为我刚刚开始使用 iOS 和 OS X),从某种意义上说,可以运行代码:

switch ([_manager state])
{
    case CBCentralManagerStateUnsupported:
        state = @"This device does not support Bluetooth Low Energy.";
        break;
    case CBCentralManagerStateUnauthorized:
        state = @"This app is not authorized to use Bluetooth Low Energy.";
        break;
    case CBCentralManagerStatePoweredOff:
        state = @"Bluetooth on this device is currently powered off.";
        break;
    case CBCentralManagerStateResetting:
        state = @"The BLE Manager is resetting; a state update is pending.";
        break;
    case CBCentralManagerStatePoweredOn:
        state = @"Bluetooth LE is turned on and ready for communication.";
        break;
    case CBCentralManagerStateUnknown:
        state = @"The state of the BLE Manager is unknown.";
        break;
    default:
        state = @"The state of the BLE Manager is unknown.";

}
Run Code Online (Sandbox Code Playgroud)

在 OS X 中提供了等效的iOS 问答(感谢 Bob),并了解设备是否支持 ble。