Is there any way to use Bluetooth LE from a c# des

2020-01-29 00:45发布

Everything I found online regarding bluetooth LE requires a universal windows app, which is completely unsuitable for me.

Is there a way to use bluetooth LE from c# without having to write my whole app as on UWP?

2条回答
再贱就再见
2楼-- · 2020-01-29 01:28

I have worked with and around the Microsoft partial Bluetooth API solutions since the XP days. I found a library from BTFramework that I have used extensively, on many platforms and in several languages. The Bluetooth Classic and Low Energy API packages from BTFramework have been easy to use, very reliable, and they've been super-responsive to any defects I did find. Our commercial product, as a result, has zero failures arising from the Bluetooth side. The team at BTFramework has taken on the job of working around Microsoft's partial implementations of the standard. We mainly code in C# dot NET, by the way. And we use many threads in the application.

查看更多
乱世女痞
3楼-- · 2020-01-29 01:32

You can use C# APIs in C# Desktop applications! I have a sample here in GitHub.

In general, to get access to the C# APIS, add two references to your project:

  1. C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
  2. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll

Note that the #2 version depends on the version of .NET that you're using.

Background tasks will not be supported, but all other Bluetooth C# features should be there.

查看更多
登录 后发表回答