16 Commits
Author SHA1 Message Date
FCS 16e2851696 neues Module SKP, Übertragung der Signalleuchte zustand von Winde an SKP
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Successful in 4m31s
build_release.yaml / Build heltec_wifi_lora_32_V3_skp (push) Successful in 2m53s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Successful in 3m19s
build_release.yaml / Release (push) Successful in 11s
2026-08-30 12:40:52 +02:00
FCS f468f09ad2 Verbesserung Settings Menü 2026-08-30 12:18:17 +02:00
FCS 333d87af3e v0.0.8a
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Successful in 3m39s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Successful in 3m21s
build_release.yaml / Release (push) Successful in 9s
2026-08-30 11:38:10 +02:00
FCS 13f1aa2148 fix: Endlosschleife Wifi auto off 2026-08-30 11:34:03 +02:00
FCS 5688f8d679 Verbesserung Redirect 2026-08-30 11:28:14 +02:00
FCS d8558b330a Build function 2026-08-30 11:25:03 +02:00
FCS 72d9923800 Changelog v0.0.8
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Failing after 3m22s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Successful in 4m18s
build_release.yaml / Release (push) Skipped
2026-08-30 11:06:12 +02:00
FCS 57ccb75847 Build Version Anzeige, WiFi auto off, redirect to Settings Site 2026-08-30 11:04:03 +02:00
FCS e5453b29fa korrekture Release
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Successful in 2m16s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Successful in 2m55s
build_release.yaml / Release (push) Successful in 9s
2026-08-28 19:08:14 +02:00
FCS ea79561bcf changelog ergänzt
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Successful in 4m1s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Successful in 3m14s
build_release.yaml / Release (push) Successful in 18s
2026-08-28 18:54:06 +02:00
FCS cbceec1887 korrektur Checksum 2026-08-28 18:53:03 +02:00
FCS e1ee1c560e Korrektur Autobuild
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Failing after 4m7s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Failing after 3m39s
build_release.yaml / Release (push) Skipped
2026-08-28 18:44:55 +02:00
FCS 97fb018d51 autobuild Remove tag Validation 2026-08-28 18:40:27 +02:00
FCS b987f7c21c Validate Tag 2026-08-28 18:38:00 +02:00
FCS fb2a0865ee Changelog 2026-08-28 18:33:17 +02:00
FCS 8ef86500db Verbesserung des AutoBuilds
build_release.yaml / Build heltec_wifi_lora_32_V3_sailplane (push) Failing after 13s
build_release.yaml / Build heltec_wifi_lora_32_V3_winde (push) Failing after 13s
build_release.yaml / Release (push) Skipped
2026-08-28 18:26:20 +02:00
9 changed files with 561 additions and 96 deletions

No files matched your search

