Skip to content

Commit

Permalink
[border-agent] update interactions with native Commissioner (openth…
Browse files Browse the repository at this point in the history
…read#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.
  • Loading branch information
abtink authored Jan 4, 2025
1 parent 1024a1f commit 127baf4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
6 changes: 1 addition & 5 deletions src/core/meshcop/border_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Commissioner>().IsDisabled());
#endif

if (Get<Mle::MleRouter>().IsAttached())
{
Start();
Expand Down
12 changes: 2 additions & 10 deletions src/core/meshcop/border_agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ class BorderAgent : public InstanceLocator, private NonCopyable
*/
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.
*
Expand Down Expand Up @@ -293,8 +283,10 @@ class BorderAgent : public InstanceLocator, private NonCopyable
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);
Expand Down
8 changes: 0 additions & 8 deletions src/core/meshcop/commissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ Error Commissioner::Start(StateCallback aStateCallback, JoinerCallback aJoinerCa
VerifyOrExit(Get<Mle::MleRouter>().IsAttached(), error = kErrorInvalidState);
VerifyOrExit(mState == kStateDisabled, error = kErrorAlready);

#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Get<BorderAgent>().Stop();
#endif

SuccessOrExit(error = Get<Tmf::SecureAgent>().Open());
SuccessOrExit(error = Get<Tmf::SecureAgent>().Bind(SendRelayTransmit, this));

Expand Down Expand Up @@ -326,10 +322,6 @@ Error Commissioner::Stop(ResignMode aResignMode)
SendKeepAlive();
}

#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
Get<BorderAgent>().Start();
#endif

exit:
if (error != kErrorAlready)
{
Expand Down

0 comments on commit 127baf4

Please sign in to comment.