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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
run: |
python3 tools/check.py
python3 tools/test_radar.py
python3 tools/test_radar_schedule.py
python3 tools/test_motion.py
python3 tools/test_policy.py
python3 tools/test_chunked.py
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Änderungen

## v0.5.4.3-dev

- **Radar fragt wieder Positionen ab:** In v0.5.4 schob jede wiederholte Routenabfrage für dasselbe Flugzeug den nächsten Positionsabruf um ein ganzes Intervall nach hinten. Weil diese Wiederholungen alle 2–5 Minuten kamen und das Kontingent-Intervall länger war, kam nie wieder ein Positionsabruf – das Radar blieb beim alten Flugzeug stehen (nachgestellt: 1 Positionsabruf in 2 Stunden). Jetzt gilt: höchstens eine adsb.lol-Routenabfrage zwischen zwei Positionsabrufen, und nur für ein neues Flugzeug.
- **Wiederholte Abfragen für dasselbe Flugzeug** laufen nur noch über adsbdb (ohne adsb.lol-Kontingent), alle 10 statt alle 2–5 Minuten, und behalten Route und Airline, statt sie bis zur Antwort zu löschen.
- **Flug-Tracker im Kontingent:** Die Live-Abfragen bei adsb.lol (bisher fest alle 15 s) folgen derselben Planung wie das Radar.
- **Hochrechnung bis 10 Minuten** (vorher 4), passend zu den längeren Intervallen.
- **Neue Prüfung** `tools/test_radar_schedule.py`: simuliert zwei Stunden mit den echten Planungsfunktionen (gleiches Flugzeug, neue Flugzeuge, Rotation) und schlägt bei v0.5.4 an.

