在关闭/挂起后保持 Windows Mobile 6.0 上的蓝牙串行端口处于活动状态
昨晚调试WinMo 6程序时遇到了意外行为,我怀疑自己是不是在做梦。但首先,有一些背景。
该程序通过串行端口与 GPS 设备进行通信。它使用带电缆的物理端口,也尝试通过蓝牙。挂起或关闭电源后,如果使用物理链路,我不需要关闭并重新打开端口。但是,如果使用蓝牙,我需要重新连接:旧句柄不会传输任何字节。重新打开大约需要 6 或 7 秒,因此应用程序在蓝牙暂停后无法立即使用。
然而,我记得一次调试,我的蓝牙串行端口在几次断电/通电周期后仍然有效且功能正常,这让我感到惊喜。我现在无法重现该行为。这是 BT 驱动程序中的错误吗?
如果您能够尝试的话,任何关于配置或 API 的提示都会很棒。
I encountered an unexpected behavior while debugging a WinMo 6 program last night, and I wonder if I was dreaming. But first, some context.
The program communicates through a serial port with a GPS device. It uses either a physical port with cable, and also tries via Bluetooth. After a suspend or power-off, I don't need to close and reopen the port if it was using the physical link. However, if using Bluetooth, I need to reconnect : no bytes are transmitted with the old handle. Reopening takes about 6 or 7 seconds, so the app is not usable right away after a suspend on Bluetooth.
However, I remember one debugging streak where my Bluetooth serial port would be still valid and functional after several power-off/power-on cycles, and it surprised me pleasantly. I cannot reproduce the behavior now. Was that a bug in the BT driver?
Any hints you have about configurations or API to try would be great, if you ever got that to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
蓝牙协议的设计使得 GPD 设备和 Windows 设备之间必须至少每隔几秒进行一次通信。如果不存在通信,则链接将超时,并且必须从头开始重新建立。
其次,是执行电源循环的方式。如果正确实现的蓝牙堆栈以正常方式进入断电状态,它将显式关闭任何打开的连接。
简而言之,蓝牙连接并不意味着可以在电源循环后继续存在,因此您的程序必须准备好在电源循环后重新建立与远程蓝牙设备的连接。
The Bluetooth protocol is designed such that there must be communication between the GPD device and your Windows device at least once every few seconds. If the communication is not present, then the link will time-out and must be established again from the ground up.
And secondly, there is the way in which you perform the power cycle. A properly implemented Bluetooth stack will explicitly close-down any open connections if it goes into a power-off state in a normal way.
In short, a Bluetooth connection is not meant to survive across a power cycle, so your program must be prepared to re-establish the connection to a remote Bluetooth device after a power cycle.