diff --git a/tests/nexus/platform/nexus_radio.cpp b/tests/nexus/platform/nexus_radio.cpp index 487dba11c..4e483de6d 100644 --- a/tests/nexus/platform/nexus_radio.cpp +++ b/tests/nexus/platform/nexus_radio.cpp @@ -30,6 +30,7 @@ #include "nexus_core.hpp" #include "nexus_node.hpp" +#include "common/crc.hpp" namespace ot { namespace Nexus { @@ -134,6 +135,9 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) VerifyOrExit(radio.mState == Radio::kStateReceive, error = kErrorInvalidState); OT_ASSERT(aFrame == &AsNode(aInstance).mRadio.mTxFrame); + + static_cast(aFrame)->UpdateFcs(); + radio.mState = Radio::kStateTransmit; Core::Get().MarkPendingAction(); @@ -353,5 +357,19 @@ Radio::Frame::Frame(const Frame &aFrame) memcpy(mPsdu, aFrame.mPsdu, mLength); } +void Radio::Frame::UpdateFcs(void) +{ + uint16_t fcs; + + VerifyOrExit(mLength >= k154FcsSize); + + fcs = CrcCalculator(kCrc16CcittPolynomial).FeedBytes(mPsdu, mLength - k154FcsSize); + + LittleEndian::WriteUint16(fcs, &mPsdu[mLength - k154FcsSize]); + +exit: + return; +} + } // namespace Nexus } // namespace ot diff --git a/tests/nexus/platform/nexus_radio.hpp b/tests/nexus/platform/nexus_radio.hpp index 3dcebdf10..9e14cf89f 100644 --- a/tests/nexus/platform/nexus_radio.hpp +++ b/tests/nexus/platform/nexus_radio.hpp @@ -55,6 +55,11 @@ struct Radio Frame(void); explicit Frame(const Frame &aFrame); + /** + * Updates the frame with the proper IEEE 802.15.4 FCS. + */ + void UpdateFcs(void); + uint8_t mPsduBuffer[kMaxFrameSize]; };