From 10086a4f56748586e320dad1437190109c16634e Mon Sep 17 00:00:00 2001 From: Li Cao Date: Fri, 13 Nov 2020 02:05:11 +0800 Subject: [PATCH] [low-power] fix csl simulation (#5785) On nRF platform, otPlatRadioGetNow always gets the LSB part of an uint64_t time. However, on simulation platform, this is not the case. So in if (otPlatRadioGetNow(&GetInstance()) < mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime + mTransmitFrame.mInfo.mTxInfo.mTxDelay) we don't get the result expected. otPlatRadioGetNow(&GetInstance()) is a very big number on simulation platform, and mTxDelayBaseTime is the LSB part of the rx time. --- src/core/mac/sub_mac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index 3424f118d..a4c32ecc9 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -356,8 +356,8 @@ void SubMac::StartCsmaBackoff(void) if (ShouldHandleTransmitTargetTime()) { - if (otPlatRadioGetNow(&GetInstance()) < - mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime + mTransmitFrame.mInfo.mTxInfo.mTxDelay) + if (Time(static_cast(otPlatRadioGetNow(&GetInstance()))) < + Time(mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime) + mTransmitFrame.mInfo.mTxInfo.mTxDelay) { mTimer.StartAt(Time(mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime), mTransmitFrame.mInfo.mTxInfo.mTxDelay);