.net 适用于 Windows 7.0 的低功耗蓝牙 API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14401435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bluetooth Low Energy API for Windows 7.0
提问by Muis
Windows 8 exposes an API to communicate to Bluetooth Low Energy (Smart) devices, but this API is not available in previous versions of Windows, so how can I communicate with a BLE dongle on Windows 7?
Windows 8 公开了一个 API 以与低功耗蓝牙(智能)设备通信,但此 API 在以前版本的 Windows 中不可用,那么我如何在 Windows 7 上与 BLE 加密狗通信?
The BLE dongle I'm currently using (BLED112) exposes a virtual serial port, over which you can send commands using their custom proprietary API, but if I implement this in my software, it will not work with dongles from other manufacturers.
我目前使用的 BLE 加密狗 (BLED112) 公开了一个虚拟串行端口,您可以通过该端口使用他们的自定义专有 API 发送命令,但是如果我在我的软件中实现了这一点,它将无法与其他制造商的加密狗一起使用。
So is there a way to communicate with BLE devices on Windows 7 which is manufacturer-independent?
那么有没有一种方法可以与制造商无关的 Windows 7 上的 BLE 设备进行通信?
回答by Timmmm
So it turns out that some people have found a workaround. Basically the idea is to notuse the Windows BLE API (which doesn't work on Windows 7) but instead to talk to the dongle directly. You can do that using WinUSB (a user-space USB driver). That driver can be installed using Zadig.
所以事实证明,有些人已经找到了解决方法。基本上这个想法是不使用 Windows BLE API(它不适用于 Windows 7),而是直接与加密狗交谈。您可以使用 WinUSB(用户空间 USB 驱动程序)来实现。可以使用 Zadig 安装该驱动程序。
Here is an example:
下面是一个例子:
https://github.com/sandeepmistry/node-bluetooth-hci-socket#windows
https://github.com/sandeepmistry/node-bluetooth-hci-socket#windows
It has C++ code to let you send HCI commands. There is also a Node library of how to use HCI for higher level BLE stuff:
它具有 C++ 代码,可让您发送 HCI 命令。还有一个关于如何将 HCI 用于更高级别的 BLE 内容的 Node 库:
https://github.com/sandeepmistry/bleno
https://github.com/sandeepmistry/bleno
I don't know if there are any non-JS libraries that do the same, but I don't think it would be hard to convert Bleno to C++ in any case.
我不知道是否有任何非 JS 库可以做同样的事情,但我认为在任何情况下都不会很难将 Bleno 转换为 C++。
回答by n4cer
Is BLE a requirement? Most BLE devices will probably be dual-mode, so you could fallback to the non-LE mode on older versions of Windows.
BLE 是必需品吗?大多数 BLE 设备可能是双模式的,因此您可以在旧版本的 Windows 上回退到非 LE 模式。
Regarding proprietary APIs, have you seen https://32feet.codeplex.com/?
关于专有 API,你见过https://32feet.codeplex.com/吗?
The documentation suggests the drivers for most dongles can be replaced with the Microsoft class driver. Though, the API also work with other stacks if replacement is not feasible (with a few caveats depending on the stack [i.e., requiring additional DLLs]).
该文档建议大多数加密狗的驱动程序可以替换为 Microsoft 类驱动程序。但是,如果替换不可行,API 也可以与其他堆栈一起使用(根据堆栈有一些警告[即,需要额外的 DLL])。
Switching to the MS stack
切换到 MS 堆栈
General Documentation
一般文件
回答by Timmmm
As far as I can tell there is currently no way to do this.
据我所知,目前没有办法做到这一点。
- The SDK for Broadcom's WIDCOMM Bluetooth stack hasn't been updated since 2009 and does not support BLE.
- Microsoft's stack only supports BLE in Windows 8.
- Broadcom 的 WIDCOMM 蓝牙堆栈的 SDK 自 2009 年以来未更新,不支持 BLE。
- Microsoft 的堆栈仅支持 Windows 8 中的 BLE。
You maybe able to get the open source BTstackto work, but their BLE implementation has only been "started", and there are no instructions for building it on Windows. Their wiki suggests that no-one has tried.
您也许可以让开源BTstack工作,但他们的 BLE 实现只是“启动”,并且没有在 Windows 上构建它的说明。他们的维基表明没有人尝试过。
If anyone has any success this way, complete instructions on how to do it would be great!
如果有人以这种方式取得任何成功,请完成有关如何做的说明会很棒!
回答by Motivator
Actually, if BT chipset in your PC (with Windows 7 installed) is BT 4.0 capable (mine is AR3012) and you have installed proper BT chipset drivers, you can do some workaround to pair your BLE (BT low energy aka Smart) device with your PC (my device was Microsoft Designer keyboard). I've clicked on BT icon in tray and chose "add device" (keyboard was in discovery mode), then clicked on discovered keyboard icon to pair it and chose "enter passcode". Then on my android phone (Samsung Galaxy S5) in Bluetooth/Available Devices menu i've clicked on discovered keyboard to pair it - it has showed me passcode to enter on the keyboard, but i've entered this code on PC and then on my keyboard - voila! It has worked like a charm. Keyboard drivers have been installed and keyboard is now working. BT device status window shows no BT connection (it's probably because no BT LE Enumerator is presented in system), but everything works fine.
实际上,如果您 PC 中的 BT 芯片组(安装了 Windows 7)支持 BT 4.0(我的是 AR3012)并且您已经安装了正确的 BT 芯片组驱动程序,您可以采取一些解决方法来将您的 BLE(BT 低功耗又名智能)设备与您的 PC(我的设备是 Microsoft Designer 键盘)。我点击了托盘中的 BT 图标并选择了“添加设备”(键盘处于发现模式),然后点击发现的键盘图标进行配对并选择“输入密码”。然后在我的 android 手机(三星 Galaxy S5)的蓝牙/可用设备菜单上,我点击了发现的键盘进行配对 - 它显示了我在键盘上输入的密码,但我已经在 PC 上输入了这个代码,然后在我的键盘 - 瞧!它就像一个魅力。键盘驱动程序已经安装,键盘现在可以工作了。

