diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c index dc6e5c0c4151..f5cdd0fd2a36 100644 --- a/core/sap/src/sap_ch_select.c +++ b/core/sap/src/sap_ch_select.c @@ -1590,13 +1590,24 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, for (chn_num = 0; chn_num < pSpectInfoParams->numSpectChans; chn_num++) { + /* + * If the Beacon has channel ID, use it other wise we + * will rely on the channelIdSelf + */ + if (pScanResult->BssDescriptor.channelId == 0) + channel_id = + pScanResult->BssDescriptor.channelIdSelf; + else + channel_id = + pScanResult->BssDescriptor.channelId; + /* * Check if channel is present in scan channel list or * not. If not present, then continue as no need to * process the beacon on this channel. */ for (i = 0; i < sap_ctx->num_of_channel; i++) { - if (pSpectCh->chNum == + if (channel_id == sap_ctx->channelList[i]) { found = true; break; @@ -1606,17 +1617,6 @@ static void sap_compute_spect_weight(tSapChSelSpectInfo *pSpectInfoParams, if (!found) continue; - /* - * if the Beacon has channel ID, use it other wise we will - * rely on the channelIdSelf - */ - if (pScanResult->BssDescriptor.channelId == 0) - channel_id = - pScanResult->BssDescriptor.channelIdSelf; - else - channel_id = - pScanResult->BssDescriptor.channelId; - if (pSpectCh && (channel_id == pSpectCh->chNum)) { if (pSpectCh->rssiAgr < pScanResult->BssDescriptor.rssi)