From 127baf4aa1e4ad338848ca9864f5ef8ee84c937f Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 3 Jan 2025 16:31:22 -0800 Subject: [PATCH] [border-agent] update interactions with native `Commissioner` (#11087) This commit updates the interaction between `BorderAgent` and the native `Commissioner`, removing the unnecessary mechanism to stop and restart the Border Agent when the commissioner is enabled and disabled. This was previously required because both modules shared the same underlying `Tmf::SecureAgent` and DTLS transport. This has been changed recently so that `BorderAgent` uses its own DTLS transport and sessions. --- src/core/meshcop/border_agent.cpp | 6 +----- src/core/meshcop/border_agent.hpp | 12 ++---------- src/core/meshcop/commissioner.cpp | 8 -------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index f498aed1c..20523602e 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -185,12 +185,8 @@ uint16_t BorderAgent::GetUdpPort(void) const { return mDtlsTransport.GetUdpPort( void BorderAgent::HandleNotifierEvents(Events aEvents) { - if ((aEvents.ContainsAny(kEventThreadRoleChanged | kEventCommissionerStateChanged))) + if (aEvents.Contains(kEventThreadRoleChanged)) { -#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD - VerifyOrExit(Get().IsDisabled()); -#endif - if (Get().IsAttached()) { Start(); diff --git a/src/core/meshcop/border_agent.hpp b/src/core/meshcop/border_agent.hpp index 08b62e227..60f4160d1 100644 --- a/src/core/meshcop/border_agent.hpp +++ b/src/core/meshcop/border_agent.hpp @@ -145,16 +145,6 @@ public: */ uint16_t GetUdpPort(void) const; - /** - * Starts the Border Agent service. - */ - void Start(void) { IgnoreError(Start(kUdpPort)); } - - /** - * Stops the Border Agent service. - */ - void Stop(void); - /** * Gets the state of the Border Agent service. * @@ -293,8 +283,10 @@ private: uint8_t mToken[Coap::Message::kMaxTokenLength]; // The CoAP Token of the original request. }; + void Start(void) { IgnoreError(Start(kUdpPort)); } Error Start(uint16_t aUdpPort); Error Start(uint16_t aUdpPort, const uint8_t *aPsk, uint8_t aPskLength); + void Stop(void); void HandleNotifierEvents(Events aEvents); void HandleTimeout(void); Error ForwardToLeader(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo, Uri aUri); diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index e58d7cf02..46c962a2c 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -268,10 +268,6 @@ Error Commissioner::Start(StateCallback aStateCallback, JoinerCallback aJoinerCa VerifyOrExit(Get().IsAttached(), error = kErrorInvalidState); VerifyOrExit(mState == kStateDisabled, error = kErrorAlready); -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE - Get().Stop(); -#endif - SuccessOrExit(error = Get().Open()); SuccessOrExit(error = Get().Bind(SendRelayTransmit, this)); @@ -326,10 +322,6 @@ Error Commissioner::Stop(ResignMode aResignMode) SendKeepAlive(); } -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE - Get().Start(); -#endif - exit: if (error != kErrorAlready) {