windows 堆栈独立的 c/c++ 蓝牙 api?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5928571/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:49:04  来源:igfitidea点击:

Stack independent c/c++ bluetooth api?

c++cwindowsbluetoothdesktop

提问by lolo


I wanted to know if there is any stack independent C/C++ bluetooth api for windows (XP, Vista, 7, x86 and x64).


我想知道是否有任何适用于 Windows(XP、Vista、7、x86 和 x64)的独立于堆栈的 C/C++ 蓝牙 api。

My target is to create a connection and send/receive some time critical data over bluetooth.

我的目标是创建一个连接并通过蓝牙发送/接收一些时间关键数据。

My researches gave me the following options and there disadvantage for this task:

我的研究给了我以下选择,但这项任务有缺点:

  • Windows Sockets for Bluetooth
    Only works with microsoft bluetooth stack
  • Using the COM port (CreateFile/ReadFile/...)
    Slower than the socket option and the user has to connect to the device first.
  • Use stack dependent API
    This would require to detect the used stack and create read/write functions for every stack. Very time consuming and I don't know if it is even possible to support all stacks
  • Writing a KMDF driver
    I thought about writing a function driver to talk directly with the bluetooth HCI driver which should be stack independent. This would be very time consuming because I would have to read the whole bluetooth spec, or is there an API for the HCI commands?
  • Windows Sockets for Bluetooth
    仅适用于微软蓝牙堆栈
  • 使用 COM 端口 (CreateFile/ReadFile/...)
    比套接字选项慢,用户必须先连接到设备。
  • 使用堆栈相关 API
    这将需要检测使用的堆栈并为每个堆栈创建读/写函数。非常耗时,我不知道是否可以支持所有堆栈
  • 编写 KMDF 驱动程序
    我想编写一个函数驱动程序来直接与应该独立于堆栈的蓝牙 HCI 驱动程序对话。这将非常耗时,因为我必须阅读整个蓝牙规范,或者是否有用于 HCI 命令的 API?

I know that there is also a commercial sdk from btframework.com which supports most (or all) bluetooth stacks, but I need a freeware option.

我知道还有一个来自 btframework.com 的商业 sdk,它支持大多数(或所有)蓝牙堆栈,但我需要一个免费软件选项。

Please tell me if there are any other options for this task.
If there aren't any, could you tell me which options you would prefer and why?
Is it okay to use Windows Sockets and ignore the other bluetooth stacks?

请告诉我此任务是否还有其他选择。
如果没有,你能告诉我你更喜欢哪种选择,为什么?
可以使用 Windows Sockets 而忽略其他蓝牙堆栈吗?

Thanks for your help :)

谢谢你的帮助 :)

采纳答案by alanjmcf

I guess one option would be to use C++/CLI to interface with my managed Bluetooth library 32feet.NET which supports most of the stacks on Windows. http://32feet.codeplex.com/

我想一种选择是使用 C++/CLI 与我的托管蓝牙库 32feet.NET 进行交互,该库支持 Windows 上的大多数堆栈。 http://32feet.codeplex.com/

回答by Jet

I've been successfully using this libraryit is called WCL but it is not free. With this you can connect through SPP without requiring to create a virtual COM port.

我已经成功地使用了这个名为 WCL 的,但它不是免费的。有了这个,您可以通过 SPP 进行连接,而无需创建虚拟 COM 端口。

While their documentation is not very good, they provide some good demo code that you may want to try.

虽然他们的文档不是很好,但他们提供了一些您可能想尝试的很好的演示代码。

It supports the Microsoft, Toshiba, Widcomm and Bluesoleil stacks and there is a native C++ implementation (as well as a .NET one).

它支持 Microsoft、Toshiba、Widcomm 和 Bluesoleil 堆栈,并且有一个本机 C++ 实现(以及一个 .NET 实现)。