[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:
Abtin Keshavarzian
2021-08-16 09:48:19 -07:00
committed by GitHub
parent fbe0d3b690
commit 6ccd4ffd78
2 changed files with 21 additions and 8 deletions
+20 -8
View File
@@ -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;
+1
View File
@@ -916,6 +916,7 @@ private:
#if OPENTHREAD_CONFIG_MULTI_RADIO
RadioTypes mTxPendingRadioLinks;
RadioTypes mTxBeaconRadioLinks;
Error mTxError;
#endif