public void emergency() { // Emergency button

    mScheduleTaskExecutor.shutdownNow();
    mScheduleTaskExecutor = Executors.newSingleThreadScheduledExecutor();

    mThreads.bWatchDog = true;

    mThreads.StartEmergency();

    AttenteMs(50);
  }
  /**
   * This function stops the steering threads using a boolean, it stops the
   *
   * <p>timer and starts the Atterissage and Watchdog threads (the emergency landing
   *
   * <p>function is the same, only the thread and thus the associated command
   *
   * <p>change).
   */
  public void atterissage() {

    mScheduleTaskExecutor.shutdownNow();
    mScheduleTaskExecutor = Executors.newSingleThreadScheduledExecutor();
    mThreads.bWatchDog = true;

    AttenteMs(50);

    mThreads.StartAtterissage();
    AttenteMs(50);
    mThreads.StartWatchDog();
  }
  /**
   * This function resets the variables (chronometer sequence, flight’s
   *
   * <p>Boolean ..) and then start Piloting threads, which use
   *
   * <p>EnvoiTrameUDP() function to send the AT command.
   */
  public void decollage() {

    mThreads.bWatchDog = false;
    iVal = 1;
    iSecondeU = 0;
    iSecondeD = 0;
    iMinuteU = 0;
    iMinuteD = 0;
    icSecondeU = 0;
    icSecondeD = 0;

    AttenteMs(50);
    mThreads.Startdecollage();

    AttenteMs(50);
    mThreads.StartPilotage();

    mScheduleTaskExecutor.scheduleAtFixedRate(mThreads.mTaskChrono, 0, 10, TimeUnit.MILLISECONDS);
  }
  /**
   * This constructor receives as parameter the address and port of the drone
   *
   * <p>to instantiate and a command to send.
   *
   * <p>It instantiates GereThreads class that manages most of the necessary
   *
   * <p>threads in the application and NavdataReceiver class that get drone status and
   *
   * <p>data.
   *
   * <p>It also creates the socket and packet with CreationSocketPacket ()
   *
   * <p>function, and starts immediatly WatchDog thread to avoid losing the
   *
   * <p>connection.
   */
  public DroneManager(
      String CommandeStart,
      String Adresse,
      int iPort,
      Drone_UI joyActivity) { // CONSTRUCTEUR RECOI l'objet de classe MainActivity en parametre

    sAdresse = Adresse;
    iPortDrone = iPort;
    CommandeGenere = CommandeStart;
    mJoy = joyActivity;

    mThreads = new ThreadsManager(this);

    udp_socket = CreationSocketPacket(CommandeStart, iPort, Adresse); // Socket creation

    NavRec = new SensorData_Receiver(udp_socket);

    mThreads.StartDonnee();

    mThreads.StartWatchDog();
  }