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

查看:122
本文介绍了在 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 会很好,虽然也有 32feet.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,建议的 API 调用 DiscoverDevicesInRange 也会查找范围内且处于可发现模式"的设备.尚未连接.在问题本身中,它指出它应该清楚地适用于 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()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));

有关更多信息,您可以查看主题Enumerate设备和官方DeviceEnumeration>AndPairing

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

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

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