[mac-frame] unify mac frame access using Get()/Set() methods (#2787)

This commit is contained in:
Shu Chen
2018-06-13 14:34:43 -07:00
committed by Jonathan Hui
parent 41f1cc24f7
commit c87a81d346
5 changed files with 25 additions and 9 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ typedef struct otRadioFrame
int8_t mRssi; ///< Received signal strength indicator in dBm for received frames.
uint8_t mLqi; ///< Link Quality Indicator for received frames.
uint8_t mMaxTxAttempts; ///< Max number of transmit attempts for an outbound frame.
bool mDidTX : 1; ///< Set to true if this frame sent from the radio. Ignored by radio driver.
bool mDidTx : 1; ///< Set to true if this frame sent from the radio. Ignored by radio driver.
bool mIsARetx : 1; ///< Set to true if this frame is a retransmission. Should be ignored by radio driver.
bool mIsCcaEnabled : 1; ///< Set to true if CCA must be enabled for this packet. False otherwise.
+6 -6
View File
@@ -1084,12 +1084,12 @@ void Mac::BeginTransmit(void)
// Disable CCA for the last attempt
if (mTransmitAttempts == (sendFrame.GetMaxTxAttempts() - 1))
{
sendFrame.mIsCcaEnabled = false;
sendFrame.SetIsCcaEnabled(false);
}
else
#endif
{
sendFrame.mIsCcaEnabled = true;
sendFrame.SetIsCcaEnabled(true);
}
if (mCsmaAttempts == 0 && mTransmitAttempts == 0)
@@ -1147,7 +1147,7 @@ void Mac::BeginTransmit(void)
if (mPcapCallback)
{
sendFrame.mDidTX = true;
sendFrame.SetDidTx(true);
mPcapCallback(&sendFrame, mPcapCallbackContext);
}
@@ -1768,7 +1768,7 @@ void Mac::HandleReceivedFrame(Frame *aFrame, otError aError)
if (mPcapCallback)
{
aFrame->mDidTX = false;
aFrame->SetDidTx(false);
mPcapCallback(aFrame, mPcapCallbackContext);
}
@@ -1841,7 +1841,7 @@ void Mac::HandleReceivedFrame(Frame *aFrame, otError aError)
// override with the rssi in setting
if (rssi != OT_MAC_FILTER_FIXED_RSS_DISABLED)
{
aFrame->mRssi = rssi;
aFrame->SetRssi(rssi);
}
#endif // OPENTHREAD_ENABLE_MAC_FILTER
@@ -1906,7 +1906,7 @@ void Mac::HandleReceivedFrame(Frame *aFrame, otError aError)
#endif // OPENTHREAD_ENABLE_MAC_FILTER
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), aFrame->mRssi);
neighbor->GetLinkInfo().AddRss(GetNoiseFloor(), aFrame->GetRssi());
if (aFrame->GetSecurityEnabled() == true)
{
+16
View File
@@ -918,6 +918,22 @@ public:
*/
void SetIsARetransmission(bool aIsARetx) { mIsARetx = aIsARetx; }
/**
* This method sets the did Tx attribute.
*
* @param[in] aDidTx TRUE if frame is sent from the radio, FALSE otherwise.
*
*/
void SetDidTx(bool aDidTx) { mDidTx = aDidTx; }
/**
* This method sets the CCA enabled attribute.
*
* @param[in] aIsCcaEnabled TRUE if CCA must be enabled for this packet, FALSE otherwise.
*
*/
void SetIsCcaEnabled(bool aIsCcaEnabled) { mIsCcaEnabled = aIsCcaEnabled; }
/**
* This method returns the IEEE 802.15.4 PSDU length.
*
+1 -1
View File
@@ -992,7 +992,7 @@ void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
goto exit;
}
if (aFrame->mDidTX)
if (aFrame->mDidTx)
{
flags |= SPINEL_MD_FLAG_TX;
}
+1 -1
View File
@@ -62,7 +62,7 @@ void NcpBase::LinkRawReceiveDone(otRadioFrame *aFrame, otError aError)
uint16_t flags = 0;
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
if (aFrame->mDidTX)
if (aFrame->mDidTx)
{
flags |= SPINEL_MD_FLAG_TX;
}