[mac] zero-duration energy scan from single tasklet (#2442)

This commit changes the implementation of zero-duration energy scan
operation so that all RSSI samples (for different channels) are taken
within the same tasklet. This ensures that the zero-duration energy
scan operation can be performed quickly and radio is switched to its
normal channel avoiding any delays caused by other tasklets and/or
platform operations.
This commit is contained in:
Abtin Keshavarzian
2018-01-03 22:19:20 +00:00
committed by Jonathan Hui
parent b7000f280b
commit 784eda5ee4
+15 -14
View File
@@ -269,16 +269,24 @@ void Mac::PerformEnergyScan(void)
SuccessOrExit(error = UpdateScanChannel());
if (!(otPlatRadioGetCaps(&GetInstance()) & OT_RADIO_CAPS_ENERGY_SCAN) || (mScanDuration == 0))
if (mScanDuration == 0)
{
while (true)
{
int8_t rssi;
RadioReceive(mScanChannel);
rssi = otPlatRadioGetRssi(&GetInstance());
ReportEnergyScanResult(rssi);
SuccessOrExit(error = UpdateScanChannel());
}
}
else if ((otPlatRadioGetCaps(&GetInstance()) & OT_RADIO_CAPS_ENERGY_SCAN) == 0)
{
RadioReceive(mScanChannel);
mEnergyScanCurrentMaxRssi = kInvalidRssiValue;
mOperationTask.Post();
if (mScanDuration != 0)
{
mMacTimer.Start(mScanDuration);
}
mMacTimer.Start(mScanDuration);
}
else
{
@@ -349,14 +357,7 @@ void Mac::SampleRssi(void)
}
}
if (mScanDuration == 0)
{
EnergyScanDone(mEnergyScanCurrentMaxRssi);
}
else
{
mOperationTask.Post();
}
mOperationTask.Post();
}
otError Mac::RegisterReceiver(Receiver &aReceiver)