mirror of
https://github.com/espressif/openthread.git
synced 2026-08-27 20:39:54 +00:00
[config] parent search (#4020)
This commit is contained in:
@@ -177,7 +177,7 @@ typedef struct otMleCounters
|
||||
*
|
||||
* A parent change can happen if device detaches from its current parent and attaches to a different one, or even
|
||||
* while device is attached when the periodic parent search feature is enabled (please see option
|
||||
* OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH).
|
||||
* OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE).
|
||||
*
|
||||
*/
|
||||
uint16_t mParentChanges;
|
||||
|
||||
@@ -338,6 +338,7 @@ HEADERS_COMMON = \
|
||||
config/mle.h \
|
||||
config/openthread-core-config-check.h \
|
||||
config/openthread-core-default-config.h \
|
||||
config/parent_search.h \
|
||||
crypto/aes_ccm.hpp \
|
||||
crypto/aes_ecb.hpp \
|
||||
crypto/ecdsa.hpp \
|
||||
|
||||
@@ -372,64 +372,6 @@
|
||||
#define OPENTHREAD_CONFIG_DTLS_APPLICATION_DATA_MAX_LENGTH 1400
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
*
|
||||
* Define as 1 to enable periodic parent search feature.
|
||||
*
|
||||
* When this feature is enabled an end-device/child (while staying attached) will periodically search for a possible
|
||||
* better parent and will switch parent if a better one is found.
|
||||
*
|
||||
* The child will periodically check the average RSS value for the current parent, and only if it is below a specific
|
||||
* threshold, a parent search is performed. The `OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL` specifies the
|
||||
* check interval (in seconds) and `OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD` gives the RSS threshold.
|
||||
*
|
||||
* Since the parent search process can be power consuming (child needs to stays in RX mode to collect parent response)
|
||||
* and to limit its impact on battery-powered devices, after a parent search is triggered, the child will not trigger
|
||||
* another one before a specified backoff interval specified by `OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL`.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#define OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL
|
||||
*
|
||||
* Specifies the interval in seconds for a child to check the trigger condition to perform a parent search.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH`).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL (9 * 60)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL
|
||||
*
|
||||
* Specifies the backoff interval in seconds for a child to not perform a parent search after triggering one.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH`).
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL (10 * 60 * 60)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD
|
||||
*
|
||||
* Specifies the RSS threshold used to trigger a parent search.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH`).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -65
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
|
||||
*
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes compile-time configurations for Parent Search.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_PARENT_SEARCH_H_
|
||||
#define CONFIG_PARENT_SEARCH_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
*
|
||||
* Define as 1 to enable periodic parent search feature.
|
||||
*
|
||||
* When this feature is enabled an end-device/child (while staying attached) will periodically search for a possible
|
||||
* better parent and will switch parent if a better one is found.
|
||||
*
|
||||
* The child will periodically check the average RSS value for the current parent, and only if it is below a specific
|
||||
* threshold, a parent search is performed. The `OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL` specifies the
|
||||
* check interval (in seconds) and `OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD` gives the RSS threshold.
|
||||
*
|
||||
* Since the parent search process can be power consuming (child needs to stays in RX mode to collect parent response)
|
||||
* and to limit its impact on battery-powered devices, after a parent search is triggered, the child will not trigger
|
||||
* another one before a specified backoff interval specified by `OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL`.
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL
|
||||
*
|
||||
* Specifies the interval in seconds for a child to check the trigger condition to perform a parent search.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE`).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_CHECK_INTERVAL (9 * 60)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL
|
||||
*
|
||||
* Specifies the backoff interval in seconds for a child to not perform a parent search after triggering one.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE`).
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_BACKOFF_INTERVAL (10 * 60 * 60)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD
|
||||
*
|
||||
* Specifies the RSS threshold used to trigger a parent search.
|
||||
*
|
||||
* Applicable only if periodic parent search feature is enabled (see `OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE`).
|
||||
*
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD
|
||||
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -65
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_PARENT_SEARCH_H_
|
||||
@@ -62,6 +62,7 @@
|
||||
#include "config/logging.h"
|
||||
#include "config/mac.h"
|
||||
#include "config/mle.h"
|
||||
#include "config/parent_search.h"
|
||||
|
||||
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE || OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || \
|
||||
OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_JOINER_ENABLE
|
||||
|
||||
@@ -98,7 +98,7 @@ Mle::Mle(Instance &aInstance)
|
||||
#if OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
, mPreviousParentRloc(Mac::kShortAddrInvalid)
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
, mParentSearchIsInBackoff(false)
|
||||
, mParentSearchBackoffWasCanceled(false)
|
||||
, mParentSearchRecentlyDetached(false)
|
||||
@@ -204,7 +204,7 @@ Mle::Mle(Instance &aInstance)
|
||||
// `SetMeshLocalPrefix()` also adds the Mesh-Local EID and subscribes
|
||||
// to the Link- and Realm-Local All Thread Nodes multicast addresses.
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
StartParentSearchTimer();
|
||||
#endif
|
||||
}
|
||||
@@ -595,7 +595,7 @@ otError Mle::BecomeDetached(void)
|
||||
Get<MeshCoP::PendingDataset>().HandleDetach();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
mParentSearchRecentlyDetached = true;
|
||||
#endif
|
||||
|
||||
@@ -769,7 +769,7 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
||||
// send announce after attached if needed
|
||||
InformPreviousChannel();
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
UpdateParentSearchState();
|
||||
#endif
|
||||
|
||||
@@ -4030,7 +4030,7 @@ exit:
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
void Mle::HandleParentSearchTimer(Timer &aTimer)
|
||||
{
|
||||
aTimer.GetOwner<Mle>().HandleParentSearchTimer();
|
||||
@@ -4135,7 +4135,7 @@ void Mle::UpdateParentSearchState(void)
|
||||
StartParentSearchTimer();
|
||||
}
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#endif // OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
|
||||
void Mle::LogMleMessage(const char *aLogString, const Ip6::Address &aAddress) const
|
||||
{
|
||||
|
||||
@@ -1741,7 +1741,7 @@ private:
|
||||
otError InformPreviousParent(void);
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
static void HandleParentSearchTimer(Timer &aTimer);
|
||||
void HandleParentSearchTimer(void);
|
||||
void StartParentSearchTimer(void);
|
||||
@@ -1795,7 +1795,7 @@ private:
|
||||
uint16_t mPreviousParentRloc;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_PERIODIC_PARENT_SEARCH
|
||||
#if OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
bool mParentSearchIsInBackoff : 1;
|
||||
bool mParentSearchBackoffWasCanceled : 1;
|
||||
bool mParentSearchRecentlyDetached : 1;
|
||||
|
||||
Reference in New Issue
Block a user