tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
648 stars 214 forks source link

mDNS doesn't appear to be reporting a hostname? #136

Open brad-colbert opened 2 years ago

brad-colbert commented 2 years ago

Prerequisites

Description

I'm looking for esp32 (appears to be default value) on my network but I'm not able to find it. I don't think mDNS is working. Is there a magic incantation?

Steps to Reproduce

Build, include in your project, try to access esp32.local (or whatever is required on your network).

System Configuration

esp-idf v4.2 DOIT ESP32 DEVKIT V1

brad-colbert commented 2 years ago

Well, it appears that the call wifi_manager_initialise_mdns() isn't implemented so I implemented my own, which I call when I receive WM_EVENT_STA_GOT_IP. Strange thing is. I'm now able to ping myhostname.local but when I point my browser to myhostname.local, it returns the AP address 10.10.0.1. Any ideas why?

Fantastic project! I should have added. Thank you!

brad-colbert commented 2 years ago

I'm not sure how to read this but there is a response in HTTP from the esp32 (.126) claiming that the "Location:" is 10.10.0.1 (from Wireshark)? I'm not sure where this is coming from. The AP should be down? Any ideas?

Frame 10207: 84 bytes on wire (672 bits), 84 bytes captured (672 bits) on interface en4, id 0 Ethernet II, Src: Espressi_67:55:94 (10:52:1c:67:55:94), Dst: Apple_b4:af:a7 (78:7b:8a:b4:af:a7) Internet Protocol Version 4, Src: 192.168.1.126, Dst: 192.168.1.213 Transmission Control Protocol, Src Port: 80, Dst Port: 63304, Seq: 65, Ack: 482, Len: 30 [2 Reassembled TCP Segments (94 bytes): #10205(64), #10207(30)] Hypertext Transfer Protocol HTTP/1.1 302 Found\r\n Content-Type: text/html\r\n Content-Length: 0\r\n Location: http://10.10.0.1\r\n \r\n [HTTP response 1/1] [Time since request: 0.038782000 seconds] [Request in frame: 10201] [Request URI: http://mele.local/settings]

brad-colbert commented 2 years ago

I'm not sure this is normal but it appears that the interface is still configured as both STA and AP? Could this be why I get the AP address? I would think the AP mode should be disabled since it's in STA mode and has an IP.

Code I changed in esp-idf/mdns.c:

            // if local netif copy is NULL, try to search for the default interface key
            if (tcpip_if == MDNS_IF_STA) {
                s_esp_netifs[MDNS_IF_STA] = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");

ESP_LOGI("mDNS", "%s: STA is netifs", __func__);
            } else if (tcpip_if == MDNS_IF_AP) {
                s_esp_netifs[MDNS_IF_AP] = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");

ESP_LOGI("mDNS", "%s: AP is netifs", __func__);

#if CONFIG_ETH_ENABLED
            } else if (tcpip_if == MDNS_IF_ETH) {
                s_esp_netifs[MDNS_IF_ETH] = esp_netif_get_handle_from_ifkey("ETH_DEF");
#endif
            }

Output on console:

(7945) HTTP_SVR: Start mDNS on station. (7955) mDNS: _mdns_get_esp_netif: STA is netifs (7965) mDNS: _mdns_get_esp_netif: AP is netifs