maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.12k stars 170 forks source link

ESP8266 RTOS SDK, mDNS, Legacy Event Loop #136

Closed mriksman closed 4 years ago

mriksman commented 4 years ago

All,

If you are using ESP8266 with the latest RTOS SDK, you may be already using Espressif's new event loop library;

esp_event_loop_create_default();
esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_AP_START, status_event_handler, NULL);

static void status_event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
    if (event_base == WIFI_EVENT) {
        if (event_id == WIFI_EVENT_AP_START) {

However, mDNS will not automatically react to these events - so you may have issues with mDNS stop working.

Please ensure you fire up the old legacy loop;

esp_event_loop_init(legacy_event_handler, NULL);

esp_err_t legacy_event_handler(void *ctx, system_event_t *event) {
    mdns_handle_system_event(ctx, event);
    return ESP_OK;
}

This is NOT an issue with ESP-IDF (ESP32) as the mDNS library has been updated to automatically register with the new event library.

mriksman commented 4 years ago

@maximkulkin For reference.