Skip to content

Commit

Permalink
[telemetry] refine telemetry calculation function's aPublisher type (
Browse files Browse the repository at this point in the history
…#2015)

Change aPublisher to pointer type. If it is not NULL, populate the
MDNS telemetry; otherwise do not populate MDNS telemetry. This helps
to reduce thread_helper's dependency issue on border_agent aPublisher.
  • Loading branch information
morningboata authored Sep 13, 2023
1 parent 6da0357 commit b67e763
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dbus/server/dbus_thread_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/utils/thread_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/utils/thread_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down

0 comments on commit b67e763

Please sign in to comment.