首页 > 解决方案 > 在 Windows 10 中与 32feetnet 蓝牙配对期间不显示配对弹出消息

问题描述

我在windows 10中尝试了两种不同的方法来连接蓝牙设备。 1)用32feetnet开发了一个应用程序并尝试连接蓝牙设备,它提示pin是否匹配消息框。2. 创建一个示例通用Windows程序(UWP)连接蓝牙设备,提示pin是否匹配的消息框。

有没有办法避免pin提示消息框。

标签: uwpbluetoothwindows-10-desktop32feet

解决方案


EventHandler authHandler = new EventHandler(handleAuthRequests); BluetoothWin32Authentication 验证器 = 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;

}

推荐阅读