diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index fcd62b8757a36c..2b983e36a0761f 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -33,7 +33,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake) set(CHIP_REQUIRE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash) -if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2")) +if(NOT "${IDF_TARGET}" STREQUAL "esp32h2") list(APPEND CHIP_REQUIRE_COMPONENTS mdns) endif() @@ -314,8 +314,15 @@ if(CONFIG_OPENTHREAD_ENABLED) list(APPEND chip_libraries $) endif() -if((NOT CONFIG_USE_MINIMAL_MDNS) AND (NOT CONFIG_IDF_TARGET_ESP32H2) AND (NOT CONFIG_IDF_TARGET_ESP32C2)) - idf_component_get_property(mdns_lib mdns COMPONENT_LIB) +if((NOT CONFIG_USE_MINIMAL_MDNS) AND (NOT CONFIG_IDF_TARGET_ESP32H2)) + idf_build_get_property(build_components BUILD_COMPONENTS) + # For IDF v5.x, the mdns component was moved to idf_managed_components. + # We should use 'espressif__mdns' for 'idf_component_get_property'. + if("espressif__mdns" IN_LIST build_components) + idf_component_get_property(mdns_lib espressif__mdns COMPONENT_LIB) + elseif("mdns" IN_LIST build_components) + idf_component_get_property(mdns_lib mdns COMPONENT_LIB) + endif() list(APPEND chip_libraries $) endif() diff --git a/src/platform/ESP32/DnssdImpl.cpp b/src/platform/ESP32/DnssdImpl.cpp index 2b31b1e6d7659b..1615ea9e1b9119 100644 --- a/src/platform/ESP32/DnssdImpl.cpp +++ b/src/platform/ESP32/DnssdImpl.cpp @@ -170,6 +170,13 @@ CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCal espError = mdns_service_txt_set(service->mType, GetProtocolString(service->mProtocol), items, static_cast(service->mTextEntrySize)); } +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + for (size_t i = 0; i < service->mSubTypeSize; i++) + { + mdns_service_subtype_add_for_host(service->mName, service->mType, GetProtocolString(service->mProtocol), service->mHostName, + service->mSubTypes[i]); + } +#endif VerifyOrExit(espError == ESP_OK, error = CHIP_ERROR_INTERNAL); exit: @@ -432,7 +439,11 @@ void MdnsQueryDone(intptr_t context) } mdns_search_once_t * searchHandle = reinterpret_cast(context); GenericContext * ctx = FindMdnsQuery(searchHandle); +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + if (mdns_query_async_get_results(searchHandle, kTimeoutMilli, &(ctx->mResult), NULL)) +#else if (mdns_query_async_get_results(searchHandle, kTimeoutMilli, &(ctx->mResult))) +#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) { if (ctx->mContextType == ContextType::Browse) {