Added a function to wait for connection indication