蓝牙扫描C# [英] Bluetooth scan C#
本文介绍了蓝牙扫描C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Windows 10上开发C#WinForms应用程序.我想执行蓝牙环境扫描并获取PC周围的所有设备列表.我还想要每个设备的RSSI.
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.
我尝试了32feet库,但是无法访问RSSI.
I have tried 32feet library but I can't access RSSI.
您有解决方案,还是应该迁移到WPF/UWP?
Have you a solution or should I migrate to WPF/UWP?
推荐答案
ok, I have found a solution here.
- 您首先必须安装Windows10开发套件.
-
然后在您的项目中,您必须添加以下库:
- You first have to install Windows10 development kit.
Then in your project you have to add this library:
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
或者您可以安装"UwpDesktop" NuGet软件包.
Or you can install the "UwpDesktop" NuGet Package.
这可与控制台应用程序,Winforms,WPF和UWP一起使用.
This works with Console app, Winforms, WPF and UWP.
这是一个简单的示例:
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);
}
}
}
这篇关于蓝牙扫描C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文