简体   繁体   中英

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. I also want the RSSI of each device.

I have tried 32feet library but I can't access RSSI.

Have you a solution or should I migrate to WPF/UWP?

ok, I have found a solution here .

  1. You first have to install Windows10 development kit.
  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.

  3. This works with Console app, Winforms, WPF and 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); } } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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