#include "esp_mac.h" #include "esp_log.h" #include "utils.h" #include "routes.h" static const char *TAG = "routes/shelly"; esp_err_t shelly_handler(httpd_req_t *req) { ESP_LOGD(TAG, "shelly_get_handler %s", req->uri); char* resp = NULL; int rc = asprintf( &resp, "{" "\"type\":\"SHSW-%s\"," "\"mac\":\""MACFMT"\"," "\"auth\":false," "\"fw\":\"20230913-112003/v1.14.0-gcb84623\"," "\"discoverable\":true," "\"longid\":1," "\"num_outputs\":1" "}", CONFIG_SHELLSP_MODEL, MAC2STR(get_wifi_mac())); if (!rc || !resp) { ESP_LOGE(TAG, "Failed to allocate response"); httpd_resp_set_status(req, HTTPD_500); httpd_resp_send(req, NULL, 0); return ESP_FAIL; } httpd_resp_set_status(req, HTTPD_200); httpd_resp_set_type(req, "application/json"); httpd_resp_sendstr(req, resp); free(resp); return ESP_OK; }