mirror of
https://github.com/espressif/openthread.git
synced 2026-08-21 01:49:52 +00:00
[mac] tx beacon on the same radio as the request in multi-radio config (#6921)
This commit updates `Mac` under `MULTI_RADIO` config to limit the radio links used when sending a MAC Beacon frame (which uses broadcast destination and therefore by default would be sent on all radios) to the same radio links from which the triggering Beacon Request frame(s) were received. This ensures that when a multi-radio node scans another multi-radio node we get one Beacon response on each radio link.
This commit is contained in:
+20
-8
@@ -856,18 +856,26 @@ TxFrame *Mac::PrepareBeaconRequest(void)
|
||||
|
||||
TxFrame *Mac::PrepareBeacon(void)
|
||||
{
|
||||
TxFrame & frame = mLinks.GetTxFrames().GetBroadcastTxFrame();
|
||||
TxFrame * frame;
|
||||
uint8_t beaconLength;
|
||||
uint16_t fcf;
|
||||
Beacon * beacon = nullptr;
|
||||
BeaconPayload *beaconPayload = nullptr;
|
||||
|
||||
fcf = Frame::kFcfFrameBeacon | Frame::kFcfDstAddrNone | Frame::kFcfSrcAddrExt;
|
||||
frame.InitMacHeader(fcf, Frame::kSecNone);
|
||||
IgnoreError(frame.SetSrcPanId(mPanId));
|
||||
frame.SetSrcAddr(GetExtAddress());
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
OT_ASSERT(!mTxBeaconRadioLinks.IsEmpty());
|
||||
frame = &mLinks.GetTxFrames().GetTxFrame(mTxBeaconRadioLinks);
|
||||
mTxBeaconRadioLinks.Clear();
|
||||
#else
|
||||
frame = &mLinks.GetTxFrames().GetBroadcastTxFrame();
|
||||
#endif
|
||||
|
||||
beacon = reinterpret_cast<Beacon *>(frame.GetPayload());
|
||||
fcf = Frame::kFcfFrameBeacon | Frame::kFcfDstAddrNone | Frame::kFcfSrcAddrExt;
|
||||
frame->InitMacHeader(fcf, Frame::kSecNone);
|
||||
IgnoreError(frame->SetSrcPanId(mPanId));
|
||||
frame->SetSrcAddr(GetExtAddress());
|
||||
|
||||
beacon = reinterpret_cast<Beacon *>(frame->GetPayload());
|
||||
beacon->Init();
|
||||
beaconLength = sizeof(*beacon);
|
||||
|
||||
@@ -892,11 +900,11 @@ TxFrame *Mac::PrepareBeacon(void)
|
||||
beaconLength += sizeof(*beaconPayload);
|
||||
}
|
||||
|
||||
frame.SetPayloadLength(beaconLength);
|
||||
frame->SetPayloadLength(beaconLength);
|
||||
|
||||
LogBeacon("Sending", *beaconPayload);
|
||||
|
||||
return &frame;
|
||||
return frame;
|
||||
}
|
||||
|
||||
bool Mac::ShouldSendBeacon(void) const
|
||||
@@ -2164,8 +2172,12 @@ bool Mac::HandleMacCommand(RxFrame &aFrame)
|
||||
|
||||
if (ShouldSendBeacon())
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
mTxBeaconRadioLinks.Add(aFrame.GetRadioType());
|
||||
#endif
|
||||
StartOperation(kOperationTransmitBeacon);
|
||||
}
|
||||
|
||||
didHandle = true;
|
||||
break;
|
||||
|
||||
|
||||
@@ -916,6 +916,7 @@ private:
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
RadioTypes mTxPendingRadioLinks;
|
||||
RadioTypes mTxBeaconRadioLinks;
|
||||
Error mTxError;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user