From ca3fa52a3bd2f0047e391e87f9060d034961421c Mon Sep 17 00:00:00 2001
From: "Hans P. Reiser"
Date: Sun, 28 Apr 2019 14:33:53 +0200
Subject: [PATCH] v0.5: merging modifications from devel branch - DL2MF's
commits - WiFi connection in background
Squashed commit of the following:
commit 5c37b3f0fa64d5fd991c03e4e04ad5575b4d780f
Author: Hans P. Reiser
Date: Sun Apr 28 14:17:52 2019 +0200
version from config.h also for html page; minor polishing
commit 9fea636d2078811932f2ed53af37370468db6697
Author: Hans P. Reiser
Date: Sun Apr 28 14:17:37 2019 +0200
version from config.h also for html page; minor polishing
commit 75eb15cc243c8ea0ada23e4f4e109467f4c0cd48
Author: Hans P. Reiser
Date: Sun Apr 28 13:29:58 2019 +0200
version info in version.h, some code formatting (arduino style)
commit 8da577a3138899314dbf8abb81bff0bd28ca1614
Author: Hans P. Reiser
Date: Sun Apr 28 13:29:53 2019 +0200
version info in version.h, some code formatting (arduino style)
commit b68ffee8b031689493e1946941d7ca60b32297f1
Author: Mike
Date: Sat Apr 27 20:54:20 2019 +0200
merging DL2MF's 71cc86cff064682e7774635d236541d7140bc819
commit c67a4fc734e415521b477847600e46bec8269230
Author: DL2MF
Date: Sat Apr 27 00:10:11 2019 +0200
merging DL2MF's e2161c57d10a61d15debd4c298984e1dca3787ec
commit 6e665cb6ab794d2c6536488a641532671186d7de
Author: DL2MF
Date: Fri Apr 26 19:21:11 2019 +0200
merging DL2MF's 25b438db84f4ca708250e2cd287c01a30a054fb7 to current devel branch
commit b467f25c05fc84976148a1b210e2c5300b1cb53e
Author: Hans P. Reiser
Date: Fri Apr 26 23:54:36 2019 +0200
working new Wifi support
commit 2959dfad4f6bf7943f3ec4c758be4989c5612f06
Author: Hans P. Reiser
Date: Fri Apr 26 23:09:09 2019 +0200
background wifi scan/connected/reconnect. partial code, incomplete, for testing station mode only (wifi=1)
---
RX_FSK/RX_FSK.ino | 956 +++++++++++++++++++++------------
RX_FSK/data/config.txt | 4 +-
RX_FSK/data/index.html | 13 +-
RX_FSK/version.h | 2 +
libraries/SondeLib/Scanner.cpp | 4 +
libraries/SondeLib/Sonde.cpp | 9 +-
libraries/SondeLib/Sonde.h | 5 +-
7 files changed, 625 insertions(+), 368 deletions(-)
create mode 100644 RX_FSK/version.h
diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino
index 4fb310d..741c08d 100644
--- a/RX_FSK/RX_FSK.ino
+++ b/RX_FSK/RX_FSK.ino
@@ -10,15 +10,15 @@
#include
#include
#include
-
-#define LORA_LED 9
+#include "version.h"
// UNCOMMENT one of the constructor lines below
-U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8=NULL; // initialize later after reading config file
+U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8 = NULL; // initialize later after reading config file
//U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Unbuffered, basic graphics, software I2C
//U8G2_SSD1306_128X64_NONAME_1_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Page buffer, SW I2C
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C Display(U8G2_R0, /* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ OLED_RST); // Full framebuffer, SW I2C
+int LORA_LED = 9; // default POUT for LORA LED used as serial monitor
int e;
AsyncWebServer server(80);
@@ -34,33 +34,39 @@ int ledPin = 1;
String ledState;
// Replaces placeholder with LED state value
-String processor(const String& var){
+String processor(const String& var) {
Serial.println(var);
- if(var == "STATE"){
- if(digitalRead(ledPin)){
+ if (var == "STATE") {
+ if (digitalRead(ledPin)) {
ledState = "ON";
}
- else{
+ else {
ledState = "OFF";
}
Serial.print(ledState);
return ledState;
}
+ if(var == "VERSION_NAME") {
+ return String(version_name);
+ }
+ if(var == "VERSION_ID") {
+ return String(version_id);
+ }
return String();
}
-#define MAX_QRG 10
-
const String sondeTypeSelect(int activeType) {
String sts = "";
- for(int i=0; i<3; i++) {
- sts += "";
+ for (int i = 0; i < 3; i++) {
+ sts += "";
}
return sts;
}
@@ -75,29 +81,35 @@ char message[10240];
void setupChannelList() {
File file = SPIFFS.open("/qrg.txt", "r");
- if(!file) {
+ if (!file) {
Serial.println("There was an error opening the file '/qrg.txt' for reading");
return;
}
- int i=0;
+ int i = 0;
sonde.clearSonde();
- Serial.println("Reading channel config:");
- while(file.available()) {
+ Serial.println("Reading channel config:");
+ while (file.available()) {
String line = file.readStringUntil('\n');
- if(!file.available()) break;
- if(line[0] == '#') continue;
+ if (!file.available()) break;
+ if (line[0] == '#') continue;
char *space = strchr(line.c_str(), ' ');
- if(!space) continue;
+ if (!space) continue;
*space = 0;
float freq = atof(line.c_str());
SondeType type;
- if(space[1]=='4') { type=STYPE_RS41; }
- else if (space[1]=='9') { type=STYPE_DFM09; }
- else if (space[1]=='6') { type=STYPE_DFM06; }
+ if (space[1] == '4') {
+ type = STYPE_RS41;
+ }
+ else if (space[1] == '9') {
+ type = STYPE_DFM09;
+ }
+ else if (space[1] == '6') {
+ type = STYPE_DFM06;
+ }
else continue;
- int active = space[3]=='+'?1:0;
+ int active = space[3] == '+' ? 1 : 0;
char *launchsite = strchr(line.c_str(), ' ');
- Serial.printf("Add %f - type %d (on/off: %d)- Site: \n",freq,type,active,launchsite);
+ Serial.printf("Add %f - type %d (on/off: %d)- Site: \n", freq, type, active, launchsite);
sonde.addSonde(freq, type, active, launchsite);
i++;
}
@@ -105,19 +117,19 @@ void setupChannelList() {
const char *createQRGForm() {
char *ptr = message;
- strcpy(ptr,"");
- return message;
+ strcpy(ptr, "");
+ return message;
}
const char *handleQRGPost(AsyncWebServerRequest *request) {
@@ -125,7 +137,7 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
// parameters: a_i, f_1, t_i (active/frequency/type)
#if 1
File f = SPIFFS.open("/qrg.txt", "w");
- if(!f) {
+ if (!f) {
Serial.println("Error while opening '/qrg.txt' for writing");
return "Error while opening '/qrg.txt' for writing";
}
@@ -133,29 +145,29 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
Serial.println("Handling post request");
#if 0
int params = request->params();
- for(int i=0; igetParam(i)->name().c_str());
}
#endif
- for(int i=1; i<=MAX_QRG; i++) {
+ for (int i = 1; i <= sonde.config.maxsonde; i++) {
snprintf(label, 10, "A%d", i);
AsyncWebParameter *active = request->getParam(label, true);
snprintf(label, 10, "F%d", i);
AsyncWebParameter *freq = request->getParam(label, true);
- if(!freq) continue;
+ if (!freq) continue;
snprintf(label, 10, "T%d", i);
AsyncWebParameter *type = request->getParam(label, true);
- if(!type) continue;
+ if (!type) continue;
const char *fstr = freq->value().c_str();
const char *tstr = type->value().c_str();
- Serial.printf("Processing a=%s, f=%s, t=%s\n", active?"YES":"NO", fstr, tstr);
- char typech = (tstr[2]=='4'?'4':tstr[3]); // Ugly TODO
- f.printf("%3.3f %c %c\n", atof(fstr), typech, active?'+':'-');
+ Serial.printf("Processing a=%s, f=%s, t=%s\n", active ? "YES" : "NO", fstr, tstr);
+ char typech = (tstr[2] == '4' ? '4' : tstr[3]); // Ugly TODO
+ f.printf("%3.3f %c %c\n", atof(fstr), typech, active ? '+' : '-');
}
f.close();
Serial.println("Channel setup finished");
Serial.println();
-
+
setupChannelList();
}
@@ -164,45 +176,52 @@ const char *handleQRGPost(AsyncWebServerRequest *request) {
#define MAX_WIFI 10
int nNetworks;
-struct { String id; String pw; } networks[MAX_WIFI];
+struct {
+ String id;
+ String pw;
+} networks[MAX_WIFI];
// FIXME: For now, we don't uspport wifi networks that contain newline or null characters
// ... would require a more sophisicated file format (currently one line SSID; one line Password
void setupWifiList() {
File file = SPIFFS.open("/networks.txt", "r");
- if(!file){
+ if (!file) {
Serial.println("There was an error opening the file '/networks.txt' for reading");
return;
}
- int i=0;
-
- while(file.available()) {
+ int i = 0;
+
+ while (file.available()) {
String line = file.readStringUntil('\n');
- if(!file.available()) break;
- networks[i].id = line;
- networks[i].pw = file.readStringUntil('\n');
- i++;
+ if (!file.available()) break;
+ networks[i].id = line;
+ networks[i].pw = file.readStringUntil('\n');
+ i++;
}
nNetworks = i;
Serial.print(i); Serial.println(" networks in networks.txt\n");
- for(int j=0; j