Bladeren bron

added and activated espressif mDNS service (#3494)

* added and activated espressif mDNS service

* moved esp-protocols to code/components
fsck-block 1 jaar geleden
bovenliggende
commit
1e60d839b7
4 gewijzigde bestanden met toevoegingen van 16 en 1 verwijderingen
  1. 3 0
      .gitmodules
  2. 1 1
      code/CMakeLists.txt
  3. 1 0
      code/components/esp-protocols
  4. 11 0
      code/components/jomjol_wlan/connect_wlan.cpp

+ 3 - 0
.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

+ 1 - 1
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

+ 1 - 0
code/components/esp-protocols

@@ -0,0 +1 @@
+Subproject commit 9b74256b518b009cd94c104e952af37bb79be273

+ 11 - 0
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");