BluetoothAdapter.GetDefaultAsync().Completed = (asyncInfo, asyncStatus) =>
{
if (asyncStatus == AsyncStatus.Completed)
{
BluetoothAdapter mBluetoothAdapter = asyncInfo.GetResults();
if (mBluetoothAdapter == null || !mBluetoothAdapter.IsCentralRoleSupported)
{
Console.WriteLine("未发现可用的蓝牙适配器");
}
}
if (asyncStatus == AsyncStatus.Error)
{
Console.WriteLine("检测蓝牙适配器时发生错误");
}
};
此外最好结合Radio的判断
通过这个判断,而不需要wmi去查询设备或者通过网络信息判断
BluetoothAdapter这个类在介绍ble的文章中都有介绍在哪引入