From 69cb203a4f0425af82958d6bf097ce45d0f5efe0 Mon Sep 17 00:00:00 2001
From: "Hans P. Reiser"
Date: Fri, 12 Apr 2019 18:53:29 +0200
Subject: [PATCH] merging devel changes 0d64f8d..9b0785b
---
README.md | 17 ++
RX_FSK/RX_FSK.ino | 364 +++++++++++++++++++++++++++------
RX_FSK/data/index.html | 58 ++++--
RX_FSK/data/networks.txt | 2 +
RX_FSK/data/qrg.txt | 8 +-
RX_FSK/data/style.css | 47 +++++
Setup.md | 66 ++++++
libraries/SondeLib/Scanner.cpp | 34 ++-
libraries/SondeLib/Sonde.cpp | 32 ++-
libraries/SondeLib/Sonde.h | 12 +-
libraries/SondeLib/aprs.cpp | 286 ++++++++++++++++++++++++++
libraries/SondeLib/aprs.h | 21 ++
12 files changed, 849 insertions(+), 98 deletions(-)
create mode 100644 Setup.md
create mode 100644 libraries/SondeLib/aprs.cpp
create mode 100644 libraries/SondeLib/aprs.h
diff --git a/README.md b/README.md
index 0b60bc9..562f1bc 100644
--- a/README.md
+++ b/README.md
@@ -43,3 +43,20 @@ A SHORT press will switch to the next channel in channels.txt
A medium press will active scan the whole band (400..406 MHz) and display a
spectrum diagram (each line == 50 kHz)
+
+## Setup
+
+Download https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
+and move to your Arduino IDE's libraries directory
+Rename to (name without "-master")
+
+Download https://github.com/me-no-dev/AsyncTCP/archive/master.zip
+and move to your Arduino IDE's libraries directory
+Rename to (name without "-master")
+
+Install Arduino ESP32 file system uploader
+https://randomnerdtutorials.com/install-esp32-filesystem-uploader-arduino-ide/
+Download https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/download/1.0/ESP32FS-1.0.zip
+Move to your Arduino IDE's tools directory
+
+
diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino
index ec03589..f49d51c 100644
--- a/RX_FSK/RX_FSK.ino
+++ b/RX_FSK/RX_FSK.ino
@@ -1,4 +1,5 @@
#include
+#include
#include
#include
#include
@@ -7,6 +8,7 @@
#include
#include
#include
+#include
//#include
//#include
@@ -26,6 +28,13 @@ int e;
AsyncWebServer server(80);
+const char * udpAddress = "192.168.179.21";
+const int udpPort = 9002;
+
+boolean connected = false;
+WiFiUDP udp;
+
+
// Set LED GPIO
const int ledPin = 2;
// Stores LED state
@@ -48,58 +57,29 @@ String processor(const String& var){
return String();
}
-void SetupAsyncServer() {
-// Route for root / web page
- server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
- request->send(200, "text/plain", "Hello, world");
- });
-
- server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest *request){
- request->send(SPIFFS, "/index.html", String(), false, processor);
- });
-
- // Route to load style.css file
- server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
- request->send(SPIFFS, "/style.css", "text/css");
- });
+#define MAX_QRG 10
- // Route to set GPIO to HIGH
- server.on("/on", HTTP_GET, [](AsyncWebServerRequest *request){
- digitalWrite(ledPin, HIGH);
- request->send(SPIFFS, "/index.html", String(), false, processor);
- });
-
- // Route to set GPIO to LOW
- server.on("/off", HTTP_GET, [](AsyncWebServerRequest *request){
- digitalWrite(ledPin, LOW);
- request->send(SPIFFS, "/index.html", String(), false, processor);
- });
-
- // Start server
- server.begin();
+const String sondeTypeSelect(int activeType) {
+ String sts = "";
+ for(int i=0; i<3; i++) {
+ sts += "";
+ }
+ return sts;
}
-int nNetworks;
-struct { String id; String pw; } networks[20];
-void setupWifiList() {
- File file = SPIFFS.open("/networks.txt", "r");
- if(!file){
- Serial.println("There was an error opening the file '/networks.txt' for reading");
- return;
- }
- 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++;
- }
- nNetworks = i;
- Serial.print(i); Serial.println(" networks in networks.txt\n");
- for(int j=0; jsend is called in createQRGForm!?!??
+char message[10240];
+
+///////////////////////// Functions for Reading / Writing QRG list from/to qrg.txt
void setupChannelList() {
File file = SPIFFS.open("/qrg.txt", "r");
@@ -122,16 +102,241 @@ void setupChannelList() {
else if (space[1]=='9') { type=STYPE_DFM09; }
else if (space[1]=='6') { type=STYPE_DFM06; }
else continue;
- Serial.printf("Adding %f with type %d\b",freq,type);
- sonde.addSonde(freq, type);
+ int active = space[3]=='+'?1:0;
+ Serial.printf("Adding %f with type %d (active: %d)\n",freq,type,active);
+ sonde.addSonde(freq, type, active);
i++;
}
+}
+
+const char *createQRGForm() {
+ char *ptr = message;
+ strcpy(ptr,"");
+ return message;
+}
+
+const char *handleQRGPost(AsyncWebServerRequest *request) {
+ char label[10];
+ // parameters: a_i, f_1, t_i (active/frequency/type)
+#if 1
+ File f = SPIFFS.open("/qrg.txt", "w");
+ if(!f) {
+ Serial.println("Error while opening '/qrg.txt' for writing");
+ return "Error while opening '/qrg.txt' for writing";
+ }
+#endif
+ 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++) {
+ 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;
+ snprintf(label, 10, "T%d", i);
+ AsyncWebParameter *type = request->getParam(label, true);
+ 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?'+':'-');
+ }
+ f.close();
+ setupChannelList();
+}
+
+
+/////////////////// Functions for reading/writing Wifi networks from networks.txt
+
+#define MAX_WIFI 10
+int nNetworks;
+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){
+ Serial.println("There was an error opening the file '/networks.txt' for reading");
+ return;
+ }
+ 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++;
+ }
nNetworks = i;
Serial.print(i); Serial.println(" networks in networks.txt\n");
for(int j=0; j