通过 com 端口将蓝牙设备连接到 Windows API

发布于 2024-10-07 04:51:40 字数 427 浏览 0 评论 0原文

所以我有一个蓝牙设备,这个设备使用SPP在PC和它自己之间传输数据。它可以作为蓝牙设备通过 Windows 正常连接。我可以找到它,输入配对码并将其分配给 COM 端口。现在我希望能够使用 Windows API 通过 com 端口发送数据,但它拒绝这样做。

我怀疑我需要正确设置 COMMCONFIG 结构(见下文) http://msdn.microsoft.com/en-us/ library/aa363188(VS.85).aspx

不幸的是我不知道什么是正确的设置。我知道 SPP 应该模拟 RS-232 通信...所以也许我必须研究一下才能找出正确的设置?或者是否有某种自动方法来设置 COMMCONFIG 结构。

So I have a bluetooth device, this device uses SPP to transfer data between the PC and itself. It connects fine through Windows as a bluetooth device. I can find it, enter the paring code and assign it to a COM port. Now I want to be able to send data through the com port using Windows API but it is refusing to do so.

I suspect that I need to setup the COMMCONFIG Structure correctly (see below)
http://msdn.microsoft.com/en-us/library/aa363188(VS.85).aspx

Unfortunately I have no idea what is the proper setting. I know SPP is supposed to emulate the RS-232 communication... so maybe I have to study up on that to figure out the right setting? Or is there some automatic way to set the COMMCONFIG structure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光礼记 2024-10-14 04:51:40

我严重怀疑这一点。如果要使用它,那么在没有驱动程序作者的文档的情况下,您将没有机会猜测自定义提供程序数据。请注意握手信号,当 DTR 信号关闭时,串行端口设备通常会忽略发送给它们的任何内容。并且在 DTR 关闭的情况下不发回任何内容。司机会效仿这一点。使用 EscapeCommFunction() 将其打开。还可以尝试使用 HyperTerminal 或 Putty 等串行通信程序来测试这一点,以便您可以隔离问题的根源。

I seriously doubt it. If it would be used then you'll have no chance at guessing at the custom provider data without docs from the driver author. Pay attention to the handshake signals, serial port devices routinely ignore anything sent to them when the DTR signal is turned off. And not send anything back with DTR off. A driver would emulate that. Use EscapeCommFunction() to turn them on. Also try a serial comm program like HyperTerminal or Putty to test this so you can isolate the source of the problem.

玩物 2024-10-14 04:51:40

为什么不使用蓝牙套接字 API?这样就不需要麻烦的(虚拟)COM 端口了。

如果您使用的是托管代码,请参阅我的库 32feet.NET

如果使用本机代码,请使用 SOCKADDR_BTH 与 Winsock 连接等等,请参阅 蓝牙和连接 (Windows) 然后您可以使用标准 Winsock 发送/接收 API

Why not use the Bluetooth sockets API? No need for troublesome (virtual) COM ports then.

If you're using managed code then see my library 32feet.NET

If using native code, use SOCKADDR_BTH with Winsock connect etc, see e.g. Bluetooth and connect (Windows) Then you can use the standard Winsock send/recv API

看海 2024-10-14 04:51:40

好的,我发现你可以使用
GetCommConfig 和 GetCommState 函数用于确定设置。

Ok, I found that you can use the
GetCommConfig and GetCommState functions to figure out the settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文