mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 15:47:46 +00:00
[notifier] signal change to active or pending Operational Dataset (#5657)
This commit is contained in:
committed by
Jonathan Hui
parent
7011a12e9a
commit
7b570c7fc1
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (35)
|
||||
#define OPENTHREAD_API_VERSION (36)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
@@ -160,6 +160,8 @@ enum
|
||||
OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE = 1 << 25, ///< Backbone Router state changed
|
||||
OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL = 1 << 26, ///< Local Backbone Router configuration changed
|
||||
OT_CHANGED_JOINER_STATE = 1 << 27, ///< Joiner state changed
|
||||
OT_CHANGED_ACTIVE_DATASET = 1 << 28, ///< Active Operational Dataset changed
|
||||
OT_CHANGED_PENDING_DATASET = 1 << 29, ///< Pending Operational Dataset changed
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -353,6 +353,14 @@ const char *Notifier::EventToString(Event aEvent) const
|
||||
case kEventJoinerStateChanged:
|
||||
retval = "JoinerState";
|
||||
break;
|
||||
|
||||
case kEventActiveDatasetChanged:
|
||||
retval = "ActDset";
|
||||
break;
|
||||
|
||||
case kEventPendingDatasetChanged:
|
||||
retval = "PndDset";
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -92,6 +92,8 @@ enum Event
|
||||
kEventThreadBackboneRouterStateChanged = OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE, ///< Backbone Router state changed
|
||||
kEventThreadBackboneRouterLocalChanged = OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL, ///< Local Backbone Router changed
|
||||
kEventJoinerStateChanged = OT_CHANGED_JOINER_STATE, ///< Joiner state changed
|
||||
kEventActiveDatasetChanged = OT_CHANGED_ACTIVE_DATASET, ///< Active Dataset changed
|
||||
kEventPendingDatasetChanged = OT_CHANGED_PENDING_DATASET, ///< Pending Dataset changed
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "common/instance.hpp"
|
||||
#include "common/locator-getters.hpp"
|
||||
#include "common/logging.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "meshcop/meshcop.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "radio/radio.hpp"
|
||||
@@ -102,6 +103,8 @@ otError DatasetManager::Restore(void)
|
||||
IgnoreError(dataset.ApplyConfiguration(GetInstance()));
|
||||
}
|
||||
|
||||
SignalDatasetChange();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -124,6 +127,7 @@ void DatasetManager::Clear(void)
|
||||
mTimestampValid = false;
|
||||
mLocal.Clear();
|
||||
mTimer.Stop();
|
||||
SignalDatasetChange();
|
||||
}
|
||||
|
||||
void DatasetManager::HandleDetach(void)
|
||||
@@ -167,6 +171,8 @@ otError DatasetManager::Save(const Dataset &aDataset)
|
||||
SendSet();
|
||||
}
|
||||
|
||||
SignalDatasetChange();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -218,6 +224,14 @@ void DatasetManager::HandleDatasetUpdated(void)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SignalDatasetChange();
|
||||
}
|
||||
|
||||
void DatasetManager::SignalDatasetChange(void) const
|
||||
{
|
||||
Get<Notifier>().Signal(mLocal.GetType() == Dataset::kActive ? kEventActiveDatasetChanged
|
||||
: kEventPendingDatasetChanged);
|
||||
}
|
||||
|
||||
otError DatasetManager::GetChannelMask(Mac::ChannelMask &aChannelMask) const
|
||||
|
||||
@@ -336,6 +336,7 @@ private:
|
||||
|
||||
bool IsActiveDataset(void) const { return GetType() == Dataset::kActive; }
|
||||
bool IsPendingDataset(void) const { return GetType() == Dataset::kPending; }
|
||||
void SignalDatasetChange(void) const;
|
||||
void HandleDatasetUpdated(void);
|
||||
void SendSet(void);
|
||||
void SendGetResponse(const Coap::Message & aRequest,
|
||||
|
||||
Reference in New Issue
Block a user