uwp - UWP BluetoothLEAdvertisementWatcherTrigger not triggering with service uuid filter
问题描述
An in-process background task with trigger is being registered:
var trigger = new BluetoothLEAdvertisementWatcherTrigger();
trigger.AdvertisementFilter.Advertisement.ServiceUuids.Add(GattServiceUuids.CyclingSpeedAndCadence);
... more background code left out for simplicity ...
Unfortunately this never gets triggered when I run the app in Do not launch, but debug my code when it starts
option.
Whenever I run the app normally with an advertisements watcher, I do get this info (so the service ID I am filtering is correct):
Local name: 'mydevice1234'
Company: ''
Service ids: '00001816-0000-1000-8000-00805f9b34fb;0000180f-0000-1000-8000-00805f9b34fb'
Unfortunately I cannot use the company ID in the filter since the company is empty on advertisements...
Any ideas why this is not triggering? The documentation only mentions the company filter, but I cannot use that.
Update 2019-10-10:
To clarify: I can perfectly communicate with the bluetooth device.
Let me try to explain what I want. Whenever the app detects that it's not running (using a background task) but sees the device has come on-line, then it should show a message: do you want to start the app? This way the user can be reminded to start the companion app.
The background advertisements watcher, based on service ids without a company, seems not to work (although it should be possible if I understand the Bluetooth standards / documentation correctly).
解决方案
根据蓝牙规范,制造商数据不是强制性的。从我的角度来看,这并不重要。
@geertvanhorrik,您提到前台观察者工作正常。我怀疑问题出在Do not launch, but debug my code when it starts option上。为了确认这一点,是否可以使用任何蓝牙协议数据包分析器(如wireshark)来验证BackgroundWatcher 是否正在接收数据?
至少可以确认 Backgroundwatcher 正在接收数据。
推荐阅读
- python - 仅包含特定区域的绘图区域(Python)
- c++ - 如何理解第一种类型的pair?
- mysql - MySQL Workbench v8.0.1 中无法使用 RANK、OVER、WINDOW 函数
- amazon-web-services - 未通过 SSH 连接到 AWS EC2 实例 URL 时无法访问
- android - 当 PDF 受 cookie 保护时,如何从 WebView 打开 PDF?
- wsl-2 - 尝试在 Windows 11 上构建示例时拒绝 Geant4 权限
- flutter - appbar中的标题字体在颤动中没有改变
- c++ - 我应该对构造函数中由“new”运算符初始化的对象成员使用“delete”吗?
- azure-data-explorer - Kusto - 不能在 DateTime 和 String 之间执行算术表达式
- javascript - canvas.toBlob 后的 Blob 太重