// Wi-Fi station-mode connection management, using the credentials in // device_config.h. // // IMPORTANT hardware caveat (honesty note, not code): the ESP32-P4 SoC has // no integrated 2.4GHz radio -- real Wi-Fi on P4 hardware requires a // companion chip (e.g. ESP32-C6) wired via SDIO/SPI running "esp-hosted", // which presents this exact same esp_wifi/esp_netif API to application code. // This file is written against that standard API surface, so it should be // portable unchanged to a hosted-mode P4 board or to a Wi-Fi-native target // (e.g. `idf.py set-target esp32s3`) -- only sdkconfig / board wiring // differs, not this code. See README.md for the full explanation. This is // exactly the kind of thing nobody can verify without the real board, so // it's called out explicitly rather than glossed over. #pragma once #include #include "esp_err.h" #include "freertos/FreeRTOS.h" #ifdef __cplusplus extern "C" { #endif // Initializes NVS (required by esp_wifi), the default netif, the event // loop, and esp_wifi in station mode, then starts connecting using // DEVICE_WIFI_SSID / DEVICE_WIFI_PASSWORD from device_config.h. Registers // an internal event handler that retries on disconnect with a capped // backoff. Call once from app_main() before starting the telemetry task. esp_err_t wifi_manager_start(void); // Blocks (efficiently, via an internal FreeRTOS event group) until the // station has an IP address, or until `timeout_ticks` elapses. // Returns ESP_OK once connected, ESP_ERR_TIMEOUT otherwise. esp_err_t wifi_manager_wait_connected(TickType_t timeout_ticks); // True if the station currently holds an IP (i.e. the last known state is // "connected"), for callers that want a non-blocking check (e.g. the // telemetry task deciding whether to bother building a request this cycle). bool wifi_manager_is_connected(void); #ifdef __cplusplus } #endif