mirror of
https://github.com/Genaker/LoraSA.git
synced 2026-03-28 17:42:59 +01:00
samples settings
This commit is contained in:
@@ -26,9 +26,11 @@
|
||||
<label for="gateway">Gateway Address</label>
|
||||
<input type="text" id="gateway" name="gateway" value="192.168.1.1"><br>
|
||||
<label for="fstart">FREQ START</label>
|
||||
<input type="text" id="fstart" name="fstart" value="800"><br>
|
||||
<input type="number" id="fstart" name="fstart" value="800"><br>
|
||||
<label for="fend">FREQ END</label>
|
||||
<input type="text" id="fend" name="fend" value="960"><br>
|
||||
<input type="number" id="fend" name="fend" value="960"><br>
|
||||
<label for="samples">SCAN SAMPLES</label>
|
||||
<input type="number" id="samples" name="samples" value="10"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -19,7 +19,7 @@ const String FEND = "fend";
|
||||
|
||||
// Variables to save values from HTML form
|
||||
String ssid = "LoraSA", pass = "1234567890", ip = "192.168.1.100",
|
||||
gateway = "192.168.1.1", fstart = "", fend = "";
|
||||
gateway = "192.168.1.1", fstart = "", fend = "", smpls = "";
|
||||
|
||||
IPAddress localIP;
|
||||
// Set your Gateway IP address
|
||||
@@ -111,23 +111,48 @@ void serverServer()
|
||||
}
|
||||
Serial.println(request->params());
|
||||
|
||||
String p = request->getParam(SSID, true)->value();
|
||||
writeParameterToParameterFile(SSID, p);
|
||||
String p;
|
||||
if (request->hasParam(IP, true))
|
||||
{
|
||||
p = request->getParam(IP, true)->value();
|
||||
writeParameterToParameterFile(IP, p);
|
||||
}
|
||||
|
||||
p = request->getParam(PASS, true)->value();
|
||||
writeParameterToParameterFile(PASS, p);
|
||||
if (request->hasParam(IP, true))
|
||||
{
|
||||
p = request->getParam(IP, true)->value();
|
||||
writeParameterToParameterFile(IP, p);
|
||||
}
|
||||
|
||||
p = request->getParam(IP, true)->value();
|
||||
writeParameterToParameterFile(IP, p);
|
||||
if (request->hasParam(IP, true))
|
||||
{
|
||||
p = request->getParam(IP, true)->value();
|
||||
writeParameterToParameterFile(IP, p);
|
||||
}
|
||||
|
||||
p = request->getParam(GATEWAY, true)->value();
|
||||
writeParameterToParameterFile(GATEWAY, p);
|
||||
if (request->hasParam(GATEWAY, true))
|
||||
{
|
||||
p = request->getParam(GATEWAY, true)->value();
|
||||
writeParameterToParameterFile(GATEWAY, p);
|
||||
}
|
||||
|
||||
p = request->getParam(FSTART, true)->value();
|
||||
writeParameterToParameterFile(FSTART, p);
|
||||
if (request->hasParam(FSTART, true))
|
||||
{
|
||||
p = request->getParam(FSTART, true)->value();
|
||||
writeParameterToParameterFile(FSTART, p);
|
||||
}
|
||||
|
||||
p = request->getParam(FEND, true)->value();
|
||||
writeParameterToParameterFile(FEND, p);
|
||||
if (request->hasParam(FEND, true))
|
||||
{
|
||||
p = request->getParam(FEND, true)->value();
|
||||
writeParameterToParameterFile(FEND, p);
|
||||
}
|
||||
|
||||
if (request->hasParam("samples", true))
|
||||
{
|
||||
p = request->getParam("samples", true)->value();
|
||||
writeParameterToParameterFile("samples", p);
|
||||
}
|
||||
|
||||
request->send(200, "text/plain",
|
||||
"Done. ESP will restart, connect to your router and "
|
||||
|
||||
59
src/main.cpp
59
src/main.cpp
@@ -145,10 +145,9 @@ int SCAN_RANGES[] = {};
|
||||
|
||||
// MHZ per page
|
||||
// to put everything into one page set RANGE_PER_PAGE = FREQ_END - 800
|
||||
uint64_t RANGE_PER_PAGE; // FREQ_END - FREQ_BEGIN
|
||||
uint64_t RANGE_PER_PAGE; // FREQ_END - CONF_FREQ_BEGIN
|
||||
|
||||
uint64_t CONF_FREQ_END, CONF_FREQ_BEGIN;
|
||||
// To Enable Multi Screen scan
|
||||
uint64_t CONF_FREQ_END, CONF_FREQ_BEGIN; // To Enable Multi Screen scan
|
||||
// uint64_t RANGE_PER_PAGE = 50;
|
||||
// Default Range on Menu Button Switch
|
||||
|
||||
@@ -228,11 +227,12 @@ uint64_t ranges_count = 0;
|
||||
int rssi = 0;
|
||||
int state = 0;
|
||||
|
||||
int CONF_SAMPLES;
|
||||
#ifdef METHOD_SPECTRAL
|
||||
constexpr int samples = SAMPLES;
|
||||
int samples = SAMPLES;
|
||||
#endif
|
||||
#ifdef METHOD_RSSI
|
||||
constexpr int samples = SAMPLES_RSSI;
|
||||
int samples = SAMPLES_RSSI;
|
||||
#endif
|
||||
|
||||
uint8_t result_index = 0;
|
||||
@@ -305,8 +305,8 @@ void osdProcess()
|
||||
// memset(max_step_range, 33, 30);
|
||||
max_bin = 32;
|
||||
|
||||
osd.displayString(12, 1, String(FREQ_BEGIN));
|
||||
osd.displayString(12, OSD_WIDTH - 8, String(FREQ_END));
|
||||
osd.displayString(12, 1, String(CONF_FREQ_BEGIN));
|
||||
osd.displayString(12, OSD_WIDTH - 8, String(CONF_FREQ_END));
|
||||
// Finding biggest in result
|
||||
// Skiping 0 and 32 31 to avoid overflow
|
||||
for (int i = 1; i < MAX_POWER_LEVELS - 3; i++)
|
||||
@@ -343,7 +343,7 @@ void osdProcess()
|
||||
#ifdef OSD_SIDE_BAR
|
||||
{
|
||||
osd.displayString(col, OSD_WIDTH - 7,
|
||||
String(FREQ_BEGIN + (col * osd_mhz_in_bin)) + "-" +
|
||||
String(CONF_FREQ_BEGIN + (col * osd_mhz_in_bin)) + "-" +
|
||||
String(max_step_range) + " ");
|
||||
}
|
||||
#endif
|
||||
@@ -404,9 +404,9 @@ void init_radio()
|
||||
// initialize SX1262 FSK modem at the initial frequency
|
||||
both.println("Init radio");
|
||||
#if defined(USING_SX1280PA) || defined(USING_LR1121)
|
||||
state = radio.beginGFSK(FREQ_BEGIN);
|
||||
state = radio.beginGFSK(CONF_FREQ_BEGIN);
|
||||
#else
|
||||
state = radio.beginFSK(FREQ_BEGIN);
|
||||
state = radio.beginFSK(CONF_FREQ_BEGIN);
|
||||
#endif
|
||||
if (state == RADIOLIB_ERR_NONE)
|
||||
{
|
||||
@@ -458,7 +458,7 @@ void init_radio()
|
||||
// calibrate only once ,,, at startup
|
||||
// TODO: check documentation (9.2.1) if we must calibrate in certain ranges
|
||||
#ifdef USING_SX1280PA
|
||||
state = radio.setFrequency(FREQ_BEGIN);
|
||||
state = radio.setFrequency(CONF_FREQ_BEGIN);
|
||||
if (state != RADIOLIB_ERR_NONE)
|
||||
{
|
||||
Serial.println("Error:setFrequency:" + String(state));
|
||||
@@ -470,9 +470,9 @@ void init_radio()
|
||||
}
|
||||
#elif USING_SX1276
|
||||
// Sets carrier frequency. Allowed values range from 137.0 MHz to 1020.0 MHz.
|
||||
radio.setFrequency(FREQ_BEGIN);
|
||||
radio.setFrequency(CONF_FREQ_BEGIN);
|
||||
#else
|
||||
radio.setFrequency(FREQ_BEGIN, true);
|
||||
radio.setFrequency(CONF_FREQ_BEGIN, true);
|
||||
#endif
|
||||
|
||||
delay(50);
|
||||
@@ -612,8 +612,6 @@ void setup(void)
|
||||
}
|
||||
}
|
||||
|
||||
init_radio();
|
||||
|
||||
initLittleFS();
|
||||
|
||||
// writeFile(LittleFS, "/text.txt", "{WIFI:{name:\"sdfsdf\", Password:\"sdfsdf\"}");
|
||||
@@ -635,16 +633,22 @@ void setup(void)
|
||||
fend = readParameterFromParameterFile(FEND);
|
||||
Serial.println("FEND: " + fend);
|
||||
|
||||
smpls = readParameterFromParameterFile("samples");
|
||||
Serial.println("SAMPLES: " + smpls);
|
||||
|
||||
both.println("Starting WIFI-SERVER");
|
||||
serverStart();
|
||||
|
||||
CONF_SAMPLES = (smpls == "") ? samples : atoi(smpls.c_str());
|
||||
samples = CONF_SAMPLES;
|
||||
CONF_FREQ_BEGIN = (fstart == "") ? FREQ_BEGIN : atoi(fstart.c_str());
|
||||
CONF_FREQ_END = (fend == "") ? FREQ_END : atoi(fend.c_str());
|
||||
|
||||
both.println("C FREQ BEGIN:" + String(CONF_FREQ_BEGIN));
|
||||
both.println("C FREQ END:" + String(CONF_FREQ_END));
|
||||
both.println("C SAMPLES:" + String(CONF_SAMPLES));
|
||||
|
||||
RANGE_PER_PAGE = CONF_FREQ_END - CONF_FREQ_BEGIN; // FREQ_END - FREQ_BEGIN
|
||||
RANGE_PER_PAGE = CONF_FREQ_END - CONF_FREQ_BEGIN; // FREQ_END - CONF_FREQ_BEGIN
|
||||
|
||||
RANGE = (int)(CONF_FREQ_END - CONF_FREQ_BEGIN);
|
||||
|
||||
@@ -654,9 +658,11 @@ void setup(void)
|
||||
|
||||
iterations = RANGE / RANGE_PER_PAGE;
|
||||
|
||||
// uint64_t range_frequency = FREQ_END - FREQ_BEGIN;
|
||||
// uint64_t range_frequency = FREQ_END - CONF_FREQ_BEGIN;
|
||||
median_frequency = (CONF_FREQ_BEGIN + CONF_FREQ_END) / 2;
|
||||
|
||||
init_radio();
|
||||
|
||||
#ifndef LILYGO
|
||||
vbat = heltec_vbat();
|
||||
both.printf("V battery: %.2fV (%d%%)\n", vbat, heltec_battery_percent(vbat));
|
||||
@@ -763,8 +769,9 @@ void setup(void)
|
||||
r.trigger_level = TRIGGER_LEVEL;
|
||||
stacked.reset(0, 0, display.width(), display.height());
|
||||
|
||||
bar = new DecoratedBarChart(display, 0, 0, display.width(), 0, FREQ_BEGIN, FREQ_END,
|
||||
LO_RSSI_THRESHOLD, HI_RSSI_THRESHOLD, r.trigger_level);
|
||||
bar = new DecoratedBarChart(display, 0, 0, display.width(), 0, CONF_FREQ_BEGIN,
|
||||
CONF_FREQ_END, LO_RSSI_THRESHOLD, HI_RSSI_THRESHOLD,
|
||||
r.trigger_level);
|
||||
|
||||
size_t b = stacked.addChart(bar);
|
||||
|
||||
@@ -778,9 +785,9 @@ void setup(void)
|
||||
|
||||
delete[] multiples;
|
||||
|
||||
waterChart =
|
||||
new WaterfallChart(display, 0, WATERFALL_START, display.width(), 0, FREQ_BEGIN,
|
||||
FREQ_END, r.trigger_level, WATERFALL_SENSITIVITY, model);
|
||||
waterChart = new WaterfallChart(display, 0, WATERFALL_START, display.width(), 0,
|
||||
CONF_FREQ_BEGIN, CONF_FREQ_END, r.trigger_level,
|
||||
WATERFALL_SENSITIVITY, model);
|
||||
|
||||
size_t c = stacked.addChart(waterChart);
|
||||
stacked.setHeight(c, stacked.height - WATERFALL_START - statusBar->height);
|
||||
@@ -1011,13 +1018,13 @@ void loop(void)
|
||||
}
|
||||
|
||||
// do the scan
|
||||
range = FREQ_END - FREQ_BEGIN;
|
||||
range = CONF_FREQ_END - CONF_FREQ_BEGIN;
|
||||
if (RANGE_PER_PAGE > range)
|
||||
{
|
||||
RANGE_PER_PAGE = range;
|
||||
}
|
||||
|
||||
r.fr_begin = FREQ_BEGIN;
|
||||
r.fr_begin = CONF_FREQ_BEGIN;
|
||||
r.fr_end = r.fr_begin;
|
||||
|
||||
// 50 is a single-screen range
|
||||
@@ -1150,7 +1157,7 @@ void loop(void)
|
||||
// Spectrum analyzer using getRSSI
|
||||
{
|
||||
LOG("METHOD RSSI");
|
||||
uint16_t max_rssi = r.rssiMethod(SAMPLES_RSSI, result,
|
||||
uint16_t max_rssi = r.rssiMethod(CONF_SAMPLES, result,
|
||||
RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE);
|
||||
|
||||
if (max_x_rssi[display_x] > max_rssi)
|
||||
@@ -1162,7 +1169,7 @@ void loop(void)
|
||||
|
||||
// if this code is not executed LORA radio doesn't work
|
||||
// basically SX1262 requires delay
|
||||
// osd.displayString(12, 1, String(FREQ_BEGIN));
|
||||
// osd.displayString(12, 1, String(CONF_FREQ_BEGIN));
|
||||
// osd.displayString(12, 30 - 8, String(FREQ_END));
|
||||
// delay(2);
|
||||
|
||||
|
||||
11
src/ui.cpp
11
src/ui.cpp
@@ -16,6 +16,8 @@
|
||||
|
||||
// temporary dirty import ... to be solved durring upcoming refactoring
|
||||
extern unsigned int RANGE_PER_PAGE;
|
||||
extern uint64_t CONF_FREQ_BEGIN;
|
||||
extern uint64_t CONF_FREQ_END;
|
||||
extern unsigned int median_frequency;
|
||||
extern unsigned int drone_detected_frequency_start;
|
||||
extern unsigned int drone_detected_frequency_end;
|
||||
@@ -95,7 +97,8 @@ void StatusBar::draw()
|
||||
// Frequency start
|
||||
display.setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display.drawString(pos_x, text_y,
|
||||
(r.fr_begin == 0) ? String(FREQ_BEGIN) : String(r.fr_begin));
|
||||
(r.fr_begin == 0) ? String(CONF_FREQ_BEGIN)
|
||||
: String(r.fr_begin));
|
||||
|
||||
// Frequency detected
|
||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||
@@ -106,7 +109,7 @@ void StatusBar::draw()
|
||||
// Frequency end
|
||||
display.setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||
display.drawString(pos_x + width, text_y,
|
||||
(r.fr_end == 0) ? String(FREQ_END) : String(r.fr_end));
|
||||
(r.fr_end == 0) ? String(CONF_FREQ_END) : String(r.fr_end));
|
||||
}
|
||||
|
||||
// Status text block
|
||||
@@ -170,11 +173,11 @@ void StatusBar::draw()
|
||||
display.drawString(pos_x, text_y, String(loop_time));
|
||||
#else
|
||||
display.setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display.drawString(pos_x, text_y, String(FREQ_BEGIN));
|
||||
display.drawString(pos_x, text_y, String(CONF_FREQ_BEGIN));
|
||||
|
||||
#endif
|
||||
display.setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||
display.drawString(pos_x + width, text_y, String(FREQ_END));
|
||||
display.drawString(pos_x + width, text_y, String(CONF_FREQ_END));
|
||||
}
|
||||
else if (ranges_count > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user