Mac OS X /蓝牙:以编程方式禁用简单配对?

时间:2010-02-06 14:29:13

标签: macos bluetooth iobluetooth

开发工具(/ Developer / Applications / Utilities / Bluetooth /)中的Bluetooth Explorer应用程序允许您关闭设备上的简单配对。 (运行应用程序,选择菜单项:“实用程序>获取本地设备信息”,然后单击“简单配对”选项卡)。

第三方应用程序如何执行此操作?

1 个答案:

答案 0 :(得分:6)

如果您不介意使用某些私人内容,可以这样做:

typedef void* BluetoothHCIRequest;
OSStatus BluetoothHCIRequestCreate(BluetoothHCIRequest* outHandle, int timeOut, void* unknownOut, int alwaysZero);
void BluetoothHCIRequestDelete(BluetoothHCIRequest hciRequest);
OSStatus BluetoothHCIWriteSimplePairingMode(BluetoothHCIRequest hciRequest, BOOL onOff);

#define HCI_TIMEOUT (3000)


void SetSimplePairing(BOOL on)
{
    BluetoothHCIRequest hciRequest = nil;

    if ( BluetoothHCIRequestCreate(&hciRequest, HCI_TIMEOUT, nil, 0) == noErr && hciRequest )
    {
        OSStatus err = BluetoothHCIWriteSimplePairingMode(hciRequest, on);
        if (err)
        {
            NSLog(@"BluetoothHCIWriteSimplePairingMode: %d", err);
        }

        BluetoothHCIRequestDelete(hciRequest);
    }
    else
    {
        NSLog(@"BluetoothHCIRequestCreate failed");
    }
}