void WiFiManager::startWebConfig() { DEBUG_PRINT(""); display.print("WiFi connected"); DEBUG_PRINT("WiFi connected"); DEBUG_PRINT(WiFi.localIP()); DEBUG_PRINT(WiFi.softAPIP()); if (!mdns.begin(_apName, WiFi.localIP())) { DEBUG_PRINT("Error setting up MDNS responder!"); display.print("mDNS error"); while(1) { delay(1000); } } DEBUG_PRINT("mDNS responder started"); // Start the server server_s.begin(); display.print("Server started"); DEBUG_PRINT("Server started"); while(serverLoop() == WM_WAIT) { //looping } display.print("All done. Bye."); DEBUG_PRINT("Setup done"); delay(10000); ESP.reset(); }
void WiFiManager::startWebConfig() { DEBUG_PRINT(""); DEBUG_PRINT("WiFi connected"); DEBUG_PRINT(WiFi.localIP()); DEBUG_PRINT(WiFi.softAPIP()); if (!mdns.begin(_apName, WiFi.localIP())) { DEBUG_PRINT("Error setting up MDNS responder!"); while (1) { delay(1000); } } DEBUG_PRINT("mDNS responder started"); // Start the server server.begin(); DEBUG_PRINT("Server started"); while (serverLoop() == WM_WAIT) { //looping if(timeout > 0 && start + timeout < millis()) { //we passed timeout value, release DEBUG_PRINT("timeout reached"); return; } } DEBUG_PRINT("Setup done"); delay(5000); ESP.reset(); }
void setup() { Serial.begin(115200); pinMode(BUTTON_PIN, INPUT); if (digitalRead(BUTTON_PIN) == 0) { Serial.println("Factory Reset"); } WiFiManager wifi; wifi.autoConnect(DEVICE_NAME); if (!mdns.begin(DEVICE_NAME, WiFi.localIP())) { Serial.println("Error setting up MDNS responder!"); } else { Serial.println("mDNS responder started"); } // Start TCP (HTTP) server server.begin(); Serial.println("TCP server started"); Serial.println("Listening on port 8266"); Serial.print("Sketch size: "); Serial.println(ESP.getSketchSize()); Serial.print("Free size: "); Serial.println(ESP.getFreeSketchSpace()); server.on("/", handle_root); server.on("/on", handle_on); server.on("/off", handle_off); httpUpdater.setup(&server); state = OFF; Serial.println("State: OFF"); pinMode(LED_PIN, OUTPUT); }
void setup(void){ pinMode(led, OUTPUT); digitalWrite(led, LED_OFF); // Note the serial rate - if you don't match it when connecting you'll get garbage. Serial.begin(115200); WiFi.begin(ssid, password); Serial.println(""); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); // This tells the network that you can access the ip address of the esp8266 via 'esp8266.local' // The first arg is the hostname - '.local' will be appended to it, the second arg is the ip address if (mdns.begin("esp8266", WiFi.localIP())) { Serial.println("MDNS responder started"); } server.on("/", handleRoot); server.on("/inline", [](){ server.send(200, "text/plain", "this works as well"); }); server.onNotFound(handleNotFound); server.begin(); Serial.println("HTTP server started"); }