kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
js-based config form, using less memory. +some cleanup
rodzic
7254558c44
commit
5c5bfa0725
|
@ -13,6 +13,7 @@
|
|||
#include <MicroNMEA.h>
|
||||
#include <Ticker.h>
|
||||
#include "esp_heap_caps.h"
|
||||
#include "soc/rtc_wdt.h"
|
||||
|
||||
#include "src/SX1278FSK.h"
|
||||
#include "src/Sonde.h"
|
||||
|
@ -567,11 +568,12 @@ void setupConfigData() {
|
|||
String line = readLine(file); //file.readStringUntil('\n');
|
||||
sonde.setConfig(line.c_str());
|
||||
}
|
||||
int shII = atoi(sonde.config.sondehub.fimport);
|
||||
int shII = sonde.config.sondehub.fiinterval * 60;
|
||||
if(shImportInterval > shII) shImportInterval = shII;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
struct st_configitems config_list[] = {
|
||||
/* General config settings */
|
||||
{"", "Software configuration", -5, NULL},
|
||||
|
@ -672,10 +674,116 @@ struct st_configitems config_list[] = {
|
|||
{"sondehub.antenna", "Antenna (optional, visisble on SondeHub tracker)", 63, &sonde.config.sondehub.antenna},
|
||||
{"sondehub.email", "SondeHub email (optional, only used to contact in case of upload errors)", 63, &sonde.config.sondehub.email},
|
||||
{"sondehub.fimport", "SondeHub freq import (interval/maxdist/maxage [min/km/min])", 18, &sonde.config.sondehub.fimport},
|
||||
};
|
||||
#endif
|
||||
#else
|
||||
struct st_configitems config_list[] = {
|
||||
/* General config settings */
|
||||
{"wifi", 0, &sonde.config.wifi},
|
||||
{"debug", 0, &sonde.config.debug},
|
||||
{"maxsonde", 0, &sonde.config.maxsonde},
|
||||
{"screenfile", 0, &sonde.config.screenfile},
|
||||
{"display", -6, sonde.config.display},
|
||||
/* Spectrum display settings */
|
||||
{"spectrum", 0, &sonde.config.spectrum},
|
||||
{"startfreq", 0, &sonde.config.startfreq},
|
||||
{"channelbw", 0, &sonde.config.channelbw},
|
||||
{"marker", 0, &sonde.config.marker},
|
||||
{"noisefloor", 0, &sonde.config.noisefloor},
|
||||
/* decoder settings */
|
||||
{"freqofs", 0, &sonde.config.freqofs},
|
||||
{"rs41.agcbw", 0, &sonde.config.rs41.agcbw},
|
||||
{"rs41.rxbw", 0, &sonde.config.rs41.rxbw},
|
||||
{"rs92.rxbw", 0, &sonde.config.rs92.rxbw},
|
||||
{"rs92.alt2d", 0, &sonde.config.rs92.alt2d},
|
||||
{"dfm.agcbw", 0, &sonde.config.dfm.agcbw},
|
||||
{"dfm.rxbw", 0, &sonde.config.dfm.rxbw},
|
||||
{"m10m20.agcbw", 0, &sonde.config.m10m20.agcbw},
|
||||
{"m10m20.rxbw", 0, &sonde.config.m10m20.rxbw},
|
||||
{"mp3h.agcbw", 0, &sonde.config.mp3h.agcbw},
|
||||
{"mp3h.rxbw", 0, &sonde.config.mp3h.rxbw},
|
||||
{"ephftp", 39, &sonde.config.ephftp},
|
||||
/* APRS settings */
|
||||
{"call", 8, sonde.config.call},
|
||||
{"passcode", 0, &sonde.config.passcode},
|
||||
/* KISS tnc settings */
|
||||
{"kisstnc.active", 0, &sonde.config.kisstnc.active},
|
||||
{"kisstnc.idformat", -2, &sonde.config.kisstnc.idformat},
|
||||
/* AXUDP settings */
|
||||
{"axudp.active", -3, &sonde.config.udpfeed.active},
|
||||
{"axudp.host", 63, sonde.config.udpfeed.host},
|
||||
{"axudp.port", 0, &sonde.config.udpfeed.port},
|
||||
{"axudp.idformat", -2, &sonde.config.udpfeed.idformat},
|
||||
{"axudp.highrate", 0, &sonde.config.udpfeed.highrate},
|
||||
/* APRS TCP settings, current not used */
|
||||
{"tcp.active", -3, &sonde.config.tcpfeed.active},
|
||||
{"tcp.host", 63, sonde.config.tcpfeed.host},
|
||||
{"tcp.port", 0, &sonde.config.tcpfeed.port},
|
||||
{"tcp.idformat", -2, &sonde.config.tcpfeed.idformat},
|
||||
{"tcp.highrate", 0, &sonde.config.tcpfeed.highrate},
|
||||
|
||||
#if FEATURE_MQTT
|
||||
/* MQTT */
|
||||
{"mqtt.active", 0, &sonde.config.mqtt.active},
|
||||
{"mqtt.id", 63, &sonde.config.mqtt.id},
|
||||
{"mqtt.host", 63, &sonde.config.mqtt.host},
|
||||
{"mqtt.port", 0, &sonde.config.mqtt.port},
|
||||
{"mqtt.username", 63, &sonde.config.mqtt.username},
|
||||
{"mqtt.password", 63, &sonde.config.mqtt.password},
|
||||
{"mqtt.prefix", 63, &sonde.config.mqtt.prefix},
|
||||
#endif
|
||||
|
||||
/* Hardware dependeing settings */
|
||||
{"disptype", 0, &sonde.config.disptype},
|
||||
{"norx_timeout", 0, &sonde.config.norx_timeout},
|
||||
{"oled_sda", 0, &sonde.config.oled_sda},
|
||||
{"oled_scl", 0, &sonde.config.oled_scl},
|
||||
{"oled_rst", 0, &sonde.config.oled_rst},
|
||||
{"tft_rs", 0, &sonde.config.tft_rs},
|
||||
{"tft_cs", 0, &sonde.config.tft_cs},
|
||||
{"tft_orient", 0, &sonde.config.tft_orient},
|
||||
{"tft_spifreq", 0, &sonde.config.tft_spifreq},
|
||||
{"button_pin", -4, &sonde.config.button_pin},
|
||||
{"button2_pin", -4, &sonde.config.button2_pin},
|
||||
{"button2_axp", 0, &sonde.config.button2_axp},
|
||||
{"touch_thresh", 0, &sonde.config.touch_thresh},
|
||||
{"power_pout", 0, &sonde.config.power_pout},
|
||||
{"led_pout", 0, &sonde.config.led_pout},
|
||||
{"gps_rxd", 0, &sonde.config.gps_rxd},
|
||||
{"gps_txd", 0, &sonde.config.gps_txd},
|
||||
{"batt_adc", 0, &sonde.config.batt_adc},
|
||||
#if 1
|
||||
{"sx1278_ss", 0, &sonde.config.sx1278_ss},
|
||||
{"sx1278_miso", 0, &sonde.config.sx1278_miso},
|
||||
{"sx1278_mosi", 0, &sonde.config.sx1278_mosi},
|
||||
{"sx1278_sck", 0, &sonde.config.sx1278_sck},
|
||||
#endif
|
||||
{"mdnsname", 14, &sonde.config.mdnsname},
|
||||
|
||||
#if FEATURE_SONDEHUB
|
||||
/* SondeHub settings */
|
||||
{"sondehub.active", 0, &sonde.config.sondehub.active},
|
||||
{"sondehub.chase", 0, &sonde.config.sondehub.chase},
|
||||
{"sondehub.host", 63, &sonde.config.sondehub.host},
|
||||
{"sondehub.callsign", 63, &sonde.config.sondehub.callsign},
|
||||
{"sondehub.lat", -7, &sonde.config.sondehub.lat},
|
||||
{"sondehub.lon", -7, &sonde.config.sondehub.lon},
|
||||
{"sondehub.alt", 19, &sonde.config.sondehub.alt},
|
||||
{"sondehub.antenna", 63, &sonde.config.sondehub.antenna},
|
||||
{"sondehub.email", 63, &sonde.config.sondehub.email},
|
||||
{"sondehub.fiactive", 0, &sonde.config.sondehub.fimactitve},
|
||||
{"sondehub.fiinterval", 0, &sonde.config.sondehub.fiinterval},
|
||||
{"sondehub.fimaxdist", 0, &sonde.config.sondehub.fimaxdist},
|
||||
{"sondehub.fimaxage", 0, &sonde.config.sondehub.fimaxage},
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
const int N_CONFIG = (sizeof(config_list) / sizeof(struct st_configitems));
|
||||
|
||||
#if 0
|
||||
// old code, no longer needed (in js now)
|
||||
|
||||
void addConfigStringEntry(char *ptr, int idx, const char *label, int len, char *field) {
|
||||
sprintf(ptr + strlen(ptr), "<tr><td>%s</td><td><input name=\"CFG%d\" type=\"text\" value=\"%s\"/></td></tr>\n",
|
||||
label, idx, field);
|
||||
|
@ -733,11 +841,46 @@ void addConfigInt8List(char *ptr, int idx, const char *label, int8_t *list) {
|
|||
}
|
||||
strcat(ptr, "\"/></td></tr>\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *createConfigForm() {
|
||||
char *ptr = message;
|
||||
strcpy(ptr, HTMLHEAD); strcat(ptr, "</head>");
|
||||
HTMLBODY(ptr, "config.html");
|
||||
strcat(ptr, "<div id=\"cfgtab\"></div>");
|
||||
strcat(ptr, "<script src=\"cfg.js\"></script>");
|
||||
strcat(ptr, "<script>\n");
|
||||
strcat(ptr, "var cf=new Map();\n");
|
||||
for(int i=0; i< N_CONFIG; i++) {
|
||||
sprintf(ptr + strlen(ptr), "cf.set(\"%s\", \"", config_list[i].name);
|
||||
switch(config_list[i].type) {
|
||||
case -4:
|
||||
case -3:
|
||||
case -2:
|
||||
case 0:
|
||||
sprintf(ptr + strlen(ptr), "%d", *(int *)config_list[i].data);
|
||||
break;
|
||||
case -6: // list
|
||||
{
|
||||
int8_t *l = (int8_t *)config_list[i].data;
|
||||
if(*l==-1) strcat(ptr, "0");
|
||||
else { sprintf(ptr + strlen(ptr), "%d", l[0]); l++; }
|
||||
while(*l != -1) {
|
||||
sprintf(ptr + strlen(ptr), ",%d", *l);
|
||||
l++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case -7: // double
|
||||
sprintf(ptr + strlen(ptr), "%f", *(double *)config_list[i].data);
|
||||
break;
|
||||
default: // string
|
||||
strcat(ptr, (char *)config_list[i].data);
|
||||
}
|
||||
strcat(ptr, "\");\n");
|
||||
}
|
||||
strcat(ptr, "configTable();\n </script>");
|
||||
#if 0
|
||||
strcat(ptr, "<table><tr><th>Option</th><th>Value</th></tr>");
|
||||
for (int i = 0; i < N_CONFIG; i++) {
|
||||
Serial.printf("%d: %s -- %d\n", i, config_list[i].label, strlen(ptr));
|
||||
|
@ -773,6 +916,7 @@ const char *createConfigForm() {
|
|||
}
|
||||
strcat(ptr, "</table>");
|
||||
//</div><div class=\"footer\"><input type=\"submit\" class=\"update\" value=\"Update\"/>");
|
||||
#endif
|
||||
HTMLSAVEBUTTON(ptr);
|
||||
HTMLBODYEND(ptr);
|
||||
Serial.printf("Config form: size=%d bytes\n", strlen(message));
|
||||
|
@ -791,8 +935,8 @@ const char *handleConfigPost(AsyncWebServerRequest *request) {
|
|||
}
|
||||
#endif
|
||||
Serial.println("File open for writing.");
|
||||
#if 1
|
||||
int params = request->params();
|
||||
#if 0
|
||||
for (int i = 0; i < params; i++) {
|
||||
String param = request->getParam(i)->name();
|
||||
Serial.println(param.c_str());
|
||||
|
@ -801,13 +945,26 @@ const char *handleConfigPost(AsyncWebServerRequest *request) {
|
|||
for (int i = 0; i < params; i++) {
|
||||
String strlabel = request->getParam(i)->name();
|
||||
const char *label = strlabel.c_str();
|
||||
if(label[strlen(label)-1]=='#') continue;
|
||||
#if 0
|
||||
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
|
||||
#endif
|
||||
AsyncWebParameter *value = request->getParam(label, true);
|
||||
if (!value) continue;
|
||||
String strvalue = value->value();
|
||||
if( strcmp(label, "button_pin") == 0 ||
|
||||
strcmp(label, "button2_pin") == 0) {
|
||||
AsyncWebParameter *touch = request->getParam(strlabel+"#", true);
|
||||
if(touch) {
|
||||
int i = atoi(strvalue.c_str());
|
||||
if(i != -1 && i != 255) i += 128;
|
||||
strvalue = String(i);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (config_list[idx].type == -4) { // input button port with "touch" checkbox
|
||||
char tmp[10];
|
||||
snprintf(tmp, 10, "TO%d", idx);
|
||||
|
@ -819,7 +976,10 @@ const char *handleConfigPost(AsyncWebServerRequest *request) {
|
|||
}
|
||||
}
|
||||
Serial.printf("Processing %s=%s\n", config_list[idx].name, strvalue.c_str());
|
||||
int wlen = f.printf("%s=%s\n", config_list[idx].name, strvalue.c_str());
|
||||
#endif
|
||||
Serial.printf("Processing %s=%s\n", label, strvalue.c_str());
|
||||
//int wlen = f.printf("%s=%s\n", config_list[idx].name, strvalue.c_str());
|
||||
int wlen = f.printf("%s=%s\n", label, strvalue.c_str());
|
||||
Serial.printf("Written bytes: %d\n", wlen);
|
||||
}
|
||||
Serial.printf("Flushing file\n");
|
||||
|
@ -1750,9 +1910,11 @@ void IRAM_ATTR button2ISR() {
|
|||
int getKeyPress() {
|
||||
KeyPress p = button1.pressed;
|
||||
button1.pressed = KP_NONE;
|
||||
#if 0
|
||||
int x = digitalRead(button1.pin);
|
||||
Serial.printf("Debug: bdd1=%ld, bdd2=%ld\b", bdd1, bdd2);
|
||||
Serial.printf("button1 press (dbl:%d) (now:%d): %d at %ld (%d)\n", button1.doublepress, x, p, button1.keydownTime, button1.numberKeyPresses);
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1863,7 +2025,7 @@ void setup()
|
|||
{
|
||||
char buf[12];
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
Serial.begin(921600 /*115200*/);
|
||||
for (int i = 0; i < 39; i++) {
|
||||
int v = gpio_get_level((gpio_num_t)i);
|
||||
Serial.printf("%d:%d ", i, v);
|
||||
|
@ -2242,9 +2404,19 @@ void loopDecoder() {
|
|||
action = (int)(res >> 8);
|
||||
// TODO: update displayed sonde?
|
||||
|
||||
#if 0
|
||||
static int i=0;
|
||||
if(i++>20) {
|
||||
i=0;
|
||||
rtc_wdt_protect_off();
|
||||
rtc_wdt_disable();
|
||||
heap_caps_dump(MALLOC_CAP_8BIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (action != ACT_NONE) {
|
||||
int newact = sonde.updateState(action);
|
||||
Serial.printf("MAIN: loopDecoder: action %s (%d) => %d [current: main=%d, rxtask=%d]\n", action2text(action), action, newact, sonde.currentSonde, rxtask.currentSonde);
|
||||
Serial.printf("MAIN: loopDecoder: action %02x (%s) => %d [current: main=%d, rxtask=%d]\n", action, action2text(action), newact, sonde.currentSonde, rxtask.currentSonde);
|
||||
action = newact;
|
||||
if (action != 255) {
|
||||
if (action == ACT_DISPLAY_SPECTRUM) {
|
||||
|
@ -3304,7 +3476,7 @@ const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
|
|||
};
|
||||
|
||||
void sondehub_handle_fimport(WiFiClient *client) {
|
||||
if (sonde.config.sondehub.fimport[0] != '0') {
|
||||
if (sonde.config.sondehub.fiactive) {
|
||||
if (shImport == 0) {
|
||||
sondehub_send_fimport(&shclient);
|
||||
} else if (shImport == 1) {
|
||||
|
@ -3336,15 +3508,9 @@ void sondehub_send_fimport(WiFiClient * client) {
|
|||
lon = gpsPos.lon;
|
||||
}
|
||||
|
||||
char *ptr = strchr(sonde.config.sondehub.fimport, '/');
|
||||
shImportInterval = atoi(sonde.config.sondehub.fimport) * 60;
|
||||
int maxdist = 200;
|
||||
int maxage = 60;
|
||||
if (ptr) {
|
||||
maxdist = atoi(ptr + 1);
|
||||
ptr = strchr(ptr + 1, '/');
|
||||
if (ptr) maxage = atoi(ptr + 1);
|
||||
}
|
||||
int maxdist = sonde.config.sondehub.fimaxdist; // km
|
||||
int maxage = sonde.config.sondehub.fimaxage * 60; // fimaxage is hours, shImportSendRequest uses minutes
|
||||
int shImportInterval = sonde.config.sondehub.fiinterval * 60; // shImportInterval is in seconds, fiinterval in minutes
|
||||
if ( !isnan(lat) && !isnan(lon) && maxdist > 0 && maxage > 0 && shImportInterval > 0 ) {
|
||||
int res = ShFreqImport::shImportSendRequest(&shclient, lat, lon, maxdist, maxage);
|
||||
if (res == 0) shImport = 1; // Request OK: wait for response
|
||||
|
@ -3391,7 +3557,8 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
|||
// If something that looks like a valid HTTP response is received, we are ready to send the next data item
|
||||
if (shState == SH_CONN_WAITACK && cnt > 11 && strncmp(rs_msg, "HTTP/1", 6) == 0) {
|
||||
shState = SH_CONN_IDLE;
|
||||
sondehub_send_fimport(client);
|
||||
if( sonde.config.sondehub.fiactive)
|
||||
sondehub_send_fimport(client);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
var cfgs = [
|
||||
[ "", "Software configuration" ],
|
||||
[ "wifi", "Wifi mode (0=off, 1=client, 2=AP, 3=auto client/AP on startup" ],
|
||||
[ "debug", "Debug mode (0/1)" ],
|
||||
[ "maxsonde", "max. number of QRG entries (must be <100)" ],
|
||||
[ "screenfile", "Screen config (0=automatic; 1-5=predefined; other=custom)" ],
|
||||
[ "display", "Display screens (scan, default, ...)" ],
|
||||
[ "", "Spectrum display settings" ],
|
||||
[ "spectrum", "Show spectrum on start (-1=no, 0=forever, >0=time [sec])" ],
|
||||
[ "startfreq", "Start frequency (MHz, default 400)" ],
|
||||
[ "channelbw", "Bandwidth (kHz)" ],
|
||||
[ "marker", "Spectrum MHz marker" ], // maybe remove, assume always ==1?
|
||||
[ "noisefloor", "Spectrum noisefloor" ],
|
||||
[ "", "Receiver configuration" ],
|
||||
[ "freqofs", "RX frequency offset (Hz)"],
|
||||
[ "rs41.agcbw", "RS41 AGC bandwidth"],
|
||||
[ "rs41.rxbw", "RS41 RX bandwidth"],
|
||||
[ "rs92.rxbw", "RS92 RX (and AGC) bandwidth"],
|
||||
[ "rs92.alt2d", "RS92 2D fix default altitude"],
|
||||
[ "dfm.agcbw", "DFM AGC bandwidth"],
|
||||
[ "dfm.rxbw", "DFM RX bandwidth"],
|
||||
[ "m10m20.agcbw", "M10/M20 AGC bandwidth"],
|
||||
[ "m10m20.rxbw", "M10/M20 RX bandwidth"],
|
||||
[ "mp3h.agcbw", "MP3H AGC bandwidth"],
|
||||
[ "mp3h.rxbw", "MP3H RX bandwidth"],
|
||||
[ "ephftp", "FTP for eph (RS92)"],
|
||||
[ "", "Data feed configuration"],
|
||||
[ "call", "Call"],
|
||||
[ "passcode", "Passcode"],
|
||||
[ "kisstnc.active", "KISS TNC (port 14590) (needs reboot)"],
|
||||
[ "kisstnc.idformat", "KISS TNC ID Format"],
|
||||
[ "axudp.active", "AXUDP active"],
|
||||
[ "axudp.host", "AXUDP Host"],
|
||||
[ "axudp.port", "AXUDP Port"],
|
||||
[ "axudp.idformat", "DFM ID Format"],
|
||||
[ "axudp.highrate", "Rate limit"],
|
||||
[ "tcp.active", "APRS TCP active"],
|
||||
[ "tcp.host", "ARPS TCP Host"],
|
||||
[ "tcp.port", "APRS TCP Port"],
|
||||
[ "tcp.idformat", "DFM ID Format"],
|
||||
[ "tcp.highrate", "Rate limit"],
|
||||
[ "mqtt.active", "MQTT Active (needs reboot)"],
|
||||
[ "mqtt.id", "MQTT client ID"],
|
||||
[ "mqtt.host", "MQTT server hostname"],
|
||||
[ "mqtt.port", "MQTT Port"],
|
||||
[ "mqtt.username", "MQTT Username"],
|
||||
[ "mqtt.password", "MQTT Password"],
|
||||
[ "mqtt.prefix", "MQTT Prefix"],
|
||||
[ "", "Hardware configuration (requires reboot)"],
|
||||
[ "disptype", "Display type (0=OLED/SSD1306, 1=ILI9225, 2=OLED/SH1106, 3=ILI9341, 4=ILI9342)"],
|
||||
[ "norx_timeout", "No-RX-Timeout in seconds (-1=disabled)"],
|
||||
[ "oled_sda", "OLED SDA/TFT SDA"],
|
||||
[ "oled_scl", "OLED SCL/TFT CLK"],
|
||||
[ "oled_rst", "OLED RST/TFT RST (needs reboot)"],
|
||||
[ "tft_rs", "TFT RS"],
|
||||
[ "tft_cs", "TFT CS"],
|
||||
[ "tft_orient", "TFT orientation (0/1/2/3), OLED flip: 3"],
|
||||
[ "tft_spifreq", "TFT SPI speed"],
|
||||
[ "button_pin", "Button input port"],
|
||||
[ "button2_pin", "Button 2 input port"],
|
||||
[ "button2_axp", "Use AXP192 PWR as Button 2"],
|
||||
[ "touch_thresh", "Touch button threshold<br>(0 for calib mode)"],
|
||||
[ "power_pout", "Power control port"],
|
||||
[ "led_pout", "LED output port"],
|
||||
[ "gps_rxd", "GPS RXD pin (-1 to disable)"],
|
||||
[ "gps_txd", "GPS TXD pin (not really needed)"],
|
||||
[ "batt_adc", "Battery measurement pin"],
|
||||
[ "sx1278_ss", "SX1278 SS"],
|
||||
[ "sx1278_miso", "SX1278 MISO"],
|
||||
[ "sx1278_mosi", "SX1278 MOSI"],
|
||||
[ "sx1278_sck", "SX1278 SCK"],
|
||||
[ "mdnsname", "mDNS name"],
|
||||
[ "", "SondeHub settings"],
|
||||
[ "sondehub.active", "SondeHub reporting (0=disabled, 1=active)"],
|
||||
[ "sondehub.chase", "SondeHub location reporting (0=off, 1=fixed, 2=chase/GPS, 3=auto)"],
|
||||
[ "sondehub.host", "SondeHub host (DO NOT CHANGE)"],
|
||||
[ "sondehub.callsign", "Callsign"],
|
||||
[ "sondehub.lat", "Latitude (optional, required to show station on SondeHub Tracker)"],
|
||||
[ "sondehub.lon", "Longitude (optional, required to show station on SondeHub Tracker)"],
|
||||
[ "sondehub.alt", "Altitude (optional, visible on SondeHub tracker)"],
|
||||
[ "sondehub.antenna", "Antenna (optional, visisble on SondeHub tracker)"],
|
||||
[ "sondehub.email", "SondeHub email (optional, only used to contact in case of upload errors)"],
|
||||
[ "", "SondeHub frequency import" ],]
|
||||
[ "sondehub.fiactive", "SondeHub frequency import active (0=disabled, 1=active)" ],
|
||||
[ "sondehub.fiinterval", "Import frequency (minutes, ≥5)" ],
|
||||
[ "sondehub.fimaxdist", "Import maximum distance (km, ≤500)" ],
|
||||
[ "sondehub.fimaxage", "Import maximum age (hours, ≤24" ],
|
||||
];
|
||||
|
||||
function mkcfg(id, key, label, value) {
|
||||
var s = "<tr class=\"cfgpanel\"><td>" + label + "</td><td><input name=\"" + key + "\" type=\"text\" value=\"" + value + "\"/></td></tr>\n";
|
||||
return s;
|
||||
}
|
||||
function mkcfgbtn(id, key, label, value) {
|
||||
var touch = "";
|
||||
var v = value;
|
||||
if(v != -1 && (v&128)) {
|
||||
touch = " checked";
|
||||
v = v & 127;
|
||||
}
|
||||
var s = "<tr class=\"cfgpanel\"><td>" + label + "</td><td><input name=\"" + key + "\" type=\"text\" size=\"3\" value=\"" + v + "\"/>";
|
||||
s += "<input type=\"checkbox\" name=\"" + key + "#\" "+touch+"> Touch</td></tr>\n";
|
||||
return s;
|
||||
}
|
||||
|
||||
function mksep(id,label) {
|
||||
return "<tr class=\"cfgheader\"><th align=\"left\" colspan=\"2\">"+label+"</th></tr>\n";
|
||||
}
|
||||
function rowdisp(id,disp) {
|
||||
var matches = document.querySelectorAll("tr."+id);
|
||||
matches.forEach(function(e) { if(disp) e.hidden=true; else e.removeAttribute('hidden');});
|
||||
hid=id; nid="N"+id;
|
||||
if(!disp) { hid=nid; nid=id; }
|
||||
document.querySelector("span."+hid).hidden=true;
|
||||
document.querySelector("span."+nid).removeAttribute('hidden');
|
||||
}
|
||||
function configTable() {
|
||||
// iterate over cfgs
|
||||
var tab = "<table width=\"100%\"><tr><th>Option</th><th>Value</th></tr>\n";
|
||||
var id=0;
|
||||
for(i=0; i<cfgs.length; i++) {
|
||||
var key = cfgs[i][0];
|
||||
var lbl = cfgs[i][1];
|
||||
if(key) {
|
||||
if(key=="button_pin" || key=="button2_pin")
|
||||
tab += mkcfgbtn("s"+id, key, lbl, cf.get(key));
|
||||
else
|
||||
tab += mkcfg("s"+id, key, lbl, cf.get(key));
|
||||
} else {
|
||||
id++;
|
||||
tab += mksep("s"+id, lbl);
|
||||
}
|
||||
}
|
||||
tab += "</table>";
|
||||
var cfgdiv = document.getElementById("cfgtab");
|
||||
cfgdiv.innerHTML = tab;
|
||||
// enable collapse / expand of items below a header
|
||||
var acc = document.getElementsByClassName("cfgheader");
|
||||
for(i=0; i<acc.length; i++) {
|
||||
acc[i].firstChild.innerHTML = "\u2212 " + acc[i].firstChild.innerHTML;
|
||||
acc[i].addEventListener("click", function() {
|
||||
achar = "\u2212";
|
||||
if(this.classList.toggle("active")) achar = "+";
|
||||
this.firstChild.innerHTML = achar + this.firstChild.innerHTML.substring(1);
|
||||
var panel = this;
|
||||
console.log(panel);
|
||||
while( panel = panel.nextElementSibling) {
|
||||
console.log(panel);
|
||||
if ( panel.className!="cfgpanel") { break; }
|
||||
if(panel.style.visibility==="collapse") {
|
||||
panel.style.visibility="visible";
|
||||
} else {
|
||||
console.log("none");
|
||||
panel.style.visibility="collapse";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -129,7 +129,13 @@ sondehub.lon=
|
|||
sondehub.alt=
|
||||
sondehub.antenna=
|
||||
sondehub.email=
|
||||
sondehub.fimport=0/100/60
|
||||
#-------------------------------#
|
||||
# Sondehub freq import settings
|
||||
#-------------------------------#
|
||||
shfimp.active=0
|
||||
shfimp.interval=60
|
||||
shfimp.maxdist=150
|
||||
shfimp.maxage=6
|
||||
#-------------------------------#
|
||||
# EOF
|
||||
#-------------------------------#
|
||||
|
|
|
@ -4,6 +4,12 @@ body, html {
|
|||
font-family: Arial;
|
||||
}
|
||||
|
||||
.active, .cfgheader:hover {
|
||||
background-color: #ccc;
|
||||
}
|
||||
.cfgpanel {
|
||||
}
|
||||
|
||||
.hamburger {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
|
|
@ -195,9 +195,6 @@ static void Gencrctab(void)
|
|||
|
||||
int RS41::setup(float frequency)
|
||||
{
|
||||
#if RS41_DEBUG
|
||||
Serial.println("Setup sx1278 for RS41 sonde");
|
||||
#endif
|
||||
if(!initialized) {
|
||||
Gencrctab();
|
||||
initrsc();
|
||||
|
@ -216,11 +213,6 @@ int RS41::setup(float frequency)
|
|||
RS41_DBG(Serial.println("Setting bitrate 4800bit/s FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if RS41_DEBUG
|
||||
float br = sx1278.getBitrate();
|
||||
Serial.print("Exact bitrate is ");
|
||||
Serial.println(br);
|
||||
#endif
|
||||
|
||||
if(sx1278.setAFCBandwidth(sonde.config.rs41.agcbw)!=0) {
|
||||
RS41_DBG(Serial.printf("Setting AFC bandwidth %d Hz FAILED", sonde.config.rs41.agcbw));
|
||||
|
@ -255,21 +247,11 @@ int RS41::setup(float frequency)
|
|||
RS41_DBG(Serial.println("Setting Packet config FAILED"));
|
||||
return 1;
|
||||
}
|
||||
#if RS41_DEBUG
|
||||
Serial.print("RS41: setting RX frequency to ");
|
||||
Serial.println(frequency);
|
||||
#endif
|
||||
int retval = sx1278.setFrequency(frequency);
|
||||
dpos = 0;
|
||||
|
||||
#if RS41_DEBUG
|
||||
RS41_DBG(Serial.println("Setting SX1278 config for RS41 finished\n"); Serial.println());
|
||||
#endif
|
||||
sx1278.clearIRQFlags();
|
||||
|
||||
// the following is already done in receivePacketTimeout()
|
||||
// sx1278.setPayloadLength(RS41MAXLEN-8); // Expect 320-8 bytes or 518-8 bytes (8 byte header)
|
||||
// sx1278.writeRegister(REG_OP_MODE, FSK_RX_MODE);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ void Sonde::nextRxSonde() {
|
|||
if(rxtask.currentSonde>=config.maxsonde) rxtask.currentSonde=0;
|
||||
}
|
||||
}
|
||||
Serial.printf("nextRxSonde: %d\n", rxtask.currentSonde);
|
||||
//Serial.printf("nextRxSonde: %d\n", rxtask.currentSonde);
|
||||
}
|
||||
void Sonde::nextRxFreq(int addkhz) {
|
||||
// last entry is for the variable frequency
|
||||
|
@ -409,7 +409,7 @@ void Sonde::setup() {
|
|||
}
|
||||
|
||||
// update receiver config
|
||||
Serial.print("Sonde.setup() on sonde index ");
|
||||
Serial.print("Sonde::setup() start on index ");
|
||||
Serial.println(rxtask.currentSonde);
|
||||
switch(sondeList[rxtask.currentSonde].type) {
|
||||
case STYPE_RS41:
|
||||
|
@ -433,7 +433,7 @@ void Sonde::setup() {
|
|||
int freq = (int)sx1278.getFrequency();
|
||||
int afcbw = (int)sx1278.getAFCBandwidth();
|
||||
int rxbw = (int)sx1278.getRxBandwidth();
|
||||
Serial.printf("Sonde.setup(): Freq %d, AFC BW: %d, RX BW: %d\n", freq, afcbw, rxbw);
|
||||
Serial.printf("Sonde::setup() done: Type %s Freq %f, AFC BW: %d, RX BW: %d\n", sondeTypeStr[sondeList[rxtask.currentSonde].type], 0.000001*freq, afcbw, rxbw);
|
||||
|
||||
// reset rxtimer / norxtimer state
|
||||
sonde.sondeList[sonde.currentSonde].lastState = -1;
|
||||
|
@ -472,7 +472,7 @@ void Sonde::receive() {
|
|||
}
|
||||
} else { // RX not ok
|
||||
if(res==RX_ERROR) flashLed(100);
|
||||
Serial.printf("RX result %d (%s), laststate was %d\n", res, (res<=3)?RXstr[res]:"?", si->lastState);
|
||||
//Serial.printf("Sonde::receive(): result %d (%s), laststate was %d\n", res, (res<=3)?RXstr[res]:"?", si->lastState);
|
||||
if(si->lastState != 0) {
|
||||
si->norxStart = millis();
|
||||
si->lastState = 0;
|
||||
|
@ -509,8 +509,8 @@ void Sonde::receive() {
|
|||
rxtask.activate = ACT_SONDE(rxtask.currentSonde);
|
||||
}
|
||||
}
|
||||
Serial.printf("Sonde:receive(): result %d (%s), event %02x => action %02x\n", res, (res<=3)?RXstr[res]:"?", event, action);
|
||||
res = (action<<8) | (res&0xff);
|
||||
Serial.printf("Sonde:receive(): Event %02x: action %02x, res %02x => %04x\n", event, action, res&0xff, res);
|
||||
// let waitRXcomplete resume...
|
||||
rxtask.receiveResult = res;
|
||||
}
|
||||
|
@ -574,22 +574,22 @@ uint8_t Sonde::timeoutEvent(SondeInfo *si) {
|
|||
now, si->norxStart, disp.layout->timeouts[2], si->lastState);
|
||||
#endif
|
||||
if(disp.layout->timeouts[0]>=0 && now - si->viewStart >= disp.layout->timeouts[0]) {
|
||||
Serial.println("Sonde.timeoutEvent: View");
|
||||
Serial.println("Sonde::timeoutEvent: View");
|
||||
return EVT_VIEWTO;
|
||||
}
|
||||
if(si->lastState==1 && disp.layout->timeouts[1]>=0 && now - si->rxStart >= disp.layout->timeouts[1]) {
|
||||
Serial.println("Sonde.timeoutEvent: RX");
|
||||
Serial.println("Sonde::timeoutEvent: RX");
|
||||
return EVT_RXTO;
|
||||
}
|
||||
if(si->lastState==0 && disp.layout->timeouts[2]>=0 && now - si->norxStart >= disp.layout->timeouts[2]) {
|
||||
Serial.println("Sonde.timeoutEvent: NORX");
|
||||
Serial.println("Sonde::timeoutEvent: NORX");
|
||||
return EVT_NORXTO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t Sonde::updateState(uint8_t event) {
|
||||
Serial.printf("Sonde::updateState for event %d\n", event);
|
||||
//Serial.printf("Sonde::updateState for event %02x\n", event);
|
||||
// No change
|
||||
if(event==ACT_NONE) return 0xFF;
|
||||
|
||||
|
|
|
@ -196,7 +196,10 @@ struct st_sondehub {
|
|||
char alt[20];
|
||||
char antenna[64];
|
||||
char email[64];
|
||||
char fimport[20];
|
||||
int fiactive;
|
||||
int fiinterval;
|
||||
int fimaxdist;
|
||||
int fimaxage;
|
||||
};
|
||||
|
||||
// to be extended
|
||||
|
@ -261,7 +264,7 @@ typedef struct st_rdzconfig {
|
|||
|
||||
struct st_configitems {
|
||||
const char *name;
|
||||
const char *label;
|
||||
// const char *label; => now handled in JS
|
||||
int type; // 0: numeric; i>0 string of length i; -1: separator; -2: type selector
|
||||
void *data;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20210917";
|
||||
const char *version_id = "devel20210918";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=16;
|
||||
|
|
Ładowanie…
Reference in New Issue