Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDNS fails on esp32 because called before network is established #866

Open
jbaudoux opened this issue Dec 22, 2024 · 0 comments
Open

MDNS fails on esp32 because called before network is established #866

jbaudoux opened this issue Dec 22, 2024 · 0 comments
Labels

Comments

@jbaudoux
Copy link

Describe the bug

MDNS is started before network is established causing failure. Device is not crashing, just MDNS fails

[   190][E][ESPmDNS.cpp:65] begin(): Failed starting MDNS
Error setting up MDNS responder

Better use event handler:

void onNetworkConnected() {
  MDNS.begin("milight-hub");
}
#if defined(ESP8266)
void onWifiConnect(const WiFiEventStationModeGotIP& event) {
  onNetworkConnected()
} 
#elif defined(ESP32)
void onEvent(arduino_event_id_t event) {
  switch (event) {
    case SYSTEM_EVENT_STA_GOT_IP:
    case ARDUINO_EVENT_ETH_GOT_IP:
      onNetworkConnected();
      break;
    default: break;
  }
}
#endif

Steps to reproduce

Start device

Expected behavior

MDNS should succeed

Setup information

Firmware version

1.13.1

Output of http://milight-hub.local/about

{"firmware":"milight-hub","version":"1.13.1-beta2","ip_address":"172.19.3.37","reset_reason":"7","variant":"esp32","free_heap":215768,"arduino_version":"v4.4.6-dirty","free_stack":5548,"flash_used":2259,"flash_total":113201,"flash_pct_free":98,"mqtt":{"configured":true,"connected":true,"status":"Connected"},"queue_stats":{"length":0,"dropped_packets":0}}

Output of http://milight-hub.local/settings

{"admin_username":"","admin_password":"","ce_pin":4,"csn_pin":5,"reset_pin":0,"led_pin":-2,"radio_interface_type":"nRF24","packet_repeats":50,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"172.19.3.140","mqtt_username":"","mqtt_password":"","mqtt_topic_pattern":"milight/commands/:device_id/:device_type/:group_id","mqtt_update_topic_pattern":"","mqtt_state_topic_pattern":"milight/state/:device_id/:device_type/:group_id","mqtt_client_status_topic":"milight/client_status","simple_mqtt_client_status":true,"discovery_port":48899,"listen_repeats":3,"state_flush_interval":10000,"mqtt_state_rate_limit":500,"mqtt_debounce_delay":500,"mqtt_retain":true,"packet_repeat_throttle_sensitivity":0,"packet_repeat_throttle_threshold":200,"packet_repeat_minimum":3,"enable_automatic_mode_switching":false,"led_mode_wifi_config":"Fast toggle","led_mode_wifi_failed":"On","led_mode_operating":"Slow blip","led_mode_packet":"Flicker","led_mode_packet_count":3,"hostname":"milight-hub","rf24_power_level":"MAX","rf24_listen_channel":"LOW","wifi_static_ip":"","wifi_static_ip_gateway":"","wifi_static_ip_netmask":"","packet_repeats_per_loop":10,"home_assistant_discovery_prefix":"homeassistant/","wifi_mode":"g","default_transition_period":500,"rf24_channels":["LOW","MID","HIGH"],"device_ids":[],"gateway_configs":[],"group_state_fields":["state","brightness","computed_color","mode","color_temp","color_mode"],"ignored_listen_protocols":[]}

Additional context

Board: esp32dev
Build with pio run --target upload -e esp32

@jbaudoux jbaudoux added the bug label Dec 22, 2024
@jbaudoux jbaudoux changed the title MDNS fails on esp32 MDNS fails on esp32 because called before network is established Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant