Question

I am developing a bluetooth application in c# to read data from sensors using 32feet.net library. I am able to communicate with sensors and able to read values , send command etc. The Communicating thread will either be waiting in read or writing command to the sensor. I expected that an IOException will be thrown when sensors suddenly powers off. but never got exception.

Need help to figure out What kind of exception will be thrown when the sensors suddenly powers off?

Was it helpful?

Solution

An exception should occur: after 20 seconds and the next IO operation you do after that. Are you waiting that long? Or is your Read call returning zero?

See #2 at https://32feet.codeplex.com/wikipage?title=Connected%20Property

In my testing with Bluetooth it seems to take about twenty seconds for one device to realise that other device has gone -- though this may be configurable. This is called the “Link Supervision Timeout” in Bluetooth. So you will have to wait up to that long for the system to know that the connection is lost, and then you will find out at your next IO operation If you start a read when there is no data being received for instance, it will block until the connection fails, or is closed (or some data is received).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top