chriscook8 / esp-arduino-apboot

ESP8266 wifi configurator in Arduino lang.. uses eeprom for configs, boots to AP mode if no working config found
152 stars 61 forks source link

Issue with launchWeb function #3

Open pluisi opened 9 years ago

pluisi commented 9 years ago

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

kishooore commented 9 years ago

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

pedronf65 commented 8 years ago

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.

gaelperon commented 8 years ago

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

DSuds commented 8 years ago

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);
  }
aekarpenko commented 8 years ago

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