C# 获取设备的蓝牙版本

C# 获取设备的蓝牙版本,c#,.net,uwp,bluetooth,windows-10,C#,.net,Uwp,Bluetooth,Windows 10,我需要验证蓝牙LE 5.0设备是否连接到计算机。我一直在查看可以查询的设备的所有属性,但没有找到包含该设备蓝牙版本的属性。这可以使用UWP或任何其他方法完成吗 这是我用来探索使用UWP可以获得的数据的代码: string aqsFilter = "System.Devices.DevObjectType:=5 AND (System.Devices.Aep.ProtocolId:=\"{BB7BB05E-5972-42B5-94FC-76EAA7084D49}\"

我需要验证蓝牙LE 5.0设备是否连接到计算机。我一直在查看可以查询的设备的所有属性,但没有找到包含该设备蓝牙版本的属性。这可以使用UWP或任何其他方法完成吗

这是我用来探索使用UWP可以获得的数据的代码:

string aqsFilter = "System.Devices.DevObjectType:=5 AND (System.Devices.Aep.ProtocolId:=\"{BB7BB05E-5972-42B5-94FC-76EAA7084D49}\" OR System.Devices.Aep.ProtocolId:=\"{E0CBF06C-CD8B-4647-BB8A-263B43F0F974}\") AND (System.Devices.Aep.IsConnected:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.Bluetooth.IssueInquiry:=System.StructuredQueryType.Boolean#False)";
        string[] requestedProperties = {
            "System.Devices.Aep.Category",
            "System.DeviceInterface.Bluetooth.DeviceAddress",
            "System.DeviceInterface.Bluetooth.Flags",
            "System.Devices.Aep.Bluetooth.Le.AddressType",
            "System.Devices.Aep.Bluetooth.Le.Appearance",
            "System.Devices.Aep.Bluetooth.Le.Appearance.Category",
            "System.Devices.Aep.Bluetooth.Le.Appearance.Subcategory",
            "System.Devices.Aep.DeviceAddress",
            "System.Devices.AepService.ServiceClassId",
            "System.Devices.Aep.ProtocolId",
            "System.Devices.AepService.ProtocolId"
        };
        DeviceInformationCollection ConnectedBluetoothDevices = await DeviceInformation.FindAllAsync(aqsFilter, requestedProperties); //aqsFilter

        foreach (DeviceInformation connectedBluetoothDevice in ConnectedBluetoothDevices)
        {
            Console.WriteLine(connectedBluetoothDevice.Name);
            Console.WriteLine("  " + connectedBluetoothDevice.Id);
            Console.WriteLine("  " + connectedBluetoothDevice.Kind.ToString());
            Console.WriteLine("  " + connectedBluetoothDevice.Properties.Count);

            foreach (KeyValuePair<string, object> property in connectedBluetoothDevice.Properties)
            {
                if (property.Value != null && property.Value.GetType().IsArray)
                {
                    String[] array = (String[])property.Value;
                    Console.WriteLine("    " + property.Key + " = " + array[0]);
                }
                else
                {
                    Console.WriteLine("    " + property.Key + " = " + property.Value);
                }
            }
        }
string aqsFilter=“System.Devices.DevObjectType:=5和(System.Devices.Aep.ProtocolId:=”{BB7BB05E-5972-42B5-94FC-76EAA708449}”或System.Devices.Aep.ProtocolId:=“{E0CBF06C-CD8B-4647-BB8A-263B43F0F974}”)和(System.Devices.Aep.IsConnected:=System.StructuredQueryType.Boolean#True或System.Devices.Aep.Bluetooth.IssueInquiry:=System.StructuredQueryType.Boolean#False)”;
字符串[]requestedProperties={
“系统.设备.Aep.类别”,
“System.DeviceInterface.Bluetooth.DeviceAddress”,
“System.DeviceInterface.Bluetooth.Flags”,
“System.Devices.Aep.Bluetooth.Le.AddressType”,
“系统。设备。Aep。蓝牙。Le。外观”,
“系统.设备.Aep.蓝牙.Le.外观.类别”,
“系统.设备.Aep.蓝牙.Le.外观.子类别”,
“系统.设备.Aep.设备地址”,
“System.Devices.AepService.ServiceClassId”,
“System.Devices.Aep.ProtocolId”,
“系统.设备.AepService.协议”
};
DeviceInformation Collection ConnectedBluetoothDevices=Wait DeviceInformation.FindAllAsync(aqsFilter,requestedProperties);//aqsFilter
foreach(连接的蓝牙设备中的设备信息连接的蓝牙设备)
{
Console.WriteLine(connectedBluetoothDevice.Name);
Console.WriteLine(“+connectedBluetoothDevice.Id”);
Console.WriteLine(“+connectedBluetoothDevice.Kind.ToString());
Console.WriteLine(“+connectedBluetoothDevice.Properties.Count”);
foreach(connectedBluetoothDevice.Properties中的KeyValuePair属性)
{
if(property.Value!=null&&property.Value.GetType().IsArray)
{
String[]数组=(String[])property.Value;
Console.WriteLine(“+property.Key+”=“+array[0]);
}
其他的
{
Console.WriteLine(“+property.Key+”=“+property.Value”);
}
}
}

System.DeviceInterface.Bluetooth.ProductVersion属性是您要查找的吗?对于蓝牙鼠标和蓝牙扬声器,该属性都为空。请告诉我您正在使用的设备是什么?我正在使用Microsoft的RJN-00025。我还临时修改了过滤器,以同时检测定期故障英国电信(非LE)设备也列出Bose SoundLink扬声器的属性。对于这两种设备,属性
System.DeviceInterface.Bluetooth.ProductVersion
为空。我查看了属性列表,但找不到包含我所需信息的属性。可能有一个,但我找不到有关如何解释它的信息:
System.DeviceInterface.Bluetooth.Flags
是您要查找的
System.DeviceInterface.Bluetooth.ProductVersion
属性吗?对于蓝牙鼠标和蓝牙扬声器,该属性都是空的。请告诉我您正在使用的设备是什么?我正在使用Microsoft的RJN-00025。我还暂时修改过滤器,以检测常规BT(非LE)设备也列出Bose SoundLink扬声器的属性。对于这两种设备,属性
System.DeviceInterface.Bluetooth.ProductVersion
为空。我查看了属性列表,但找不到包含我所需信息的属性。可能有一个,但我找不到有关如何解释它的信息:
System.DeviceInterface.Bluetooth.Flags