mirror of
https://github.com/espressif/openthread.git
synced 2026-08-31 14:29:54 +00:00
[discovery] allow (S)SED devices to perform MLE Discovery (#8832)
Signed-off-by: Lukasz Duda <[email protected]>
This commit is contained in:
committed by
Jonathan Hui
parent
2c8a0af244
commit
7ec184d68e
@@ -53,7 +53,7 @@ extern "C" {
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (304)
|
||||
#define OPENTHREAD_API_VERSION (305)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -264,6 +264,8 @@ bool otThreadIsSingleton(otInstance *aInstance);
|
||||
/**
|
||||
* This function starts a Thread Discovery scan.
|
||||
*
|
||||
* @note A successful call to this function enables the rx-on-when-idle mode for the entire scan procedure.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
* @param[in] aScanChannels A bit vector indicating which channels to scan (e.g. OT_CHANNEL_11_MASK).
|
||||
* @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter).
|
||||
|
||||
@@ -152,6 +152,12 @@ Error DiscoverScanner::Discover(const Mac::ChannelMask &aScanChannels,
|
||||
mScanChannel = Mac::ChannelMask::kChannelIteratorFirst;
|
||||
mState = (mScanChannels.GetNextChannel(mScanChannel) == kErrorNone) ? kStateScanning : kStateScanDone;
|
||||
|
||||
// For rx-off-when-idle device, temporarily enable receiver during discovery procedure.
|
||||
if (!Get<Mle>().IsDisabled() && !Get<Mle>().IsRxOnWhenIdle())
|
||||
{
|
||||
Get<MeshForwarder>().SetRxOnWhenIdle(true);
|
||||
}
|
||||
|
||||
Mle::Log(Mle::kMessageSend, Mle::kTypeDiscoveryRequest, destination);
|
||||
|
||||
exit:
|
||||
@@ -225,6 +231,12 @@ void DiscoverScanner::HandleDiscoveryRequestFrameTxDone(Message &aMessage)
|
||||
|
||||
void DiscoverScanner::HandleDiscoverComplete(void)
|
||||
{
|
||||
// Restore Data Polling or CSL for rx-off-when-idle device.
|
||||
if (!Get<Mle>().IsDisabled() && !Get<Mle>().IsRxOnWhenIdle())
|
||||
{
|
||||
Get<MeshForwarder>().SetRxOnWhenIdle(false);
|
||||
}
|
||||
|
||||
switch (mState)
|
||||
{
|
||||
case kStateIdle:
|
||||
|
||||
@@ -733,7 +733,7 @@ Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames)
|
||||
VerifyOrExit(frame != nullptr);
|
||||
}
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
if (Get<Mac::Mac>().IsCslEnabled() && mSendMessage->IsSubTypeMle())
|
||||
else if (Get<Mac::Mac>().IsCslEnabled() && mSendMessage->IsSubTypeMle())
|
||||
{
|
||||
mSendMessage->SetLinkSecurityEnabled(true);
|
||||
}
|
||||
@@ -1669,7 +1669,10 @@ bool MeshForwarder::CalcIePresent(const Message *aMessage)
|
||||
iePresent |= (aMessage != nullptr && aMessage->IsTimeSync());
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
iePresent |= Get<Mac::Mac>().IsCslEnabled();
|
||||
if (!(aMessage != nullptr && aMessage->GetSubType() == Message::kSubTypeMleDiscoverRequest))
|
||||
{
|
||||
iePresent |= Get<Mac::Mac>().IsCslEnabled();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2764,6 +2764,7 @@ Error MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, const M
|
||||
uint16_t delay;
|
||||
|
||||
VerifyOrExit((message = NewMleMessage(kCommandDiscoveryResponse)) != nullptr, error = kErrorNoBufs);
|
||||
message->SetDirectTransmission();
|
||||
message->SetPanId(aDiscoverRequestMessage.GetPanId());
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
// Send the MLE Discovery Response message on same radio link
|
||||
|
||||
Reference in New Issue
Block a user