Connecting to BLE, device available but not found

I use an android connection with another BLE device. The data transfer works very well, but the first connection sometimes it doesn't find the device and therefore there is no connection. Even on the target device it appears as connected. Sometimes I have to disconnect the bluetooth from the phone again, even to pair the device and disconnect from the target device. All this gives a feeling of malfunction. It's as if android memorizes the connection and doesn't reset when it's not connected.
Is it possible to put something in the scren_ini that define everything in the Blutooth so that it always works correctly.

I put the blocks that I use to connect BLE, the extension is the latest revision.
en Screen1_inicializar


Un saludo.