private bool Callback(IntPtr pvParam, ref BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams) { switch (pAuthCallbackParams.authenticationMethod) { case BluetoothAuthenticationMethod.Passkey: case BluetoothAuthenticationMethod.NumericComparison: BLUETOOTH_AUTHENTICATE_RESPONSE__NUMERIC_COMPARISON_PASSKEY_INFO nresponse = new BLUETOOTH_AUTHENTICATE_RESPONSE__NUMERIC_COMPARISON_PASSKEY_INFO { authMethod = pAuthCallbackParams.authenticationMethod, bthAddressRemote = pAuthCallbackParams.deviceInfo.Address, numericComp_passkey = pAuthCallbackParams.Numeric_Value_Passkey }; return(Win32Native.BluetoothSendAuthenticationResponseEx(IntPtr.Zero, ref nresponse) == 0); case BluetoothAuthenticationMethod.Legacy: BLUETOOTH_AUTHENTICATE_RESPONSE__PIN_INFO response = new BLUETOOTH_AUTHENTICATE_RESPONSE__PIN_INFO(); response.authMethod = pAuthCallbackParams.authenticationMethod; response.bthAddressRemote = pAuthCallbackParams.deviceInfo.Address; response.pinInfo.pin = new byte[16]; System.Text.Encoding.ASCII.GetBytes(_pin).CopyTo(response.pinInfo.pin, 0); response.pinInfo.pinLength = _pin.Length; return(Win32Native.BluetoothSendAuthenticationResponseEx(IntPtr.Zero, ref response) == 0); } return(false); }