Skip to content

Commit

Permalink
[radio] fix low power multi-vendor certification failures
Browse files Browse the repository at this point in the history
OpenThread stack update change 992be2781->a363396eb (in commit 2c459e3a3) had a change in the stack to clarify and adjust various CSL timing units to existing 802.15.4 standards based timing concepts.

See openthread/openthread@6da6e09

One of the changes was to clarify that the rxTimestamp (used to calculate "next" CSL transmissions) should point to the end of the sync header (SHR). So when scheduling our transmit, we must make sure to subtract the SHR duration value from our base time since this is already accounted for when calculating next CSL transmission delay.

Co-authored-by: Suvesh Pratapa <[email protected]>
  • Loading branch information
lmnotran and suveshpratapa committed Nov 22, 2023
1 parent 723a4f0 commit 2ecb046
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/src/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ static const RAIL_IEEE802154_Config_t sRailIeee802154Config = {
#define SHR_SIZE 5 // 4 bytes of preamble, 1 byte sync-word
#endif

#define SHR_DURATION_US 160 // Duration of SHR in us.

// Misc
static volatile uint32_t miscRadioState = 0;
static bool emPendingData = false;
Expand Down Expand Up @@ -1634,7 +1636,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
sTxFrame->mInfo.mTxInfo.mTxDelay = 3000; // Chosen after internal certification testing
}
#endif
updateIeInfoTxFrame(sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime + sTxFrame->mInfo.mTxInfo.mTxDelay + 160);
updateIeInfoTxFrame(sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime + sTxFrame->mInfo.mTxInfo.mTxDelay +
SHR_DURATION_US);
// Note - we need to call this outside of txCurrentPacket as for Series 2,
// this results in calling the SE interface from a critical section which is not permitted.

Expand Down Expand Up @@ -1823,8 +1826,8 @@ void txCurrentPacket(void)
// Note that both use single CCA config, overriding any CCA/CSMA configs from the stack
//
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
RAIL_ScheduleTxConfig_t scheduleTxOptions = {.when = sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime
+ sTxFrame->mInfo.mTxInfo.mTxDelay,
RAIL_ScheduleTxConfig_t scheduleTxOptions = {.when = sTxFrame->mInfo.mTxInfo.mTxDelayBaseTime +
sTxFrame->mInfo.mTxInfo.mTxDelay - SHR_DURATION_US,
.mode = RAIL_TIME_ABSOLUTE,
.txDuringRx = RAIL_SCHEDULED_TX_DURING_RX_POSTPONE_TX};

Expand Down Expand Up @@ -3032,8 +3035,9 @@ static bool validatePacketTimestamp(RAIL_RxPacketDetails_t *pPacketDetails, uint
// Get the timestamp when the SFD was received
otEXPECT_ACTION(pPacketDetails->timeReceived.timePosition != RAIL_PACKET_TIME_INVALID, rxTimestampValid = false);

// + 1 for the 1-byte PHY header
pPacketDetails->timeReceived.totalPacketBytes = packetLength + 1;
// + PHY HEADER SIZE for PHY header
// We would not need this if PHR is not included and we want the MHR
pPacketDetails->timeReceived.totalPacketBytes = packetLength + PHY_HEADER_SIZE;

otEXPECT_ACTION((RAIL_GetRxTimeSyncWordEndAlt(gRailHandle, pPacketDetails) == RAIL_STATUS_NO_ERROR),
rxTimestampValid = false);
Expand Down

0 comments on commit 2ecb046

Please sign in to comment.