Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Änderungen

## v0.5.4.2-dev

- **Netzwerk-Wächter repariert:** In v0.5.4 setzte er sich jede Sekunde selbst zurück, sobald seit dem Start irgendeine Antwort kam. Löste er aus, verband er das WLAN jede Sekunde neu – der Würfel kam nie wieder ins Netz, und der geplante Neustart wurde nie erreicht. Jetzt beendet nur eine *neue* Antwort nach dem Neuverbinden den Alarm; bleibt sie aus, folgt nach 5 Minuten der Neustart. Logik in `src/NetWatch.h` mit Tests.
- **Start-Verbindung:** 30 s statt 18 s, bevor der Setup-Hotspot öffnet. Der Log hält fest, nach wie vielen ms die Funkverbindung und die IP-Adresse kamen (bzw. den WLAN-Status bei Fehler).
- **Anzeigename bei Ortswechsel** als Dialog („Der Anzeigename „…“ passt vielleicht nicht mehr zum neuen Ort.“ – Leeren/Behalten) statt als Hinweis zwischen den Feldern.

## v0.5.4.1-dev

- **WLAN wie in v0.5.3.1:** Das feste Setzen von PHY-Modus und Sendeleistung vor jeder Verbindung (v0.5.4) ist zurückgenommen. Damit fand der Würfel das WLAN beim Start oft nicht innerhalb von 18 s, landete im Setup-Hotspot und startete nach rund 83 s neu; Abrufe dauerten zwei- bis dreimal so lange, das Webinterface reagierte zäh.
Expand Down
6 changes: 3 additions & 3 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Bought as a small Wi-Fi cube with a rather modest stock firmware – and from day one with the plan to turn it into something of my own.

