From 15902b0230de64b80339ba80247f36111f9e1713 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Thu, 30 May 2019 23:27:33 +0200 Subject: [PATCH] some cleanup --- RX_FSK/RX_FSK.ino | 26 +++++++++++++++----------- libraries/SondeLib/DFM.cpp | 4 ++-- libraries/SondeLib/Display.cpp | 4 ++-- libraries/SondeLib/RS92.cpp | 4 ++-- libraries/SondeLib/nav_gps_vel.inc | 2 ++ libraries/SondeLib/rs92gps.inc | 9 ++++++--- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 995085d..1b4b4e6 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -226,6 +226,7 @@ const char *handleQRGPost(AsyncWebServerRequest *request) { Serial.println(); delay(500); setupChannelList(); + return ""; } @@ -318,6 +319,7 @@ const char *handleWIFIPost(AsyncWebServerRequest *request) { } f.close(); setupWifiList(); + return ""; } // Show current status @@ -327,7 +329,7 @@ void addSondeStatus(char *ptr, int i) strcat(ptr, ""); sprintf(ptr + strlen(ptr), "\n", s->freq, sondeTypeStr[s->type], - s->validID ? s->id : "", + s->validID ? s->id : "", s->lat, s->lon, s->alt); sprintf(ptr + strlen(ptr), "
%3.3f MHz, Type: %s
ID: %s
QTH: %.6f,%.6f h=%.0fm
GEO-App - ", s->lat, s->lon); sprintf(ptr + strlen(ptr), "WX.DL2MF.de - ", s->id); @@ -439,7 +441,6 @@ void addConfigSeparatorEntry(char *ptr) { const char *createConfigForm() { char *ptr = message; - char tmp[4]; strcpy(ptr, "
"); for (int i = 0; i < N_CONFIG; i++) { switch (config_list[i].type) { @@ -466,7 +467,6 @@ const char *createConfigForm() { 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"); @@ -499,6 +499,7 @@ const char *handleConfigPost(AsyncWebServerRequest *request) { f.close(); currentDisplay = sonde.config.display; setupConfigData(); + return ""; } const char *ctrlid[] = {"rx", "scan", "spec", "wifi", "rx2", "scan2", "spec2", "wifi2"}; @@ -561,6 +562,7 @@ const char *handleControlPost(AsyncWebServerRequest *request) { button2.pressed = KP_LONG; } } + return ""; } // bad idea. prone to buffer overflow. use at your own risk... @@ -607,7 +609,6 @@ const char *handleEditPost(AsyncWebServerRequest *request) { const char *createUpdateForm(boolean run) { char *ptr = message; - char tmp[4]; strcpy(ptr, ""); if (run) { strcat(ptr, "

Doing update, wait until reboot