+91 -24
View File
@@ -1,46 +1,72 @@
on: on:
push: push:
tags: tags:
- "*" - "v*"
concurrency:
group: release-${{ gitea.ref }}
cancel-in-progress: true
jobs: jobs:
build: build:
env: env:
RUNNER_TOOL_CACHE: /toolcache RUNNER_TOOL_CACHE: /toolcache
PLATFORMIO_BUILD_CACHE_DIR: ~/.platformio/.build_cache PLATFORMIO_BUILD_CACHE_DIR: ~/.platformio/.build_cache
PLATFORMIO_CACHE_DIR: ~/.platformio/.cachedir PLATFORMIO_CACHE_DIR: ~/.platformio/.cachedir
name: Build name: Build ${{ matrix.environment }}
strategy:
fail-fast: false
matrix:
environment:
- heltec_wifi_lora_32_V3_sailplane
- heltec_wifi_lora_32_V3_winde
- heltec_wifi_lora_32_V3_skp
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest container: catthehacker/ubuntu:act-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Cache - name: Cache
uses: actions/cache@v4 uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with: with:
path: | path: |
~/.cache/pip ~/.cache/pip
~/.platformio/.cache ~/.platformio/.cache
~/.platformio/.build_cache ~/.platformio/.build_cache
~/.platformio/.cachedir ~/.platformio/.cachedir
key: ${{ runner.os }}-pio key: ${{ runner.os }}-pio-6.1.18-${{ hashFiles('platformio.ini', 'extra_script.py') }}
restore-keys: |
${{ runner.os }}-pio-6.1.18-
${{ runner.os }}-pio-
- name: Set up python - name: Set up python
uses: actions/setup-python@v5 uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with: with:
python-version: "3.14.0" python-version: "3.14.0"
architecture: "x64" architecture: "x64"
- name: Install PlatformIO - name: Install PlatformIO
run: python3 -m pip install platformio==6.1.18 run: python3 -m pip install platformio==6.1.18
- name: Build firmwares - name: Static analysis
run: FIRMWARE_VERSION=${{gitea.ref_name}} platformio run run: python3 -m platformio check --environment "${{ matrix.environment }}"
- name: Archive - name: Build firmware
uses: christopherhx/gitea-upload-artifact@v4 env:
FIRMWARE_VERSION: ${{ gitea.ref_name }}
run: python3 -m platformio run --environment "${{ matrix.environment }}"
- name: Verify firmware and create checksum
run: |
FIRMWARE_FILE=$(find ".pio/build/${{ matrix.environment }}" -maxdepth 1 -type f -name 'firmware_*.bin' -print -quit)
test -n "$FIRMWARE_FILE"
sha256sum "$FIRMWARE_FILE" > "firmware-${{ matrix.environment }}.sha256"
- name: Archive firmware
uses: christopherhx/gitea-upload-artifact@62ac910c5d3dfa85c7cb2df15afe2e342b2407c2 # v4
with: with:
name: firmware name: firmware-${{ matrix.environment }}
path: .pio/build/*/firmware_*.bin path: |
.pio/build/${{ matrix.environment }}/firmware_*.bin
firmware-${{ matrix.environment }}.sha256
retention-days: 1 retention-days: 1
release: release:
name: Release name: Release
# if: startsWith(github.event.ref, 'refs/tags/v') if: startsWith(gitea.ref, 'refs/tags/v')
needs: build needs: build
permissions: permissions:
contents: write contents: write
@@ -48,17 +74,58 @@ jobs:
container: catthehacker/ubuntu:act-latest container: catthehacker/ubuntu:act-latest
steps: steps:
- name: Checkout repo for CHANGELOG - name: Checkout repo for CHANGELOG
uses: actions/checkout@v4 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download artifacts - name: Download Sailplane artifact
uses: christopherhx/gitea-download-artifact@v4 uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4
with: with:
name: firmware name: firmware-heltec_wifi_lora_32_V3_sailplane
path: firmware path: firmware/sailplane
# - name: Display structure of downloaded files - name: Download Winde artifact
# run: ls -R uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4
- name: release with:
uses: akkuman/gitea-release-action@v1 name: firmware-heltec_wifi_lora_32_V3_winde
path: firmware/winde
- name: Download SKP artifact
uses: christopherhx/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # v4
with:
name: firmware-heltec_wifi_lora_32_V3_skp
path: firmware/skp
- name: Verify release assets
run: |
RELEASE_VERSION="${{ gitea.ref_name }}"
SAILPLANE_FILE=$(find firmware/sailplane -type f -name 'firmware_*.bin' -print -quit)
WINDE_FILE=$(find firmware/winde -type f -name 'firmware_*.bin' -print -quit)
SKP_FILE=$(find firmware/skp -type f -name 'firmware_*.bin' -print -quit)
test -n "$SAILPLANE_FILE"
test -n "$WINDE_FILE"
test -n "$SKP_FILE"
cp "$SAILPLANE_FILE" "firmware/firmware_sailplane_${RELEASE_VERSION}.bin"
cp "$WINDE_FILE" "firmware/firmware_winde_${RELEASE_VERSION}.bin"
cp "$SKP_FILE" "firmware/firmware_skp_${RELEASE_VERSION}.bin"
(cd firmware && sha256sum "firmware_sailplane_${RELEASE_VERSION}.bin" > "firmware_sailplane_${RELEASE_VERSION}.sha256")
(cd firmware && sha256sum "firmware_winde_${RELEASE_VERSION}.bin" > "firmware_winde_${RELEASE_VERSION}.sha256")
(cd firmware && sha256sum "firmware_skp_${RELEASE_VERSION}.bin" > "firmware_skp_${RELEASE_VERSION}.sha256")
test -s "firmware/firmware_sailplane_${RELEASE_VERSION}.bin"
test -s "firmware/firmware_winde_${RELEASE_VERSION}.bin"
test -s "firmware/firmware_skp_${RELEASE_VERSION}.bin"
test -s "firmware/firmware_sailplane_${RELEASE_VERSION}.sha256"
test -s "firmware/firmware_winde_${RELEASE_VERSION}.sha256"
test -s "firmware/firmware_skp_${RELEASE_VERSION}.sha256"
(cd firmware && sha256sum -c "firmware_sailplane_${RELEASE_VERSION}.sha256")
(cd firmware && sha256sum -c "firmware_winde_${RELEASE_VERSION}.sha256")
(cd firmware && sha256sum -c "firmware_skp_${RELEASE_VERSION}.sha256")
test -s LICENSE
test -s THIRD_PARTY_NOTICES.md
- name: Create release
uses: akkuman/gitea-release-action@5a83c90484ef4355121df5eb60558c8ce66e81ac # v1
with: with:
files: |- files: |-
**/firmware_*.bin firmware/firmware_sailplane_${{ gitea.ref_name }}.bin
body_path: "CHANGELOG.md" firmware/firmware_winde_${{ gitea.ref_name }}.bin
firmware/firmware_skp_${{ gitea.ref_name }}.bin
firmware/firmware_sailplane_${{ gitea.ref_name }}.sha256
firmware/firmware_winde_${{ gitea.ref_name }}.sha256
firmware/firmware_skp_${{ gitea.ref_name }}.sha256
LICENSE
THIRD_PARTY_NOTICES.md
body_path: "CHANGELOG.md"
+49 -3
View File
@@ -1,6 +1,50 @@
CHANGELOG CHANGELOG
## v0.1.0 (30.08.2026)
+ modulabhängige Einstellungen im Webinterface nur noch für genutzte Werte sichtbar
+ gemeinsame AP-/OTA-Logik für die Module beibehalten
## 0.0.7 (28.08.2026) ### Winden Modul
+ Warnleuchten-Erkennung ergänzt
+ Statusmeldung via LoRa an das SKP-Modul senden
### SKP Modul
+ neues Modul, ebenfalls mit Webinterface für Settings und OTA
+ empfangene Warnleuchten-Status via LoRa ausgewertet
+ Relais Steuerung
---
## v0.0.8a (30.08.2026)
+ fix: Wifi Auto off Nachrichten Schleife
+ Verbesserung Redirect to Einstellungs Seite
+ Verbesserung AutoBuild
---
## v0.0.8 (30.08.2026)
+ Firmware-Version als Build-Tag im Code und im Webinterface eingebaut
+ WLAN-Name für Segelflug- und Winden-Module angepasst (`Telemetry-<Callsign>` bzw. `Telemetry-Winch`)
+ Webinterface zeigt aktuell geladene Firmware-Version an
+ Speichern der Einstellungen springt nach dem Speichern auf die Startseite mit Erfolg/Fehlerstatus zurück
+ Captive-Portal / DNS-Weiterleitung für das Webinterface ergänzt
+ Access Point bleibt nur 5 Minuten nach PowerOn aktiv, wenn kein Client verbunden ist, und wird dann automatisch deaktiviert
---
## v0.0.7d (28.08.2026)
+ AutoBuild und Release-Prozess für Versionsnamen, Prüfsummen und Release-Artefakte korrigiert
---
## v0.0.7c (28.08.2026)
+ korrektur AutoBuild (Checksum)
---
## v0.0.7b (28.08.2026)
+ korrektur AutoBuild
---
## v0.0.7a (28.08.2026)
+ verbessertes AutoBuild
---
## v0.0.7 (28.08.2026)
+ Webinterface über eigenen WLAN-Access-Point ergänzt + Webinterface über eigenen WLAN-Access-Point ergänzt
+ Persistente Konfiguration für WLAN-Name, WLAN-Passwort und Callsign + Persistente Konfiguration für WLAN-Name, WLAN-Passwort und Callsign
+ Lizenzinformationen für Projektcode und Drittanbieterbibliotheken ergänzt + Lizenzinformationen für Projektcode und Drittanbieterbibliotheken ergänzt
@@ -18,7 +62,8 @@ CHANGELOG
+ Initialisierung von Servo und LED-Ring korrigiert + Initialisierung von Servo und LED-Ring korrigiert
+ NMEA-Nachrichtenprüfung und Fehlerbehandlung beim Empfang verbessert + NMEA-Nachrichtenprüfung und Fehlerbehandlung beim Empfang verbessert
## 0.0.6 (18.01.2025) ---
## v0.0.6 (18.01.2026)
+ Anpassung Programmablaufplan + Anpassung Programmablaufplan
### Segeflug Modul ### Segeflug Modul
@@ -28,7 +73,8 @@ CHANGELOG
### Winden Modul ### Winden Modul
+ empfangen im NMEA Format + empfangen im NMEA Format
## 0.0.5 (30.11.2025) ---
## v0.0.5 (30.11.2025)
+ Formatierung Code + Formatierung Code
### Segeflug Modul ### Segeflug Modul
+ Luftdrucksensor (BMP180) hinzugefügt, für Höhe und Vario + Luftdrucksensor (BMP180) hinzugefügt, für Höhe und Vario
+15 -12
View File
@@ -4,6 +4,8 @@
# Winden-Telemetry # Winden-Telemetry
Aktuelle Version: v0.1.0
Der eigene Projektcode steht unter der MIT-Lizenz. Die verwendeten Der eigene Projektcode steht unter der MIT-Lizenz. Die verwendeten
Drittanbieterbibliotheken bleiben unter ihren jeweiligen Original-Lizenzen. Drittanbieterbibliotheken bleiben unter ihren jeweiligen Original-Lizenzen.
Eine Übersicht der Komponenten, Versionen und Lizenzbedingungen steht in Eine Übersicht der Komponenten, Versionen und Lizenzbedingungen steht in
@@ -33,7 +35,10 @@ für den Projektcode steht in [LICENSE](LICENSE).
- [x] Analoge Anzeige in der Winde - [x] Analoge Anzeige in der Winde
- [x] Farbige LEDs für Limits - [x] Farbige LEDs für Limits
- [x] Übertragungszeit Begrenzen - [x] Übertragungszeit Begrenzen
- [ ] Übertragung Rundumleuchten Signal an Start - [x] 12V-Warnleuchten-Erkennung am Wind-Modul via GPIO 5
- [x] NMEA-Statusübertragung zum SKP-Modul mit Prefix $PWTLW
- [x] SKP-Modul mit Relaissteuerung über GPIO 7 und Timeout-Sicherung
- [x] eigenes SKP-Webinterface mit WLAN- und OTA-Funktionen
- [x] Luftdrucksensor für Höhe und Vario - [x] Luftdrucksensor für Höhe und Vario
### Webinterface und Firmware-Update ### Webinterface und Firmware-Update
@@ -45,16 +50,14 @@ Winde `Winde-Telemetry`.
- Passwort: `telemetry` - Passwort: `telemetry`
- Webadresse: `http://192.168.4.1/` - Webadresse: `http://192.168.4.1/`
Im Webinterface können WLAN-Name und WLAN-Passwort sowie Callsign, minimale und maximale Geschwindigkeit Im Webinterface lassen sich die WLAN-Einstellungen verwalten. Je nach Modul
gespeichert werden. Die Werte bleiben nach einem Neustart erhalten. Die werden nur die tatsächlich genutzten Werte angezeigt. Die Werte bleiben nach
Sailplane-Firmware lädt sie beim Start und verwendet sie für die Telemetrie, einem Neustart erhalten. Das Sailplane-Modul verwendet sie für Telemetrie und
die Schlepp-Erkennung und die maximale Übertragungszeit. Die Winden-Firmware verwendet die gespeicherten Schlepp-Erkennung, während die Wind- und SKP-Module die passenden Betriebswerte
Grenzen für die Anzeige beim Start; empfangene Telemetriegrenzen werden danach für ihren jeweiligen Betrieb übernehmen.
weiterhin aus dem LoRa-Paket übernommen.
Für ein Firmware-Update die zur jeweiligen Hardware passende `.bin`-Datei aus Für ein Firmware-Update die passende `.bin`-Datei aus `.pio/build/<environment>/`
`.pio/build/<environment>/` auswählen. Nach erfolgreichem Upload startet das auswählen. Nach einem erfolgreichen Upload startet das Gerät automatisch neu.
Gerät automatisch neu.
## Aufbau ## Aufbau
@@ -95,9 +98,9 @@ Die Platine ist so gestaltet das sie individuell bestückt werden kann, je nach
| I2C_4 | optional| optional| optional| | I2C_4 | optional| optional| optional|
| GPIO3 | optional| optional| optional| | GPIO3 | optional| optional| optional|
| GPIO4 | optional| optional| optional| | GPIO4 | optional| optional| optional|
| GPIO5 | optional| Eingang Warnleuchte |optional| | GPIO5 | optional| Eingang Warnleuchte | optional|
| GPIO6 | optional| LED Ring | optional| | GPIO6 | optional| LED Ring | optional|
| GPIO7 | optional| Servo | für Relais| | GPIO7 | optional| Servo | Relaissteuerung |
+16 -3
View File
@@ -1,10 +1,23 @@
import os import os
Import("env") from typing import Any
# PlatformIO injects Import() and env at runtime. The editor does not know these
# names at file-load time, so we keep a short, explicit guard and silence the
# static-analysis warning for the SCons hook itself.
try:
Import("env") # type: ignore[name-defined]
except NameError:
env: Any = None
if env is None:
raise RuntimeError("This script must be run by PlatformIO's SCons environment.")
# Access to global construction environment # Access to global construction environment
build_tag = env['PIOENV'] build_tag = env["PIOENV"]
version_tag = os.getenv("FIRMWARE_VERSION") version_tag = os.getenv("FIRMWARE_VERSION", "dev").strip()
# CPPDEFINES ensures the macro expands to a valid C string literal instead of a bare identifier.
env.Append(CPPDEFINES=[("FIRMWARE_VERSION", f'\\"{version_tag}\\"')])
env.Replace(PROGNAME="firmware_%s_%s" % (build_tag, version_tag)) env.Replace(PROGNAME="firmware_%s_%s" % (build_tag, version_tag))
# include toolchain paths # include toolchain paths
+208 -20
View File
@@ -1,9 +1,11 @@
#include "webinterface.h" #include "webinterface.h"
#include <Arduino.h> #include <Arduino.h>
#include <DNSServer.h>
#include <Preferences.h> #include <Preferences.h>
#include <Update.h> #include <Update.h>
#include <WebServer.h> #include <WebServer.h>
#include <WiFi.h> #include <WiFi.h>
#include <cctype>
namespace namespace
{ {
@@ -13,22 +15,62 @@ constexpr char default_callsign[] = "D1234";
constexpr int default_min_speed = 80; constexpr int default_min_speed = 80;
constexpr int default_max_speed = 150; constexpr int default_max_speed = 150;
constexpr unsigned int default_active_time_seconds = 90; constexpr unsigned int default_active_time_seconds = 90;
constexpr unsigned long access_point_timeout_ms = 5UL * 60UL * 1000UL;
constexpr char telemetry_ap_prefix[] = "Telemetry-";
String default_access_point_name() String default_access_point_name()
{ {
#ifdef DEVICE_SAILPLANE #ifdef DEVICE_SAILPLANE
return String("Sailplane-") + default_callsign; return String(telemetry_ap_prefix) + default_callsign;
#elif defined(DEVICE_SKP)
return String(telemetry_ap_prefix) + "SKP";
#else #else
return "Winde-Telemetry"; return String(telemetry_ap_prefix) + "Winch";
#endif #endif
} }
String generated_access_point_name(const String &callsign)
{
#ifdef DEVICE_SAILPLANE
String safe_callsign = callsign;
if (safe_callsign.length() == 0)
safe_callsign = default_callsign;
return String(telemetry_ap_prefix) + safe_callsign;
#elif defined(DEVICE_SKP)
return String(telemetry_ap_prefix) + "SKP";
#else
return String(telemetry_ap_prefix) + "Winch";
#endif
}
String url_encode(const String &value)
{
String encoded;
encoded.reserve(value.length() * 3);
for (unsigned int i = 0; i < value.length(); ++i)
{
const char c = value.charAt(i);
if (std::isalnum(static_cast<unsigned char>(c)) || c == '-' || c == '_' || c == '.' || c == '~')
encoded += c;
else
{
char buffer[4];
snprintf(buffer, sizeof(buffer), "%%%02X", static_cast<unsigned char>(c));
encoded += buffer;
}
}
return encoded;
}
WebServer server(80); WebServer server(80);
DNSServer dns_server;
Preferences preferences; Preferences preferences;
TelemetrySettings *active_settings = nullptr; TelemetrySettings *active_settings = nullptr;
bool restart_after_update = false; bool restart_after_update = false;
bool update_failed = false; bool update_failed = false;
bool access_point_restart_pending = false; bool access_point_restart_pending = false;
bool access_point_active = false;
unsigned long access_point_started_ms = 0UL;
String html_escape(const String &value) String html_escape(const String &value)
{ {
@@ -41,6 +83,73 @@ String html_escape(const String &value)
return escaped; return escaped;
} }
bool is_captive_portal_target(const String &host, const String &uri)
{
String lowercase_host = host;
lowercase_host.toLowerCase();
String lowercase_uri = uri;
lowercase_uri.toLowerCase();
static const char *captive_hosts[] = {
"connectivitycheck.gstatic.com",
"clients3.google.com",
"google.com",
"www.google.com",
"msftconnecttest.com",
"msftncsi.com",
"captive.apple.com",
"www.apple.com",
"apple.com",
"connectivitycheck.android.com"};
for (const char *candidate : captive_hosts)
{
if (lowercase_host == candidate)
return true;
}
static const char *captive_paths[] = {
"/generate_204",
"/hotspot-detect.html",
"/library/test/success.html",
"/connecttest.txt",
"/redirect",
"/ncsi.txt",
"/success.txt",
"/wap"};
for (const char *candidate : captive_paths)
{
if (lowercase_uri == candidate)
return true;
}
return false;
}
void redirect_to_root(const String &message, bool success)
{
String location = String("/?status=") + (success ? "success" : "error") + "&msg=" + url_encode(message);
server.sendHeader("Location", location, true);
server.send(303, "text/plain; charset=utf-8", "");
}
void handle_captive_portal_redirect()
{
String host = server.hostHeader();
String uri = server.uri();
if (is_captive_portal_target(host, uri))
{
server.sendHeader("Location", "/", true);
server.send(302, "text/plain; charset=utf-8", "");
return;
}
server.send(404, "text/plain; charset=utf-8", "Not Found");
}
void send_page(const String &message = String()) void send_page(const String &message = String())
{ {
String page; String page;
@@ -51,28 +160,39 @@ void send_page(const String &message = String())
"body{font-family:sans-serif;max-width:38rem;margin:2rem auto;padding:0 1rem}" "body{font-family:sans-serif;max-width:38rem;margin:2rem auto;padding:0 1rem}"
"label{display:block;margin-top:1rem}input{box-sizing:border-box;width:100%;padding:.6rem;font-size:1rem}" "label{display:block;margin-top:1rem}input{box-sizing:border-box;width:100%;padding:.6rem;font-size:1rem}"
"button{margin-top:1rem;padding:.65rem 1rem;font-size:1rem}" "button{margin-top:1rem;padding:.65rem 1rem;font-size:1rem}"
".msg{padding:.6rem;background:#e5f4e8}small{color:#555}" ".msg{padding:.6rem;background:#e5f4e8}.error{padding:.6rem;background:#fbe5e5}small{color:#555}"
"</style></head><body><h1>Winden-Telemetry</h1>"); "</style></head><body><h1>Winden-Telemetry</h1>");
if (message.length() > 0) if (message.length() > 0)
{ {
page += F("<p class='msg'>"); page += F("<p class='");
page += String(message.startsWith("Fehler") || message.startsWith("Ungueltig") || message.startsWith("Invalid") ? "error" : "msg");
page += F("'>");
page += html_escape(message); page += html_escape(message);
page += F("</p>"); page += F("</p>");
} }
page += F("<form method='post' action='/settings'>" page += F("<p><small>Firmware: ");
page += html_escape(firmware_version_string());
page += F("</small></p><form method='post' action='/settings'>"
"<label>WLAN-Name<input name='ap_name' maxlength='32' required value='"); "<label>WLAN-Name<input name='ap_name' maxlength='32' required value='");
page += html_escape(active_settings->access_point_name); page += html_escape(active_settings->access_point_name);
page += F("'></label><label>WLAN-Passwort<input name='ap_password' type='password' minlength='8' maxlength='63' required value='"); page += F("'></label><label>WLAN-Passwort<input name='ap_password' type='password' minlength='8' maxlength='63' required value='");
page += html_escape(active_settings->access_point_password); page += html_escape(active_settings->access_point_password);
page += F("'></label><label>Callsign<input name='callsign' maxlength='16' required value='"); page += F("'></label>");
#ifdef DEVICE_SAILPLANE
page += F("<label>Callsign<input name='callsign' maxlength='16' required value='");
page += html_escape(active_settings->callsign); page += html_escape(active_settings->callsign);
page += F("'></label><label>Min Speed (km/h)<input name='min' type='number' min='0' max='300' required value='"); page += F("'></label><label>Min Speed (km/h)<input name='min' type='number' min='0' max='300' required value='");
page += String(active_settings->min_speed); page += String(active_settings->min_speed);
page += F("'></label><label>Max Speed (km/h)<input name='max' type='number' min='1' max='300' required value='"); page += F("'></label><label>Max Speed (km/h)<input name='max' type='number' min='1' max='300' required value='");
page += String(active_settings->max_speed); page += String(active_settings->max_speed);
page += F("'></label><label>Uebertragungszeit (Sekunden)<input name='active_time' type='number' min='1' max='600' required value='"); page += F("'></label>");
#endif
#ifdef DEVICE_SAILPLANE
page += F("<label>Uebertragungszeit (Sekunden)<input name='active_time' type='number' min='1' max='600' required value='");
page += String(active_settings->active_time_seconds); page += String(active_settings->active_time_seconds);
page += F("'></label><button type='submit'>Speichern</button></form>" page += F("'></label>");
#endif
page += F("<button type='submit'>Speichern</button></form>"
"<h2>Firmware aktualisieren</h2><form method='post' action='/update' enctype='multipart/form-data'>" "<h2>Firmware aktualisieren</h2><form method='post' action='/update' enctype='multipart/form-data'>"
"<input name='firmware' type='file' accept='.bin' required><button type='submit'>Upload starten</button>" "<input name='firmware' type='file' accept='.bin' required><button type='submit'>Upload starten</button>"
"</form><p><small>Access Point: "); "</form><p><small>Access Point: ");
@@ -83,21 +203,31 @@ void send_page(const String &message = String())
bool parse_settings(TelemetrySettings &settings) bool parse_settings(TelemetrySettings &settings)
{ {
#ifdef DEVICE_SAILPLANE
String callsign = server.arg("callsign"); String callsign = server.arg("callsign");
String access_point_name = server.arg("ap_name");
String access_point_password = server.arg("ap_password");
int min_speed = server.arg("min").toInt(); int min_speed = server.arg("min").toInt();
int max_speed = server.arg("max").toInt(); int max_speed = server.arg("max").toInt();
int active_time_seconds = server.arg("active_time").toInt(); int active_time_seconds = server.arg("active_time").toInt();
callsign.trim(); callsign.trim();
if (callsign.length() == 0 || callsign.length() > 16 || min_speed < 0 || max_speed > 300 || min_speed >= max_speed || active_time_seconds < 1 || active_time_seconds > 600)
return false;
#else
String callsign = settings.callsign;
int min_speed = settings.min_speed;
int max_speed = settings.max_speed;
int active_time_seconds = settings.active_time_seconds;
#endif
String access_point_name = server.arg("ap_name");
String access_point_password = server.arg("ap_password");
access_point_name.trim(); access_point_name.trim();
access_point_password.trim(); access_point_password.trim();
if (access_point_name.length() == 0 || access_point_name.length() > 32 || access_point_password.length() < 8 || access_point_password.length() > 63 || callsign.length() == 0 || callsign.length() > 16 || min_speed < 0 || max_speed > 300 ||
min_speed >= max_speed || active_time_seconds < 1 || active_time_seconds > 600) if (access_point_password.length() < 8 || access_point_password.length() > 63)
return false; return false;
settings.callsign = callsign; settings.callsign = callsign;
settings.access_point_name = access_point_name; settings.access_point_name = generated_access_point_name(callsign);
settings.access_point_password = access_point_password; settings.access_point_password = access_point_password;
settings.min_speed = min_speed; settings.min_speed = min_speed;
settings.max_speed = max_speed; settings.max_speed = max_speed;
@@ -107,7 +237,13 @@ bool parse_settings(TelemetrySettings &settings)
void handle_root() void handle_root()
{ {
send_page(); String message = server.arg("msg");
String status = server.arg("status");
if (status == "error" && message.length() == 0)
message = "Ungueltige Einstellungen";
else if (status == "success" && message.length() == 0)
message = "Einstellungen gespeichert.";
send_page(message);
} }
void handle_settings() void handle_settings()
@@ -115,10 +251,13 @@ void handle_settings()
TelemetrySettings updated = *active_settings; TelemetrySettings updated = *active_settings;
if (!parse_settings(updated)) if (!parse_settings(updated))
{ {
server.send(400, "text/plain; charset=utf-8", "Ungueltige Einstellungen"); redirect_to_root("Ungueltige Einstellungen", false);
return; return;
} }
const bool ap_name_changed = active_settings->access_point_name != updated.access_point_name;
const bool ap_password_changed = active_settings->access_point_password != updated.access_point_password;
active_settings->callsign = updated.callsign; active_settings->callsign = updated.callsign;
active_settings->access_point_name = updated.access_point_name; active_settings->access_point_name = updated.access_point_name;
active_settings->access_point_password = updated.access_point_password; active_settings->access_point_password = updated.access_point_password;
@@ -131,8 +270,11 @@ void handle_settings()
preferences.putInt("min", active_settings->min_speed); preferences.putInt("min", active_settings->min_speed);
preferences.putInt("max", active_settings->max_speed); preferences.putInt("max", active_settings->max_speed);
preferences.putUInt("active_time", active_settings->active_time_seconds); preferences.putUInt("active_time", active_settings->active_time_seconds);
send_page("Einstellungen gespeichert.");
access_point_restart_pending = true; if (ap_name_changed || ap_password_changed)
access_point_restart_pending = true;
redirect_to_root("Einstellungen gespeichert.", true);
} }
void handle_update_upload() void handle_update_upload()
@@ -188,6 +330,15 @@ void handle_update_result()
} }
} // namespace } // namespace
String firmware_version_string(void)
{
#ifdef FIRMWARE_VERSION
return String(FIRMWARE_VERSION);
#else
return "dev";
#endif
}
bool webinterface_begin(TelemetrySettings &settings) bool webinterface_begin(TelemetrySettings &settings)
{ {
active_settings = &settings; active_settings = &settings;
@@ -197,9 +348,13 @@ bool webinterface_begin(TelemetrySettings &settings)
settings.access_point_password = preferences.getString("ap_password", default_access_point_password); settings.access_point_password = preferences.getString("ap_password", default_access_point_password);
settings.min_speed = preferences.getInt("min", default_min_speed); settings.min_speed = preferences.getInt("min", default_min_speed);
settings.max_speed = preferences.getInt("max", default_max_speed); settings.max_speed = preferences.getInt("max", default_max_speed);
settings.active_time_seconds = preferences.getUInt("active_time", default_active_time_seconds); settings.active_time_seconds = preferences.getUInt("active_time", default_active_time_seconds);
if (settings.access_point_name.length() == 0 || settings.access_point_name.length() > 32 || settings.access_point_password.length() < 8 || settings.access_point_password.length() > 63 || settings.callsign.length() == 0 || settings.min_speed < 0 || settings.min_speed >= settings.max_speed ||
settings.max_speed > 300 || settings.active_time_seconds < 1 || settings.active_time_seconds > 600) bool settings_valid = settings.access_point_name.length() > 0 && settings.access_point_name.length() <= 32 && settings.access_point_password.length() >= 8 && settings.access_point_password.length() <= 63;
#ifdef DEVICE_SAILPLANE
settings_valid = settings_valid && settings.callsign.length() > 0 && settings.min_speed >= 0 && settings.min_speed < settings.max_speed && settings.max_speed <= 300 && settings.active_time_seconds >= 1 && settings.active_time_seconds <= 600;
#endif
if (!settings_valid)
{ {
settings.callsign = default_callsign; settings.callsign = default_callsign;
settings.access_point_name = default_access_point_name(); settings.access_point_name = default_access_point_name();
@@ -208,16 +363,37 @@ bool webinterface_begin(TelemetrySettings &settings)
settings.max_speed = default_max_speed; settings.max_speed = default_max_speed;
settings.active_time_seconds = default_active_time_seconds; settings.active_time_seconds = default_active_time_seconds;
} }
else
{
settings.access_point_name = generated_access_point_name(settings.callsign);
}
WiFi.mode(WIFI_AP); WiFi.mode(WIFI_AP);
bool ap_started = WiFi.softAP(settings.access_point_name, settings.access_point_password); bool ap_started = WiFi.softAP(settings.access_point_name, settings.access_point_password);
if (!ap_started) if (!ap_started)
return false; return false;
access_point_active = true;
access_point_started_ms = millis();
dns_server.start(53, "connectivitycheck.gstatic.com", WiFi.softAPIP());
dns_server.start(53, "clients3.google.com", WiFi.softAPIP());
dns_server.start(53, "msftconnecttest.com", WiFi.softAPIP());
dns_server.start(53, "msftncsi.com", WiFi.softAPIP());
dns_server.start(53, "captive.apple.com", WiFi.softAPIP());
dns_server.start(53, "apple.com", WiFi.softAPIP());
dns_server.start(53, "*", WiFi.softAPIP());
server.on("/", HTTP_GET, handle_root); server.on("/", HTTP_GET, handle_root);
server.on("/generate_204", HTTP_GET, handle_captive_portal_redirect);
server.on("/hotspot-detect.html", HTTP_GET, handle_captive_portal_redirect);
server.on("/connecttest.txt", HTTP_GET, handle_captive_portal_redirect);
server.on("/ncsi.txt", HTTP_GET, handle_captive_portal_redirect);
server.on("/success.txt", HTTP_GET, handle_captive_portal_redirect);
server.on("/settings", HTTP_POST, handle_settings); server.on("/settings", HTTP_POST, handle_settings);
server.on("/update", HTTP_POST, handle_update_result, handle_update_upload); server.on("/update", HTTP_POST, handle_update_result, handle_update_upload);
server.onNotFound(handle_captive_portal_redirect);
server.begin(); server.begin();
Serial.print("Firmware-Version: ");
Serial.println(firmware_version_string());
Serial.print("Webinterface: http://"); Serial.print("Webinterface: http://");
Serial.println(WiFi.softAPIP()); Serial.println(WiFi.softAPIP());
return true; return true;
@@ -226,13 +402,25 @@ bool webinterface_begin(TelemetrySettings &settings)
void webinterface_handle(void) void webinterface_handle(void)
{ {
server.handleClient(); server.handleClient();
dns_server.processNextRequest();
if (access_point_restart_pending) if (access_point_restart_pending)
{ {
access_point_restart_pending = false; access_point_restart_pending = false;
WiFi.softAPdisconnect(true); WiFi.softAPdisconnect(true);
access_point_active = false;
delay(100); delay(100);
if (!WiFi.softAP(active_settings->access_point_name, active_settings->access_point_password)) if (!WiFi.softAP(active_settings->access_point_name, active_settings->access_point_password))
Serial.println("Access Point konnte nicht neu gestartet werden"); Serial.println("Access Point konnte nicht neu gestartet werden");
else
access_point_active = true;
access_point_started_ms = millis();
}
if (access_point_active && WiFi.softAPgetStationNum() == 0 && (millis() - access_point_started_ms) >= access_point_timeout_ms)
{
Serial.println("Access Point nach 5 Minuten ohne Client deaktiviert");
WiFi.softAPdisconnect(true);
access_point_active = false;
} }
} }
+1
View File
@@ -13,6 +13,7 @@ struct TelemetrySettings
unsigned int active_time_seconds; unsigned int active_time_seconds;
}; };
String firmware_version_string(void);
bool webinterface_begin(TelemetrySettings &settings); bool webinterface_begin(TelemetrySettings &settings);
void webinterface_handle(void); void webinterface_handle(void);
const TelemetrySettings &webinterface_settings(void); const TelemetrySettings &webinterface_settings(void);
+11 -2
View File
@@ -41,11 +41,20 @@
#define servoPin 7 #define servoPin 7
/**WS8212 **/ /**WS8212 **/
// Which pin on is connected to the WS8212? // Which pin on is connected to the WS8212?
#define NEOPIN 6 #define NEOPIN 6
// How many NeoPixels are attached // How many NeoPixels are attached
#define NUMPIXELS 12 #define NUMPIXELS 12
#define pixeloffset 6 #define pixeloffset 6
#define WARN_LIGHT_SENSE_PIN 5
#define WARN_LIGHT_DETECT_THRESHOLD 1000
#define WARN_LIGHT_TX_INTERVAL_MS 5000UL
#endif
#ifdef DEVICE_SKP
#define RELAY_PIN 7
#define RELAY_PULSE_MS 500UL
#define WARNING_TIMEOUT_MS 5000UL
#endif #endif
+10
View File
@@ -63,3 +63,13 @@ build_flags =
-D DEVICE_WINDE -D DEVICE_WINDE
upload_port = COM9 upload_port = COM9
monitor_port = COM9 monitor_port = COM9
[env:heltec_wifi_lora_32_V3_skp]
extends = common
board = heltec_wifi_lora_32_V3
lib_deps =
${common.lib_deps}
lib_ignore = sailplane, winde
build_flags =
${common.build_flags}
-D DEVICE_SKP
+160 -32
View File
@@ -22,17 +22,87 @@ bool sensors_ready = false;
SX1262 radio = new Module(LORA_NSS, LORA_DIO1, LORA_NRST, LORA_BUSY); SX1262 radio = new Module(LORA_NSS, LORA_DIO1, LORA_NRST, LORA_BUSY);
bool radio_ready = false; bool radio_ready = false;
String nmea_checksum(String str)
{
byte cs = 0;
for (unsigned int n = 1; n < str.length(); n++)
{
if (str[n] == '*')
break;
cs ^= str[n];
}
if (cs < 0x10)
return "*0" + String(cs, HEX);
else
return "*" + String(cs, HEX);
}
#ifdef DEVICE_WINDE #ifdef DEVICE_WINDE
volatile bool receivedFlag = false; volatile bool receivedFlag = false;
bool warning_light_active = false;
bool last_warning_light_state = false;
unsigned long last_warning_light_tx_ms = 0UL;
#if defined(ESP8266) || defined(ESP32) #if defined(ESP8266) || defined(ESP32)
ICACHE_RAM_ATTR ICACHE_RAM_ATTR
#endif #endif
void setFlag(void) void setFlag(void)
{ {
// we got a packet, set the flag
receivedFlag = true; receivedFlag = true;
} }
bool read_warning_light_voltage()
{
int raw = analogRead(WARN_LIGHT_SENSE_PIN);
return raw > WARN_LIGHT_DETECT_THRESHOLD;
}
void send_warning_light_state(bool active)
{
String payload = "$PWTLW," + String(active ? "1" : "0");
payload += nmea_checksum(payload);
Serial.println(payload);
int state = radio.transmit(payload);
if (state != RADIOLIB_ERR_NONE)
{
Serial.print("Warnleuchte Status senden fehlgeschlagen, code ");
Serial.println(state);
}
}
#endif
#ifdef DEVICE_SKP
volatile bool skpReceivedFlag = false;
bool relay_active = false;
unsigned long relay_off_deadline = 0UL;
unsigned long last_valid_warning_ms = 0UL;
#if defined(ESP8266) || defined(ESP32)
ICACHE_RAM_ATTR
#endif
void skpSetFlag(void)
{
skpReceivedFlag = true;
}
void set_relay_state(bool active)
{
relay_active = active;
digitalWrite(RELAY_PIN, active ? HIGH : LOW);
if (active)
relay_off_deadline = millis() + RELAY_PULSE_MS;
else
relay_off_deadline = 0UL;
}
void trigger_relay_pulse()
{
last_valid_warning_ms = millis();
if (relay_active)
digitalWrite(RELAY_PIN, LOW);
delay(20);
set_relay_state(true);
}
#endif #endif
#ifdef HELTEC_WIFI_LORA_32_V3 #ifdef HELTEC_WIFI_LORA_32_V3
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, OLED_RST, OLED_CLK, OLED_DATA); U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, OLED_RST, OLED_CLK, OLED_DATA);
@@ -66,6 +136,29 @@ void setup()
Serial.println(state); Serial.println(state);
Serial.println(F("Webinterface bleibt verfuegbar")); Serial.println(F("Webinterface bleibt verfuegbar"));
} }
#ifdef DEVICE_WINDE
pinMode(WARN_LIGHT_SENSE_PIN, INPUT);
analogReadResolution(12);
analogSetPinAttenuation(WARN_LIGHT_SENSE_PIN, ADC_11db);
last_warning_light_state = read_warning_light_voltage();
#endif
#ifdef DEVICE_SKP
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
relay_active = false;
last_valid_warning_ms = millis();
radio.setPacketReceivedAction(skpSetFlag);
if (radio_ready)
{
state = radio.startReceive();
if (state != RADIOLIB_ERR_NONE)
{
Serial.print(F("SKP Receive failed, code "));
Serial.println(state);
radio_ready = false;
}
}
#endif
u8g2.begin(); u8g2.begin();
u8g2.clearBuffer(); u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB14_tr); u8g2.setFont(u8g2_font_ncenB14_tr);
@@ -105,21 +198,6 @@ void setup()
u8g2.sendBuffer(); u8g2.sendBuffer();
} }
String nmea_checksum(String str)
{
byte cs = 0;
for (unsigned int n = 1; n < str.length(); n++)
{
if (str[n] == '*')
break;
cs ^= str[n];
}
if (cs < 0x10)
return "*0" + String(cs, HEX);
else
return "*" + String(cs, HEX);
}
void draw_rssi(int Rssi){ void draw_rssi(int Rssi){
u8g2.drawFrame(102,8,4,3); u8g2.drawFrame(102,8,4,3);
u8g2.drawFrame(107,6,4,5); u8g2.drawFrame(107,6,4,5);
@@ -222,22 +300,6 @@ String getSplitValue(String data, char separator, int index)
} }
return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
} }
#ifdef DEVICE_WINDE
void decode_start(String data)
{
data_from = getSplitValue(data, ',', 1);
data_speed = (getSplitValue(data, ',', 2)).toInt();
data_min = (getSplitValue(data, ',', 3)).toInt();
data_max = (getSplitValue(data, ',', 4)).toInt();
}
void decode_airborn(String data)
{
data_from = getSplitValue(data, ',', 1);
data_speed = 0;
data_min = 0;
data_max = 0;
}
bool valid_nmea(String data) bool valid_nmea(String data)
{ {
@@ -256,6 +318,23 @@ bool valid_nmea(String data)
return received_checksum == expected_checksum; return received_checksum == expected_checksum;
} }
#ifdef DEVICE_WINDE
void decode_start(String data)
{
data_from = getSplitValue(data, ',', 1);
data_speed = (getSplitValue(data, ',', 2)).toInt();
data_min = (getSplitValue(data, ',', 3)).toInt();
data_max = (getSplitValue(data, ',', 4)).toInt();
}
void decode_airborn(String data)
{
data_from = getSplitValue(data, ',', 1);
data_speed = 0;
data_min = 0;
data_max = 0;
}
bool decode_msg(String data) bool decode_msg(String data)
{ {
String pos1 = getSplitValue(data, ',', 0); String pos1 = getSplitValue(data, ',', 0);
@@ -281,6 +360,55 @@ bool decode_msg(String data)
void loop() void loop()
{ {
webinterface_handle(); webinterface_handle();
#ifdef DEVICE_WINDE
bool current_warning_light_state = read_warning_light_voltage();
if (current_warning_light_state != last_warning_light_state)
{
last_warning_light_state = current_warning_light_state;
last_warning_light_tx_ms = millis();
send_warning_light_state(current_warning_light_state);
}
#endif
#ifdef DEVICE_SKP
if (relay_active && millis() >= relay_off_deadline)
{
set_relay_state(false);
}
if (radio_ready && skpReceivedFlag)
{
skpReceivedFlag = false;
String str;
int state = radio.readData(str);
if (state == RADIOLIB_ERR_NONE)
{
if (!valid_nmea(str))
{
Serial.println("Ungueltige SKP-Nachricht");
}
else if (getSplitValue(str, ',', 0) == "$PWTLW")
{
String status_field = getSplitValue(str, ',', 1);
status_field.trim();
bool warning_active = status_field == "1" || status_field == "ON" || status_field == "true";
if (warning_active)
{
trigger_relay_pulse();
Serial.println("Warnleuchte aktiv -> Relais an");
}
else
{
set_relay_state(false);
last_valid_warning_ms = millis();
Serial.println("Warnleuchte inaktiv -> Relais aus");
}
}
}
}
if (millis() - last_valid_warning_ms > WARNING_TIMEOUT_MS)
{
set_relay_state(false);
}
#endif
#ifdef DEVICE_SAILPLANE #ifdef DEVICE_SAILPLANE
if (!sensors_ready) if (!sensors_ready)
{ {