1

I tried two different approaches to connect to Bluetooth device in windows 10. 1)Developed an application with 32feetnet and tried to connect to Bluetooth device, it is prompting with whether pin is matched or not message box. 2. Created a sample Universal Windows program(UWP) to connect to Bluetooth device, it is prompting with whether pin is matched or not message box.

Is there any away to avoid the pin prompting message box.

  • [Same question and asnwer](https://stackoverflow.com/questions/49469499/supressing-system-dialog-when-pairing-bluetooth-devices-using-win-7-or-win-10/49473916#49473916) – Mike Petrichenko Aug 22 '18 at 20:15
  • Hi Mike, I saw your answer in the other link, Can you please share me the code details if you don't have concerns. My skype id is ashok_palakurthi – Ashok Palakurthi Aug 28 '18 at 17:36
  • 1
    https://stackoverflow.com/questions/36919276/bluetooth-pairing-ssp-on-windows-10-with-32feet-net also helped me in solving this. – Ashok Palakurthi Sep 07 '18 at 13:05

1 Answers1

0

EventHandler authHandler = new EventHandler(handleAuthRequests); BluetoothWin32Authentication authenticator = new BluetoothWin32Authentication(authHandler);

private void btnPairSSP_Click(object sender, EventArgs e)
{
    BluetoothDeviceInfo selectedDevice = devices[lstBTDevices.SelectedIndex];
    if (MessageBox.Show(String.Format("Would you like to attempt to pair with {0}?", selectedDevice.DeviceName), "Pair Device", MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        Task t = new Task(PairBluetoothTask);
        t.Start();
    }
}

private void PairBluetoothTask()
{
    BluetoothDeviceInfo selectedDevice = devices[lstBTDevices.SelectedIndex];
    if (BluetoothSecurity.PairRequest(selectedDevice.DeviceAddress, null))
    {
        MessageBox.Show("We paired!");
    }
    else
    {
        MessageBox.Show("Failed to pair!");
    }

}

private void handleAuthRequests(object sender, BluetoothWin32AuthenticationEventArgs e)
{
    e.Confirm = true;

}