I am doing my first attempts to use FlightSimControls.

At first , I was using a single FlightSim.update() at the beginning of loop().
Worked so far in case XPlane is already running.

But the typical situation is, that my Teensy Board is already running for a while until XPlane comes up and the communication may start.

As the the next attempt, I tried this code which does not work:

Code:
void loop() {
  bool FSactive=false;
  
  // put your main code here, to run repeatedly:
  FlightSim.update();
  delay(400);
  Serial.println("After initial FlightSim.update()");

  while(1)
  {
    if ((FlightSim.isEnabled()==true) && (FSactive==false))
    {
      Serial.println("Xplaen is ONLINE now");
      FSactive=true;
      FlightSim.update();
      delay(500);
      updateGearLEDs();
      
    }

    if((FlightSim.isEnabled()==false) && (FSactive==true))
    {
      FSactive=false;
      Serial.println("XPlane now OFFLINE");
    }

    if((FlightSim.isEnabled()==false) && (FSactive==false))
    {
      FSactive=false;
      Serial.println("XPlane now OFFLINE");
    }
   } //while
}
Is there a reliable method to detect whether XPlane is running or not and/or initiate a reconnect in case the connection is lost?