适用于Windows桌面C#应用程序的Bluetooth 4.0(低能耗)API [英] Bluetooth 4.0 (low energy) API for windows desktop C# application

查看:176
本文介绍了适用于Windows桌面C#应用程序的Bluetooth 4.0(低能耗)API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,可以在Windows桌面应用程序中使用c#与Adafruit bluefruit LE(nRF8001芯片组)板接口(据我所见,我无法使用Windows.Devices命名空间而不将其侵入. )

I am looking for a way to interface with an Adafruit bluefruit LE (nRF8001 chipset) board, using c# in a windows desktop app (From what I've seen, I cannot use the Windows.Devices namespace without hacking it in.)

该设备已与平板电脑正确配对,并且在那里似乎没有问题,我只是在寻找一种从程序中接收数据的方法.

The device is properly paired to my tablet and seems to have no problems there, I'm just looking for a way to receive data from it in my program.

必须有一种方法可以做到这一点,我不能认为微软只会将蓝牙仅限于都市应用,而我只是找不到它.

There has to be a way to do this, I cant think that Microsoft would limit using bluetooth to metro apps only, I just cant find it.

推荐答案

因此,为了后代:

  1. 网络上的每个地方都说将以下内容放入您的csproj文件:

  1. Everywhere on the net says to put the below in your csproj file:

< PropertyGroup> < TargetPlatformVersion> 8.0</TargetPlatformVersion> </PropertyGroup>

<PropertyGroup> <TargetPlatformVersion>8.0</TargetPlatformVersion> </PropertyGroup>

如果您正在运行Windows 8.1,这实际上是不正确的,您必须将8.1而不是8.0放在那里.通过此更改,您可以在引用对话框的Windows->核心部分中引用"Windows"程序集.将8.0放到那里,您会得到一堆您不想要的其他东西.

This is actually incorrect if you are running windows 8.1, you have to put 8.1 there instead of 8.0. This change will allow you to reference the "Windows" assembly in the windows -> core section of the references dialog. Putting 8.0 there gets you a bunch of other things there that you don't want.

  1. 您还必须引用此dll:

C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETCore \ v4.5.1 \ System.Runtime.WindowsRuntime.dll

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5.1\System.Runtime.WindowsRuntime.dll

其中包含一些扩展方法,这些扩展方法使您可以在Windows.Foundation.IAsyncOperation实例上使用常规的await调用.这是必需的,因为这些实例不包含await关键字要查找的GetAwaiter方法.

Which contains extension methods that allow you to use regular await calls on Windows.Foundation.IAsyncOperation instances. This is required because those instances don't contain the GetAwaiter method that the await keyword looks for.

之后,您应该可以在桌面应用程序中使用WinRT API.

After that you should be able to use the WinRT API in your desktop application.

这篇关于适用于Windows桌面C#应用程序的Bluetooth 4.0(低能耗)API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