   File configFile = SPIFFS.open(CONFNAME, "w");
   if (configFile) {
         Serial.println("saveConfigCallback: opened config file for writing the config");
+  } else {
+        Serial.println("saveConfigCallback: cannot opent the config file for write");
+        return;
   }
-  DynamicJsonBuffer jsonBuffer;
   Serial.println("saveConfigCallback: config file has been opened for savig the config and JSON buffer has been created successfully");
-  // TODO: PUT stassid and stapass to jsonBuffer
-  // TODO: print jsonBuffer to configFile
-  // ...
+  StaticJsonBuffer<200> jsonBuffer;
+  JsonObject& json = jsonBuffer.createObject();
+  json["sta_ssid"] = stassid;
+  json["sta_pass"] = stapass;
+  json.printTo(configFile);
+  Serial.println("saveConfigCallback: config save ok");
 }
 
 void configModeCallback(WiFiManager *myWfMan) {

void loop() {
  // put your main code here, to run repeatedly:
  // myServer.handleClient();
  delay(1000);
}

    wfMan.startConfigPortal(ssid.c_str(), AP_PASSW);
  }

  /* Connect to the AP if not connected by the WiFiManager */
  WiFi.setAutoConnect(false);
  WiFi.setAutoReconnect(true);
  for (uint8_t count = 5; count > 0; count--) {
