 const char WIFIFAIL[] PROGMEM = {'WiFi: failed to connect to the AP'};
 const char WIFICONF[] PROGMEM = {'Current config: '};
 const char WIFIIP[] PROGMEM = {'IP: '};
+const char WIFICONNECTTRY[] PROGMEM = {'Trying to connect to the AP... '};
 
 /* Global constants */
 #define MAX_CONNTRY 5
 #define PWM_FREQ 100
 #define CONFNAME "/wificreds.conf"
 
+#define SLEDS_OFF { digitalWrite(D6, false); digitalWrite(D7, false); digitalWrite(D8, false); }
+#define CAPTIVE_ON { digitalWrite(D6, false); digitalWrite(D7, false); digitalWrite(D8, true); }
+#define BOOT_ON { digitalWrite(D6, true); digitalWrite(D7, true); digitalWrite(D8, false); }
+#define ERROR_ON { digitalWrite(D6, true); digitalWrite(D7, false); digitalWrite(D8, false); }
+#define OK_ON { digitalWrite(D6, false); digitalWrite(D7, true); digitalWrite(D8, false); }
+
+#define DEBUG 1
+
 /* Global variables */
 ESP8266WebServer myServer(8080);
+WiFiManager wfMan;
+
 String stassid = "";
 String stapass = "";
+String mqtt_channel = "";
+String mqtt_user = "";
+String mqtt_pass = "";
+
+WiFiManagerParameter mqttchannel("mqttchannel", "MQTT Channel",(const char*)mqtt_channel.c_str(), 40);
+WiFiManagerParameter mqttuser("mqttuser", "MQTT User", (const char*)mqtt_user.c_str(), 20);
+WiFiManagerParameter mqttpass("mqttpass", "MQTT Password",(const char*)mqtt_pass.c_str(), 20);
 
 void deleteWifiConfig() {
   cli();

        return;
  }
  Serial.println(FPSTR(CONFOPENSAVE));
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& json = jsonBuffer.createObject();
  json["sta_ssid"] = stassid;
  json["sta_pass"] = stapass;
  json.printTo(configFile);
  Serial.println(FPSTR(CONFSAVED));
}

    WiFi.printDiag(Serial);
    Serial.print(FPSTR(WIFIIP));
    Serial.println(WiFi.localIP());
    OK_ON;
  }

  /*