"); @@ -635,6 +636,7 @@ const char *handleUpdatePost(AsyncWebServerRequest *request) { } Serial.println("Updating: " + *updateBin); enterMode(ST_UPDATE); + return ""; } @@ -1172,10 +1174,10 @@ void loopDecoder() { #endif // sonde knows the current type and frequency, and delegates to the right decoder int res = sonde.waitRXcomplete(); - int action, event; + int action, event = 0; if ((res >> 8) == 0xFF) { // no implicit action returned from RXTask // Handle events that change display or sonde - uint8_t event = getKeyPressEvent(); + event = getKeyPressEvent(); if (!event) event = sonde.timeoutEvent(); // Check if there is an action for this event Serial.printf("Event: %d\n", event); @@ -1201,7 +1203,7 @@ void loopDecoder() { if (0 && res == 0 && connected) { //Send a packet with position information // first check if ID and position lat+lonis ok - if (sonde.si()->validID && (sonde.si()->validPos & 0x03 == 0x03)) { + if (sonde.si()->validID && ((sonde.si()->validPos & 0x03) == 0x03)) { Serial.println("Sending position via UDP"); SondeInfo *s = sonde.si(); char raw[201]; @@ -1309,7 +1311,7 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) { case (WIFI_AUTH_OPEN): return "Open"; case (WIFI_AUTH_WEP): - return "WEP"; + return "WEP"; case (WIFI_AUTH_WPA_PSK): return "WPA_PSK"; case (WIFI_AUTH_WPA2_PSK): @@ -1318,6 +1320,8 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) { return "WPA_WPA2_PSK"; case (WIFI_AUTH_WPA2_ENTERPRISE): return "WPA2_ENTERPRISE"; + default: + return ""; } } @@ -1427,11 +1431,13 @@ void WiFiEvent(WiFiEvent_t event) case SYSTEM_EVENT_ETH_GOT_IP: Serial.println("Obtained IP address"); break; + default: + break; } } -int wifiConnect(int16_t res) { +void wifiConnect(int16_t res) { Serial.printf("WLAN scan result: found %d networks\n", res); // pick best network @@ -1570,8 +1576,6 @@ void loopWifiScan() { int line = 0; int cnt = 0; - int marker = 0; - char buf[5]; WiFi.disconnect(true); WiFi.mode(WIFI_STA); diff --git a/libraries/SondeLib/DFM.cpp b/libraries/SondeLib/DFM.cpp index bbc650c..227a5c8 100644 --- a/libraries/SondeLib/DFM.cpp +++ b/libraries/SondeLib/DFM.cpp @@ -77,13 +77,13 @@ int DFM::setup(float frequency, int inv) } -#define bit(value,bitpos) ((value>>(7-bitpos))&0x01) +#define bitpick(value,bitpos) (((value)>>(7-(bitpos)))&0x01) // Input: str: packed data, MSB first void DFM::deinterleave(uint8_t *str, int L, uint8_t *block) { int i, j; for (j = 0; j < B; j++) { // L = 7 (CFG), 13 (DAT1, DAT2) for (i = 0; i < L; i++) { - block[B*i+j] = bit( str[(L*j+i)/8], (L*j+i)&7 )?0:1; + block[B*i+j] = bitpick( str[(L*j+i)/8], (L*j+i)&7 )?0:1; } } } diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 80273c7..27431e7 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -146,7 +146,7 @@ void Display::setLayout(int layoutIdx) { void Display::drawLat(DispEntry *de) { SETFONT(de->fmt); if(!sonde.si()->validPos) { - u8x8->drawString(de->x,de->y," "); + u8x8->drawString(de->x,de->y," "); return; } snprintf(buf, 16, "%2.5f", sonde.si()->lat); @@ -155,7 +155,7 @@ void Display::drawLat(DispEntry *de) { void Display::drawLon(DispEntry *de) { SETFONT(de->fmt); if(!sonde.si()->validPos) { - u8x8->drawString(de->x,de->y," "); + u8x8->drawString(de->x,de->y," "); return; } snprintf(buf, 16, "%2.5f", sonde.si()->lon); diff --git a/libraries/SondeLib/RS92.cpp b/libraries/SondeLib/RS92.cpp index 636e8ae..b636627 100644 --- a/libraries/SondeLib/RS92.cpp +++ b/libraries/SondeLib/RS92.cpp @@ -584,7 +584,7 @@ int RS92::receive() { int RS92::waitRXcomplete() { int res=0; uint32_t t0 = millis(); - while( rxtask.receiveResult < 0 && millis()-t0 < 2000) { delay(20); } + while( rxtask.receiveResult == 0xFFFF && millis()-t0 < 2000) { delay(20); } if( rxtask.receiveResult<0 || rxtask.receiveResult==RX_TIMEOUT) { res = RX_TIMEOUT; @@ -593,7 +593,7 @@ int RS92::waitRXcomplete() { } else { res = RX_ERROR; } - rxtask.receiveResult = -1; + rxtask.receiveResult = 0xFFFF; Serial.printf("RS92::waitRXcomplete returning %d (%s)\n", res, RXstr[res]); return res; } diff --git a/libraries/SondeLib/nav_gps_vel.inc b/libraries/SondeLib/nav_gps_vel.inc index 437114a..a5b8ce6 100644 --- a/libraries/SondeLib/nav_gps_vel.inc +++ b/libraries/SondeLib/nav_gps_vel.inc @@ -8,7 +8,9 @@ */ #include +#ifndef PI #define PI (3.1415926535897932384626433832795) +#endif #define RELATIVISTIC_CLOCK_CORRECTION (-4.442807633e-10) // combined constant defined in IS-GPS-200 [s]/[sqrt(m)] #define GRAVITY_CONSTANT (3.986005e14) // gravity constant defined on IS-GPS-200 [m^3/s^2] diff --git a/libraries/SondeLib/rs92gps.inc b/libraries/SondeLib/rs92gps.inc index 16f2094..ccf7f71 100644 --- a/libraries/SondeLib/rs92gps.inc +++ b/libraries/SondeLib/rs92gps.inc @@ -632,7 +632,7 @@ int get_Cal() { #include "nav_gps_vel.inc" -EPHEM_t alm[33]; +//we only use ephs EPHEM_t alm[33]; //EPHEM_t eph[33][24]; EPHEM_t *ephs = NULL; @@ -713,6 +713,8 @@ void prn12(uint8_t *prn_le, uint8_t prns[12]) { int calc_satpos_alm(EPHEM_t alm[], double t, SAT_t *satp) { + return -1; +#if 0 double X, Y, Z, vX, vY, vZ; int j; int week; @@ -754,6 +756,7 @@ int calc_satpos_alm(EPHEM_t alm[], double t, SAT_t *satp) { } return 0; +#endif } int calc_satpos_rnx(EPHEM_t eph[][24], double t, SAT_t *satp) { @@ -931,12 +934,12 @@ int get_pseudorange() { // GPS Sat Pos (& Vel) - if (almanac) calc_satpos_alm( alm, gpstime/1000.0, sat); + //if (almanac) calc_satpos_alm( alm, gpstime/1000.0, sat); if (ephem) calc_satpos_rnx2(ephs, gpstime/1000.0, sat); // GPS Sat Pos t -= 1s if (option_vel == 1) { - if (almanac) calc_satpos_alm( alm, gpstime/1000.0-1, sat1s); + //if (almanac) calc_satpos_alm( alm, gpstime/1000.0-1, sat1s); if (ephem) calc_satpos_rnx2(ephs, gpstime/1000.0-1, sat1s); }
OptionValue