esp-arduino-apboot icon indicating copy to clipboard operation
esp-arduino-apboot copied to clipboard

Issue with launchWeb function

Open pluisi opened this issue 9 years ago • 5 comments

Hi I had a problem with an error. When starting the ESP for the first time, it should open the Access Point, and consequently the mDNS should be configured to run using the WiFi.softApIp, not the WiFi.localIp, as you do within your code. This generated an error and did not started the web server. Here is how I tried to fix the function.

void launchWeb(int webtype) {
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println(WiFi.localIP());
     Serial.println(WiFi.softAPIP());
     IPAddress ip2BeUsed;
    if(webtype==1) {
        ip2BeUsed = WiFi.softAPIP();
    } else {
        ip2BeUsed = WiFi.localIP();
    }
    if (!mdns.begin("esp8266", ip2BeUsed)) {
        Serial.println("Error setting up MDNS responder!");
        while(1) { 
            delay(1000);
        }
    }
    Serial.println("mDNS responder started");
    // Start the server
    server.begin();
    Serial.println("Server started");   
    int b = 20;
    int c = 0;
    while(b == 20) { 
        b = mdns1(webtype);
    }
}

I hope it helps Thanks for your great work Pierluigi

pluisi avatar Aug 15 '15 17:08 pluisi

I am still facing the issue with "launchWeb". execution stops at infinite while loop with error "Error setting up MDNS responder!". Please help me.

kishooore avatar Sep 25 '15 14:09 kishooore

I'm also having the message "Error setting up MDNS responder!" all the time even thought I made the fix above. What can I do to fix it? Thanks in advance.

pedronf65 avatar Oct 30 '15 21:10 pedronf65

I have the same problem : "Error setting up MDNS responder!"

I tried the @pluisi fix but I'm still facing the problem

How can I fix it ?

Thanks

I'm using Arduino 1.6.5 IDE & NodeMcu board

gaelperon avatar Nov 02 '15 08:11 gaelperon

Looking at the code in the mDNS header the second parameter is ignored anyway:

  bool begin(const char* hostName);
  //for compatibility
  bool begin(const char* hostName, IPAddress ip, uint32_t ttl=120){
    return begin(hostName);
  }

DSuds avatar Dec 06 '15 03:12 DSuds

You need WiFi.mode(WIFI_AP); before WiFi.softAP(ssid);. Without setting mode, mdns.begin("esp8266") returns false.

aekarpenko avatar Dec 15 '15 16:12 aekarpenko