From 1edde90d91fff21343bdb8560eafcba6d5cf1331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Mon, 10 Feb 2020 02:12:17 +0100 Subject: [PATCH] [sub-mac] fix incorrect timer configuration for energy scanning (#4538) This fixes the implementation of Energy Scanning in case the platform does not support it, but uses timer with microsecond resolution. This is not the case with nRF528xx but found it during code inspection. I've verified that after removing OT_RADIO_CAPS_ENERGY_SCAN capability, the Energy Scan now works correctly. --- src/core/mac/sub_mac.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index c5c05ac1d..8ff1b0da6 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -431,6 +431,8 @@ exit: void SubMac::SampleRssi(void) { + assert(!RadioSupportsEnergyScan()); + int8_t rssi = GetRssi(); if (rssi != kInvalidRssiValue) @@ -443,7 +445,11 @@ void SubMac::SampleRssi(void) if (TimerMilli::GetNow() < mEnergyScanEndTime) { +#if OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE + mTimer.StartAt(mTimer.GetFireTime(), kEnergyScanRssiSampleInterval * 1000UL); +#else mTimer.StartAt(mTimer.GetFireTime(), kEnergyScanRssiSampleInterval); +#endif } else {