Bluetooth client connect blocking

I use Bluetooth client to connect to a server.
my server is not always here. so i try to connect client several times with a clock until it found and connect to server.

The proble i have is while client try to connect it froose my program until it succed to connect or return an error.

so during this period i can't tap any button and actions are stopped.

is there a way to prevent this ?
giving priority to operator's actions even if it stop client's research ?

Change the join and disconnect logic to be less onerous. Why when bluetooth cannot connect, you always disconnect it even though it is not connected? What is your clock time "ClockRecconectClient"?

what do you mean here ?

it try to reconnect if not connected or connection lost..

The point is that the module must try to connect less often, e.g. every 3s. Attempting to connect too often will cause the application to freeze. You can also add a connection attempt counter. For example, after 10 unsuccessful attempts, the application may stop or extend the time between attempts even further.

I try to reconnect every 2 minutes...
but the problem is my app freeze each time it try to reconect...just 3 seconds but it's a problem to operator to acces control buttons of my app and for a countdown on screen...

In my opinion, it cannot be helped. Connecting is a synchronous method and the application stops for a moment.

It s what i was affraid about...

Hello jean-marc

It's difficult for us to follow your code - your naming of Screens, Components, Blocks etc is the main cause. I would say that if you had to return to this code in six months to edit it, you would struggle to understand it too :upside_down_face:

See my website:

Now, the way you have coded is unconventional in App Inventor terms - looks like code loosely translated from another programming language?

One of the issues is this:

Here is a basic template project for Bluetooth Classic send, which you can modify to Connect with UUID etc. Many App Inventor Users have started their projects successfully using the methods in this project.

BT_Basic_Setup_Send.aia (8.5 KB)

Once connected, loss of connection should be a rare event. If the connection is lost, do not send a "disconnect" command - that simply results in another error. Just have a simple re-connect button that runs (in my example) Clock_Timer_Connect again. At least the Users are kept informed and know they have to wait for the connection - same as any other Chat service.