ESP32: fix some build errors when enabling platform mdns/disabling srp client (#33544)
* ESP32: fix some build errors when enabling platform mdns/disable srp client
* Restyled by clang-format
---------
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h
index e6d7870..e347df1 100644
--- a/src/platform/ESP32/CHIPDevicePlatformConfig.h
+++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h
@@ -54,8 +54,17 @@
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
#endif // CONFIG_ENABLE_MATTER_OVER_THREAD
+#ifdef CONFIG_OPENTHREAD_SRP_CLIENT
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 0
+#endif // CONFIG_OPENTHREAD_SRP_CLIENT
+
+#ifdef CONFIG_OPENTHREAD_DNS_CLIENT
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CONFIG_OPENTHREAD_DNS_CLIENT
+#else
+#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 0
+#endif // CONFIG_OPENTHREAD_DNS_CLIENT
#ifdef CONFIG_ENABLE_ETHERNET_TELEMETRY
#define CHIP_DEVICE_CONFIG_ENABLE_ETHERNET 1
diff --git a/src/platform/ESP32/DnssdImpl.cpp b/src/platform/ESP32/DnssdImpl.cpp
index 1ca0721..df83ec8 100644
--- a/src/platform/ESP32/DnssdImpl.cpp
+++ b/src/platform/ESP32/DnssdImpl.cpp
@@ -30,6 +30,7 @@
#endif
using namespace ::chip::DeviceLayer;
+using chip::DeviceLayer::Internal::ESP32Utils;
namespace chip {
namespace Dnssd {
@@ -39,7 +40,7 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
ReturnErrorOnFailure(EspDnssdInit(initCallback, errorCallback, context));
#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ReturnErrorOnFailure(OpenThreadDnssdInit(initCallback, errorCallback, context));
#endif
return CHIP_NO_ERROR;
@@ -52,7 +53,7 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
ReturnErrorOnFailure(EspDnssdPublishService(service, callback, context));
#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdPublishService(service, callback, context));
@@ -66,7 +67,7 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
ReturnErrorOnFailure(EspDnssdRemoveServices());
#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdRemoveServices());
@@ -77,7 +78,7 @@
CHIP_ERROR ChipDnssdFinalizeServiceUpdate()
{
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdFinalizeServiceUpdate());
@@ -91,13 +92,12 @@
intptr_t * browseIdentifier)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
- if (ConnectivityMgr().IsWiFiStationProvisioned() ||
- Internal::ESP32Utils::HasIPv6LinkLocalAddress(Internal::ESP32Utils::kDefaultEthernetNetifKey))
+ if (ConnectivityMgr().IsWiFiStationProvisioned() || ESP32Utils::HasIPv6LinkLocalAddress(ESP32Utils::kDefaultEthernetNetifKey))
{
ReturnErrorOnFailure(EspDnssdBrowse(type, protocol, addressType, interface, callback, context, browseIdentifier));
}
#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdBrowse(type, protocol, addressType, interface, callback, context, browseIdentifier));
@@ -115,13 +115,12 @@
void * context)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
- if (ConnectivityMgr().IsWiFiStationProvisioned() ||
- Internal::ESP32Utils::HasIPv6LinkLocalAddress(Internal::ESP32Utils::kDefaultEthernetNetifKey))
+ if (ConnectivityMgr().IsWiFiStationProvisioned() || ESP32Utils::HasIPv6LinkLocalAddress(ESP32Utils::kDefaultEthernetNetifKey))
{
ReturnErrorOnFailure(EspDnssdResolve(service, interface, callback, context));
}
#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT && CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
if (ConnectivityMgr().IsThreadProvisioned())
{
ReturnErrorOnFailure(OpenThreadDnssdResolve(service, interface, callback, context));
diff --git a/src/platform/ESP32/ESP32DnssdImpl.cpp b/src/platform/ESP32/ESP32DnssdImpl.cpp
index 2c896a0..e898a9c 100644
--- a/src/platform/ESP32/ESP32DnssdImpl.cpp
+++ b/src/platform/ESP32/ESP32DnssdImpl.cpp
@@ -355,7 +355,7 @@
Inet::IPAddress IPAddr;
error = GetIPAddress(IPAddr, currentResult->addr);
SuccessOrExit(error);
- ctx->mService[servicesIndex].mAddress.SetValue(IPAddr);
+ ctx->mService[servicesIndex].mAddress.emplace(IPAddr);
}
currentResult = currentResult->next;
servicesIndex++;
diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h
index 6b9e1f7..317bff7 100644
--- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h
+++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h
@@ -230,7 +230,6 @@
DnsBrowseCallback mDnsBrowseCallback;
DnsResolveCallback mDnsResolveCallback;
- GeneralFaults<kMaxNetworkFaults> mNetworkFaults;
struct DnsServiceTxtEntries
{
@@ -264,6 +263,8 @@
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
+ GeneralFaults<kMaxNetworkFaults> mNetworkFaults;
+
inline ImplClass * Impl() { return static_cast<ImplClass *>(this); }
};
diff --git a/src/platform/OpenThread/OpenThreadDnssdImpl.cpp b/src/platform/OpenThread/OpenThreadDnssdImpl.cpp
index cb205df..f5b0a85 100644
--- a/src/platform/OpenThread/OpenThreadDnssdImpl.cpp
+++ b/src/platform/OpenThread/OpenThreadDnssdImpl.cpp
@@ -24,6 +24,7 @@
CHIP_ERROR OpenThreadDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context)
{
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ReturnErrorOnFailure(ThreadStackMgr().SetSrpDnsCallbacks(initCallback, errorCallback, context));
uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength];
@@ -33,6 +34,9 @@
MakeHostName(hostname, sizeof(hostname), mac);
return ThreadStackMgr().ClearSrpHost(hostname);
+#else
+ return CHIP_ERROR_NOT_IMPLEMENTED;
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
}
const char * GetProtocolString(DnssdServiceProtocol protocol)