/**
   * sayHello (SELECT AID APDU ISO 7816-4)
   *
   * @param appletName
   * @param commandId
   * @return boolean
   */
  @Override
  public boolean sayHello(String appletName, int commandHelloId) {
    try {
      AppletModel model = null;
      try {
        model = SeqlMetadata.getInstance(configFile).getAppletByAlias(appletName);
      } catch (Exception e) {
        e.printStackTrace();
      }
      if (model == null) {
        callback.onNoApplet();
      }

      channel = openChannel(model);

      byte[] apdu = null;
      APDUResponse resp = new APDUResponse();
      try {
        // select the applet
        apdu = APDUModel.getSelectAidApdu(BytesTool.hexStringToByteArray(model.getAID()));
        apdu = sendCommand(apdu, channel);
        resp.setResponse(apdu);
        return APDUModel.isResponseSucceded(resp.getStatusWord());
      } catch (Exception e) {
        e.printStackTrace();
        callback.onNoApplet();
      }
    } catch (NoSuchElementException e) {
      callback.onNoApplet();
    } catch (IOException e) {
      callback.onNoSecureElement();
    } catch (NoReaderException e) {
      callback.onNoReader();
    } catch (NoSecureElementException e) {
      callback.onNoSecureElement();
    } catch (BadRequestException e) {
      callback.onBadRequest(e.getMessage());
    } catch (Exception e) {
      callback.onNotConnected();
    }
    return false;
  }
  /**
   * execute
   *
   * @param command
   * @param commandId
   * @return boolean
   */
  @Override
  public boolean execute(final String command, final int commandId) {
    // new Thread(){
    // public void run(){
    Map<String, Object> maps = null;
    try {

      maps = SeqlParser.parseSeql(command, configFile);

      if (maps == null) throw new BadRequestException("Command not supported!");
      return executeCommand(maps, commandId);

    } catch (BadRequestException ex) {
      ex.printStackTrace();
      if (callback != null) callback.onBadRequest(ex.getMessage());
    } catch (NoSuchElementException ex) {
      ex.printStackTrace();
      if (callback != null) callback.onNoApplet();
    } catch (NoSecureElementException ex) {
      ex.printStackTrace();
      if (callback != null) callback.onNoSecureElement();
    } catch (NoReaderException ex) {
      ex.printStackTrace();
      if (callback != null) callback.onNoReader();
    } catch (ChannelNotOpenException e) {
      e.printStackTrace();
      if (callback != null) callback.onNotConnected();
    } catch (IOException e) {
      e.printStackTrace();
      if (callback != null) callback.onIOException(e.getMessage());
    } catch (Exception e) {
      if (callback != null) callback.onBadRequest(e.getMessage());
    }
    // }
    // }.start();
    return false;
  }