some cleanup

This commit is contained in:
Hansi, dl9rdz 2019-05-30 23:27:33 +02:00
parent fc60655dfa
commit 15902b0230
6 changed files with 29 additions and 20 deletions

View File

@ -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, "<table>");
sprintf(ptr + strlen(ptr), "<tr><td id=\"sfreq\">%3.3f MHz, Type: %s</td><tr><td>ID: %s</td></tr><tr><td>QTH: %.6f,%.6f h=%.0fm</td></tr>\n",
s->freq, sondeTypeStr[s->type],
s->validID ? s->id : "<??>",
s->validID ? s->id : "<?""?>",
s->lat, s->lon, s->alt);
sprintf(ptr + strlen(ptr), "<tr><td><a target=\"_empty\" href=\"geo:%.6f,%.6f\">GEO-App</a> - ", s->lat, s->lon);
sprintf(ptr + strlen(ptr), "<a target=\"_empty\" href=\"https://wx.dl2mf.de/?%s\">WX.DL2MF.de</a> - ", s->id);
@ -439,7 +441,6 @@ void addConfigSeparatorEntry(char *ptr) {
const char *createConfigForm() {
char *ptr = message;
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>Option</th><th>Value</th></tr>");
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, "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"></head><body><form action=\"update.html\" method=\"post\">");
if (run) {
strcat(ptr, "<p>Doing update, wait until reboot</p>");
@ -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);

View File

@ -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;
}
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -8,7 +8,9 @@
*/
#include <inttypes.h>
#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]

View File

@ -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);
}