mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 12:17:47 +00:00
[child-supervision] remove dummy implementation of child supervision (#6628)
This commit removes dummy implementation of ChildSupervisor and SupervisionListener. And add macro to ensure that these data members only exist in ThreadNetif when child supervisor option is enabled. In particular, ChildSupervisor only exists when child supervisor option is enabled and it is FTD.
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
|
||||
using namespace ot;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
uint16_t otChildSupervisionGetInterval(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
@@ -56,6 +58,8 @@ void otChildSupervisionSetInterval(otInstance *aInstance, uint16_t aInterval)
|
||||
instance.Get<Utils::ChildSupervisor>().SetSupervisionInterval(aInterval);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint16_t otChildSupervisionGetCheckTimeout(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
@@ -780,15 +780,18 @@ template <> inline Sntp::Client &Instance::Get(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
#if OPENTHREAD_FTD
|
||||
template <> inline Utils::ChildSupervisor &Instance::Get(void)
|
||||
{
|
||||
return mThreadNetif.mChildSupervisor;
|
||||
}
|
||||
|
||||
#endif
|
||||
template <> inline Utils::SupervisionListener &Instance::Get(void)
|
||||
{
|
||||
return mThreadNetif.mSupervisionListener;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_PING_SENDER_ENABLE
|
||||
template <> inline Utils::PingSender &Instance::Get(void)
|
||||
|
||||
@@ -423,10 +423,12 @@ void IndirectSender::HandleSentFrameToChild(const Mac::TxFrame &aFrame,
|
||||
|
||||
VerifyOrExit(mEnabled);
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
if (aError == kErrorNone)
|
||||
{
|
||||
Get<Utils::ChildSupervisor>().UpdateOnSend(aChild);
|
||||
}
|
||||
#endif
|
||||
|
||||
// A zero `nextOffset` indicates that the sent frame is an empty
|
||||
// frame generated by `PrepareFrameForChild()` when there was no
|
||||
|
||||
@@ -407,12 +407,16 @@ void MeshForwarder::SetRxOnWhenIdle(bool aRxOnWhenIdle)
|
||||
if (aRxOnWhenIdle)
|
||||
{
|
||||
mDataPollSender.StopPolling();
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
Get<Utils::SupervisionListener>().Stop();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
mDataPollSender.StartPolling();
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
Get<Utils::SupervisionListener>().Start();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,7 +1115,9 @@ void MeshForwarder::HandleReceivedFrame(Mac::RxFrame &aFrame)
|
||||
payload = aFrame.GetPayload();
|
||||
payloadLength = aFrame.GetPayloadLength();
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
Get<Utils::SupervisionListener>().UpdateOnReceive(macSource, linkInfo.IsLinkSecurityEnabled());
|
||||
#endif
|
||||
|
||||
switch (aFrame.GetType())
|
||||
{
|
||||
|
||||
@@ -117,6 +117,7 @@ Error MeshForwarder::SendMessage(Message &aMessage)
|
||||
break;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
case Message::kTypeSupervision:
|
||||
{
|
||||
Child *child = Get<Utils::ChildSupervisor>().GetDestination(aMessage);
|
||||
@@ -124,6 +125,7 @@ Error MeshForwarder::SendMessage(Message &aMessage)
|
||||
mIndirectSender.AddMessageForSleepyChild(aMessage, *child);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
aMessage.SetDirectTransmission();
|
||||
|
||||
@@ -139,8 +139,12 @@ ThreadNetif::ThreadNetif(Instance &aInstance)
|
||||
, mSrpServer(aInstance)
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
#if OPENTHREAD_FTD
|
||||
, mChildSupervisor(aInstance)
|
||||
#endif
|
||||
, mSupervisionListener(aInstance)
|
||||
#endif
|
||||
, mAnnounceBegin(aInstance)
|
||||
, mPanIdQuery(aInstance)
|
||||
, mEnergyScan(aInstance)
|
||||
|
||||
@@ -288,11 +288,15 @@ private:
|
||||
Srp::Server mSrpServer;
|
||||
#endif
|
||||
|
||||
Utils::ChildSupervisor mChildSupervisor;
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
#if OPENTHREAD_FTD
|
||||
Utils::ChildSupervisor mChildSupervisor;
|
||||
#endif
|
||||
Utils::SupervisionListener mSupervisionListener;
|
||||
AnnounceBeginServer mAnnounceBegin;
|
||||
PanIdQueryServer mPanIdQuery;
|
||||
EnergyScanServer mEnergyScan;
|
||||
#endif
|
||||
AnnounceBeginServer mAnnounceBegin;
|
||||
PanIdQueryServer mPanIdQuery;
|
||||
EnergyScanServer mEnergyScan;
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
TimeSync mTimeSync;
|
||||
|
||||
@@ -85,7 +85,9 @@ namespace Utils {
|
||||
*
|
||||
*/
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE && OPENTHREAD_FTD
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
/**
|
||||
* This class implements a child supervisor.
|
||||
@@ -171,23 +173,7 @@ private:
|
||||
uint16_t mSupervisionInterval;
|
||||
};
|
||||
|
||||
#else // #if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE && OPENTHREAD_FTD
|
||||
|
||||
class ChildSupervisor
|
||||
{
|
||||
public:
|
||||
explicit ChildSupervisor(otInstance &) {}
|
||||
void Start(void) {}
|
||||
void Stop(void) {}
|
||||
void SetSupervisionInterval(uint16_t) {}
|
||||
uint16_t GetSupervisionInterval(void) const { return 0; }
|
||||
Child * GetDestination(const Message &) const { return nullptr; }
|
||||
void UpdateOnSend(Child &) {}
|
||||
};
|
||||
|
||||
#endif // #if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE && OPENTHREAD_FTD
|
||||
|
||||
#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
#endif // #if OPENTHREAD_FTD
|
||||
|
||||
/**
|
||||
* This class implements a child supervision listener.
|
||||
@@ -262,19 +248,6 @@ private:
|
||||
TimerMilli mTimer;
|
||||
};
|
||||
|
||||
#else // #if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
|
||||
class SupervisionListener : private NonCopyable
|
||||
{
|
||||
public:
|
||||
SupervisionListener(otInstance &) {}
|
||||
void Start(void) {}
|
||||
void Stop(void) {}
|
||||
void SetTimeout(uint16_t) {}
|
||||
uint16_t GetTimeout(void) const { return 0; }
|
||||
void UpdateOnReceive(const Mac::Address &, bool) {}
|
||||
};
|
||||
|
||||
#endif // #if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user