Skip to content

Commit

Permalink
[pcap] fix pcap callback for TX frames (openthread#10678)
Browse files Browse the repository at this point in the history
This commit fixes the pcap callback for TX frames:

* Report the tx frame on each tx started callback, so that
  retransmissions can be captured.
* Set the RSSI to be invalid for TX frames.
  • Loading branch information
bukepo authored Sep 6, 2024
1 parent 4459c54 commit a887530
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/core/mac/sub_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,6 @@ void SubMac::BeginTransmit(void)

SetState(kStateTransmit);

if (mPcapCallback.IsSet())
{
mPcapCallback.Invoke(&mTransmitFrame, true);
}

error = Get<Radio>().Transmit(mTransmitFrame);

if (error == kErrorInvalidState && mTransmitFrame.mInfo.mTxInfo.mTxDelay > 0)
Expand All @@ -497,6 +492,11 @@ void SubMac::BeginTransmit(void)

void SubMac::HandleTransmitStarted(TxFrame &aFrame)
{
if (mPcapCallback.IsSet())
{
mPcapCallback.Invoke(&aFrame, true);
}

if (ShouldHandleAckTimeout() && aFrame.GetAckRequest())
{
StartTimer(kAckTimeout);
Expand Down
7 changes: 4 additions & 3 deletions src/ncp/ncp_base_mtd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4600,9 +4600,10 @@ void NcpBase::HandlePcapFrame(const otRadioFrame *aFrame, bool aIsTx)
SuccessOrExit(mEncoder.WriteData(aFrame->mPsdu, aFrame->mLength));

// Append metadata (rssi, etc)
SuccessOrExit(mEncoder.WriteInt8(aFrame->mInfo.mRxInfo.mRssi)); // RSSI
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise floor (Currently unused)
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags
SuccessOrExit(
mEncoder.WriteInt8((aIsTx ? static_cast<int8_t>(OT_RADIO_RSSI_INVALID) : aFrame->mInfo.mRxInfo.mRssi))); // RSSI
SuccessOrExit(mEncoder.WriteInt8(-128)); // Noise floor (Currently unused)
SuccessOrExit(mEncoder.WriteUint16(flags)); // Flags

SuccessOrExit(mEncoder.OpenStruct()); // PHY-data
// Empty for now
Expand Down

0 comments on commit a887530

Please sign in to comment.