Not to display Pairing pop up mssage during Bluetooth pairing With 32feetnet in Windows 10

∥☆過路亽.° 提交于 2019-12-11 05:00:03

问题


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.


回答1:


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;

}


来源:https://stackoverflow.com/questions/51974013/not-to-display-pairing-pop-up-mssage-during-bluetooth-pairing-with-32feetnet-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!