[dataset] add build option for GenerateLocal (#9215)

This commit is contained in:
Jonathan Hui
2023-06-30 09:53:28 -07:00
committed by GitHub
parent 77d1f3d1b5
commit 60db56f0c0
7 changed files with 40 additions and 5 deletions
+1
View File
@@ -134,6 +134,7 @@ ot_option(OT_NAT64_TRANSLATOR OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE "NAT64 t
ot_option(OT_NEIGHBOR_DISCOVERY_AGENT OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE "neighbor discovery agent")
ot_option(OT_NETDATA_PUBLISHER OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE "Network Data publisher")
ot_option(OT_NETDIAG_CLIENT OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE "Network Diagnostic client")
ot_option(OT_OPERATIONAL_DATASET_AUTO_INIT OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT "operational dataset auto init")
ot_option(OT_OTNS OPENTHREAD_CONFIG_OTNS_ENABLE "OTNS")
ot_option(OT_PING_SENDER OPENTHREAD_CONFIG_PING_SENDER_ENABLE "ping sender" ${OT_APP_CLI})
ot_option(OT_PLATFORM_NETIF OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE "platform netif")
+12
View File
@@ -530,4 +530,16 @@
#define OPENTHREAD_CONFIG_ALLOW_EMPTY_NETWORK_NAME 0
#endif
/**
* @def OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
*
* Define as 1 to enable support for locally initializing an Active Operational Dataset.
*
* @note This functionality is deprecated and not recommended.
*
*/
#ifndef OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
#define OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT 0
#endif
#endif // CONFIG_MISC_H_
+2
View File
@@ -633,6 +633,8 @@ ActiveDatasetManager::ActiveDatasetManager(Instance &aInstance)
bool ActiveDatasetManager::IsPartiallyComplete(void) const { return mLocal.IsSaved() && !mTimestampValid; }
bool ActiveDatasetManager::IsComplete(void) const { return mLocal.IsSaved() && mTimestampValid; }
bool ActiveDatasetManager::IsCommissioned(void) const
{
Dataset::Info datasetInfo;
+13 -2
View File
@@ -382,12 +382,21 @@ public:
* Is primarily used to determine whether a user has supplied a partial Active Dataset for use
* with joining a network.
*
* @retval TRUE if an Active Dataset is saved but does not include an Active Timestamp.
* @retval FALSE if an Active Dataset is not saved or does include an Active Timestamp.
* @retval TRUE If an Active Dataset is saved but does not include an Active Timestamp.
* @retval FALSE If an Active Dataset is not saved or does include an Active Timestamp.
*
*/
bool IsPartiallyComplete(void) const;
/**
* Indicates whether the Active Dataset is complete.
*
* @retval TRUE If an Active Dataset is saved and includes an Active Timestamp.
* @retval FALSE If an Active Dataset is not saved or does include an Active Timestamp.
*
*/
bool IsComplete(void) const;
/**
* Indicates whether or not a valid network is present in the Active Operational Dataset.
*
@@ -471,6 +480,7 @@ public:
*/
void StartLeader(void);
#if OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
/**
* Generate a default Active Operational Dataset.
*
@@ -481,6 +491,7 @@ public:
*/
Error GenerateLocal(void);
#endif
#endif
private:
template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
+4
View File
@@ -296,6 +296,7 @@ exit:
return error;
}
#if OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
Error ActiveDatasetManager::GenerateLocal(void)
{
Error error = kErrorNone;
@@ -395,6 +396,9 @@ exit:
}
void ActiveDatasetManager::StartLeader(void) { IgnoreError(GenerateLocal()); }
#else // OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
void ActiveDatasetManager::StartLeader(void) {}
#endif // OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
template <>
void ActiveDatasetManager::HandleTmf<kUriActiveSet>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
+4
View File
@@ -246,7 +246,11 @@ Error MleRouter::BecomeLeader(void)
uint32_t partitionId;
uint8_t leaderId;
#if OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
VerifyOrExit(!Get<MeshCoP::ActiveDatasetManager>().IsPartiallyComplete(), error = kErrorInvalidState);
#else
VerifyOrExit(Get<MeshCoP::ActiveDatasetManager>().IsComplete(), error = kErrorInvalidState);
#endif
VerifyOrExit(!IsDisabled(), error = kErrorInvalidState);
VerifyOrExit(!IsLeader(), error = kErrorNone);
VerifyOrExit(IsRouterEligible(), error = kErrorNotCapable);
+4 -3
View File
@@ -108,6 +108,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
@@ -120,7 +121,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=OFF \
-DOT_15_4=ON -DOT_TREL=OFF -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
@@ -134,7 +135,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=OFF -DOT_TREL=ON \
-DOT_15_4=OFF -DOT_TREL=ON -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die
@@ -148,7 +149,7 @@ case ${build_config} in
cd "${top_builddir}" || die "cd failed"
cmake -GNinja -DOT_PLATFORM=simulation -DOT_COMPILE_WARNING_AS_ERROR=ON -DOT_COVERAGE=${ot_coverage} \
-DOT_THREAD_VERSION=1.3.1 -DOT_APP_CLI=OFF -DOT_APP_NCP=ON -DOT_APP_RCP=OFF \
-DOT_15_4=ON -DOT_TREL=ON \
-DOT_15_4=ON -DOT_TREL=ON -DOT_OPERATIONAL_DATASET_AUTO_INIT=ON \
-DOT_CONFIG=../tests/toranj/openthread-core-toranj-config-simulation.h \
"${top_srcdir}" || die
ninja || die