Mac OS X / Bluetooth: программно отключить простое сопряжение?

Приложение Bluetooth Explorer из инструментов разработчика (/ Developer / Applications / Utilities / Bluetooth /) позволяет отключить простое сопряжение на вашем устройстве. (Запустите приложение, выберите пункт меню: «Утилиты> Получить информацию о локальном устройстве» и щелкните вкладку «Простое сопряжение»).

Как это сделает стороннее приложение?


person Josh Freeman    schedule 06.02.2010    source источник


Ответы (1)


Если вы не против использовать какие-то личные вещи, вы можете сделать это так:

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");
    }
}
person Ken Aspeslagh    schedule 06.02.2010