Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Question: is mDNS supposed to work in AP mode ?

Open luc-github opened this issue 11 years ago • 13 comments

Hi I have tried mDNS sample in Station Mode, and it works very well - excellent! But I have issue in AP mode: I have modified the sample code to start in AP mode without password

  // Connect to WiFi network
  //WiFi.begin(ssid, password);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid);

and started mDNS using AP IP if (!mdns.begin("esp8266", WiFi.softAPIP())) {

webserver answer as expected on browser if using ip address (normal), but no answer when using http://esp8266.local - seems mDNS started without issue and I do not see any error on serial.

Is that normal ? or do I miss to setup something ?

Thanks,

Luc

luc-github avatar Apr 22 '15 04:04 luc-github

I have tried this and it seems that multicast doesn't work over softAP interface. For multicast destinations udp_send returns error code 1, which is not one of lwIP error codes (which are all negative), so it must be coming from the lower level (netif->output). This looks like an issue with Espressif's softAP interface.

igrr avatar Apr 27 '15 16:04 igrr

Ok thanks a lot for your answer so I close the issue or you want to keep a tracker ?

luc-github avatar Apr 28 '15 00:04 luc-github

Verified fixed - sorry for the delay thanks again for your great work

luc-github avatar Sep 07 '15 10:09 luc-github

I cannot seem to make this work. Using the current staging board manager build .begin("esp8266", WiFi.softAPIP()) and .begin("esp8266") both return false.

gregslomin avatar Oct 07 '15 06:10 gregslomin

I have same issue - seems something is broken since last test No answer on STA neither AP on OSX/Windows/Android

luc-github avatar Oct 08 '15 12:10 luc-github

Seems using a String and c_str() is not working well and even can lead to exception 28 like:

String shost = "esp8266";
.....
if (!mdns.begin(shost.c_str())) ...

but using an array of char is ok, like :

char hostname [12+1];
...
strcpy (hostname,"ESP_008261");
...
if (!mdns.begin(hostname)) ...

now both AP and STA are answering

luc-github avatar Oct 16 '15 03:10 luc-github

Is this an issue with the String class or an issue with const char pointers? Does the ESP8266 attempt to append a .local on the end of the given hostname and reuse the same memory?

gregslomin avatar Oct 16 '15 08:10 gregslomin

looking at the mDNS code, the content is copied so should not have issue

// Copy in domain characters as lowercase
  for (int i = 0; i < n; ++i)
    _hostName[i] = tolower(domain[i]);
  _hostName[n] = '\0';

luc-github avatar Oct 16 '15 11:10 luc-github

I noticed I needed "WiFi.mode(WIFI_AP);" before "WiFi.softAP(ssid);" Without setting mode, .begin("esp8266") returns false.

This worked both with a String and the strcpy above.

karlbackstrom avatar Oct 20 '15 11:10 karlbackstrom

Hey there,

I'm sorry for reopening this old thread after almost 2 years, but I have the same issue. Does someone have the solution for that ?

Kind regards.

aluis-rcastro avatar Jul 20 '17 09:07 aluis-rcastro

It works for me

On Jul 20, 2017 5:39 AM, "andre luis" [email protected] wrote:

Hey there,

I'm sorry for reopening this old thread after almost 2 years, but I have the same issue. Does someone have the solution for that ?

Kind regards.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/esp8266/Arduino/issues/96#issuecomment-316652153, or mute the thread https://github.com/notifications/unsubscribe-auth/AQC6Bj1ibkRe5jw7LhYzubVMaw2rdsIJks5sPyBTgaJpZM4EFvfG .

devyte avatar Jul 20 '17 14:07 devyte

Use Captive Portal for redirect. Perfect!

creatormir avatar Feb 05 '20 18:02 creatormir