commit e98d8e9b339847287fb84f933456c05b46695444 Author: Xavier Date: Sat Dec 10 14:57:48 2022 +0100 first commit diff --git a/Display.pdf b/Display.pdf new file mode 100644 index 0000000..6da7c7b Binary files /dev/null and b/Display.pdf differ diff --git a/README.md b/README.md new file mode 100755 index 0000000..bb159d3 --- /dev/null +++ b/README.md @@ -0,0 +1,296 @@ + RadioSonde Version 1.0.0 +============================ + + + + + + + + + +Projet basé sur le travail de DL9RDZ +==================================== + +Pour TTGO LORA 32 esp32 pico D4
+Décodage de RadioSonde RS41/92 and DFM06/09/17 et M10+/20 et MP3H + +Attention à la version de votre TTGO!
+vous devez modifier dans config.txt, le port de l'écran OLED
+- TTGO v1: SDA=4 SCL=15, RST=16
+- TTGO v2: SDA=21 SCL=22, RST=16
+- puis pour le GPS:
+ Lilygo esp32 GPS pin 34 Rx, 12 Tx
+- puis Buzzer
+ par defaut 4 si gps mettre 2
+- puis led
+ par defaut 25
+ +## Version en production 1.0.0 devel 1.0.1 + +## 1.0.0 +refonte du system OS, et des pages Web
+toujours avec la gestion:
+- du buzzer
+- du db ou smetre
+- de la vbat nouvelle gestion(plus necessaire calibrage)
+- suppression du mode telemetry export csv
+- suppression de la bousole
+- importation des RadioSonde Thank's DL9RDZ
+- gestion update OTA
+ +## 0.9.2 +Correctif Dash SiteWeb config +ADD API SondeHub Thank's DL9RDZ + +## 0.9.1 +Corection RS41
+Correction DFM 06/09
+Add DFM17
+Correction for all trame recived for M10 and M20 1000ms to 1512ms,
+Correction formulaire QRG, and end RS no save + +## 0.9.0 +Add M20 + +## 0.8.8 + +Add M10+
+Add Temps restant avant impacte au sol si 99: 0. 0 soit le balon de la sonde n a pas encore éclaté,
+ou les informations ne sont pas disponible actuellement
+Add Test Buzzer au démarrage "Arche Perdu" Lol pour des chasseurs de sonde!
+Compatible Lilygo esp32 GPS inboard pin 34 Rx, 12 Tx + +## 0.8.7 + +correction bug Buzzer Off->On->Off
+Add GainLNA RX SX1278FSK on Web config paramètre
+Add update OTA Os + DataWeb
+correction bugs sondmap.html
+correction text upgrade Os et DataWeb
+correction texte boussole S et N
+correction bugs distance 4928Km si lat et lon =0 erroné
+correction bugs fonction Vbat
+Add Telemetry width export data.csv
+Suppression µSD incompatible avec pin SX1278FSK et SPI
+Add transfert Telemetry To µSD on put SD automatic + +## 0.8.5 + +Evolution majeur du système
+affichage du pourcentage de la batterie en mode scanning
+création d'une fenetre Batterie, Boussole
+suppresion lib et code TFT
+création Azimute, elevation correction de Bugs majeur , mineur
+Ajout fonction Smetre, Buzzer, QTH, Gps on off ...
+mise à jour OTA
+trop de modification pour toutes les expliciter! + +## 0.8.1 + +modification de la partie Web + +## 0.8.0 + +travail de refonte et réécriture du code + +------------------------------------------------------------------------------- + +## Les Boutons optionnel à ajouter(souder) +sur les GPIO 1002 et 1004
+attention: + ++3.3V--[ SW ]---GPIO----[ R1 ]---/ R1=10 ou 12KOhms + +- appuie court <1.5 seconds
+- appuie double court 0.5 seconds
+- appuie moyen 2-4 seconds
+- appuie long >5 seconds + +## Buzzer optionnel à ajouter(souder) +sur les GPIO 25 ou 12 suivant le modèl + +GPIO --[ BUZZER ]---/ + +## Wifi configuration + +Au démarrage, si aucune connexion possible au wifi paramètré, il monte un Wifi AP
+le SSID et mot de passe par défaut est: Radiosonde
+en mode AP, il doit être en 192.168.4.1,
+mais vous avez aussi la possibilité de mettre http://radiosonde.local dans n'importe quel Wifi +connecté. + + + +## Mode Scanne + +Le fichier qrg.txt contient la liste par défaut des cannaux. +pour y configurer les noms, fréquences et mode [M=M10, 6=DFM06, 9=DFM09 et 4=RS41] + + +## Mode Réception + +En réception, une seul fréquence est décodé, les infos de la sonde (ID, GPS, RSSI, ...) +seront affichées dans plusieur fenetre à choisir ( 0 à 6) à configurer dans la page Web +rubrique config. +In receiving mode, a single frequency will be decoded, and sonde info (ID, GPS +coordinates, RSSI) will be displayed. The bar above the IP address indicates, +for the last 18 frames, if reception was successfull (|) or failed (.) +A DOUBLE press will switch to scanning mode. +A SHORT press will switch to the next channel in channels.txt + +## Mode Analyseur + +Le mode analyseur de spectre (400..406 MHz) est affiché (chaque ligne == 50 kHz) +Pour les cartes TTGO sans bouton configurable, il y a un nouveau paramètre dans config.txt: +- spectrum=10 // 0=off / 1-99 nombre de seconds pour afficher l'analyseur +- timer=1 // 0=off / 1= afficher le compte à rebours du spectre dans l'affichage du spectre +- marker=1 // 0=off / 1= afficher la fréquence dans l'affichage du spectre + +## Setup + +voir Setup.md pour l'installation! + +73 +Xavier + + + + RadioSonde Version 0.9.1 +============================ + + + + + + + + + +Projet basé sur le travail de DL9RDZ +==================================== + +Pour TTGO LORA 32 esp32 pico D4
+Décodage de RadioSonde RS41/92 and DFM06/09/17 et M10+/20 + +Attention à la version de votre TTGO!
+vous devez modifier dans config.txt, le port de l'écran OLED
+- TTGO v1: SDA=4 SCL=15, RST=16
+- TTGO v2: SDA=21 SCL=22, RST=16 + +## Version en production 0.9.1 devel 0.9.2 + +## 0.9.1 +Corection RS41
+Correction DFM 06/09
+Add DFM17
+Correction for all trame recived for M10 and M20 1000ms to 1512ms,
+Correction formulaire QRG, and end RS no save + +## 0.9.0 +Add M20 + +## 0.8.8 + +Add M10+
+Add Temps restant avant impacte au sol si 99: 0. 0 soit le balon de la sonde n a pas encore éclaté,
+ou les informations ne sont pas disponible actuellement
+Add Test Buzzer au démarrage "Arche Perdu" Lol pour des chasseurs de sonde!
+Compatible Lilygo esp32 GPS inboard pin 34 Rx, 12 Tx + +## 0.8.7 + +correction bug Buzzer Off->On->Off
+Add GainLNA RX SX1278FSK on Web config paramètre
+Add update OTA Os + DataWeb
+correction bugs sondmap.html
+correction text upgrade Os et DataWeb
+correction texte boussole S et N
+correction bugs distance 4928Km si lat et lon =0 erroné
+correction bugs fonction Vbat
+Add Telemetry width export data.csv
+Suppression µSD incompatible avec pin SX1278FSK et SPI
+Add transfert Telemetry To µSD on put SD automatic + +## 0.8.5 + +Evolution majeur du système
+affichage du pourcentage de la batterie en mode scanning
+création d'une fenetre Batterie, Boussole
+suppresion lib et code TFT
+création Azimute, elevation correction de Bugs majeur , mineur
+Ajout fonction Smetre, Buzzer, QTH, Gps on off ...
+mise à jour OTA
+trop de modification pour toutes les expliciter! + +## 0.8.1 + +modification de la partie Web + +## 0.8.0 + +travail de refonte et réécriture du code + +------------------------------------------------------------------------------- + +## Les Boutons optionnel à ajouter(souder) +sur les GPIO 1002 et 1004
+attention: + ++3.3V--[ SW ]---GPIO----[ R1 ]---/ R1=10 ou 12KOhms + +- appuie court <1.5 seconds
+- appuie double court 0.5 seconds
+- appuie moyen 2-4 seconds
+- appuie long >5 seconds + +## Buzzer optionnel à ajouter(souder) +sur les GPIO 25 ou 12 suivant le modèl + +GPIO --[ BUZZER ]---/ + +## Wifi configuration + +Au démarrage, si aucune connexion possible au wifi paramètré, il monte un Wifi AP
+le SSID et mot de passe par défaut est: Radiosonde
+en mode AP, il doit être en 192.168.4.1,
+mais vous avez aussi la possibilité de mettre http://radiosonde.local dans n'importe quel Wifi +connecté. + + + +## Mode Scanne + +Le fichier qrg.txt contient la liste par défaut des cannaux. +pour y configurer les noms, fréquences et mode [M=M10, 6=DFM06, 9=DFM09 et 4=RS41] + + +## Mode Réception + +En réception, une seul fréquence est décodé, les infos de la sonde (ID, GPS, RSSI, ...) +seront affichées dans plusieur fenetre à choisir ( 0 à 6) à configurer dans la page Web +rubrique config. +In receiving mode, a single frequency will be decoded, and sonde info (ID, GPS +coordinates, RSSI) will be displayed. The bar above the IP address indicates, +for the last 18 frames, if reception was successfull (|) or failed (.) +A DOUBLE press will switch to scanning mode. +A SHORT press will switch to the next channel in channels.txt + +## Mode Analyseur + +Le mode analyseur de spectre (400..406 MHz) est affiché (chaque ligne == 50 kHz) +Pour les cartes TTGO sans bouton configurable, il y a un nouveau paramètre dans config.txt: +- spectrum=10 // 0=off / 1-99 nombre de seconds pour afficher l'analyseur +- timer=1 // 0=off / 1= afficher le compte à rebours du spectre dans l'affichage du spectre +- marker=1 // 0=off / 1= afficher la fréquence dans l'affichage du spectre + +## Setup + +voir Setup.md pour l'installation! + +73 +Xavier + + + + diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino new file mode 100644 index 0000000..ffbf127 --- /dev/null +++ b/RX_FSK/RX_FSK.ino @@ -0,0 +1,3874 @@ +#include "features.h" +#include "version.h" + +#include "axp20x.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "esp_heap_caps.h" +#include "soc/rtc_wdt.h" + +#include "src/SX1278FSK.h" +#include "src/Sonde.h" +#include "src/Display.h" +#include "src/Scanner.h" +#include "src/geteph.h" +#include "src/rs92gps.h" +#include "src/aprs.h" +#include "src/ShFreqImport.h" +#include "src/RS41.h" +#include "src/json.h" +#if FEATURE_CHASEMAPPER +#include "src/Chasemapper.h" +#endif + +#if FEATURE_MQTT +#include "src/mqtt.h" +#endif + +//#define ESP_MEM_DEBUG 1 +//int e; + +enum MainState { ST_DECODER, ST_SPECTRUM, ST_WIFISCAN, ST_UPDATE, ST_TOUCHCALIB }; +static MainState mainState = ST_WIFISCAN; // ST_WIFISCAN; +const char *mainStateStr[5] = {"DECODER", "SPECTRUM", "WIFISCAN", "UPDATE", "TOUCHCALIB" }; + +AsyncWebServer server(80); +AsyncWebSocket ws("/ws"); + +AXP20X_Class axp; +#define PMU_IRQ 35 +SemaphoreHandle_t axpSemaphore; +// 0: cleared; 1: set; 2: do not check, also query state of axp via i2c on each loop +uint8_t pmu_irq = 0; + +String updateHost = "xavier.debert.free.fr"; +int updatePort = 80; +String updateBinM = "/RS/radiosonde/update.ino.bin"; +String updateBinD = "/RS/radiosondedevel/update.ino.bin"; +String *updateBin = &updateBinM; +String updateDataWeb = "/RS/dataweb/data.tar"; + +#define LOCALUDPPORT 14580 +//Get real UTC time from NTP server +const char* ntpServer = "pool.ntp.org"; +const long gmtOffset_sec = 0; //UTC +const int daylightOffset_sec = 0; //UTC + +boolean connected = false; +WiFiUDP udp; +WiFiClient client; + +/* Sonde.h: enum SondeType { STYPE_DFM,, STYPE_RS41, STYPE_RS92, STYPE_M10M20, STYPE_M10, STYPE_M20, STYPE_MP3H }; */ +const char *sondeTypeStrSH[NSondeTypes] = { "DFM", "RS41", "RS92", "Mxx"/*never sent*/, "M10", "M20", "MRZ" }; +const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL, + "DFM06", // 0x06 + "PS15", // 0x07 + NULL, NULL, + "DFM09", // 0x0A + "DFM17", // 0x0B + "DFM09P", // 0x0C + "DFM17", // 0x0D + NULL, NULL + }; + +// Times in ms, i.e. station: 10 minutes, mobile: 20 seconds +#define APRS_STATION_UPDATE_TIME (10*60*1000) +#define APRS_MOBILE_STATION_UPDATE_TIME (20*1000) +unsigned long time_last_aprs_update = -APRS_STATION_UPDATE_TIME; + +#if FEATURE_SONDEHUB +#define SONDEHUB_STATION_UPDATE_TIME (60*60*1000) // 60 min +#define SONDEHUB_MOBILE_STATION_UPDATE_TIME (30*1000) // 30 sec +WiFiClient shclient; // Sondehub v2 +int shImportInterval = 0; +char shImport = 0; +unsigned long time_last_update = 0; +#endif +/* SH_LOC_OFF: never send position information to SondeHub + SH_LOC_FIXED: send fixed position (if specified in config) to sondehub + SH_LOC_CHASE: always activate chase mode and send GPS position (if available) + SH_LOC_AUTO: if there is no valid GPS position, or GPS position < MIN_LOC_AUTO_DIST away from known fixed position: use FIXED mode + otherwise, i.e. if there is a valid GPS position and (either no fixed position in config, or GPS position is far away from fixed position), use CHASE mode. +*/ +// same constants used for SondeHub and APRS +enum { SH_LOC_OFF, SH_LOC_FIXED, SH_LOC_CHASE, SH_LOC_AUTO }; +/* auto mode is chase if valid GPS position and (no fixed location entered OR valid GPS position and distance in lat/lon deg to fixed location > threshold) */ +#define MIN_LOC_AUTO_DIST 200 /* meter */ +#define SH_LOC_AUTO_IS_CHASE ( gpsPos.valid && ( (isnan(sonde.config.rxlat) || isnan(sonde.config.rxlon) ) || \ + calcLatLonDist( gpsPos.lat, gpsPos.lon, sonde.config.rxlat, sonde.config.rxlon ) > MIN_LOC_AUTO_DIST ) ) +extern float calcLatLonDist(float lat1, float lon1, float lat2, float lon2); + +// KISS over TCP for communicating with APRSdroid +WiFiServer tncserver(14580); +WiFiClient tncclient; +// JSON over TCP for communicating with the rdzSonde (rdzwx-go) Android app +WiFiServer rdzserver(14570); +WiFiClient rdzclient; +// APRS over TCP for radiosondy.info etc +AsyncClient tcpclient; + +#if FEATURE_MQTT +unsigned long lastMqttUptime = 0; +boolean mqttEnabled; +MQTT mqttclient; +#endif +boolean forceReloadScreenConfig = false; + +enum KeyPress { KP_NONE = 0, KP_SHORT, KP_DOUBLE, KP_MID, KP_LONG }; + +// "doublepress" is now also used to eliminate key glitch on TTGO T-Beam startup (SENSOR_VN/GPIO39) +struct Button { + uint8_t pin; + uint32_t numberKeyPresses; + KeyPress pressed; + unsigned long keydownTime; + int8_t doublepress; + bool isTouched; +}; +Button button1 = {0, 0, KP_NONE, 0, -1, false}; +Button button2 = {0, 0, KP_NONE, 0, -1, false}; + + +static int lastDisplay = 1; +static int currentDisplay = 1; + +// timestamp when spectrum display was activated +static unsigned long specTimer; + +void enterMode(int mode); +void WiFiEvent(WiFiEvent_t event); + +char buffer[85]; +MicroNMEA nmea(buffer, sizeof(buffer)); + +// Read line from file, independent of line termination (LF or CR LF) +String readLine(Stream &stream) { + String s = stream.readStringUntil('\n'); + int len = s.length(); + if (len == 0) return s; + if (s.charAt(len - 1) == '\r') s.remove(len - 1); + return s; +} + +// Read line from file, without using dynamic memory allocation (String class) +// returns length line. +int readLine(Stream &stream, char *buffer, int maxlen) { + int n = stream.readBytesUntil('\n', buffer, maxlen); + buffer[n] = 0; + if (n <= 0) return 0; + if (buffer[n - 1] == '\r') { + buffer[n - 1] = 0; + n--; + } + return n; +} + + +// Replaces placeholder with LED state value +String processor(const String& var) { + Serial.println(var); + if (var == "MAPCENTER") { + double lat, lon; + if (gpsPos.valid) { + lat = gpsPos.lat; + lon = gpsPos.lon; + } + else { + lat = sonde.config.rxlat; + lon = sonde.config.rxlon; + } + if ( !isnan(lat) && !isnan(lon) ) { + char p[40]; + snprintf(p, 40, "%g,%g", lat, lon); + return String(p); + } else { + return String("48,13"); + } + } + if (var == "VERSION_NAME") { + return String(version_name); + } + if (var == "VERSION_ID") { + return String(version_id); + } + if (var == "FULLNAMEID") { + char tmp[128]; + snprintf(tmp, 128, "%s-%c%d", version_id, SPIFFS_MAJOR + 'A' - 1, SPIFFS_MINOR); + return String(tmp); + } + if (var == "AUTODETECT_INFO") { + char tmpstr[128]; + const char *fpstr; + int i = 0; + while (fingerprintValue[i] != sonde.fingerprint && fingerprintValue[i] != -1) i++; + if (fingerprintValue[i] == -1) { + fpstr = "Unknown board"; + } else { + fpstr = fingerprintText[i]; + } + snprintf(tmpstr, 128, "Fingerprint %d (%s)", sonde.fingerprint, fpstr); + return String(tmpstr); + } + if (var == "EPHSTATE") { + return String(ephtxt[ephstate]); + } + return String(); +} + +const String sondeTypeSelect(int activeType) { + String sts = ""; + for (int i = 0; i < NSondeTypes; i++) { + sts += "