       break;
     case 3:
       mode = "AP+STA";
-      // statements
       break;
     case 4:
       mode = "----";
       break;
     default:
-      // statements
       break;
   }
   return mode;

        scanResp += "\"rssi\" :\"";
        scanResp += WiFi.RSSI(netIndex);
        scanResp += "\"}";
        //Serial.println("scan3");
        //debug_log +=  String("bss" + String(netIndex) + ": " + WiFi.SSID(netIndex) + "\t( " + WiFi.RSSI(netIndex) + " )\n" );
        if (netIndex != tot - 1)
          scanResp += ",";
      }
      //Serial.println("scan3");
      scanResp += "]}}";
      //ETS_SPI_INTR_ENABLE();
      server.send(200, "text/plain", scanResp);
      //Serial.println("scan4");
    });

    server.on("/connect", HTTP_GET, []() {
        newSSID_param = "DHLabs";// request->getParam("essid")->value();
        newPASSWORD_param = "dhlabsrfid01";//request->getParam("passwd")->value();
        server.send(200, "text/plain", "1");
        //WiFi.begin("DHLabs","dhlabsrfid01");
        //cflag = true;
        const char* newSSID = newSSID_param.c_str();
        const char* newPASSWORD = newPASSWORD_param.c_str();
        // Serial.println("1");
        // Serial.println(newSSID);
        // Serial.println(newPASSWORD);
        //ETS_SPI_INTR_DISABLE();
        WiFi.begin(newSSID,newPASSWORD);
        //ETS_SPI_INTR_ENABLE();

    });

      server.on("/connstatus", HTTP_GET, []() {
        String ipadd = (WiFi.getMode() == 1 || WiFi.getMode() == 3) ? toStringIp(WiFi.localIP()) : toStringIp(WiFi.softAPIP());
        //request->send(200, "text/plain", String("{\"status\":\"connecting\"}"));
        server.send(200, "text/plain", String("{\"url\":\"got IP address\", \"ip\":\""+ipadd+"\", \"modechange\":\"no\", \"ssid\":\""+WiFi.SSID()+"\", \"reason\":\"pippoREASON\"}"));

    });


    server.on("/setmode", []() {
      int newMode = int(server.hasArg("mode"));

      switch (newMode) {
        case 1 :
        case 3 :
          server.send(200, "text/plain", String("Mode changed " + toStringWifiMode(WiFi.getMode())));
          WiFi.mode( intToWifiMode(newMode) );
          //        Serial.println("ok change mode " + toStringWifiMode(WiFi.getMode()));
          break;
        case 2 :
          //        Serial.println("ok change mode " + toStringWifiMode(WiFi.getMode()));
          server.send(200, "text/plain", String("Mode changed " + toStringWifiMode(WiFi.getMode())));
          WiFi.mode( WIFI_AP );
          break;
      }
    });

    server.on("/log/reset", []() {

      server.send(200, "text/plain",  "1");
    });

    server.on("/special", []() {
       dhcp = server.hasArg("dhcp");
       staticIP_param = server.hasArg("staticip");
       netmask_param = server.hasArg("netmask");
       gateway_param = server.hasArg("gateway");

       if (dhcp == "off") {
         conflag = true;
         delay(5000);
         server.send(200, "text/plain", String("{\"url\":\"" + staticIP_param + "\"}"));
       }
       else {
         conflag = false;
         server.send(200, "text/plain",  "1");
         //WiFi.begin(ssid, password);
         //while ( WiFi.waitForConnectResult() != WL_CONNECTED ) {
           //delay ( 5000 );
           //Serial.print ( "." );
           //ESP.restart();
         //}
       }
     });

    // server.on("/list", HTTP_GET, handleFileList);
    // //load editor
    // server.on("/edit", HTTP_GET, [](){
    //   if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound");
    // });
    // //create file
    // server.on("/edit", HTTP_PUT, handleFileCreate);
    // //delete file
    // server.on("/edit", HTTP_DELETE, handleFileDelete);
    // //first callback is called after the request has ended with all parsed arguments
    // //second callback handles file uploads at that location
    // server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);

    //called when the url is not defined here
    //use it to load content from SPIFFS

      }

      scanResp += "{\"result\": { \"APs\" : [ ";
      //ETS_SPI_INTR_DISABLE();
      for (int netIndex = 0; netIndex < tot; netIndex++) {
        scanResp += "{\"enc\" : \"";
