From c0274c20b254bd180a6c1215acce5fc336c63a18 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 6 Jun 2024 07:55:04 -0400 Subject: [PATCH 1/2] Log errors if AdvertiseOperational fails --- examples/platform/linux/CommissionerMain.cpp | 2 +- .../operational-credentials-server.cpp | 2 +- src/app/server/CommissioningWindowManager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/platform/linux/CommissionerMain.cpp b/examples/platform/linux/CommissionerMain.cpp index 3ffac89a6e08e9..e8da5d70b25e8a 100644 --- a/examples/platform/linux/CommissionerMain.cpp +++ b/examples/platform/linux/CommissionerMain.cpp @@ -216,7 +216,7 @@ CHIP_ERROR InitCommissioner(uint16_t commissionerPort, uint16_t udcListenPort, F gCommissionerDiscoveryController.SetCommissionerCallback(&gCommissionerCallback); // advertise operational since we are an admin - app::DnssdServer::Instance().AdvertiseOperational(); + ReturnLogErrorOnFailure(app::DnssdServer::Instance().AdvertiseOperational()); ChipLogProgress(Support, "InitCommissioner nodeId=0x" ChipLogFormatX64 " fabric.fabricId=0x" ChipLogFormatX64 " fabricIndex=0x%x", diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 12fe1c43de0baf..510ea384765178 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -703,7 +703,7 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co needRevert = false; // We might have a new operational identity, so we should start advertising it right away. - app::DnssdServer::Instance().AdvertiseOperational(); + LogErrorOnFailure(app::DnssdServer::Instance().AdvertiseOperational()); // Notify the attributes containing fabric metadata can be read with new data MatterReportingAttributeChangeCallback(commandPath.mEndpointId, OperationalCredentials::Id, diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index f11261ad9c444d..8a3c474f277d03 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -84,7 +84,7 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv } else if (event->Type == DeviceLayer::DeviceEventType::kOperationalNetworkEnabled) { - app::DnssdServer::Instance().AdvertiseOperational(); + LogErrorOnFailure(app::DnssdServer::Instance().AdvertiseOperational()); ChipLogProgress(AppServer, "Operational advertising enabled"); } #if CONFIG_NETWORK_LAYER_BLE From e3be2939c5e7297ccc5a2e1b4ddeec902bb2d963 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 6 Jun 2024 09:57:10 -0400 Subject: [PATCH 2/2] Update log text --- .../operational-credentials-server.cpp | 6 +++++- src/app/server/CommissioningWindowManager.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 510ea384765178..366694a8c504d3 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -703,7 +703,11 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co needRevert = false; // We might have a new operational identity, so we should start advertising it right away. - LogErrorOnFailure(app::DnssdServer::Instance().AdvertiseOperational()); + err = app::DnssdServer::Instance().AdvertiseOperational(); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Operational advertising failed: %" CHIP_ERROR_FORMAT, err.Format()); + } // Notify the attributes containing fabric metadata can be read with new data MatterReportingAttributeChangeCallback(commandPath.mEndpointId, OperationalCredentials::Id, diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 8a3c474f277d03..229fd67c5bb24b 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -84,8 +84,15 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv } else if (event->Type == DeviceLayer::DeviceEventType::kOperationalNetworkEnabled) { - LogErrorOnFailure(app::DnssdServer::Instance().AdvertiseOperational()); - ChipLogProgress(AppServer, "Operational advertising enabled"); + CHIP_ERROR err = app::DnssdServer::Instance().AdvertiseOperational(); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Operational advertising failed: %" CHIP_ERROR_FORMAT, err.Format()); + } + else + { + ChipLogProgress(AppServer, "Operational advertising enabled"); + } } #if CONFIG_NETWORK_LAYER_BLE else if (event->Type == DeviceLayer::DeviceEventType::kCloseAllBleConnections)