Files
yggdrasil/thermo_sensor/main/ygg_http_routes.c
T
2026-09-11 10:19:50 +02:00

25 lines
597 B
C

#include "esp_http_server.h"
#include "ygg_http_routes.h"
extern float last_temperature;
esp_err_t ygg_get_temp_handler(httpd_req_t *req)
{
float current_temp = last_temperature;
char response_json[64];
snprintf(response_json, sizeof(response_json), "{\"temperature\": %.1f}", current_temp);
httpd_resp_set_type(req, "application/json");
httpd_resp_send(req, response_json, HTTPD_RESP_USE_STRLEN);
return ESP_OK;
}
const httpd_uri_t ygg_temp_uri = {
.uri = "/temp",
.method = HTTP_GET,
.handler = ygg_get_temp_handler,
.user_ctx = NULL
};