Question

The Bluetooth Explorer app from the dev tools (/Developer/Applications/Utilities/Bluetooth/) allows you to turn off Simple Pairing on your device. (Run the app, select menu item: "Utilities>Get Local Device Info", and click on the "Simple Pairing" tab).

How would a 3rd-party application do this?

Was it helpful?

Solution

If you don't mind using some private stuff, you can do it like this:

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");
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top