Xan*_*vis 7 .net c# bluetooth windows-10 uwp
这个问题可能很愚蠢,也许第一个被接受的答案将解释为什么这不是一个预期的用例。
是否可以获得已经连接到机器的 BT 设备列表?
机器是 Win10 机器,使用“纯”C#/.Net 会很好,虽然也有 32feet。BT 设备不是BTLE(低能量)。
设备已经通过正常的 Windows 例程连接,目标是获取有关设备和连接状态的某种状态信息。
附录:我搜索了很多,大多数结果都在谈论如何配对和/或连接,Win7、8 和 10 的不同功能让我很困惑。这就是为什么我这次不想包含任何代码:-)
我看到了在 C# .NET 框架中获取蓝牙设备列表并通读了答案和评论。它显然不是关于 UWP,而是关于 CLI,而且,它似乎不起作用。即使使用 32feet,建议的 API 调用 DiscoverDevicesInRange 也会查找范围内且处于“可发现模式”的设备。尚未连接。在问题本身中,它指出它应该清楚地适用于 Windows.Devices.Bluetooth,但我找不到任何实际有效的东西。
您可以使用DeviceInformation.FindAllAsync(String)方法查找已配对或已连接的蓝牙设备,您可以指定字符串为BluetoothDevice.GetDeviceSelectorFromPairingState(true)或BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected)如下代码。
//Paired bluetooth devices
DeviceInformationCollection PairedBluetoothDevices =
await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromPairingState(true));
//Connected bluetooth devices
DeviceInformationCollection ConnectedBluetoothDevices =
await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));
Run Code Online (Sandbox Code Playgroud)
有关更多信息,您可以查看Enumerate devices主题和官方DeviceEnumerationAndPairing示例。
| 归档时间: |
|
| 查看次数: |
8195 次 |
| 最近记录: |