简体   繁体   English

如何为 BLE 设备设置 RequestPreferredConnectionParameters ThroughputOptimized 属性?

[英]How to set the RequestPreferredConnectionParameters ThroughputOptimized property for a BLE device?

C++, WinRT, VS2017, Win10 C++,WinRT,VS2017,Win10

I am connecting to a Bluetooth LE Device that will respond with an electrical shock when the command is sent.我正在连接一个蓝牙 LE 设备,该设备会在发送命令时以电击响应。 I notice, however, that there is about a 1 second delay from the time the command is written to the Tx characteristic and the time the electrical shock is actually felt.然而,我注意到,从命令写入 Tx 特性到实际感觉到电击之间大约有 1 秒的延迟。

At first I was thinking that the connection was being dropped between writes and that the delay was possibly the need for a new connection to be established before the write could take place.起初,我认为写入之间的连接正在断开,延迟可能是需要在写入发生之前建立新的连接。 But, IF the ConnectionStatus() is actually correct, the device is staying connected.但是,如果ConnectionStatus()实际上是正确的,则设备保持连接状态。

So, I see that in the BluetoothLEDevice class there is a RequestPreferredConnectionParameters() method.所以,我看到在BluetoothLEDevice class 中有一个RequestPreferredConnectionParameters()方法。 I have already created a BluetoothLEDevice object (device) and I would think that this would come up in Intellisense but the closest thing that comes up is device.RequestAccessAsync .我已经创建了一个BluetoothLEDevice object (设备),我认为这会出现在 Intellisense 中,但最接近的是device.RequestAccessAsync

The docs for RequestPreferredConnectionParameters say that there is a ThroughputOptimized property that" RequestPreferredConnectionParameters的文档说有一个ThroughputOptimized属性“

gets a more aggressive set of connection parameters, optimized for faster throughput at the expense of power usage.获得一组更积极的连接参数,以牺牲功耗为代价进行优化以提高吞吐量。

That SOUNDS like it would speed up my connection and write speeds.听起来它会加快我的连接和写入速度。 But how do I do that.但我该怎么做。

Does anyone know how to set this property for a BLE device or even if I am barking up the wrong tree?有谁知道如何为 BLE 设备设置此属性,或者即使我叫错了树?

The answer is that I failed to drill down and read the details of BluetoothLEDevice.RequestPreferredConnectionParameters .答案是我未能深入阅读并阅读BluetoothLEDevice.RequestPreferredConnectionParameters的详细信息。 I see now that it applies to WinRT Build 22000, Build 22621. In my case I am using NuGet 2017 which has an older version of WinRT.我现在看到它适用于 WinRT Build 22000、Build 22621。就我而言,我使用的是 NuGet 2017,它具有旧版本的 WinRT。 I'm assuming that NuGet is the way that WinRT is updated.我假设 NuGet 是更新 WinRT 的方式。

When I try to update to the more recent NuGet 2.0.22xx I get the traditional 2613 compile errors which may or may not be caused by only one or two problems.当我尝试更新到更新的 NuGet 2.0.22xx 时,我得到了传统的 2613 编译错误,这些错误可能仅由一两个问题引起,也可能不是。 At least this has been my sad experience.至少这是我悲惨的经历。

I see that one of the thousands of errors is the this co_await expression requires a suitable "await_ready" function even though it is being used inside of a winrt::Windows::Foundation::IAsyncAction function.我看到数以千计的错误之一是this co_await expression requires a suitable "await_ready" function ,即使它在winrt::Windows::Foundation::IAsyncAction ZC1DF425268E17A98 中使用。 In trying to track down this one error I have used the recommended namespaces and included the recommended header files but all of that just got me deeper into the swamp.在尝试追踪这一错误时,我使用了推荐的命名空间并包含了推荐的 header 文件,但所有这些都让我更深入地了解了沼泽。 I have also tried the fire_and_forget return type but the error remains.我也尝试了fire_and_forget返回类型,但错误仍然存在。

For now I'm going back to NuGet 2017. I am trying to keep to VS2017 for now because my main app is fairly large and uses several 3rd party libraries that would all have to be recompiled.现在我要回到 NuGet 2017 年。我现在正试图保持 VS2017,因为我的主应用程序相当大,并且使用了几个都必须重新编译的第三方库。 My experience is that when porting to a new VS the gremlins come out of the woodwork and it takes time to squash them all.我的经验是,当移植到新的 VS 时,gremlins 会从木制品中冒出来,需要时间才能将它们全部压扁。 I was hoping not to have to do that until I have more free time.我希望在我有更多空闲时间之前不必这样做。

Any suggestions about using NuGet 2.0.22xxx in a VS2017 MFC app would be appreciated.任何有关在 VS2017 MFC 应用程序中使用 NuGet 2.0.22xxx 的建议将不胜感激。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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