diff options
author | xengineering <me@xengineering.eu> | 2025-04-15 22:12:54 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2025-04-16 18:03:40 +0200 |
commit | f4faa103108356bcf53fb7c8829e95f012b21a4a (patch) | |
tree | f0f8e40c0a66090fd027ac31bf5ce213aaf97b63 /fw/app/src/http.c | |
parent | d25c8e08ce6a977977e38365ace9af16acf09195 (diff) | |
download | iot-contact-f4faa103108356bcf53fb7c8829e95f012b21a4a.tar iot-contact-f4faa103108356bcf53fb7c8829e95f012b21a4a.tar.zst iot-contact-f4faa103108356bcf53fb7c8829e95f012b21a4a.zip |
fw: app: http: Add working GET /settings.json
Diffstat (limited to 'fw/app/src/http.c')
-rw-r--r-- | fw/app/src/http.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fw/app/src/http.c b/fw/app/src/http.c index 081629b..83a3568 100644 --- a/fw/app/src/http.c +++ b/fw/app/src/http.c @@ -13,6 +13,7 @@ #include <zephyr/net/http/service.h> #include <zephyr/net/http/status.h> +#include "settings.h" #include "ws.h" @@ -98,9 +99,16 @@ static int settings_handler( struct http_response_ctx *response_ctx, void *user_data ) { - static const char dummy[] = "{\"syslog\":{\"target\":{\"ip\":\"fe80::1\"}}}\n"; - response_ctx->body = (const uint8_t *)dummy; - response_ctx->body_len = sizeof(dummy) - 1; + static char buffer[100]; + + int ret = settings_to_json(buffer, sizeof(buffer)); + if (ret < 0) { + LOG_ERR("Could not serialize payload for settings request"); + return ret; + } + + response_ctx->body = (const uint8_t *)buffer; + response_ctx->body_len = ret; response_ctx->final_chunk = true; response_ctx->status = HTTP_200_OK; |