我正在尝试以编程方式将我的Windows 8笔记本与Android设备配对。
我正在使用Windows bluetooth API:
NativeMethods.BluetoothRegisterForAuthenticationEx(ref device, out m_regHandle, myCallback, IntPtr.Zero);
BLUETOOTH_DEVICE_INFO btDevice= new BLUETOOTH_DEVICE_INFO(device.ToInt64());
byte[] pbtOobData = (byte[]) null;
string myPin = "357689"
NativeMethods.BluetoothAuthenticateDevice(IntPtr.Zero, IntPtr.Zero, ref btDevice, myPin, myPin.Length);
这些是Pinvoke声明:
[DllImport("Irprops.cpl", CharSet = CharSet.Unicode, SetLastError = true)]
internal extern static int BluetoothAuthenticateDevice(IntPtr hwndParent, IntPtr hRadio, ref BLUETOOTH_DEVICE_INFO pbtdi, string pszPasskey, int ulPasskeyLength);
[DllImport("bthprops.cpl", CharSet = CharSet.Unicode, SetLastError = true)]
internal extern static uint BluetoothRegisterForAuthenticationEx(ref BLUETOOTH_DEVICE_INFO pbtdi, out BluetoothAuthenticationRegistrationHandle phRegHandle, NativeMethods.BluetoothAuthenticationCallbackEx pfnCallback, IntPtr pvParam);
我可以使用这种方法配对设备,我可以看到设备中有一对配对请求。但问题是请求中的PIN不是我指定的PIN。
如何设置自己的PIN?