我尝试了两种不同的方法来连接到Windows 10中的蓝牙设备.1)开发了一个32feetnet的应用程序并尝试连接到蓝牙设备,它提示是否匹配引脚消息框。 2.创建一个示例通用Windows程序(UWP)连接到蓝牙设备,提示是否匹配引脚消息框。
有没有什么可以避免引脚提示消息框。
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;
}