How to identify connection lost on HC-06?
My first one or couple of HC-06es brought its LED signal out to a pin on the base board, labeled "STATE" on mine. I tested the LED state on every loop and if it was changing regularly, took that to indicate whether it was waiting for a connection.

Later modules no longer bring out the LED signal but it is available on module's edge-pin 24, according to a (now 6yo) datasheet.



By cutting the plastic sleeve and bringing out the signal to the baseboard again, you use it to monitor the connection.