Can't Get Error To Come Up When Bluetooth Disconnects

BluetoothDisconnect.aia (232.0 KB)

Been struggling with this for a while.

Would like the to be able to notify the user when bluetooth has disconnected.

Any help is much appreciate.

Thanks for that.
But unfortunately it does not seem to work.
Here is is in my app.BluetoothDisconnect2.aia (232.9 KB)

Doesnt seem like this should be a difficult thing to do, nonetheless it has me baffled.

you are correct, the method provided there can’t work…

as the bluetooth protocol was designed, there is no way to detect, if a connection still is alive, therefore you have to send regularly (i.e. poll) some data to the device. And if you get an error, then you know, that the connection was lost…

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Thanks,
That makes sense.
I can certainly poll, but am unsure how to sense/get an error.
Can you help?

@Juan_Antonio showed it here

Taifun

Try this:

Thanks to all for your help, you really helped me understand what is going on and how to resolve it.

Since my arduino is sending temperature updates to my app at a faster rate than my app is looking for information, there should always be bytes waiting to be received if I am connected. I simply make the assumption that if there are no bytes available to receive then I must be disconnected.

Worked like a charm!