2010-02-06 112 views
1

開發工具(/ Developer/Applications/Utilities/Bluetooth /)中的藍牙資源管理器應用程序允許您關閉設備上的簡單配對。 (運行應用程序,選擇菜單項:「實用程序>獲取本地設備信息」,然後單擊「簡單配對」選項卡)。Mac OS X /藍牙:以編程方式禁用簡單配對?

第三方應用程序如何做到這一點?

回答

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

這工作,謝謝! – 2010-02-06 23:05:15

相關問題