public void waitForReady(long how_long) throws IOException {
  long since=System.currentTimeMillis();
synchronized (state_mutex) {
    while (true) {
      if (state == State.DEMO) {
        return;
      }
 else       if (state == State.ERROR || state == State.DISCONNECTED) {
        throw new IOException("Connection Error");
      }
 else       if ((System.currentTimeMillis() - since) >= how_long) {
        try {
          disconnect();
        }
 catch (        IOException e) {
        }
        throw new IOException("Timeout connecting to ARDrone");
      }
      long p=Math.min(how_long - (System.currentTimeMillis() - since),how_long);
      if (p > 0) {
        try {
          state_mutex.wait(p);
        }
 catch (        InterruptedException e) {
        }
      }
    }
  }
}

public void waitForReady ( long how_long ) throws IOException { long since = System . currentTimeMillis ( ) ; synchronized ( state_mutex ) { while ( true ) { if ( state == State . DEMO ) { return ; } else if ( state == State . ERROR || state == State . DISCONNECTED ) { throw new IOException ( "Connection Error" ) ; } else if ( ( System . currentTimeMillis ( ) - since ) >= how_long ) { try { disconnect ( ) ; } catch ( IOException e ) { } throw new IOException ( "Timeout connecting to ARDrone" ) ; } long p = Math . min ( how_long - ( System . currentTimeMillis ( ) - since ) , how_long ) ; if ( p > 0 ) { try { state_mutex . wait ( p ) ; } catch ( InterruptedException e ) { } } } } }
wait for drone to switch to demo mode . throw exception if this not succeeded within given timeout . should be called right after connect ( ) . this is a convenience function . another way to achieve the same result is using status change callback .
