简体   繁体   English

UWP应用程序无法在“ BluetoothCacheMode.Uncached”模式下工作,而只能在“ BluetoothCacheMode.Cached”模式下工作,为什么?

[英]The UWP app does not work in “BluetoothCacheMode.Uncached” mode, it only works in “BluetoothCacheMode.Cached” mode, why?

I am using this code--> https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/BluetoothLE/cs/Scenario2_Client.xaml.cs on "Blue Gecko bgm13p22" microcontroller BLE device to read its services and characterstics. 我正在使用此代码-> https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/BluetoothLE/cs/Scenario2_Client.xaml.cs在“ Blue Gecko bgm13p22”微控制器BLE设备上进行读取其服务和特色。 If I use "BluetoothCacheMode.Uncached" mode it says "Device Unreachable" but when I use "BluetoothCacheMode.Cached" mode it shows already stored characterstics or services, but not in real time. 如果我使用“ BluetoothCacheMode.Uncached”模式,则会显示“设备无法访问”,但是当我使用“ BluetoothCacheMode.Cached”模式时,它将显示已存储的特性或服务,但不会实时显示。

Why is this happening? 为什么会这样呢?

Please help Thanks 请帮忙谢谢

You say "already stored characteristics or services", so I presume you have successfully read them at least once. 您说“已经存储的特性或服务”,所以我认为您至少已经成功阅读了一次。 They have been saved in the Bluetooth Cache. 它们已保存在蓝牙缓存中。

In your instance, using BluetoothCacheMode.Cached doesn't connect to the device to look for characteristics - it looks in the Bluetooth cache, that's why it doesn't show them "real time". 在您的实例中,使用BluetoothCacheMode.Cached 不会连接到设备以查找特征-它会在Bluetooth缓存中查找,这就是为什么它不“实时”显示它们的原因。 Using BluetoothCacheMode.Uncached attempts a connection and it fails. 使用BluetoothCacheMode.Uncached尝试连接,但失败。

With "Device Unreachable" as a response, the first thing to try is to refresh the device object. 使用“设备无法访问”作为响应,首先要尝试的是刷新设备对象。

    BluetoothLEDevice device = await BluetoothLEDevice.FromIdAsync(deviceId); 
    .....

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

相关问题 “等待selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached);”不返回任何内容 - “await selectedCharacteristic.ReadValueAsync(BluetoothCacheMode.Uncached);” does not return anything 如何在UWP应用程序中仅启用横向模式? - How to enable only landscape mode in a UWP app? 仅在发布模式下的 UWP 异常 - UWP exception in release mode only UWP App-AdControl不显示任何带有测试模式值的内容 - UWP App - AdControl does not display anything with test mode values 为什么我的 WinForm 应用程序无法在发布模式下运行? - Why my WinForm app not work in release mode? 为什么在MVC3中使用Ajax动态加载表只能在兼容模式下工作? - Why does loading a table dynamically using ajax in MVC3 only work in compatability mode? UWP 未处理异常仅在 Release 模式下 - UWP unhandled exception only in Release mode 更新仅适用于调试模式 - Update only works in debug mode UWP 应用程序在 Visual Studio 调试模式下工作,但发布版本无法运行,缺少 DLL (C#) - UWP App works in Visual Studio debug mode, but the release build won't run, missing DLL (C#) 发布模式 UWP 应用程序在平板电脑模式下和 OnSuspended 中的代码崩溃 - Release mode UWP app crashes when in tablet mode and with code in OnSuspended
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM