#include #include #include WebServer server(80); // 📡 WiFi AP personnalisé const char* ssid = "Futuro Tech Solutions"; const char* password = "FT001331"; // 💡 LED const int ledPin = 2; // 🔁 compteur login int loginCount = 0; // ======================= // 🌐 PAGE HTML (AUTH UI) // ======================= const char HTML_PAGE[] PROGMEM = R"rawliteral( ESP32 LOCK

🔐 ESP32 LOCK

)rawliteral"; // ======================= // 🌐 PAGE WEB // ======================= void handleRoot() { server.send_P(200, "text/html", HTML_PAGE); } // ======================= // 💡 LED REGISTER // ======================= void handleRegisterLED() { for (int i = 0; i < 10; i++) { digitalWrite(ledPin, HIGH); delay(250); digitalWrite(ledPin, LOW); delay(250); } server.send(200, "text/plain", "OK"); } // ======================= // 🔐 LED LOGIN (toggle) // ======================= void handleLoginLED() { loginCount++; if (loginCount % 2 == 1) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } server.send(200, "text/plain", "OK"); } // ======================= // SETUP // ======================= void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // 📡 WiFi AP WiFi.softAP(ssid, password); Serial.println("WiFi AP démarré"); Serial.println(WiFi.softAPIP()); // 🌍 mDNS → accès: http://esp32.lock if (MDNS.begin("esp32")) { Serial.println("mDNS démarré : http://esp32.lock"); } // 🌐 routes server.on("/", handleRoot); // 💡 API LED server.on("/led/register", handleRegisterLED); server.on("/led/login", handleLoginLED); server.begin(); } // ======================= // LOOP // ======================= void loop() { server.handleClient(); }