/**
   * Methode : checkSavedData : Traitement des données recu et sauvegarder dans le buffer de
   * reception
   *
   * @param first_data
   * @param last_data
   * @param data
   * @return flag : if the data is saved correctly
   * @throws java.lang.InterruptedException
   */
  private boolean checkSavedData(String first_data, String last_data, String[] data)
      throws InterruptedException {
    System.out.println("<--- BEGIN OF THE checkSavedData() methode --->");
    boolean flag = false;

    if ((first_data != null && first_data.equals(DEBUT_ENVOIE_INFORMATION_ACCREDITEE))
        && (last_data != null && last_data.equals(FIN_ENVOIE_INFORMATION_ACCREDITEE))) {
      System.out.println("First if");
      if (data != null) {

        System.out.println("Before calling saveAccreditedInformation()");
        flag = saveAccreditedInformation(data);
        System.out.println("After calling saveAccreditedInformation()");

        if (flag) {
          System.out.println("The data is saved correctly");
          Thread.sleep(500);
          super.sendData(INFORMATION_ACCREDITEE_ENREGISTRE_CORRECTEMENT);
        } else {
          System.out.println("The data is not saved because it contains some invalid data");
          Thread.sleep(500);
          super.sendData(INFORMATION_ACCREDITEE_DONNEES_ERONEES);
        }
      } else {
        System.out.println("The data is not saved because it contains some invalid data");
        Thread.sleep(500);
        super.sendData(INFORMATION_ACCREDITEE_DONNEES_ERONEES);
        System.out.println("Le buffer est invalide");
        flag = false;
      }
    }
    if ((first_data != null && first_data.equals(DEBUT_ENVOIE_CLE_ACCES_ACCREDITEE))
        && (last_data != null && last_data.equals(FIN_ENVOIE_CLE_ACCES_ACCREDITEE))) {
      System.out.println("First if");
      if (data != null) {

        System.out.println("Before calling checkSharingConfirmation()");
        flag = addDeviceLink(data);
        System.out.println("After calling checkSharingConfirmation()");

        if (flag) {
          System.out.println("The data is saved correctly");
          Thread.sleep(500);
          super.sendData(CLE_ACCES_ACCREDITEE_ENREGISTREE_CORRECTEMENT);
          this.getSerial().shutdown();
          super.openUartPort();
        } else {
          System.out.println("The data is not saved because it contains some invalid data");
          Thread.sleep(500);
          super.sendData(CLE_ACCES_ACCREDITEE_DONNEES_ERONNEES);
        }
      } else {
        System.out.println("The data is not saved because it contains some invalid data");
        Thread.sleep(500);
        super.sendData(CLE_ACCES_ACCREDITEE_DONNEES_ERONNEES);
        System.out.println("Le buffer est invalide");
        flag = false;
      }
    }
    // ===>
    else {
      flag = false;
      System.out.println("First Else ");
    }

    System.out.println("<--- END OF THE checkSavedData() methode -->");
    return flag;
  }