From b2c8147a31c410f4859e1ffb87df1d4a0ed51738 Mon Sep 17 00:00:00 2001 From: whd <7058128+superwhd@users.noreply.github.com> Date: Fri, 26 Jan 2024 01:28:06 +0800 Subject: [PATCH] [border-agent] enable `otBorderAgentGetId` API when Border Agent is enabled (#9794) This could simplify the build configuration by omitting `OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`. --- src/core/common/settings.cpp | 6 +++--- src/core/common/settings.hpp | 6 +++--- src/core/config/border_agent.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/common/settings.cpp b/src/core/common/settings.cpp index 504eb7c56..3e1f860ee 100644 --- a/src/core/common/settings.cpp +++ b/src/core/common/settings.cpp @@ -106,7 +106,7 @@ void SettingsBase::SrpServerInfo::Log(Action aAction) const } #endif -#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE void SettingsBase::BorderAgentId::Log(Action aAction) const { char buffer[sizeof(BorderAgentId) * 2 + 1]; @@ -115,7 +115,7 @@ void SettingsBase::BorderAgentId::Log(Action aAction) const sw.AppendHexBytes(GetId().mId, sizeof(BorderAgentId)); LogInfo("%s BorderAgentId {id:%s}", ActionToString(aAction), buffer); } -#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE +#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE #endif // OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO) @@ -531,7 +531,7 @@ void Settings::Log(Action aAction, Error aError, Key aKey, const void *aValue) break; #endif -#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE case kKeyBorderAgentId: reinterpret_cast(aValue)->Log(aAction); break; diff --git a/src/core/common/settings.hpp b/src/core/common/settings.hpp index 199eb9fe0..9716cb87a 100644 --- a/src/core/common/settings.hpp +++ b/src/core/common/settings.hpp @@ -767,7 +767,7 @@ public: } OT_TOOL_PACKED_END; #endif // OPENTHREAD_CONFIG_SRP_SERVER_ENABLE && OPENTHREAD_CONFIG_SRP_SERVER_PORT_SWITCH_ENABLE -#if OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE +#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE /** * Represents the Border Agent ID. * @@ -784,7 +784,7 @@ public: * Initializes the `BorderAgentId` object. * */ - void Init(void) { mId = {}; } + void Init(void) { memset(&mId, 0, sizeof(mId)); } /** * Returns the Border Agent ID. @@ -813,7 +813,7 @@ public: MeshCoP::BorderAgent::Id mId; } OT_TOOL_PACKED_END; -#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE +#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE && OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE protected: explicit SettingsBase(Instance &aInstance) diff --git a/src/core/config/border_agent.h b/src/core/config/border_agent.h index 5769fe177..9be5db107 100644 --- a/src/core/config/border_agent.h +++ b/src/core/config/border_agent.h @@ -72,7 +72,7 @@ * */ #ifndef OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE -#define OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE 0 +#define OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE 1 #endif /**