working version with config page (readonly)

This commit is contained in:
Hans P. Reiser 2019-04-15 20:59:30 +02:00
parent d2e1b84991
commit 88d75b55c3
4 changed files with 39 additions and 9 deletions

View File

@ -26,8 +26,11 @@ int e;
AsyncWebServer server(80); AsyncWebServer server(80);
const char * udpAddress = "192.168.42.20"; #define LOCALUDPPORT 9002
const int udpPort = 9002;
// moved to sonde.config
//const char * udpAddress = "192.168.42.20";
//const int udpPort = 9002;
boolean connected = false; boolean connected = false;
WiFiUDP udp; WiFiUDP udp;
@ -278,13 +281,13 @@ struct st_configitems config_list[N_CONFIG] = {
{"Call", 8, sonde.config.call}, {"Call", 8, sonde.config.call},
{"Passcode", 8, sonde.config.passcode}, {"Passcode", 8, sonde.config.passcode},
{"---", -1, NULL}, {"---", -1, NULL},
{"AXUDP active", -3, sonde.config.udpfeed.active}, {"AXUDP active", -3, &sonde.config.udpfeed.active},
{"AXUDP Host", 63, sonde.config.udpfeed.host}, {"AXUDP Host", 63, sonde.config.udpfeed.host},
{"AXUDP Port", 0, &sonde.config.udpfeed.port}, {"AXUDP Port", 0, &sonde.config.udpfeed.port},
{"DFM ID Format", -2, &sonde.config.udpfeed.idformat}, {"DFM ID Format", -2, &sonde.config.udpfeed.idformat},
{"Rate limit", 0, &sonde.config.udpfeed.highrate}, {"Rate limit", 0, &sonde.config.udpfeed.highrate},
{"---", -1, NULL}, {"---", -1, NULL},
{"APRS TCP active", -3, sonde.config.tcpfeed.active}, {"APRS TCP active", -3, &sonde.config.tcpfeed.active},
{"ARPS TCP Host", 63, sonde.config.tcpfeed.host}, {"ARPS TCP Host", 63, sonde.config.tcpfeed.host},
{"APRS TCP Port", 0, &sonde.config.tcpfeed.port}, {"APRS TCP Port", 0, &sonde.config.tcpfeed.port},
{"DFM ID Format", -2, &sonde.config.tcpfeed.idformat}, {"DFM ID Format", -2, &sonde.config.tcpfeed.idformat},
@ -314,7 +317,7 @@ void addConfigSeparatorEntry(char *ptr) {
const char *createConfigForm() { const char *createConfigForm() {
char *ptr = message; char *ptr = message;
char tmp[4]; char tmp[4];
strcpy(ptr,"<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"></head><body><form action=\"config.html\" method=\"post\"><table><tr><th>Nr</th><th>SSID</th><th>Password</th></tr>"); strcpy(ptr,"<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"></head><body><form action=\"config.html\" method=\"post\"><table><tr><th>Option</th><th>Value</th></tr>");
for(int i=0; i<N_CONFIG; i++) { for(int i=0; i<N_CONFIG; i++) {
switch(config_list[i].type) { switch(config_list[i].type) {
case -3: // in/offt case -3: // in/offt
@ -334,7 +337,7 @@ const char *createConfigForm() {
break; break;
} }
} }
strcat(ptr,"</table><input type=\"submit\" value=\"Update\"></input></form></body></html>"); strcat(ptr,"</table><input type=\"submit\" value=\"Update not yet implemented\"></input></form></body></html>");
return message; return message;
} }
@ -551,7 +554,7 @@ void loopDecoder() {
const char *str = aprs_senddata(s->lat, s->lon, s->hei, s->hs, s->dir, s->vs, sondeTypeStr[s->type], s->id, "TE0ST", "EO"); const char *str = aprs_senddata(s->lat, s->lon, s->hei, s->hs, s->dir, s->vs, sondeTypeStr[s->type], s->id, "TE0ST", "EO");
int rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN); int rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN);
Serial.print("Sending: "); Serial.println(raw); Serial.print("Sending: "); Serial.println(raw);
udp.beginPacket(udpAddress,udpPort); udp.beginPacket(sonde.config.udpfeed.host,sonde.config.udpfeed.port);
udp.write((const uint8_t *)raw,rawlen); udp.write((const uint8_t *)raw,rawlen);
udp.endPacket(); udp.endPacket();
} }
@ -632,7 +635,7 @@ void WiFiEvent(WiFiEvent_t event){
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
//initializes the UDP state //initializes the UDP state
//This initializes the transfer buffer //This initializes the transfer buffer
udp.begin(WiFi.localIP(),udpPort); udp.begin(WiFi.localIP(),LOCALUDPPORT);
connected = true; connected = true;
break; break;
case SYSTEM_EVENT_STA_DISCONNECTED: case SYSTEM_EVENT_STA_DISCONNECTED:
@ -684,12 +687,14 @@ void loopWifiScan() {
Serial.print("."); Serial.print(".");
u8x8.drawString(15,7,_scan[cnt&1]); u8x8.drawString(15,7,_scan[cnt&1]);
cnt++; cnt++;
#if 0
if(cnt==4) { if(cnt==4) {
WiFi.disconnect(true); // retry, for my buggy FritzBox WiFi.disconnect(true); // retry, for my buggy FritzBox
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
WiFi.begin(id, pw); WiFi.begin(id, pw);
} }
if(cnt==10) { #endif
if(cnt==15) {
WiFi.disconnect(true); WiFi.disconnect(true);
delay(1000); delay(1000);
WiFi.softAP(networks[0].id.c_str(),networks[0].pw.c_str()); WiFi.softAP(networks[0].id.c_str(),networks[0].pw.c_str());

View File

@ -18,6 +18,7 @@
<button class="tablinks" onclick="selTab(event,'QRG')" id="defaultTab">QRG</button> <button class="tablinks" onclick="selTab(event,'QRG')" id="defaultTab">QRG</button>
<button class="tablinks" onclick="selTab(event,'WIFI')">WLAN</button> <button class="tablinks" onclick="selTab(event,'WIFI')">WLAN</button>
<button class="tablinks" onclick="selTab(event,'Data')">Data</button> <button class="tablinks" onclick="selTab(event,'Data')">Data</button>
<button class="tablinks" onclick="selTab(event,'Config')">Config</button>
<button class="tablinks" onclick="selTab(event,'About')">About</button> <button class="tablinks" onclick="selTab(event,'About')">About</button>
</div> </div>
@ -36,6 +37,11 @@
<iframe src="status.html" style="border:none;" width="100%%" height="100%%"></iframe> <iframe src="status.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div> </div>
<div id="Config" class="tabcontent">
<h3>Config</h3>
<iframe src="config.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div>
<div id="About" class="tabcontent"> <div id="About" class="tabcontent">
<h3>About</h3> <h3>About</h3>
RDZSonde RDZSonde

View File

@ -47,6 +47,23 @@ static uint8_t empty_tile1[8]={0x00, 0xF0, 0x88, 0x48, 0x28, 0xF0, 0x00, 0x00};
static uint8_t empty_tile2[8]={0x00, 0x11, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00}; static uint8_t empty_tile2[8]={0x00, 0x11, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00};
static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00}; static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00};
Sonde::Sonde() {
config.noisefloor = -130;
strcpy(config.call,"NOCALL");
strcpy(config.passcode, "---");
config.udpfeed.active = 1;
config.udpfeed.type = 0;
strcpy(config.udpfeed.host, "192.168.42.20");
config.udpfeed.port = 9002;
config.udpfeed.highrate = 1;
config.udpfeed.idformat = ID_DFMGRAW;
config.tcpfeed.active = 0;
config.tcpfeed.type = 1;
strcpy(config.tcpfeed.host, "radiosondy.info");
config.tcpfeed.port = 12345;
config.tcpfeed.highrate = 10;
config.tcpfeed.idformat = ID_DFMDXL;
}
void Sonde::setIP(const char *ip, bool AP) { void Sonde::setIP(const char *ip, bool AP) {
memset(myIP_tiles, 0, 11*8); memset(myIP_tiles, 0, 11*8);

View File

@ -55,6 +55,8 @@ public:
int nSonde; int nSonde;
SondeInfo sondeList[MAXSONDE+1]; SondeInfo sondeList[MAXSONDE+1];
Sonde();
void clearSonde(); void clearSonde();
void addSonde(float frequency, SondeType type, int active); void addSonde(float frequency, SondeType type, int active);
void nextConfig(); void nextConfig();