[英]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.