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

查看:43
本文介绍了在 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.

是否可以获得已经连接到机器的BT设备列表?

Is it possible to get a list of BT devices, that are already connect to the machine?

这台机器是 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,而且它似乎不起作用.即使是 32 英尺,因为对 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)code> 或 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));

有关详细信息,您可以查看主题 Enumeratedevices 和官方 DeviceEnumerationAndPairing 示例.

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

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

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