configuration editable via web
This commit is contained in:
parent
0981210762
commit
01229e0160
|
|
@ -75,7 +75,8 @@ const String sondeTypeSelect(int activeType) {
|
|||
//trying to work around
|
||||
//"assertion "heap != NULL && "free() target pointer is outside heap areas"" failed:"
|
||||
// which happens if request->send is called in createQRGForm!?!??
|
||||
char message[10240];
|
||||
char message[10240*4]; //needs to be large enough for all forms (not checked in code)
|
||||
// QRG form is currently about 24kb with 100 entries
|
||||
|
||||
///////////////////////// Functions for Reading / Writing QRG list from/to qrg.txt
|
||||
|
||||
|
|
@ -301,32 +302,49 @@ void setupConfigData() {
|
|||
|
||||
|
||||
struct st_configitems {
|
||||
const char *name;
|
||||
const char *label;
|
||||
int type; // 0: numeric; i>0 string of length i; -1: separator; -2: type selector
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct st_configitems config_list[] = {
|
||||
{"ShowSpectrum (s)", 0, &sonde.config.spectrum},
|
||||
{"Startfreq (MHz)", 0, &sonde.config.startfreq},
|
||||
{"Bandwidth (kHz)", 0, &sonde.config.channelbw},
|
||||
{"---", -1, NULL},
|
||||
{"Call", 8, sonde.config.call},
|
||||
{"Passcode", 8, sonde.config.passcode},
|
||||
{"---", -1, NULL},
|
||||
{"AXUDP active", -3, &sonde.config.udpfeed.active},
|
||||
{"AXUDP Host", 63, sonde.config.udpfeed.host},
|
||||
{"AXUDP Port", 0, &sonde.config.udpfeed.port},
|
||||
{"DFM ID Format", -2, &sonde.config.udpfeed.idformat},
|
||||
{"Rate limit", 0, &sonde.config.udpfeed.highrate},
|
||||
{"---", -1, NULL},
|
||||
{"APRS TCP active", -3, &sonde.config.tcpfeed.active},
|
||||
{"ARPS TCP Host", 63, sonde.config.tcpfeed.host},
|
||||
{"APRS TCP Port", 0, &sonde.config.tcpfeed.port},
|
||||
{"DFM ID Format", -2, &sonde.config.tcpfeed.idformat},
|
||||
{"Rate limit", 0, &sonde.config.tcpfeed.highrate},
|
||||
{"---", -1, NULL},
|
||||
{"Spectrum noise floor", 0, &sonde.config.noisefloor}
|
||||
/* General config settings */
|
||||
{"wifi","Wifi mode (0/1/2/3)", 0, &sonde.config.wifi},
|
||||
{"debug","Debug mode (0/1)", 0, &sonde.config.debug},
|
||||
{"maxsonde","Maxsonde (requires reboot?)", 0, &sonde.config.maxsonde},
|
||||
/* Spectrum display settings */
|
||||
{"spectrum","ShowSpectrum (s)", 0, &sonde.config.spectrum},
|
||||
{"startfreq","Startfreq (MHz)", 0, &sonde.config.startfreq},
|
||||
{"channelbw","Bandwidth (kHz)", 0, &sonde.config.channelbw},
|
||||
{"timer","Spectrum Timer", 0, &sonde.config.timer},
|
||||
{"marker","Spectrum MHz marker", 0, &sonde.config.marker},
|
||||
{"noisefloor","Sepctrum noisefloor", 0, &sonde.config.noisefloor},
|
||||
{"---", "---", -1, NULL},
|
||||
/* APRS settings */
|
||||
{"call","Call", 8, sonde.config.call},
|
||||
{"passcode","Passcode", 8, sonde.config.passcode},
|
||||
{"---", "---", -1, NULL},
|
||||
/* AXUDP settings */
|
||||
{"axudp.active","AXUDP active", -3, &sonde.config.udpfeed.active},
|
||||
{"axudp.host","AXUDP Host", 63, sonde.config.udpfeed.host},
|
||||
{"axudp.port","AXUDP Port", 0, &sonde.config.udpfeed.port},
|
||||
{"axudp.idformat","DFM ID Format", -2, &sonde.config.udpfeed.idformat},
|
||||
{"axudp.highrate","Rate limit", 0, &sonde.config.udpfeed.highrate},
|
||||
{"---", "---", -1, NULL},
|
||||
/* APRS TCP settings, current not used */
|
||||
{"tcp.active","APRS TCP active", -3, &sonde.config.tcpfeed.active},
|
||||
{"tcp.host","ARPS TCP Host", 63, sonde.config.tcpfeed.host},
|
||||
{"tcp.port","APRS TCP Port", 0, &sonde.config.tcpfeed.port},
|
||||
{"tcp.idformat","DFM ID Format", -2, &sonde.config.tcpfeed.idformat},
|
||||
{"tcp.highrate","Rate limit", 0, &sonde.config.tcpfeed.highrate},
|
||||
{"---", "---", -1, NULL},
|
||||
/* Hardware dependeing settings */
|
||||
{"oled_sda","OLED SDA (needs reboot)", 0, &sonde.config.oled_sda},
|
||||
{"oled_scl","OLED SCL (needs reboot)", 0, &sonde.config.oled_scl},
|
||||
{"oled_rst","OLED RST (needs reboot)", 0, &sonde.config.oled_rst},
|
||||
{"button_pin","Button input port (needs reboot)", 0, &sonde.config.button_pin},
|
||||
{"led_pout","LED output port (needs reboot)", 0, &sonde.config.led_pout},
|
||||
};
|
||||
const static int N_CONFIG=(sizeof(config_list)/sizeof(struct st_configitems));
|
||||
|
||||
|
|
@ -371,11 +389,43 @@ const char *createConfigForm() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
strcat(ptr, "</table><input type=\"submit\" value=\"Update not yet implemented\"></input></form></body></html>");
|
||||
strcat(ptr, "</table><input type=\"submit\" value=\"Update\"></input></form></body></html>");
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
const char *handleConfigPost(AsyncWebServerRequest *request) {
|
||||
char label[10];
|
||||
// parameters: a_i, f_1, t_i (active/frequency/type)
|
||||
#if 1
|
||||
File f = SPIFFS.open("/config.txt", "w");
|
||||
if (!f) {
|
||||
Serial.println("Error while opening '/config.txt' for writing");
|
||||
return "Error while opening '/config.txt' for writing";
|
||||
}
|
||||
#endif
|
||||
Serial.println("Handling post request");
|
||||
#if 1
|
||||
int params = request->params();
|
||||
for (int i = 0; i < params; i++) {
|
||||
Serial.println(request->getParam(i)->name().c_str());
|
||||
}
|
||||
#endif
|
||||
for (int i = 0; i < params; i++) {
|
||||
const char *label = request->getParam(i)->name().c_str();
|
||||
if(strncmp(label, "CFG", 3)!=0) continue;
|
||||
int idx = atoi(label+3);
|
||||
Serial.printf("idx is %d\n", idx);
|
||||
if(config_list[idx].type == -1) continue; // skip separator entries, should not happen
|
||||
AsyncWebParameter *value = request->getParam(label, true);
|
||||
if(!value) continue;
|
||||
Serial.printf("Processing %s=%s\n", config_list[idx].name, value->value().c_str());
|
||||
f.printf("%s=%s\n", config_list[idx].name, value->value().c_str());
|
||||
}
|
||||
f.close();
|
||||
setupConfigData();
|
||||
}
|
||||
|
||||
|
||||
const char* PARAM_MESSAGE = "message";
|
||||
void SetupAsyncServer() {
|
||||
|
|
@ -412,7 +462,10 @@ void SetupAsyncServer() {
|
|||
server.on("/config.html", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "text/html", createConfigForm());
|
||||
});
|
||||
|
||||
server.on("/config.html", HTTP_POST, [](AsyncWebServerRequest * request) {
|
||||
handleConfigPost(request);
|
||||
request->send(200, "text/html", createConfigForm());
|
||||
});
|
||||
server.on("/status.html", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||
request->send(200, "text/html", createStatusForm());
|
||||
});
|
||||
|
|
@ -522,6 +575,11 @@ void setup()
|
|||
char buf[12];
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
for(int i=0; i<39; i++) {
|
||||
int v = gpio_get_level((gpio_num_t)i);
|
||||
Serial.printf("%d:%d ",i,v);
|
||||
}
|
||||
Serial.println("");
|
||||
pinMode(LORA_LED, OUTPUT);
|
||||
|
||||
aprs_gencrctab();
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ led_pout=9
|
|||
# OLED Setup is depending on hardware of LoRa board
|
||||
# TTGO v1: SDA=4 SCL=15, RST=16
|
||||
# TTGO v2: SDA=21 SCL=22, RST=16
|
||||
oled_sda=21
|
||||
oled_scl=22
|
||||
# No specification in config file: try autodetection (gpio4 pin level at startup)
|
||||
#oled_sda=21
|
||||
#oled_scl=22
|
||||
oled_rst=16
|
||||
#-------------------------------#
|
||||
# General config settings
|
||||
|
|
@ -24,7 +25,7 @@ startfreq=400
|
|||
channelbw=10
|
||||
spectrum=10
|
||||
timer=1
|
||||
noisefloor=-110
|
||||
noisefloor=-125
|
||||
marker=1
|
||||
#-------------------------------#
|
||||
# APRS settings
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ int scandisp[NCHAN/PIXSAMPL];
|
|||
#define PLOT_N 128
|
||||
#define TICK1 (128/6)
|
||||
#define TICK2 (TICK1/4)
|
||||
#define PLOT_MIN -250
|
||||
//#define PLOT_MIN -250
|
||||
#define PLOT_MIN (sonde.config.noisefloor*2)
|
||||
#define PLOT_SCALE(x) (x<PLOT_MIN?0:(x-PLOT_MIN)/2)
|
||||
|
||||
const byte tilepatterns[9]={0,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFF};
|
||||
|
|
|
|||
|
|
@ -50,10 +50,19 @@ static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
|
|||
Sonde::Sonde() {
|
||||
config.button_pin = 0;
|
||||
config.led_pout = 9;
|
||||
// Try autodetecting board type
|
||||
// Seems like on startup, GPIO4 is 1 on v1 boards, 0 on v2.1 boards?
|
||||
int autodetect = gpio_get_level((gpio_num_t)4);
|
||||
if(autodetect==1) {
|
||||
config.oled_sda = 4;
|
||||
config.oled_scl = 15;
|
||||
} else {
|
||||
config.oled_sda = 21;
|
||||
config.oled_scl = 22;
|
||||
}
|
||||
//
|
||||
config.oled_rst = 16;
|
||||
config.noisefloor = -130;
|
||||
config.noisefloor = -125;
|
||||
strcpy(config.call,"NOCALL");
|
||||
strcpy(config.passcode, "---");
|
||||
config.maxsonde=15;
|
||||
|
|
@ -109,6 +118,7 @@ void Sonde::setConfig(const char *cfg) {
|
|||
config.oled_rst = atoi(val);
|
||||
} else if(strcmp(cfg,"maxsonde")==0) {
|
||||
config.maxsonde = atoi(val);
|
||||
if(config.maxsonde>MAXSONDE) config.maxsonde=MAXSONDE;
|
||||
} else if(strcmp(cfg,"debug")==0) {
|
||||
config.debug = atoi(val);
|
||||
} else if(strcmp(cfg,"wifi")==0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue