[test] verify behavior of RxChannelAfterTxDone (#10817)

This commit adds a test to verify RX channel is switched correctly after TX done.
This commit is contained in:
Yakun Xu
2024-10-11 08:26:28 -07:00
committed by GitHub
parent 2ea0155129
commit c4262af670
3 changed files with 49 additions and 1 deletions
+1 -1
View File
@@ -345,7 +345,7 @@ otError otPlatRadioDisable(otInstance *) { return OT_ERROR_NONE; }
otError otPlatRadioSleep(otInstance *) { return OT_ERROR_NONE; }
otError otPlatRadioReceive(otInstance *, uint8_t) { return OT_ERROR_NONE; }
otError otPlatRadioReceive(otInstance *, uint8_t aChannel) { return FakePlatform::CurrentPlatform().Receive(aChannel); }
otError otPlatRadioTransmit(otInstance *, otRadioFrame *aFrame)
{
+8
View File
@@ -36,6 +36,7 @@
#include <inttypes.h>
#include <openthread/error.h>
#include <openthread/instance.h>
#include <openthread/platform/radio.h>
#include <openthread/platform/time.h>
@@ -71,8 +72,14 @@ public:
virtual void StartMicroAlarm(uint32_t aT0, uint32_t aDt);
virtual void StopMicroAlarm();
uint8_t GetReceiveChannel(void) const { return mChannel; }
virtual otRadioFrame *GetTransmitBuffer() { return &mTransmitFrame; }
virtual otError Transmit(otRadioFrame *aFrame);
virtual otError Receive(uint8_t aChannel)
{
mChannel = aChannel;
return OT_ERROR_NONE;
}
virtual otError SettingsGet(uint16_t aKey, uint16_t aIndex, uint8_t *aValue, uint16_t *aValueLength) const;
virtual otError SettingsSet(uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength);
@@ -106,6 +113,7 @@ protected:
otRadioFrame mTransmitFrame;
uint8_t mTransmitBuffer[OT_RADIO_FRAME_MAX_SIZE];
uint8_t mChannel = 0;
uint8_t mFlash[kFlashSwapSize * kFlashSwapNum];
+40
View File
@@ -92,3 +92,43 @@ TEST(RadioSpinelTransmit, shouldPassDesiredTxPowerToRadioPlatform)
platform.GoInMs(1000);
}
TEST(RadioSpinelTransmit, shouldCauseSwitchingToRxChannelAfterTxDone)
{
FakeCoprocessorPlatform platform;
constexpr Mac::PanId kSrcPanId = 0x1234;
constexpr Mac::PanId kDstPanId = 0x4321;
constexpr uint8_t kDstAddr[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
constexpr uint16_t kSrcAddr = 0xac00;
constexpr int8_t kTxPower = 100;
uint8_t frameBuffer[OT_RADIO_FRAME_MAX_SIZE];
Mac::TxFrame txFrame;
txFrame.mPsdu = frameBuffer;
{
Mac::TxFrame::Info frameInfo;
frameInfo.mType = Mac::Frame::kTypeData;
frameInfo.mVersion = Mac::Frame::kVersion2006;
frameInfo.mAddrs.mSource.SetShort(kSrcAddr);
frameInfo.mAddrs.mDestination.SetExtended(kDstAddr);
frameInfo.mPanIds.SetSource(kSrcPanId);
frameInfo.mPanIds.SetDestination(kDstPanId);
frameInfo.mSecurityLevel = Mac::Frame::kSecurityEncMic32;
frameInfo.PrepareHeadersIn(txFrame);
}
txFrame.mInfo.mTxInfo.mTxPower = kTxPower;
txFrame.mChannel = 11;
txFrame.mInfo.mTxInfo.mRxChannelAfterTxDone = 25;
ASSERT_EQ(platform.mRadioSpinel.Enable(FakePlatform::CurrentInstance()), kErrorNone);
ASSERT_EQ(platform.mRadioSpinel.Receive(11), kErrorNone);
ASSERT_EQ(platform.mRadioSpinel.Transmit(txFrame), kErrorNone);
platform.GoInMs(1000);
EXPECT_EQ(platform.GetReceiveChannel(), 25);
}