mirror of
https://github.com/Genaker/LoraSA.git
synced 2026-05-03 03:53:01 +02:00
Display scan results received over LoRa
This commit is contained in:
54
src/main.cpp
54
src/main.cpp
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user