mirror of
https://github.com/skoelle/wt32sc01-dashboard.git
synced 2026-09-18 01:40:24 +00:00
http_client/weather_api/calendar_api/departures_api are hardware- independent (HTTP GET + ArduinoJson parsing, same endpoints, same JSON). Kept verbatim per PLAN.md migration strategy; only changed #include "../../include/secrets.h" -> #include <secrets.h> to match the PlatformIO include/ layout (no functional change).
26 lines
601 B
C++
26 lines
601 B
C++
#include "http_client.h"
|
|
#include <HTTPClient.h>
|
|
#include <WiFi.h>
|
|
|
|
ApiResult httpGet(const String &url, uint32_t timeoutMs) {
|
|
ApiResult result;
|
|
if (WiFi.status() != WL_CONNECTED) {
|
|
result.success = false;
|
|
result.httpCode = -1;
|
|
return result;
|
|
}
|
|
HTTPClient http;
|
|
http.setTimeout(timeoutMs);
|
|
http.begin(url);
|
|
int code = http.GET();
|
|
result.httpCode = code;
|
|
if (code == HTTP_CODE_OK) {
|
|
result.body = http.getString();
|
|
result.success = true;
|
|
} else {
|
|
result.success = false;
|
|
}
|
|
http.end();
|
|
return result;
|
|
}
|