简体   繁体   English

蓝牙扫描C#

[英]Bluetooth scan C#

I'm developing a C# WinForms app on Windows 10. I want to perform a Bluetooth environment scan and get devices list all around the PC. 我正在Windows 10上开发C#WinForms应用程序。我想执行蓝牙环境扫描并获取PC周围的设备列表。 I also want the RSSI of each device. 我还希望每个设备的RSSI。

I have tried 32feet library but I can't access RSSI. 我已经尝试过32feet库,但是无法访问RSSI。

Have you a solution or should I migrate to WPF/UWP? 您是否有解决方案,还是应该迁移到WPF / UWP?

ok, I have found a solution here . 好的,我在这里找到了解决方案。

  1. You first have to install Windows10 development kit. 您首先必须安装Windows10开发套件。
  2. Then in your project you have to add this library: 然后,在您的项目中,您必须添加以下库:

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

    Or you can install the "UwpDesktop" NuGet Package. 或者,您可以安装“ UwpDesktop” NuGet软件包。

  3. This works with Console app, Winforms, WPF and UWP. 这适用于控制台应用程序,Winforms,WPF和UWP。

  4. Here is a simple example: 这是一个简单的示例:

     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); } } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM