Bluetooth scan C#

此生再无相见时 提交于 2019-12-04 21:28:36

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);
            }
        }
    }
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!