代码之家  ›  专栏  ›  技术社区  ›  Josh Freeman

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

  •  1
  • Josh Freeman  · 技术社区  · 16 年前

    第三方应用程序如何做到这一点?

    1 回复  |  直到 16 年前
        1
  •  6
  •   Ken Aspeslagh    16 年前

    如果你不介意使用一些私人物品,你可以这样做:

    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");
        }
    }