uwp - 在 Windows 10 中与 32feetnet 蓝牙配对期间不显示配对弹出消息
问题描述
我在windows 10中尝试了两种不同的方法来连接蓝牙设备。 1)用32feetnet开发了一个应用程序并尝试连接蓝牙设备,它提示pin是否匹配消息框。2. 创建一个示例通用Windows程序(UWP)连接蓝牙设备,提示pin是否匹配的消息框。
有没有办法避免pin提示消息框。
解决方案
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;
}
推荐阅读
- javascript - 从客户端验证从具有数十个 C# 属性的对象更改的任何属性
- php - PhP READING arduino 发送的串口数据
- javascript - Javascript 类型不匹配检测
- python - 通过另一个 python 脚本启动后,python 脚本不会在文本文件中写入一个单词
- python - 什么时候可以在 setup.py 脚本中使用来自 python 的后续次要版本更新的功能?
- sql-server - SQL Server TempLog.ldf 变得太大
- java - 如何在 Spring Rest 控制器中使用地图集合
- jasmine - Jasmine Data Provider - 如何运行单个测试
- docker - Tomcat 9 Manager、Docker 和无法通过登录
- java - 将日期从 java.util.Date 转换为 javax.xml.datatype.XMLGregorianCalendar 时更改