2010-02-06 119 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

相关问题