Bluetooth Client Disconnect Event Handler

Hello everyone.

I’m working with Kodular since a couple of weeks. I really like the way it works!

But now, I’m having some trouble with the bluetooth client.
Connecting and data exchange works fine.

But it happens that the other device (ESP32) is offline/disconnected.
To find out, I used a block with a timer, see picture. But it won’t work:

It always says, ‘Bluetooth-Client1.IsConnected = true’, although it is false.
Can anyone help?

Thank you!

yes, this is correct
to find out, if the connection is broken, you have to send something and if the connection is broken, you will get the following error back

Error 516: Unable to write: Connection reset by peer

you can catch that error in the Screen.ErrorOccurred event, see also A simple Bluetooth Chat with App Inventor 2

Taifun

Hi Taifun,
thank you for your solution!

Using the ErrorHandler will work.

Denyo