在Windows 10上为BLE GATT设备开发HID输入设备驱动程序 [英] Developing an HID input device driver for a BLE GATT device on Windows 10
问题描述
(This is a crosspost from the MSDN forums since there hasn't been any response there for quite some time and I thought I would get better answers here.)
我有一个包含自定义GATT服务的BLE设备,无法修改其固件.我想监听来自该服务的GATT特征事件,并让Windows将它们作为HID报告使用,以使Windows将其识别为另一设备.我将如何去做?
I have a BLE device containing a custom GATT service, of which I cannot modify the firmware. I want to listen for the GATT characteristic events from that service, and make Windows consume them as HID reports to make Windows recognize it as another device. How would I go about doing this?
我进行了一些研究,发现以下信息:
I conducted some research, and found the information below:
- 有请勿使用VS2017/WDK10进行编译
- 为了从非HID设备注入HID报告,您需要使用更详细的页面和用于Windows IoT核心版的示例
- 它似乎是不允许为
BthLeEnum
创建筛选器驱动程序
- 适用于C ++的BLE GATT函数在MSDN上 >
- 有一个
- There were BLE GATT Profile driver samples in WDK 8.0, but they are outdated and do not compile with VS2017 / WDK10
- In order to inject HID reports from a non-HID device, you need to use the virtual HID framework for which there are a more detailed page and a sample.
- There is also a sample for Windows IoT Core
- It seems to be not allowed to create filter drivers for
BthLeEnum
- The available BLE GATT functions for C++ are on MSDN
- There is a sample on using them for a client app (not a driver)
我的问题是,在这里需要哪种方法来创建此驱动程序?
- 我是否需要创建两个 驱动程序(虚拟HID驱动程序和GATT Profile驱动程序),然后以某种方式将它们彼此连接?
- 我需要从虚拟HID驱动程序进行Bluetooth LE API调用吗?
- 我需要创建一个进行HID调用的GATT配置文件驱动程序吗?
- 还是其他东西?
- Do I need to create two drivers (a virtual HID driver and a GATT Profile driver), and then somehow connect them to each other?
- Do I need to make the Bluetooth LE API calls from the virtual HID driver?
- Do I need to create a GATT Profile driver that makes HID calls?
- Or something else entirely?
甚至在Windows 10上仍允许使用GATT配置文件驱动程序,因为它似乎是
Are GATT Profile drivers even still allowed on Windows 10, since it seems it is not allowed to create filter drivers for BthLeEnum
?
我真的很感谢Alain花时间回答这个问题,因此我将他的回答标记为对这个问题的回答;但是对我来说,这个问题尚未完全解决.看到该问题已获得超过10票,我认为它应该得到更广泛的答案.可以改进/添加的要点是:
I really appreciate that Alain took the time to answer the question and therefore I marked his answer as answer to the question; however for me the question is not completely answered yet. Seeing that the question already got more than 10 votes, I think it deserves a more extensive answer. Points that could be improved / added are:
-
意见背后的论点(例如,为什么要用UMDF微型驱动程序而不是VHF驱动程序,为什么要使用需要使用cppwinrt而不是简单地使用我在研究中发现的C ++蓝牙功能的UWP蓝牙API,如何编写GATT配置文件驱动程序呢? , 等等.).没有这种说法,我将无法从建议中学到很多东西.
- 我的子问题的答案
- 从驱动程序使用cppwinrt代码的示例,以及是否可以在其中访问这些API.对此是否有任何限制(因为代码将无法从appx运行)? Cppwinrt在这里被介绍为新事物,但是我找不到在驱动程序上下文中使用cppwinrt的任何文档.
- 对我自己的研究进行了一些反思-当前的答案与我发现的好点无关.这种思考将帮助我更好地理解该主题.
- the argumentation behind the advice (e.g. why UMDF minidriver instead of VHF driver, why to use UWP bluetooth APIs requiring to use cppwinrt instead of simply using the C++ Bluetooth functions that I found in my research, what about writing a GATT Profile driver, etc.). Without that argumentation I won't learn much from the advice.
- answers to my subquestions
- examples of using cppwinrt code from a driver and whether it is possible to access those APIs there. Are there any limitations to that (since the code will not be running from an appx)? Cppwinrt is pitched here as something new, but I can't find any documentation of using cppwinrt in the context of a driver.
- some reflection on my own research - the current answer doesn't touch upon what points I found are good or not. This reflection would help me to understand the topic better.
我认为Alain在VHF上推荐了UMDF HID微型驱动程序,因为VHF需要编写KMDF驱动程序. UMDF的优点是易于调试(可以在本地PC上调试),较少的安全性(和签名)限制,并且在驱动程序中存在错误时也没有对机器进行错误检查的风险.
I suppose that Alain recommended a UMDF HID minidriver over VHF because VHF requires writing a KMDF driver. UMDF has the benefits of easier debugging (can be debugged on local pc), less security (and signing) restrictions and no risk of bugchecking a machine when there is a bug in the driver.
为了能够创建一个注入RadialController事件的客户端应用程序(而不是必须编写对私有开发人员来说是一个很大障碍的驱动程序),我发布了.如果您认为值得支持,请考虑投票.
In order to make it possible to create a client application that injects RadialController events (rather than having to write a driver which is a very high barrier for private developers), I posted a request for it on Feedback Hub. Please consider voting for it if you think that is worth supporting.
推荐答案
最好的方法是创建UMDF HID驱动程序( https://docs.microsoft.com/zh-cn/uwp/api/windows.devices.bluetooth.genericattributeprofile ).
The best approach to this would be to create a UMDF HID driver (https://docs.microsoft.com/en-us/windows-hardware/drivers/wdf/creating-umdf-hid-minidrivers) that installs on the bthleenum device node that is created for the device's custom service and use the new Bluetooth LE UWP apis (https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.genericattributeprofile).
在非商店应用程序中使用UWP Apis存在一些歧义,但这是不正确的.这些Apis几乎可以在所有条件下使用.如果需要帮助来设置项目,这里有一个C ++/UWP示例,可以帮助您入门.
There is some ambiguity about the use of UWP Apis from non store application, but this is incorrect. These Apis are usable in pretty much every conditions. In case you need help setting up your project, here is a C++/UWP sample that can help you get started.
我希望这会有所帮助! 阿兰
I hope this helps! Alain
这篇关于在Windows 10上为BLE GATT设备开发HID输入设备驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!