agent: channel scan task: Prevent duplicate neighbor entries caused by multiple and/or invalid neighbor results

- Fixed issue where valid neighbors were reported multiple times when scan requests included multiple opclasses sharing the same channel.
- Duplicate entries occurred because each opclass result appended the same neighbor repeatedly.
- Implemented a check during insertion to ensure each neighbor is added only once based on BSSID and spectrum_info_present flag.
- Zero-initialized neighbors were reported because multiple spectrum entries existed for the same scan result, which is invalid. Once duplicate neighbor additions were prevented, this issue was resolved as w
ell.

Closes PPM-3698

Signed-off-by: Cem KOC <cem.koc@airties.com>
This commit is contained in:
Cem KOC
2025-12-17 15:09:37 +03:00
parent c822865d9d
commit e7b7f8927c

View File

@@ -845,8 +845,22 @@ bool ChannelScanTask::store_radio_scan_result(const std::shared_ptr<sScanRequest
* the channel element's channel number. * the channel element's channel number.
*/ */
if (_20MHz_channels.find(results.channel) != _20MHz_channels.end()) { if (_20MHz_channels.find(results.channel) != _20MHz_channels.end()) {
LOG(DEBUG) << "Setting result in channel " << ch_elem.channel_number; auto &results_vector = request->radio_scans->cached_results[ch_elem.channel_number];
request->radio_scans->cached_results[ch_elem.channel_number].push_back(results); auto it = std::find_if(results_vector.begin(), results_vector.end(),
[&](const beerocks_message::sChannelScanResults &rhs) {
return rhs.bssid == results.bssid &&
rhs.spectrum_info_present ==
results.spectrum_info_present;
});
if (it == results_vector.end()) {
LOG(DEBUG) << "Setting result in channel " << ch_elem.channel_number;
results_vector.push_back(results);
} else {
LOG(DEBUG) << "Ignoring duplicated result in channel "
<< ch_elem.channel_number;
}
// Move on to next operating class in radio scan // Move on to next operating class in radio scan
break; break;
} }