【问题标题】:Bluetooth scan C#蓝牙扫描 C#
【发布时间】:2018-03-25 13:15:36
【问题描述】:

我正在 Windows 10 上开发 C# WinForms 应用程序。我想执行蓝牙环境扫描并获取 PC 周围的设备列表。我还想要每个设备的RSSI。

我尝试了 32feet 库,但无法访问 RSSI。

您有解决方案还是我应该迁移到 WPF/UWP?

【问题讨论】:

  • 我假设您已经在 32feet 文档下看到了 RSSI section 以获取对等设备信息。您要求的内容在 Windows 桌面上可能是不可能的。
  • @JeffBridgman 谢谢,Windows 7 或更低版本无法访问 RSSI。但是可以使用 Windows 10(我正在使用的平台)访问它。我在 Windows 10 上尝试了 32feet,但 RSSI 似乎不起作用。我认为问题在于 32f lib 女巫不兼容。
  • edit your question 包含更多关于“似乎不起作用”的意思的详细信息可能会有所帮助。您找不到可以获取信息的功能/属性吗?返回的信息是不是你所期望的?你有错误吗?您当前用于访问 RSSI 的代码也可用于添加对原始问题的编辑。
  • @khmub 本主题适用于 Windows 7,蓝牙 7 和 10 之间存在许多差异

标签: c# winforms bluetooth windows-10 rssi


【解决方案1】:

好的,我找到了解决方案here。

  1. 您首先要安装 Windows10 开发工具包。
  2. 然后在你的项目中你必须添加这个库:

    C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
    

    或者您可以安装“UwpDesktop”NuGet 包。

  3. 这适用于控制台应用、Winforms、WPF 和 UWP。

  4. 这是一个简单的例子:

    using Windows.Devices.Bluetooth.Advertisement;
    
    namespace BeaconExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                var watcher = new BluetoothLEAdvertisementWatcher();
                watcher.Received += Watcher_Received;
                watcher.Start();
            }
    
            private static void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
            {
                Console.WriteLine(args.BluetoothAddress.ToString("x") + ";" + args.RawSignalStrengthInDBm);
            }
        }
    }
    

【讨论】:

  • 仅链接的答案可能会出现问题(因为链接可能会在以后断开)。如果您总结了解决方案是什么,将对社区有所帮助。例如,也许您必须选择不同的项目类型或平台......或使用特定的 nuget 包......或者该属性可能不是您所期望的......所有有用的信息给下一个人问题:)
猜你喜欢
  • 2015-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多