mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 01:17:46 +00:00
[bbr] handle role changes directly in BackboneRouter::Local (#13112)
This commit updates `BackboneRouter::Local` to receive role change events directly from the `Notifier`. Previously, `Bbr::Local` was indirectly relying on `BackboneRouter::Leader` to emit events even when the PBBR configuration had not changed (e.g., during role transitions). The previous design was fragile and created an unnecessary dependency. `Bbr::Local` now independently tracks role changes to ensure it correctly evaluates its own status (e.g., deciding whether to register as the Primary BBR).
This commit is contained in:
committed by
Jonathan Hui
parent
c5efa406c2
commit
9137b82dbe
@@ -240,7 +240,19 @@ exit:
|
||||
void Local::HandleBackboneRouterPrimaryUpdate(PrimaryEvent aEvent)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aEvent);
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
void Local::HandleNotifierEvents(Events aEvents)
|
||||
{
|
||||
if (aEvents.Contains(kEventThreadRoleChanged))
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
void Local::UpdateState(void)
|
||||
{
|
||||
VerifyOrExit(IsEnabled() && Get<Mle::Mle>().IsAttached());
|
||||
|
||||
// Wait some jitter before trying to Register.
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "common/locator.hpp"
|
||||
#include "common/log.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "common/time_ticker.hpp"
|
||||
#include "net/netif.hpp"
|
||||
#include "thread/network_data.hpp"
|
||||
@@ -73,6 +74,7 @@ namespace BackboneRouter {
|
||||
class Local : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
friend class ot::TimeTicker;
|
||||
friend class ot::Notifier;
|
||||
|
||||
public:
|
||||
typedef otBackboneRouterDomainPrefixCallback DomainPrefixCallback; ///< Domain Prefix callback.
|
||||
@@ -265,6 +267,8 @@ private:
|
||||
};
|
||||
|
||||
void SetState(State aState);
|
||||
void HandleNotifierEvents(Events aEvents);
|
||||
void UpdateState(void);
|
||||
void RemoveService(void);
|
||||
void HandleTimeTick(void);
|
||||
void AddDomainPrefixToNetworkData(void);
|
||||
|
||||
@@ -104,6 +104,9 @@ void Notifier::EmitEvents(void)
|
||||
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
|
||||
Get<BackboneRouter::Leader>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
|
||||
Get<BackboneRouter::Local>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE
|
||||
Get<Dhcp6::Server>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user