From 4a9b462ceaa89c2cd9d135e6df0941a10eb97aaf Mon Sep 17 00:00:00 2001 From: Stefan Koelle Date: Sun, 2 Aug 2026 10:30:14 +0200 Subject: [PATCH] Phase 2: add Serial-log API verification at boot Fetch weather/calendar/departures once in setup() after WiFi and dump parsed fields to Serial, so JSON parsing against the three real endpoints can be verified on hardware independently of the UI. API layer itself unchanged (1:1 from m5stack-dashboard). --- src/main.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ea0c12e..d7bd0f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,9 @@ #include #include #include "display/display_setup.h" +#include "api/weather_api.h" +#include "api/calendar_api.h" +#include "api/departures_api.h" namespace { @@ -27,6 +30,44 @@ void connectWifi() { } } +// Phase 2 verification: fetch all three APIs once at boot and dump parsed +// fields to Serial so JSON parsing can be verified independently of the UI. +void verifyApisViaSerial() { + Serial.println("\n=== Wetter ==="); + WeatherData w = fetchWeather(); + Serial.printf("valid=%d temp=%d symbol=%s desc=%s forecast=%u\n", + w.valid, w.current.temperature, + w.current.symbol.c_str(), w.current.description.c_str(), + w.forecast.size()); + for (size_t i = 0; i < w.forecast.size() && i < 3; ++i) { + const auto &f = w.forecast[i]; + Serial.printf(" [%u] %s %dC %s precip=%.2f/%s\n", i, f.time.c_str(), + f.temperature, f.description.c_str(), + f.precipitationProbability, f.precipitationType.c_str()); + } + + Serial.println("\n=== Kalender ==="); + CalendarData c = fetchCalendar(); + Serial.printf("valid=%d events=%u\n", c.valid, c.events.size()); + for (size_t i = 0; i < c.events.size() && i < 3; ++i) { + const auto &e = c.events[i]; + Serial.printf(" [%u] %s | %s all_day=%d\n", i, e.summary.c_str(), + e.startAt.c_str(), e.allDay); + } + + Serial.println("\n=== MVG ==="); + DeparturesData d = fetchDepartures(); + Serial.printf("valid=%d departures=%u\n", d.valid, d.departures.size()); + for (size_t i = 0; i < d.departures.size() && i < 3; ++i) { + const auto &dep = d.departures[i]; + Serial.printf(" [%u] %s %s -> %s %s delay=%d cancel=%d\n", i, + dep.type.c_str(), dep.line.c_str(), + dep.destination.c_str(), dep.timeStr.c_str(), + dep.delayMin, dep.cancelled); + } + Serial.println("=== API verification done ===\n"); +} + void btn_event_cb(lv_event_t *e) { lv_obj_t *label = (lv_obj_t *)lv_event_get_user_data(e); static int n = 0; @@ -56,6 +97,7 @@ void setup() { Serial.println("WT32-SC01 Plus booting..."); display_init(); connectWifi(); + verifyApisViaSerial(); buildTestScreen(); Serial.println("Setup done."); }