获取Windows 10上已连接的蓝牙设备的列表 [英] Getting a list of already connected bluetooth devices on Windows 10

查看:1183
本文介绍了获取Windows 10上已连接的蓝牙设备的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能很愚蠢,也许第一个被接受的答案将是解释为什么这不是预期的用例的问题。

This question might be stupid, and maybe the first accepted answer will be one that explains why this is not an intended use-case.

是否有可能

该机器是Win10机器,使用纯 C#/。Net会很好,尽管那里也是32英尺。
BT设备不是 BTLE(低能耗)。

The machine is a Win10 box and using "pure" C#/.Net would be nice, although there is also 32feet. The BT device is not BTLE (low energy).

该设备已经通过正常的Windows例程和目标连接了将会获得有关设备和连接状态的某种状态信息。

The device is already connected via the normal Windows routines and the goal would be to get some kind of status information about the device and the connection status.

附录:我搜索了很多,大多数结果都谈论如何配对和/或连接Win7、8和10的不同功能使我非常困惑。这就是为什么我这次不想包括任何代码的原因:-)

Addendum: I searched a lot and most results talk about how to pair and/or connect and the different capabilities of Win7, 8 and 10 confused me quite a lot. That's why I don't want to include any code, this time :-)

我看到了在C#.NET框架中获取蓝牙设备列表,并仔细阅读答案和注释。显然,它与UWP无关,而与CLI有关,此外,它似乎也不起作用。即使使用32feet,建议的对DiscoverDevicesInRange的API调用也会查找范围内且处于可发现模式的设备。尚未连接。在问题本身中,它指出它显然应该与Windows.Devices.Bluetooth一起使用,但是我找不到任何实际起作用的东西。

I saw Getting a list of bluetooth devices in a C# .NET framework and read through the answer and the comments. It is explicitly not about UWP but a CLI and furthermore, it doesn't seem to work. Even with 32feet, as the suggested API call to DiscoverDevicesInRange looks for devices that are in range and are in ‘discoverable mode’. Not connected yet. In the question itself it states that it should clearly work with Windows.Devices.Bluetooth, but I couldn't find anything that actually works.

推荐答案

您可以使用 DeviceInformation.FindAllAsync(String)方法,您可以将字符串指定为 BluetoothDevice.GetDeviceSelectorFromPairingState(true) BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected)作为以下代码。

You can find the Paired or Connected Bluetooth device by using the DeviceInformation.FindAllAsync(String) method, you can specify the string to be BluetoothDevice.GetDeviceSelectorFromPairingState(true) or BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected) as the following code.

//Paired bluetooth devices
DeviceInformationCollection PairedBluetoothDevices =
       await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromPairingState(true));
//Connected bluetooth devices
DeviceInformationCollection ConnectedBluetoothDevices =
       await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));

有关更多信息,请参见主题枚举设备和官方 DeviceEnumerationAndPairing 示例。

For more information, you can see the topic Enumerate devices and the official DeviceEnumerationAndPairing sample.

这篇关于获取Windows 10上已连接的蓝牙设备的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