串行蓝牙断开检测C++
如何检测Windows上是否断开连接的蓝牙设备?
这是我尝试的:
//return true if there is a connection
bool works()
{
//portcom(handle to virtual serial port) and dcb are already initialised
if(!GetCommState(portcom, &dcb)) return 0;
return SetCommState(portcom, &dcb);
}
但是它仅检查端口是否存在并且存在(因为蓝牙端口根本没有关闭)。所以这无效:(
How to detect if bluetooth device disconnected on windows?
Here is what I tried:
//return true if there is a connection
bool works()
{
//portcom(handle to virtual serial port) and dcb are already initialised
if(!GetCommState(portcom, &dcb)) return 0;
return SetCommState(portcom, &dcb);
}
But it only checks whether the port exists and it exists(because bluetooth ports aren't closed at all). So this doesnt work :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以通过枚举蓝牙设备来检查蓝牙是否连接。
” bluetoothfindfirstdevice 和
bluetoothfindnextdevice
列举设备,并确定fconnected
参数是否是bluetooth_device_info_info_struct_info_struct
结构结构。I think you can check if the bluetooth is connected by enumerating the bluetooth devices.
bluetooth api
Use
BluetoothFindFirstDevice
andBluetoothFindNextDevice
to enumerate devices, and determine whether Bluetooth is connected through thefConnected
parameter in theBLUETOOTH_DEVICE_INFO_STRUCT
structure.