Device goes out of range?

Topics: Bluetooth - Microsoft
Aug 14, 2012 at 11:41 PM

I'm trying to better handle the case in which the device I'm talking to wanders out of range.  Currently, calls to write return immediately and appear to queue up in some buffer - when the device comes back, it receives these messages*.

I'd like to be able to know that it hasn't received the messages after some timeout so I can report the device as missing.

I'm on Windows 7 64 bit using the Microsoft stack.  I am wrapping a BinaryReader and a BinaryWriter around the NetworkStream returned by BluetoothClient.GetStream.  I have tried setting a writeTimeout, without success.



* Usually this is only one or two because I'll block while trying to read the response.

Aug 19, 2012 at 8:52 PM

Bluetooth will keep trying to maintain a connection for a period of time if it isn't getting responses from the peer. The time is the Link Supervisory Timeout. Normally 20 seconds.

There isn't any notification before that time that packets are not getting through.

You'll probably have to add a periodic packet to your protocol if you want to know of device out of range earlier.