![]() |
KC868-A16 - Custom Form Wifimanager Root content - Printable Version +- Smart Home Automation Forum (https://www.kincony.com/forum) +-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=1) +--- Forum: KC868-HxB series Smart Controller (https://www.kincony.com/forum/forumdisplay.php?fid=2) +--- Thread: KC868-A16 - Custom Form Wifimanager Root content (/showthread.php?tid=7877) |
KC868-A16 - Custom Form Wifimanager Root content - venuakil2 - 03-27-2025 Hi All, I am trying to add new form to root page and configure the form as per my requirements. Please check below sample code is not working. And send me Latest Arduino IDE wifimanager sample example code. #include <WiFiManager.h> // https://github.com/tzapu/WiFiManager #include <FS.h> #include <SPIFFS.h> const char* htmlFile = "/index.html"; void setup() { Serial.begin(115200); // Initialize SPIFFS if (!SPIFFS.begin(true)) { Serial.println("An Error has occurred while mounting SPIFFS"); return; } // Create WiFiManager instance WiFiManager wifiManager; // Set custom root page handler wifiManager.setCustomHeadElement("<style>body{background-color:#f0f0f0;}</style>"); wifiManager.setAPCallback([](WiFiManager *wm) { // This runs when AP mode is started // Add custom route handler for root page wm->server->on("/", HTTP_GET, [wm]() { if (SPIFFS.exists(htmlFile)) { File file = SPIFFS.open(htmlFile, "r"); if (file) { wm->server->sendHeader("Content-Encoding", "gzip"); // If file is compressed wm->server->streamFile(file, "text/html"); file.close(); return; } } // Fallback to default if file not found wm->server->send(200, "text/html", "<html><body><h1>WiFi Config</h1>" "<p>Please connect to WiFi network</p>" "<p>Then configure your settings</p></body></html>"); }); }); // Start WiFiManager if (!wifiManager.autoConnect("MyAP")) { Serial.println("Failed to connect"); //////////// ESP.restart(); } Serial.println("Connected!"); } void loop() { // Your code here } RE: KC868-A16 - Custom Form Wifimanager Root content - admin - 03-27-2025 maybe you can change your ESP32 board verison in arudino IDE. about "wifiManager", you can visit author's webpage download directly. |