mirror of
https://github.com/espressif/openthread.git
synced 2026-08-18 08:29:52 +00:00
[mac] fix tx counters (#2134)
This commit is contained in:
committed by
Jonathan Hui
parent
850713f09b
commit
141ceb0446
@@ -953,6 +953,7 @@ typedef struct otMacCounters
|
||||
uint32_t mTxRetry; ///< The number of retransmission times.
|
||||
uint32_t mTxErrCca; ///< The number of CCA failure times.
|
||||
uint32_t mTxErrAbort; ///< The number of frame transmission failures due to abort error.
|
||||
uint32_t mTxErrBusyChannel; ///< The number of frames that were dropped due to a busy channel.
|
||||
uint32_t mRxTotal; ///< The total number of received packets.
|
||||
uint32_t mRxUnicast; ///< The total number of unicast packets received.
|
||||
uint32_t mRxBroadcast; ///< The total number of broadcast packets received.
|
||||
|
||||
@@ -667,6 +667,7 @@ void Interpreter::ProcessCounters(int argc, char *argv[])
|
||||
mServer->OutputFormat(" TxOther: %d\r\n", counters->mTxOther);
|
||||
mServer->OutputFormat(" TxRetry: %d\r\n", counters->mTxRetry);
|
||||
mServer->OutputFormat(" TxErrCca: %d\r\n", counters->mTxErrCca);
|
||||
mServer->OutputFormat(" TxErrBusyChannel: %d\r\n", counters->mTxErrBusyChannel);
|
||||
mServer->OutputFormat("RxTotal: %d\r\n", counters->mRxTotal);
|
||||
mServer->OutputFormat(" RxUnicast: %d\r\n", counters->mRxUnicast);
|
||||
mServer->OutputFormat(" RxBroadcast: %d\r\n", counters->mRxBroadcast);
|
||||
|
||||
+21
-30
@@ -991,8 +991,6 @@ void Mac::TransmitDoneTask(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otErro
|
||||
|
||||
mMacTimer.Stop();
|
||||
|
||||
mCounters.mTxTotal++;
|
||||
|
||||
txFrame->GetDstAddr(addr);
|
||||
|
||||
if (aError == OT_ERROR_NONE && txFrame->GetAckRequest() && aAckFrame != NULL)
|
||||
@@ -1009,17 +1007,6 @@ void Mac::TransmitDoneTask(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otErro
|
||||
}
|
||||
}
|
||||
|
||||
if (addr.mShortAddress == kShortAddrBroadcast)
|
||||
{
|
||||
// Broadcast frame
|
||||
mCounters.mTxBroadcast++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unicast frame
|
||||
mCounters.mTxUnicast++;
|
||||
}
|
||||
|
||||
if (aError == OT_ERROR_ABORT)
|
||||
{
|
||||
mCounters.mTxErrAbort++;
|
||||
@@ -1171,8 +1158,6 @@ void Mac::HandleMacTimer(Timer &aTimer)
|
||||
|
||||
void Mac::HandleMacTimer(void)
|
||||
{
|
||||
Address addr;
|
||||
|
||||
switch (mOperation)
|
||||
{
|
||||
case kOperationActiveScan:
|
||||
@@ -1200,21 +1185,6 @@ void Mac::HandleMacTimer(void)
|
||||
|
||||
case kOperationTransmitData:
|
||||
otLogDebgMac(GetInstance(), "Ack timer fired");
|
||||
mCounters.mTxTotal++;
|
||||
|
||||
mTxFrame->GetDstAddr(addr);
|
||||
|
||||
if (addr.mShortAddress == kShortAddrBroadcast)
|
||||
{
|
||||
// Broadcast frame
|
||||
mCounters.mTxBroadcast++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unicast Frame
|
||||
mCounters.mTxUnicast++;
|
||||
}
|
||||
|
||||
SentFrame(OT_ERROR_NO_ACK);
|
||||
break;
|
||||
|
||||
@@ -1263,6 +1233,7 @@ void Mac::SentFrame(otError aError)
|
||||
{
|
||||
Frame &sendFrame(*mTxFrame);
|
||||
Sender *sender;
|
||||
Address addr;
|
||||
|
||||
mTransmitAttempts++;
|
||||
|
||||
@@ -1302,6 +1273,26 @@ void Mac::SentFrame(otError aError)
|
||||
mTransmitAttempts = 0;
|
||||
mCsmaAttempts = 0;
|
||||
|
||||
mCounters.mTxTotal++;
|
||||
|
||||
if (aError == OT_ERROR_CHANNEL_ACCESS_FAILURE)
|
||||
{
|
||||
mCounters.mTxErrBusyChannel++;
|
||||
}
|
||||
|
||||
mTxFrame->GetDstAddr(addr);
|
||||
|
||||
if (addr.mShortAddress == kShortAddrBroadcast)
|
||||
{
|
||||
// Broadcast frame
|
||||
mCounters.mTxBroadcast++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unicast Frame
|
||||
mCounters.mTxUnicast++;
|
||||
}
|
||||
|
||||
if (sendFrame.GetAckRequest())
|
||||
{
|
||||
mCounters.mTxAckRequested++;
|
||||
|
||||
Reference in New Issue
Block a user