## 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.
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.2--dev-orange)
![Version](https://img.shields.io/badge/version-v0.5.4.3--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.2%20pending-yellow)
![Hardware test](https://img.shields.io/badge/hardware%20test-v0.5.4.3%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.2-dev
## Status: v0.5.4.3-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.2--dev-orange)
![Version](https://img.shields.io/badge/version-v0.5.4.3--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.2%20offen-yellow)
![Hardwaretest](https://img.shields.io/badge/hardwaretest-v0.5.4.3%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.2-dev
## Entwicklungsstand: v0.5.4.3-dev

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

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).
Stand: v0.5.4.3-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.2-dev
## Hardwaretest v0.5.4.3-dev

0b. **v0.5.4.3:** Radar über eine Stunde: Im Log kommen regelmäßig „Radar.Position | OK“-Zeilen (Abstand ≈ „Radar-Intervall“ im Status); höchstens eine „Radar.Route“ zwischen zwei Positionen; spätere Prüfungen desselben Flugzeugs nur als „Radar.Metadata“.

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.

Expand Down Expand Up @@ -49,6 +51,7 @@ Dieselben Prüfungen führt der Workflow [`build.yml`](.github/workflows/build.y
```sh
python3 tools/check.py
python3 tools/test_radar.py
python3 tools/test_radar_schedule.py
python3 tools/test_motion.py
python3 tools/test_policy.py
python3 tools/test_chunked.py
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.2-dev",
"version": "0.5.4.3-dev",
"private": true,
"scripts": {
"test:webui": "node tests/webui.cjs"
Expand Down
27 changes: 17 additions & 10 deletions src/Flight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

static FlightSnapshot g_f = {};
static uint32_t g_lastPollMs = 0;
// At most one adsb.lol route lookup between two position requests (never starve positions).
static bool g_routeSincePoll = false;
static bool g_hasPolled = false;
static uint32_t g_lastOkMs = 0;
// A provider cooldown retains the last aircraft until a new request completes.
Expand Down Expand Up @@ -90,7 +92,7 @@ static bool lookupRouteAdsbLol(const FlightSnapshot& f,RoutePoint pos,Enrichment
// A route lookup takes the place of the next position request (savings mode).
uint8_t skip=adsbLolQuotaWaitMs()?1:(serviceWaitMs(SERVICE_ADSB_LOL)?2:(!tlsHeapReady(adsbLolRx())?4:0));
if(skip){diagLookup(f.hex,f.callsign);diagEvent(D_RADAR_ROUTE,DS_SKIPPED,0,skip);return false;}
g_lastPollMs=millis();
g_lastPollMs=millis();g_routeSincePoll=true;
DiagRequest trace(D_RADAR_ROUTE);diagLookup(f.hex,f.callsign);trace.stage(DS_TLS);
BearSSL::WiFiClientSecure client;makeSecure(client,&g_routeSession,adsbLolRx());
HTTPClient http;http.setTimeout(5000);http.setReuse(false);
Expand Down Expand Up @@ -217,7 +219,8 @@ static void enrichFlight(FlightSnapshot& f,RoutePoint pos) {
char brand[19];
if(entry->airline[0]&&!airlineBrand(f.callsign,brand,sizeof(brand)))strlcpy(f.airline,entry->airline,sizeof(f.airline));
if(entry->type[0]&&metadataTypeMatches(f.typeCode,f.category,entry->typeCode))strlcpy(f.typeName,entry->type,sizeof(f.typeName));
if(entry->route.count && (uint32_t)(now-entry->checked)<300000UL &&
// Routes stay valid between the 10-minute checks; the position check still applies.
if(entry->route.count && (uint32_t)(now-entry->checked)<900000UL &&
routePositionPlausible(pos,entry->airports,entry->airportCount,f.onGround,f.altitudeKnown,f.altitudeFt)){
f.route=entry->route;strlcpy(f.origin,f.route.airports[0],sizeof(f.origin));
strlcpy(f.destination,f.route.airports[f.route.count-1],sizeof(f.destination));
Expand All @@ -232,25 +235,28 @@ static Enrichment* currentEnrichment(){
// The adsb.lol route lookup replaces a position request: it needs a free slot
// in the quota and keeps the minimum distance after a provider limit.
static bool routeSlotFree(){
if(adsbLolWaitMs())return false;
if(g_routeSincePoll||adsbLolWaitMs())return false;
uint32_t minimum=serviceMinIntervalMs(SERVICE_ADSB_LOL);
return !minimum||(uint32_t)(millis()-g_lastPollMs)>=minimum;
}
bool flightEnrichmentDue(){
if(!g_f.valid||g_f.error||!routePointValid(g_position)||!g_f.callsign[0])return false;
Enrichment* e=currentEnrichment();
if(e&&e->phase<3)return e->phase==0?routeSlotFree():!serviceWaitMs(SERVICE_ADSB_DB);
return (!e||(uint32_t)(millis()-e->checked)>=(e->route.count?300000UL:120000UL)) &&
(!g_lastEnrichmentMs||(uint32_t)(millis()-g_lastEnrichmentMs)>=60000UL) && routeSlotFree();
if(g_lastEnrichmentMs&&(uint32_t)(millis()-g_lastEnrichmentMs)<60000UL)return false;
// New aircraft: full lookup including adsb.lol. The same aircraft later: adsbdb
// only (no adsb.lol quota), every 10 minutes, keeping what was found.
if(!e)return routeSlotFree();
return (uint32_t)(millis()-e->checked)>=600000UL&&!serviceWaitMs(SERVICE_ADSB_DB);
}
void flightEnrich(){
if(!flightEnrichmentDue())return;
Enrichment* e=currentEnrichment();
if(!e||e->phase>=3){
if(!e){e=&g_cache[g_cacheNext];g_cacheNext=(g_cacheNext+1)%3;}
if(!e){
e=&g_cache[g_cacheNext];g_cacheNext=(g_cacheNext+1)%3;
*e={};e->used=true;e->checked=millis();g_lastEnrichmentMs=e->checked;
strlcpy(e->hex,g_f.hex,sizeof(e->hex));strlcpy(e->callsign,g_f.callsign,sizeof(e->callsign));
}
}else if(e->phase>=3){e->phase=1;e->checked=millis();g_lastEnrichmentMs=e->checked;}
if(e->phase==0)lookupRouteAdsbLol(g_f,g_position,*e);
else if(e->phase==1)lookupMetadata(g_f,g_position,*e);
else lookupAirline(g_f,*e);
Expand All @@ -274,8 +280,8 @@ void flightReset() {

bool flightPollDue(uint16_t pollSec, float visibleShare) {
if(adsbLolWaitMs())return false;
// A pending route lookup for the shown aircraft goes first and takes this slot.
if(flightEnrichmentDue())return false;
// The first route lookup of a new aircraft goes first and takes this slot.
{Enrichment* e=currentEnrichment();if((!e||e->phase==0)&&flightEnrichmentDue())return false;}
if (!g_hasPolled) return true;
if(pollSec<RADAR_MIN_POLL_SEC)pollSec=RADAR_MIN_POLL_SEC;
uint32_t interval=(uint32_t)pollSec*1000UL;
Expand Down Expand Up @@ -399,6 +405,7 @@ bool flightFetch(float homeLat, float homeLon, uint16_t radiusKm, uint8_t hideMa
struct Completion {~Completion(){g_lastPollMs=millis();}} completion;
g_lastPollMs = millis();
g_hasPolled = true;
g_routeSincePoll = false;
g_lastHttp = 0;
if (WiFi.status() != WL_CONNECTED) { trace.stage(DS_NO_WIFI); return flightFailure("kein WLAN"); }
if (!tlsHeapReady(g_adsbLolRx ? g_adsbLolRx : 512)) { trace.stage(DS_HEAP); return flightFailure("übersprungen: Heap"); }
Expand Down
2 changes: 1 addition & 1 deletion src/RadarMotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct RadarMotion {

// Estimates stop after this time at the latest; slower polls freeze the values.
static const uint32_t RADAR_MOTION_MIN_MS = 60000UL;
static const uint32_t RADAR_MOTION_MAX_MS = 240000UL;
static const uint32_t RADAR_MOTION_MAX_MS = 600000UL; // up to 10 min (quota intervals)
// The altitude follows the vertical rate for a shorter time: aircraft level off.
static const uint32_t RADAR_MOTION_ALT_MS = 45000UL;
// Grace for request duration before a value counts as overdue.
Expand Down
7 changes: 5 additions & 2 deletions src/TrackFlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ bool trackedFlightStatusPollDue(uint16_t pollMinutes) {
return (uint32_t)(millis() - g_lastStatusPollMs) >= (uint32_t)pollMinutes * 60000UL;
}

bool trackedFlightLivePollDue(uint16_t pollSeconds) {
bool trackedFlightLivePollDue(uint16_t pollSeconds, float visibleShare) {
if (adsbLolWaitMs()||!g_t.valid || g_t.terminal || !g_t.flightIcao[0]) return false;
if (g_lastLivePollMs == 0) return true;
return (uint32_t)(millis() - g_lastLivePollMs) >= (uint32_t)pollSeconds * 1000UL;
// Same quota planning as the radar (AdsbQuota.h): spread over every window.
uint32_t interval = (uint32_t)pollSeconds * 1000UL, budget = adsbLolBudgetIntervalMs(visibleShare);
if (interval < budget) interval = budget;
return (uint32_t)(millis() - g_lastLivePollMs) >= interval;
}

const TrackedFlightSnapshot& trackedFlightData() { return g_t; }
Expand Down
2 changes: 1 addition & 1 deletion src/TrackFlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct TrackedFlightSnapshot {

void trackedFlightReset();
bool trackedFlightStatusPollDue(uint16_t pollMinutes);
bool trackedFlightLivePollDue(uint16_t pollSeconds = 15);
bool trackedFlightLivePollDue(uint16_t pollSeconds = 15, float visibleShare = 1.0f);
bool trackedFlightFetchStatus(const String& apiKey, const String& flightNumber);
bool trackedFlightFetchLive();
const TrackedFlightSnapshot& trackedFlightData();
Expand Down
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.2-dev"
#define FW_VERSION "0.5.4.3-dev"
#define FW_REPO "github.com/du13500/pixelstop"
#define FW_USER_AGENT FW_NAME "/" FW_VERSION " (+https://" FW_REPO ")"
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,15 @@ static bool radarActive() {
uint32_t shown=(uint32_t)(millis()-lastModeSwitchMs);
return shown+RADAR_PREFETCH_MS>=stayMs;
}
// Share of the rotation the radar is visible; used to spread the daily budget.
static float radarVisibleShare() {
// Share of the rotation a view is visible (radar incl. prefetch); used to spread the quota.
static float modeVisibleShare(uint8_t mode,uint32_t extraSec) {
if(enabledModeCount()<=1) return 1.0f;
uint32_t total=0;
for(uint8_t i=0;i<MODE_COUNT;i++) if(modeEnabled(i)) total+=max((uint16_t)5,cfg.rotationSec[i]);
uint32_t radar=max((uint16_t)5,cfg.rotationSec[MODE_PLANE])+RADAR_PREFETCH_MS/1000UL;
return total?min(1.0f,(float)radar/(float)total):1.0f;
uint32_t shown=max((uint16_t)5,cfg.rotationSec[mode])+extraSec;
return total?min(1.0f,(float)shown/(float)total):1.0f;
}
static float radarVisibleShare() { return modeVisibleShare(MODE_PLANE,RADAR_PREFETCH_MS/1000UL); }

// ---- local config ------------------------------------------------------------
static const char* CFG_PATH = "/config.json";
Expand Down Expand Up @@ -1690,7 +1691,7 @@ void loop() {
flightEnrich();if(cfg.mode==MODE_PLANE)drawPlane(false);ran=true;
}else if(cfg.mode==MODE_TRACKED_FLIGHT&&cfg.trackedFlightNo.length()&&cfg.aviationstackKey.length()){
if(task==4&&trackedFlightStatusPollDue(cfg.trackerStatusPollMin)){trackedFlightFetchStatus(cfg.aviationstackKey,cfg.trackedFlightNo);trackedFlightFetchRoute();drawTrackedFlight(false);ran=true;}
else if(task==5&&trackedFlightLivePollDue(15)){trackedFlightFetchLive();trackedFlightFetchRoute();drawTrackedFlight(false);ran=true;}
else if(task==5&&trackedFlightLivePollDue(15,modeVisibleShare(MODE_TRACKED_FLIGHT,0))){trackedFlightFetchLive();trackedFlightFetchRoute();drawTrackedFlight(false);ran=true;}
}
if(ran){deferBackgroundNetwork();break;}
}
Expand Down
6 changes: 3 additions & 3 deletions src/webui_html.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static const uint8_t WEBUI_GZ[] PROGMEM = {
0xa7, 0x75, 0x35, 0x97, 0x50, 0xcf, 0x68, 0x39, 0x67, 0x79, 0x6b, 0x8b, 0x6b, 0xf7, 0x36, 0x85, 0xc5, 0xe7, 0xde, 0x26,
0xdb, 0x9c, 0xee, 0x91, 0x39, 0x65, 0xef, 0x1e, 0xd4, 0x6c, 0x56, 0x1f, 0xfc, 0x6e, 0x0c, 0x7b, 0x12, 0xf8, 0x35, 0xb2,
0x18, 0x19, 0x49, 0x54, 0x92, 0x8c, 0x54, 0x2d, 0xd3, 0x80, 0x84, 0xaf, 0x7b, 0xc0, 0x8a, 0x81, 0x2a, 0x44, 0xd6, 0x87,
0x8d, 0xbd, 0x93, 0x66, 0x63, 0xb7, 0xb1, 0xd3, 0xd8, 0x02, 0x4d, 0x3d, 0x41, 0x57, 0xc8, 0x47, 0x4f, 0x68, 0x0a, 0x0d,
0x8d, 0xbd, 0x93, 0x66, 0x63, 0xb7, 0xb1, 0xd3, 0xd8, 0x06, 0x4d, 0x3d, 0x41, 0x57, 0xc8, 0x47, 0x4f, 0x68, 0x0a, 0x0d,
0xc2, 0x64, 0x60, 0x39, 0x91, 0xef, 0xd4, 0x79, 0xa9, 0xbb, 0x1b, 0x8f, 0x9d, 0xf9, 0x2c, 0x41, 0xa2, 0x3f, 0x64, 0xde,
0x05, 0x1d, 0x08, 0x31, 0x5d, 0x35, 0x08, 0xfd, 0xbb, 0x85, 0x64, 0x8b, 0xe5, 0xc3, 0x0d, 0x91, 0xb7, 0x61, 0x41, 0xbf,
0xe5, 0xd4, 0x67, 0xdd, 0x0d, 0x27, 0x78, 0x0f, 0xd0, 0x81, 0xed, 0xec, 0x40, 0xfc, 0xb8, 0xb7, 0x29, 0x4a, 0x94, 0xb4,
Expand Down Expand Up @@ -954,8 +954,8 @@ static const uint8_t WEBUI_GZ[] PROGMEM = {
0x6a, 0xd6, 0xf0, 0x2e, 0x59, 0x4e, 0x27, 0xc3, 0x4a, 0xae, 0xaa, 0xb6, 0x86, 0x94, 0x2d, 0x16, 0x52, 0xf2, 0x24, 0xae,
0x6f, 0xcd, 0x3c, 0xa5, 0xf2, 0x42, 0x45, 0x34, 0x2e, 0x7f, 0xd9, 0x27, 0xf7, 0xde, 0x7a, 0x4d, 0xea, 0x0c, 0x6a, 0xea,
0xf6, 0x59, 0xfe, 0xfd, 0x75, 0x79, 0xf7, 0x90, 0x42, 0x60, 0x4b, 0x11, 0xa6, 0xaa, 0x85, 0x7c, 0xc9, 0xa8, 0x5e, 0x43,
0x54, 0x06, 0x7e, 0xcf, 0x14, 0xd1, 0x07, 0x48, 0x9b, 0x43, 0x61, 0x64, 0x10, 0x6f, 0x60, 0xef, 0xda, 0xff, 0x01, 0x21,
0x9a, 0xc4, 0x69, 0x65, 0xf2, 0x00, 0x00
0x54, 0x06, 0x7e, 0xcf, 0x14, 0xd1, 0x07, 0x48, 0x9b, 0x43, 0x61, 0x64, 0x10, 0x6f, 0x60, 0xef, 0xda, 0xff, 0x01, 0x92,
0xa0, 0xb5, 0xd7, 0x65, 0xf2, 0x00, 0x00
};
static const size_t WEBUI_GZ_LEN = sizeof(WEBUI_GZ);

Expand Down
9 changes: 6 additions & 3 deletions tools/test_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def fn(name):
static Enrichment g_cache[3]={};static uint8_t g_cacheNext=0;static uint32_t g_lastEnrichmentMs=0;
static const char *g_routeStatus="",*g_routeSource="",*g_stage="";
enum {SERVICE_ADSB_LOL,SERVICE_ADSB_DB};uint32_t waits[2]={};uint32_t serviceWaitMs(int i){return waits[i];}
static uint32_t quotaWait=0,minInterval=0,g_lastPollMs=0;uint32_t adsbLolWaitMs(){return waits[SERVICE_ADSB_LOL]>quotaWait?waits[SERVICE_ADSB_LOL]:quotaWait;}uint32_t serviceMinIntervalMs(int){return minInterval;}
static uint32_t quotaWait=0,minInterval=0,g_lastPollMs=0;static bool g_routeSincePoll=false;uint32_t adsbLolWaitMs(){return waits[SERVICE_ADSB_LOL]>quotaWait?waits[SERVICE_ADSB_LOL]:quotaWait;}uint32_t serviceMinIntervalMs(int){return minInterval;}
static int calls[3]={};
static bool pauseRoute=false;
static bool lookupRouteAdsbLol(const FlightSnapshot&,RoutePoint,Enrichment&){calls[0]++;if(pauseRoute)waits[SERVICE_ADSB_LOL]=30000;return false;}
Expand All @@ -42,13 +42,16 @@ def fn(name):
strcpy(g_f.typeCode,"B39M");strcpy(g_f.typeName,"Boeing 737 MAX 9");enrichFlight(g_f,g_position);assert(!strcmp(g_f.typeName,"Boeing 737 MAX 9"));
flightEnrich();assert(calls[0]==1&&calls[1]==1&&calls[2]==0);
waits[SERVICE_ADSB_DB]=30000;assert(!flightEnrichmentDue());waits[SERVICE_ADSB_DB]=0;
flightEnrich();assert(calls[2]==1);assert(!flightEnrichmentDue());now=120999;assert(!flightEnrichmentDue());now=121000;assert(flightEnrichmentDue());
flightEnrich();assert(calls[2]==1);assert(!flightEnrichmentDue());now=600999;assert(!flightEnrichmentDue());now=601000;assert(flightEnrichmentDue());
// The same aircraft later: adsbdb only (no adsb.lol quota), found data is kept.
strcpy(currentEnrichment()->airline,"Kept Air");flightEnrich();assert(calls[0]==1&&calls[1]==2&&!strcmp(currentEnrichment()->airline,"Kept Air"));flightEnrich();flightEnrich();assert(calls[0]==1&&!flightEnrichmentDue());
g_f.error=true;assert(!flightEnrichmentDue());g_f.error=false;
g_f.callsign[0]='A';now=2000;assert(!flightEnrichmentDue());now=61000;assert(flightEnrichmentDue());
g_f.callsign[0]='A';now=602000;assert(!flightEnrichmentDue());now=662000;assert(flightEnrichmentDue());
// The route lookup needs a free quota slot and keeps the minimum distance after a 429.
g_cache[0]={};g_cache[1]={};g_cache[2]={};g_lastEnrichmentMs=0;
quotaWait=5000;assert(!flightEnrichmentDue());quotaWait=0;
minInterval=20000;g_lastPollMs=now-19999;assert(!flightEnrichmentDue());g_lastPollMs=now-20000;assert(flightEnrichmentDue());minInterval=0;
g_routeSincePoll=true;assert(!flightEnrichmentDue());g_routeSincePoll=false;
g_position.lat=NAN;assert(!flightEnrichmentDue());
// A route request can impose the shared provider pause as well.
g_position={51,13};g_f.error=false;g_cache[0]={};g_cache[1]={};g_cache[2]={};g_lastEnrichmentMs=0;pauseRoute=true;
Expand Down
2 changes: 1 addition & 1 deletion tools/test_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
m.hasRate=true;m.rateFpm=600;m.sampleMs=0xFFFFF000U;assert(radarMotionAltitudeFt(m,1000,0xFFFFF000U+6000U,lim)==1060);
m.sampleMs=5000;assert(radarMotionAltitudeFt(m,1000,4000,lim)==1000);
// Limits follow the interval: at least 60 s, at most 4 min.
assert(radarMotionLimitMs(5000)==60000&&radarMotionLimitMs(120000)==135000&&radarMotionLimitMs(900000)==240000);
assert(radarMotionLimitMs(5000)==60000&&radarMotionLimitMs(120000)==135000&&radarMotionLimitMs(420000)==435000&&radarMotionLimitMs(900000)==600000);
// Status dot.
assert(radarDotState(500,30000,false)==RADAR_DOT_NEW);
assert(radarDotState(500,30000,true)==RADAR_DOT_ESTIMATED);
Expand Down
Loading
Loading