mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 22:57:46 +00:00
[netif] add notification for up or down (#3248)
This commit is contained in:
@@ -285,6 +285,7 @@ enum
|
||||
OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL = 1 << 23, ///< Channel Manager new pending Thread channel changed
|
||||
OT_CHANGED_SUPPORTED_CHANNEL_MASK = 1 << 24, ///< Supported channel mask changed
|
||||
OT_CHANGED_BORDER_AGENT_STATE = 1 << 25, ///< Border agent state changed
|
||||
OT_CHANGED_THREAD_NETIF_STATE = 1 << 26, ///< Thread network interface state changed
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
@@ -114,31 +113,34 @@ ThreadNetif::ThreadNetif(Instance &aInstance)
|
||||
|
||||
otError ThreadNetif::Up(void)
|
||||
{
|
||||
if (!mIsUp)
|
||||
{
|
||||
// Enable the MAC just in case it was disabled while the Interface was down.
|
||||
mMac.SetEnabled(true);
|
||||
GetIp6().AddNetif(*this);
|
||||
mMeshForwarder.Start();
|
||||
mCoap.Start(kCoapUdpPort);
|
||||
VerifyOrExit(!mIsUp);
|
||||
|
||||
// Enable the MAC just in case it was disabled while the Interface was down.
|
||||
mMac.SetEnabled(true);
|
||||
GetIp6().AddNetif(*this);
|
||||
mMeshForwarder.Start();
|
||||
mCoap.Start(kCoapUdpPort);
|
||||
#if OPENTHREAD_ENABLE_DNS_CLIENT
|
||||
mDnsClient.Start();
|
||||
mDnsClient.Start();
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_SNTP_CLIENT
|
||||
mSntpClient.Start();
|
||||
#endif
|
||||
#if OPENTHREAD_ENABLE_CHANNEL_MONITOR
|
||||
GetInstance().GetChannelMonitor().Start();
|
||||
GetInstance().GetChannelMonitor().Start();
|
||||
#endif
|
||||
mMleRouter.Enable();
|
||||
mIsUp = true;
|
||||
}
|
||||
mMleRouter.Enable();
|
||||
mIsUp = true;
|
||||
GetNotifier().Signal(OT_CHANGED_THREAD_NETIF_STATE);
|
||||
|
||||
exit:
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError ThreadNetif::Down(void)
|
||||
{
|
||||
VerifyOrExit(mIsUp);
|
||||
|
||||
mCoap.Stop();
|
||||
#if OPENTHREAD_ENABLE_DNS_CLIENT
|
||||
mDnsClient.Stop();
|
||||
@@ -159,7 +161,9 @@ otError ThreadNetif::Down(void)
|
||||
#if OPENTHREAD_ENABLE_DTLS
|
||||
mDtls.Stop();
|
||||
#endif
|
||||
GetNotifier().Signal(OT_CHANGED_THREAD_NETIF_STATE);
|
||||
|
||||
exit:
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user