[![Build](https://github.com/du13500/pixelstop/actions/workflows/build.yml/badge.svg)](https://github.com/du13500/pixelstop/actions/workflows/build.yml)
![Version](https://img.shields.io/badge/version-v0.5.4.1--dev-orange)
![Version](https://img.shields.io/badge/version-v0.5.4.2--dev-orange)
![Hardware](https://img.shields.io/badge/hardware-ESP8266%20%C2%B7%20SmallTV--Ultra-blue)
![Hardware test](https://img.shields.io/badge/hardware%20test-v0.5.4.1%20pending-yellow)
![Hardware test](https://img.shields.io/badge/hardware%20test-v0.5.4.2%20pending-yellow)
![Hobby project](https://img.shields.io/badge/hobby%20project-non--commercial-lightgrey)
![License](https://img.shields.io/badge/license-MIT-green)
![Mission](https://img.shields.io/badge/mission-Know%20before%20you%20go-ff5d56)
Expand Down Expand Up @@ -59,7 +59,7 @@ Plus night mode, brightness down to 1 %, place search with a map, Greek and Cyri

</details>

## Status: v0.5.4.1-dev
## Status: v0.5.4.2-dev

| Area | Status |
| --- | --- |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Gekauft als kleiner WLAN-Würfel mit eher bescheidener Werksfirmware – und von Anfang an mit dem Plan, etwas Eigenes daraus zu machen.

[![Build](https://github.com/du13500/pixelstop/actions/workflows/build.yml/badge.svg)](https://github.com/du13500/pixelstop/actions/workflows/build.yml)
![Version](https://img.shields.io/badge/version-v0.5.4.1--dev-orange)
![Version](https://img.shields.io/badge/version-v0.5.4.2--dev-orange)
![Hardware](https://img.shields.io/badge/hardware-ESP8266%20%C2%B7%20SmallTV--Ultra-blue)
![Hardwaretest](https://img.shields.io/badge/hardwaretest-v0.5.4.1%20offen-yellow)
![Hardwaretest](https://img.shields.io/badge/hardwaretest-v0.5.4.2%20offen-yellow)
![Hobbyprojekt](https://img.shields.io/badge/hobbyprojekt-nicht%20kommerziell-lightgrey)
![Lizenz](https://img.shields.io/badge/lizenz-MIT-green)
![Mission](https://img.shields.io/badge/mission-Know%20before%20you%20go-ff5d56)
Expand Down Expand Up @@ -59,7 +59,7 @@ Dazu kommen Nachtmodus, Helligkeit ab 1 %, Ortssuche mit Karte, griechische und

</details>

## Entwicklungsstand: v0.5.4.1-dev
## Entwicklungsstand: v0.5.4.2-dev

| Bereich | Stand |
| --- | --- |
Expand Down
6 changes: 4 additions & 2 deletions TESTPLAN.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Testplan

Stand: v0.5.4.1-dev (10.11.2026). Dieser Plan wird mit jeder Version aktualisiert; frühere Pläne stehen in der Git-Historie, Änderungen in [`CHANGELOG.md`](CHANGELOG.md).
Stand: v0.5.4.2-dev (10.11.2026). Dieser Plan wird mit jeder Version aktualisiert; frühere Pläne stehen in der Git-Historie, Änderungen in [`CHANGELOG.md`](CHANGELOG.md).

## Hardwaretest v0.5.4.1-dev
## Hardwaretest v0.5.4.2-dev

0a. **v0.5.4.2:** Im Log nach jedem Start eine Zeile „WLAN | verbunden“ (HTTP-Feld = Funkverbindung nach ms, Wert = IP nach ms). Bei Problemen „WLAN | Fehler“ mit Status. Anzeigename: Ort um mehr als 5 km verschieben → Dialog mit Leeren/Behalten.

0. **v0.5.4.1:** Nach dem Flashen und nach mehreren Neustarts verbindet sich der Würfel wieder in wenigen Sekunden (kein Setup-Hotspot, kein Neustart nach ~83 s); Radarabrufe wieder um 1–2 s; Speichern ohne geänderten Hostnamen startet nicht neu.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixelstop-checks",
"version": "0.5.4.1-dev",
"version": "0.5.4.2-dev",
"private": true,
"scripts": {
"test:webui": "node tests/webui.cjs"
Expand Down
2 changes: 1 addition & 1 deletion src/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void printEvent(Print& out,const Event& e){
char b[160];snprintf(b,sizeof(b),"%lu ms | %s | %s | HTTP %d | Heap %lu B | Block %lu B | Wert %lu\n",(unsigned long)e.at,op,stage,e.code,(unsigned long)e.heap,(unsigned long)e.block,(unsigned long)e.value);out.print(b);
}
void diagPrint(Print& out){
out.print(F(FW_NAME " v" FW_VERSION " Diagnose\nWert: bei OK/Fehler Dauer in ms; bei Pause Wartezeit in ms. Zeit: seit jeweiligem Start.\nHTTP -1: Verbindung fehlgeschlagen; -11: Antwort-Timeout; 429: Anbieterlimit.\nRadar.Position: erfolgreiche Abrufe als eine Zeile mit dem kleinsten Heap waehrend des Abrufs.\nleer: Anbieter kennt keine Daten zum Flugzeug. uebersprungen (Wert): 1 Kontingent, 2 Pause, 4 Speicher. verworfen: Route passt nicht (Wert = Entfernung in km).\nReset: "));out.println(resetReason);out.print(F("Reset-Info: "));out.println(resetInfo);
out.print(F(FW_NAME " v" FW_VERSION " Diagnose\nWert: bei OK/Fehler Dauer in ms; bei Pause Wartezeit in ms. Zeit: seit jeweiligem Start.\nHTTP -1: Verbindung fehlgeschlagen; -11: Antwort-Timeout; 429: Anbieterlimit.\nRadar.Position: erfolgreiche Abrufe als eine Zeile mit dem kleinsten Heap waehrend des Abrufs.\nleer: Anbieter kennt keine Daten zum Flugzeug. uebersprungen (Wert): 1 Kontingent, 2 Pause, 4 Speicher. verworfen: Route passt nicht (Wert = Entfernung in km).\nWLAN beim Start: HTTP-Feld = Funkverbindung nach ms (0 = keine), Wert = IP nach ms bzw. WLAN-Status bei Fehler.\nReset: "));out.println(resetReason);out.print(F("Reset-Info: "));out.println(resetInfo);
if(previousValid){out.print(F("Letzter RTC-Marker des vorherigen Starts (Hinweis, kein Ursachenbeweis):\n"));Event e={previous.at,previous.heap,previous.block,previous.value,(int16_t)previous.code,(uint8_t)previous.op,(uint8_t)previous.stage};printEvent(out,e);}else out.println(F("Kein gueltiger vorheriger RTC-Marker. Stromverlust/OTA kann ihn loeschen."));
if(hasLastError){out.println(F("Letzter Fehler dieses Starts (separat behalten):"));printEvent(out,lastError);if(lastErrorLookup[0])out.println(lastErrorLookup);}
out.println(F("Letzte 24 Ereignisse dieses Starts:"));for(uint8_t i=0;i<count;i++)printEvent(out,events[(next+24-count+i)%24]);
Expand Down
37 changes: 37 additions & 0 deletions src/NetWatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once
// Network watchdog: 10 minutes without any HTTP answer although requests were
// tried (or without Wi-Fi) -> reconnect Wi-Fi; if 5 more minutes bring no new
// answer although requests were tried (or Wi-Fi is still down) -> restart.
// The waiting time doubles after each such restart in a row (`factor`), so an
// outage of one provider does not restart the cube every quarter of an hour.
// Only a NEW answer (after the reconnect) ends the alarm.
// Pure functions without Arduino dependencies so they can be tested on the host.
#include <stdint.h>

static const uint32_t NET_SILENT_MS = 600000UL, NET_RECONNECT_MS = 300000UL;

struct NetWatch { uint32_t start; uint32_t stageAt; uint8_t stage; };
enum NetAction : uint8_t { NET_OK, NET_RECONNECT, NET_RESTART };

// true if millis() value a is set and later than b (wrap-safe)
inline bool netAfter(uint32_t a, uint32_t b) { return a && (int32_t)(a - b) > 0; }

// answer/attempt: millis() of the last HTTP answer / request attempt (0 = none).
// silent receives the time since the last answer (or the start of watching).
inline NetAction netWatchStep(NetWatch& w, uint32_t now, uint32_t answer, uint32_t attempt,
bool wifiDown, uint32_t wifiLostAt, uint32_t factor, uint32_t& silent) {
const uint32_t ref = netAfter(answer, w.start) ? answer : w.start;
silent = now - ref;
if (w.stage && netAfter(answer, w.stageAt)) w.stage = 0; // new answer after reconnect
const uint32_t limit = NET_SILENT_MS * (factor ? factor : 1);
const uint32_t down = wifiDown && wifiLostAt ? now - wifiLostAt : 0;
if (w.stage == 0) {
if ((netAfter(attempt, ref) && silent >= limit) || down >= limit) {
w.stage = 1; w.stageAt = now ? now : 1;
return NET_RECONNECT;
}
return NET_OK;
}
if (now - w.stageAt >= NET_RECONNECT_MS && (netAfter(attempt, w.stageAt) || wifiDown)) return NET_RESTART;
return NET_OK;
}
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
// Single place for name and version; every User-Agent is built from it.
#define FW_NAME "PixelStop"
#define FW_VERSION "0.5.4.1-dev"
#define FW_VERSION "0.5.4.2-dev"
#define FW_REPO "github.com/du13500/pixelstop"
#define FW_USER_AGENT FW_NAME "/" FW_VERSION " (+https://" FW_REPO ")"
46 changes: 24 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "RadarPolicy.h"
#include "DestinationFormat.h"
#include "WebGuard.h"
#include "NetWatch.h"
#include "AdsbQuota.h"

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -169,6 +170,8 @@ static DNSServer dns;
static bool apMode = false;
// Rescue mode after repeated crashes: web interface and update only (no requests).
static bool rescueMode = false;
// millis() of the first radio association (Wi-Fi event), for the start-up log.
static volatile uint32_t wifiAssocMs = 0;
static uint32_t lastSecond = 0;
static uint8_t lastMinute = 255;
static uint32_t lastModeSwitchMs = 0;
Expand Down Expand Up @@ -1178,14 +1181,19 @@ static void connectWiFi() {
WiFi.hostname(cfg.hostname.c_str());
WiFi.setAutoReconnect(true);
// The SSID is used exactly as stored, including blanks at the end.
const uint32_t begun=millis();
WiFi.begin(cfg.ssid.c_str(), cfg.pass.c_str());
gfx->fillScreen(C_BLACK);
centerText(TR("WLAN","WI-FI"), 80, 4, C_YELLOW);
centerText(TR("verbinden...","connecting..."), 126, 2, C_GRAY);

// 30 s: the radio link may stand while the address (DHCP) still takes a moment.
uint32_t start=millis();
while(WiFi.status()!=WL_CONNECTED && millis()-start<18000){delay(200);yield();}
if(WiFi.status()!=WL_CONNECTED){startAP();return;}
while(WiFi.status()!=WL_CONNECTED && millis()-start<30000){delay(200);yield();}
// Log: HTTP field = radio link after ms (0 = none), value = address after ms / Wi-Fi status.
const uint32_t assoc=netAfter(wifiAssocMs,begun)?wifiAssocMs-begun:0;
if(WiFi.status()!=WL_CONNECTED){diagEvent(D_WIFI,DS_FAILED,(int)assoc,WiFi.status());startAP();return;}
diagEvent(D_WIFI,DS_WIFI_UP,(int)assoc,millis()-begun);

apMode=false;
if(MDNS.begin(cfg.hostname.c_str())) MDNS.addService("http","tcp",80);
Expand Down Expand Up @@ -1235,42 +1243,36 @@ static void drawRescue() {
}

// Wi-Fi events arrive outside loop(); they are only noted there.
static WiFiEventHandler wifiLostHandler, wifiGotIpHandler;
static WiFiEventHandler wifiLostHandler, wifiGotIpHandler, wifiAssocHandler;
static volatile uint8_t wifiEvents = 0, wifiLostReason = 0;
static uint32_t wifiLostAt = 0, netWatchStart = 0, netStageAt = 0;
static uint32_t wifiLostAt = 0;
static NetWatch netWatch = {};
static uint16_t wifiReconnects = 0;
static uint8_t netStage = 0;
static void wifiEventsBegin() {
wifiLostHandler = WiFi.onStationModeDisconnected([](const WiFiEventStationModeDisconnected& e) { wifiLostReason = e.reason; wifiEvents |= 1; });
wifiGotIpHandler = WiFi.onStationModeGotIP([](const WiFiEventStationModeGotIP&) { wifiEvents |= 2; });
wifiAssocHandler = WiFi.onStationModeConnected([](const WiFiEventStationModeConnected&) { if (!wifiAssocMs) wifiAssocMs = millis(); });
}
static void wifiEventsHandle(uint32_t now) {
if (!netWatchStart) { wifiEvents = 0; return; } // first connection during start-up
if (!netWatch.start) { wifiEvents = 0; return; } // first connection during start-up
if (wifiEvents & 1) { wifiEvents &= ~1; if (!wifiLostAt) { wifiLostAt = now ? now : 1; diagEvent(D_WIFI, DS_WIFI_LOST, wifiLostReason); } }
if (wifiEvents & 2) {
wifiEvents &= ~2;
if (wifiLostAt) { wifiReconnects++; diagEvent(D_WIFI, DS_WIFI_UP, WiFi.RSSI(), (now - wifiLostAt) / 1000UL); wifiLostAt = 0; }
}
}
// Network watchdog: 10 minutes without any HTTP answer although requests were
// tried (or without Wi-Fi) -> reconnect Wi-Fi; 5 more minutes -> restart. The
// waiting time doubles after each such restart in a row (RTC), so an outage
// of one provider does not restart the cube every quarter of an hour.
static const uint32_t NET_SILENT_MS = 600000UL, NET_RECONNECT_MS = 300000UL;
// Network watchdog (NetWatch.h): reconnect after 10 silent minutes, restart 5 minutes later.
static void networkWatchdog(uint32_t now) {
const uint32_t answer = diagNetworkAnswerMs(), attempt = diagNetworkAttemptMs();
uint32_t ref = netWatchStart;
if (answer && (uint32_t)(answer - ref) < 0x80000000UL) ref = answer;
if (ref == answer && answer) { netStage = 0; if (bootState.hangRestarts) { bootState.hangRestarts = 0; bootStateWrite(); } }
const bool tried = attempt && (uint32_t)(attempt - ref) < 0x80000000UL && attempt != ref;
const uint32_t answer = diagNetworkAnswerMs();
if (bootState.hangRestarts && netAfter(answer, netWatch.start)) { bootState.hangRestarts = 0; bootStateWrite(); }
const uint32_t factor = 1UL << (bootState.hangRestarts > 3 ? 3 : bootState.hangRestarts);
const bool wifiDown = WiFi.status() != WL_CONNECTED && wifiLostAt;
const uint32_t silent = now - ref, down = wifiDown ? now - wifiLostAt : 0;
if (netStage == 0 && ((tried && silent >= NET_SILENT_MS * factor) || down >= NET_SILENT_MS * factor)) {
uint32_t silent = 0;
const NetAction action = netWatchStep(netWatch, now, answer, diagNetworkAttemptMs(),
WiFi.status() != WL_CONNECTED && wifiLostAt, wifiLostAt, factor, silent);
if (action == NET_RECONNECT) {
diagEvent(D_WIFI, DS_WIFI_RETRY, WiFi.status(), silent / 1000UL);
WiFi.disconnect(); WiFi.begin(cfg.ssid.c_str(), cfg.pass.c_str());
netStage = 1; netStageAt = now;
} else if (netStage == 1 && (uint32_t)(now - netStageAt) >= NET_RECONNECT_MS && (tried || wifiDown)) {
} else if (action == NET_RESTART) {
if (bootState.hangRestarts < 255) bootState.hangRestarts++;
diagEvent(D_WIFI, DS_REJECTED, WiFi.status(), silent / 1000UL);
restartNow();
Expand Down Expand Up @@ -1606,7 +1608,7 @@ void setup() {
wifiEventsBegin();
connectWiFi();
setupWeb();
netWatchStart=millis();
netWatch.start=millis();
if(apMode)apRetryAt=millis()+60000UL;

if(rescueMode){drawRescue();return;}
Expand Down
Loading
Loading