Compare commits
4
Commits
72d9923800
...
v0.0.8a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
333d87af3e | ||
|
|
13f1aa2148 | ||
|
|
5688f8d679 | ||
|
|
d8558b330a |
No files matched your search
@@ -1,4 +1,9 @@
|
||||
CHANGELOG
|
||||
## 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`)
|
||||
|
||||
+14
-3
@@ -1,12 +1,23 @@
|
||||
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
|
||||
build_tag = env['PIOENV']
|
||||
build_tag = env["PIOENV"]
|
||||
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.Append(CPPDEFINES=[("FIRMWARE_VERSION", f'\\"{version_tag}\\"')])
|
||||
env.Replace(PROGNAME="firmware_%s_%s" % (build_tag, version_tag))
|
||||
|
||||
# include toolchain paths
|
||||
|
||||
@@ -65,6 +65,7 @@ TelemetrySettings *active_settings = nullptr;
|
||||
bool restart_after_update = false;
|
||||
bool update_failed = 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)
|
||||
@@ -78,6 +79,51 @@ String html_escape(const String &value)
|
||||
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);
|
||||
@@ -85,6 +131,21 @@ void redirect_to_root(const String &message, bool success)
|
||||
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())
|
||||
{
|
||||
String page;
|
||||
@@ -174,6 +235,9 @@ void handle_settings()
|
||||
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->access_point_name = updated.access_point_name;
|
||||
active_settings->access_point_password = updated.access_point_password;
|
||||
@@ -186,7 +250,10 @@ void handle_settings()
|
||||
preferences.putInt("min", active_settings->min_speed);
|
||||
preferences.putInt("max", active_settings->max_speed);
|
||||
preferences.putUInt("active_time", active_settings->active_time_seconds);
|
||||
access_point_restart_pending = true;
|
||||
|
||||
if (ap_name_changed || ap_password_changed)
|
||||
access_point_restart_pending = true;
|
||||
|
||||
redirect_to_root("Einstellungen gespeichert.", true);
|
||||
}
|
||||
|
||||
@@ -282,11 +349,24 @@ bool webinterface_begin(TelemetrySettings &settings)
|
||||
if (!ap_started)
|
||||
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("/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("/update", HTTP_POST, handle_update_result, handle_update_upload);
|
||||
server.onNotFound(handle_captive_portal_redirect);
|
||||
server.begin();
|
||||
Serial.print("Firmware-Version: ");
|
||||
Serial.println(firmware_version_string());
|
||||
@@ -303,16 +383,20 @@ void webinterface_handle(void)
|
||||
{
|
||||
access_point_restart_pending = false;
|
||||
WiFi.softAPdisconnect(true);
|
||||
access_point_active = false;
|
||||
delay(100);
|
||||
if (!WiFi.softAP(active_settings->access_point_name, active_settings->access_point_password))
|
||||
Serial.println("Access Point konnte nicht neu gestartet werden");
|
||||
else
|
||||
access_point_active = true;
|
||||
access_point_started_ms = millis();
|
||||
}
|
||||
|
||||
if (WiFi.softAPgetStationNum() == 0 && (millis() - access_point_started_ms) >= access_point_timeout_ms)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user