public void start() {
    try {
      logger.info("Starting...");
      writer.start();
      provider.start();
      shouldStop.set(false);
      worker.start();

      logger.info("Recording...");
    } catch (Exception e) {
      e.printStackTrace();
      this.stop();
    }
  }
  public void stop() {
    logger.info("Stopping...");

    try {
      shouldStop.set(true);
      worker.join(5000);
      logger.info("Stopping MQTT...");
      provider.stop();
      logger.info("Closing file...");
      writer.stop();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }