Display scan results received over LoRa

This commit is contained in:
Sassa NF
2025-01-04 17:14:20 +00:00
parent a2076c7a36
commit ed976d1b38
3 changed files with 65 additions and 0 deletions

View File

@@ -924,6 +924,12 @@ void configureDetection()
range = RANGE;
configurePages();
if (bar != NULL)
{
bar->bar.min_x = CONF_FREQ_BEGIN;
bar->bar.max_x = CONF_FREQ_END;
}
}
void readConfigFile()
@@ -1450,6 +1456,8 @@ void loraSendMessage(Message &m);
Result<int16_t, Message *> checkRadio(RadioComms &c);
void display_scan_result(ScanTaskResult &dump);
/*
* If m.to is LOOP, the message is directed at this module; enact the message.
* If m.to is not LOOP, send the message via the respective interface.
@@ -2199,3 +2207,49 @@ void reportScan()
loraSendMessage(m);
}
void display_scan_result(ScanTaskResult &dump)
{
if (bar == NULL)
return;
// assuming this module and the peer are in sync w.r.t. scan ranges
if (config.detection_strategy.equalsIgnoreCase("RSSI"))
{
for (int i = 0; i < dump.sz; i++)
bar->bar.updatePoint(dump.freqs_khz[i] / 1000, dump.rssis[i]);
bar->draw();
display.display();
return;
}
if (config.detection_strategy.equalsIgnoreCase("RSSI_MAX"))
{
float step = (bar->bar.max_x - bar->bar.min_x) / bar->bar.width;
bar->bar.clear();
for (int i = 0; i < config.scan_ranges_sz; i++)
{
int j;
for (j = 0; j < dump.sz; j++)
{
if (config.scan_ranges[i].start_khz <= dump.freqs_khz[j] &&
config.scan_ranges[i].end_khz >= dump.freqs_khz[j])
break;
}
int16_t rssi = j < dump.sz ? dump.rssis[j] : bar->bar.min_y;
for (float f = config.scan_ranges[i].start_khz / 1000;
f <= config.scan_ranges[i].end_khz / 1000; f += step)
bar->bar.updatePoint(f, rssi);
}
bar->draw();
display.display();
return;
}
}