Bluetooth connection button color

Hello. I have this issue. The text inside the Bluetooth connect button changes color when it connects (from black to blue), and this works. But I want it to turn black again if the connection is lost, and this isn't happening. It stays blue even if I turn off the Bluetooth receiving module. Help.

Are you sure your BtClock2 timer is firing?

I believe it is correct

Hard to say without seeing more of your blocks. Maybe pload your ,aia?
And, it would be more clear if you were using an if-then-else block set.


In addition to what @Ghica and @Taifun have already siad, the way that I've used in my app's is to make a handshake between the client and the server. In other words the connected device shall send periodically (i.e. once each minute) a "live" character that the app shall read. If within two minutes the app does not receive the "live", it is intended as a BT disconnection and the "Disconnection warning" is issued. To actuate the reading every two minutes the app shall set a specific clock.

In detail:

  • The device sends every 1 minute a '$' (with a dedicated sending not the same of the data frame).
  • A fast clock (clock1) in the app receives anything from the BT. If the character received is a '$' it sets a flag: BTlive = TRUE.
  • A slow clock (clock2) in the app (each two minutes) checks the BTlive.
    if BTlive == FALSE => declares BT failure
    if BTlive == TRUE => declares the BT is live, and sets the flag to FALSE, so the next tick if no '$' has been received in the meanwhile, on the next clock2 tick it declares BT disconnection.
    Hoping it helps you.
1 Like

(added to FAQ)