   while (!client.connected()) {
     Serial.print("Attempting MQTT connection...");
     // Attempt to connect
-    if (client.connect(clientId.c_str(), mqtt_user, mqtt_password)) {
+    if (client.connect(clientId.c_str(), settings.mqtt_user, settings.mqtt_password)) {
       Serial.print("connected with id : ");
       Serial.println(clientId);
       // Once connected, publish an announcement...


//save the custom parameters to FS
void doSaveConfig() {
  if (shouldSaveConfig) {
    Serial.println("saving config");
    DynamicJsonBuffer jsonBuffer;
    JsonObject& json = jsonBuffer.createObject();
    json["mqtt_server"] = mqtt_server;
    json["mqtt_port"] = mqtt_port;
    json["mqtt_user"] = mqtt_user;
    json["mqtt_password"] = mqtt_password;

    File configFile = SPIFFS.open(config_path, "w");
    if (!configFile) {
      Serial.println("failed to open config file for writing");
    }

    json.printTo(Serial);
    json.printTo(configFile);
    configFile.close();
    //end save
  }else {
    Serial.println("do not save config");
  }
}

void fsInit() {

  Serial.println("fsInit");
  //clean FS, for testing
  //SPIFFS.format();

  //read configuration from FS json
  Serial.println("mounting FS...");

  if (SPIFFS.begin()) {
    Serial.println("mounted file system");
    if (SPIFFS.exists(config_path)) {
      //file exists, reading and loading
      Serial.println("reading config file");
      File configFile = SPIFFS.open(config_path, "r");
      if (configFile) {
        Serial.println("opened config file");
        size_t size = configFile.size();
        // Allocate a buffer to store contents of the file.
        std::unique_ptr<char[]> buf(new char[size]);

        configFile.readBytes(buf.get(), size);
        DynamicJsonBuffer jsonBuffer;
        JsonObject& json = jsonBuffer.parseObject(buf.get());
        json.printTo(Serial);
        if (json.success()) {
          Serial.println("\nparsed json");

          strcpy(mqtt_server, json["mqtt_server"]);
          strcpy(mqtt_port_config, json["mqtt_port"]);
          strcpy(mqtt_user, json["mqtt_user"]);
          strcpy(mqtt_password, json["mqtt_password"]);

          info();

        } else {
          Serial.println("failed to load json config");
        }
      }
    }
  } else {
    Serial.println("failed to mount FS");
  }
  //end read
}

void resetConfig() {
  Serial.println("Config : reset");

  if (SPIFFS.begin() && SPIFFS.exists(config_path)) {
    SPIFFS.remove(config_path);
  }

  WiFiManager wifiManager;
  wifiManager.resetSettings();

}


  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length

WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 120);
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port_config, 6);
WiFiManagerParameter custom_mqtt_user("user", "mqtt user", mqtt_user, 120);
WiFiManagerParameter custom_mqtt_password("password", "mqtt password", mqtt_password, 120);

void initWifiManager() {
  Serial.println("initWifiManager");
info();
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;

    Serial.begin(115200);
    Serial.println("Setup");

    // Setup
    configInit();
    initWifiManager();
    doSaveConfig();
    info();

    // MQTT
    client.setCallback(callback);
    client.setServer(settings.mqtt_server, String(settings.mqtt_port).toInt());
    reconnect();

    //
