winform调用 ble低耗能蓝牙接口 InTheHand.Net.Personal.dll不支持ble低耗能蓝牙
用WIN10自带的await BluetoothLEDevice.FromIdAsyn没有反应
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Windows.Devices.Bluetooth;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private BluetoothLEDevice bluetoothLeDevice = null;
public Form1()
{
InitializeComponent();
}
private async void ConnectButton_Click()
{
try
{
// BT_Code: BluetoothLEDevice.FromIdAsync must be called from a UI thread because it may prompt for consent.
bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync("BluetoothLE#BluetoothLEb8:86:87:f6:1e:a5-78:a5:04:91:db:fc");
}
catch (Exception ex) when ((uint)ex.HResult == 0x800710df)
{
// ERROR_DEVICE_NOT_AVAILABLE because the Bluetooth radio is not on.
}
}
private void button1_Click(object sender, EventArgs e)
{
ConnectButton_Click();
}
}
}