Auto connect BLE


how can I make BLE auto connect when disconnected by clicking the checkbox and when it is connected BLE stops searching and when disconnected it will search automatically