diff --git a/src/dbus/server/dbus_thread_object.cpp b/src/dbus/server/dbus_thread_object.cpp index 2a2d2eac50d..b183c650320 100644 --- a/src/dbus/server/dbus_thread_object.cpp +++ b/src/dbus/server/dbus_thread_object.cpp @@ -1412,7 +1412,7 @@ otError DBusThreadObject::GetTelemetryDataHandler(DBusMessageIter &aIter) threadnetwork::TelemetryData telemetryData; auto threadHelper = mNcp->GetThreadHelper(); - VerifyOrExit(threadHelper->RetrieveTelemetryData(*mPublisher, telemetryData) == OT_ERROR_NONE); + VerifyOrExit(threadHelper->RetrieveTelemetryData(mPublisher, telemetryData) == OT_ERROR_NONE); { const std::string telemetryDataBytes = telemetryData.SerializeAsString(); diff --git a/src/utils/thread_helper.cpp b/src/utils/thread_helper.cpp index 1fcca2a6820..9cd2dd8e30d 100644 --- a/src/utils/thread_helper.cpp +++ b/src/utils/thread_helper.cpp @@ -888,7 +888,7 @@ void ThreadHelper::DetachGracefullyCallback(void) } #if OTBR_ENABLE_TELEMETRY_DATA_API -otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher &aPublisher, threadnetwork::TelemetryData &telemetryData) +otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadnetwork::TelemetryData &telemetryData) { otError error = OT_ERROR_NONE; @@ -1260,9 +1260,10 @@ otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher &aPublisher, threadn #endif // OTBR_ENABLE_DNSSD_DISCOVERY_PROXY // Start of MdnsInfo section. + if (aPublisher != nullptr) { auto mdns = wpanBorderRouter->mutable_mdns(); - const MdnsTelemetryInfo &mdnsInfo = aPublisher.GetMdnsTelemetryInfo(); + const MdnsTelemetryInfo &mdnsInfo = aPublisher->GetMdnsTelemetryInfo(); CopyMdnsResponseCounters(mdnsInfo.mHostRegistrations, mdns->mutable_host_registration_responses()); CopyMdnsResponseCounters(mdnsInfo.mServiceRegistrations, mdns->mutable_service_registration_responses()); diff --git a/src/utils/thread_helper.hpp b/src/utils/thread_helper.hpp index eb5863e6810..10d38770a8b 100644 --- a/src/utils/thread_helper.hpp +++ b/src/utils/thread_helper.hpp @@ -260,12 +260,12 @@ class ThreadHelper /** * This method populates the telemetry data and returns the error code if error happens. * - * @param[in] aPublisher The Mdns::Publisher + * @param[in] aPublisher The Mdns::Publisher to provide MDNS telemetry if it is not `nullptr`. * @param[in] telemetryData The telemetry data to be populated. * * @returns The error code if error happens during the population of the telemetry data. */ - otError RetrieveTelemetryData(Mdns::Publisher &aPublisher, threadnetwork::TelemetryData &telemetryData); + otError RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadnetwork::TelemetryData &telemetryData); #endif // OTBR_ENABLE_TELEMETRY_DATA_API /**