Bluetooth Low Energy API for Windows 7.0

2019-01-14 22:03发布

问题:

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?

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.

So is there a way to communicate with BLE devices on Windows 7 which is manufacturer-independent?

回答1:

So it turns out that some people have found a workaround. Basically the idea is to not use 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.

Here is an example:

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:

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.



回答2:

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.

Regarding proprietary APIs, have you seen 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]).

Switching to the MS stack

https://32feet.codeplex.com/wikipage?title=Switching%20any%20dongle%20to%20the%20Microsoft%20stack&referringTitle=Documentation

General Documentation

https://32feet.codeplex.com/documentation



回答3:

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.

You may be able to get the open source BTstack to 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.

If anyone has any success this way, complete instructions on how to do it would be great!



回答4:

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.