When using a bluetooth connection one of the services is a virtual com port.
I am using this virtual com port via the visa drivers to write and read commands and responses to a bluetooth device.
What is the best way to determine the bluetooth connection has been lost. The is port connected is a National instruments proprietary instrument. So that is not an option, I'm looking for others that will yield a fast and fool proof method of detection.
By default visa communication does not have built in handshaking which would be the easiest way to determine when a connection is lost or disconnected. For an intentional disconnect, the easiest way to notify bluetooth receiver would be to send a signal which required an acknowledgement before disconnecting. With that said, that won't work for an unprompted disconnect--going out of range, low power, etc.
One thing you could do is develop a heartbeat type of communication--every so often send a specific bit of data that causes the device to respond that can be recognized so the host knows the device is still connected. A single transmission of a specific integer or a boolean or any other predetermined bit of data can be used as the "heartbeat." You can send this heartbeat every second, or every minute... whatever you would like, and that checks if the connection is still open.
Unfortunately you will have to build up something that basically does what TCP/IP has built into it in handshaking. Let us know if you have any questions about that.
I have not check if the property node work for virtual COM port (works with real COM Port), could try the same. (Attached SerialPort.png)
only works with National instrument devices
I'm thinking that when the connectionis lost, some place in the computer there is recognition that the connection is lost. Some DLL or line assertion etc. I just don't know enough about that part of the hardware to look it up.