Both httpd servers now expose JSON endpoints (POST /api/wifi on the commissioning AP; GET /api/status, GET/POST /api/mqtt on the settings server) instead of form-urlencoded bodies, with CORS enabled (http_cors.h) so a separately-hosted web app can call them from a browser across origins -- not just the on-device pages, which now use the same endpoints via fetch() too. No JSON library ships with ESP-IDF v6.0.2 core (verified: no cJSON, no bundled json component). Given these payloads are tiny, flat, fixed-shape objects, json_helpers.h hand-rolls minimal strstr-based extraction rather than adding a 4th external registry dependency (already have mdns, mqtt, led_strip). The settings page (mqtt.cpp) changes from server-side snprintf-built dynamic HTML to a static embedded settings.html that fetches /api/mqtt on load -- simpler code, and the actual point of the refactor: the same API a future kvida-sdk client can use. url_decode.h is removed (no longer needed once request bodies are JSON instead of form-urlencoded). Verified end-to-end against real hardware: /api/status, /api/mqtt, and the CORS preflight for POST /api/mqtt all return correct responses/headers when queried with a cross-origin Origin header. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
8 lines
317 B
CMake
8 lines
317 B
CMake
idf_component_register(
|
|
SRCS "src/commissioning.cpp" "src/dns_server.c" "src/mqtt.cpp"
|
|
INCLUDE_DIRS "include"
|
|
PRIV_INCLUDE_DIRS "src"
|
|
PRIV_REQUIRES esp_wifi esp_netif esp_event esp_http_server esp_timer nvs_flash espressif__mqtt espressif__mdns
|
|
EMBED_FILES "src/portal.html" "src/settings.html"
|
|
)
|