Detecting Bluetooth SPP serial port disconnect (C# 4.5, Windows 8.1)

时间:2015-09-01 21:45:35

标签: c# windows bluetooth

C# application using .NET 4.5 running on Windows 8.1

Classic Bluetooth device connects and uses SPP, using Microsoft Bluetooth stack only. Device is paired prior starting the application (the application is not involved in pairing and thinks its a real serial port).

Application connects to the SPP COM port using C# SerialPort class.

All works OK, until...

Bluetooth device is powered off, but... SerialPort.IsConnected still reports true (for at least a minute).

I've tried hooking the main form's WndProc and trapping WM_DEVICECHANGE, but while I see messages for USB devices coming and going, no message is generated after the Bluetooth device is powered off.

Anybody know how to get PROMPT and ACCURATE information about the connection?

Thanks!

Best Regards, Dave

0 个答案:

没有答案