Mac OS X / Bluetooth: programación desactivar emparejamiento simple?
-
19-09-2019 - |
Pregunta
La aplicación Explorador de Bluetooth desde las herramientas dev (/ desarrollador / Aplicaciones / Utilidades / Bluetooth /) le permite apagar Simple Pairing en su dispositivo. (Ejecutar la aplicación, seleccione la opción: "Utilidades> Obtener Información del dispositivo local", y haga clic en la pestaña "Simple Pairing").
¿Cómo sería una aplicación de 3 ª parte hacer esto?
Solución
Si no les importa usar algunas cosas en privado, puede hacerlo de esta manera:
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");
}
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow