diff --git a/.gitmodules b/.gitmodules index 9e869709..595462aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "code/components/stb"] path = code/components/stb url = https://github.com/nothings/stb.git +[submodule "code/components/esp-protocols"] + path = code/components/esp-protocols + url = https://github.com/espressif/esp-protocols.git diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 0ec36fe9..bd58e8ef 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16.0) -list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common components/esp-tflite-micro) +list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common components/esp-tflite-micro components/esp-protocols/components/mdns) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp diff --git a/code/components/esp-protocols b/code/components/esp-protocols new file mode 160000 index 00000000..9b74256b --- /dev/null +++ b/code/components/esp-protocols @@ -0,0 +1 @@ +Subproject commit 9b74256b518b009cd94c104e952af37bb79be273 diff --git a/code/components/jomjol_wlan/connect_wlan.cpp b/code/components/jomjol_wlan/connect_wlan.cpp index 03a4cd75..106f81b8 100644 --- a/code/components/jomjol_wlan/connect_wlan.cpp +++ b/code/components/jomjol_wlan/connect_wlan.cpp @@ -49,6 +49,9 @@ #define ets_delay_us(a) esp_rom_delay_us(a) #endif +#include "../esp-protocols/components/mdns/include/mdns.h" + + static const char *TAG = "WIFI"; static bool APWithBetterRSSI = false; @@ -657,6 +660,14 @@ esp_err_t wifi_init_sta(void) else { LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Set hostname to: " + wlan_config.hostname); } + //initialize mDNS service + retval = mdns_init(); + if (retval != ESP_OK) { + LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "mdns_init failed! Error: " + std::to_string(retval)); + } else { + //set mdns hostname + mdns_hostname_set(wlan_config.hostname.c_str()); + } } LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Init successful");