remove PSRAM usage
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -64,7 +64,7 @@ esp_err_t api_capabilities_get_handler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "GET /api/capabilities");
|
ESP_LOGI(TAG, "GET /api/capabilities");
|
||||||
|
|
||||||
// Thread nur für esp32c6 oder esp32h2 verfügbar
|
// Thread only available for esp32c6 or esp32h2
|
||||||
bool thread = false;
|
bool thread = false;
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2)
|
#if defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2)
|
||||||
thread = true;
|
thread = true;
|
||||||
@@ -95,7 +95,7 @@ esp_err_t api_wifi_scan_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
uint16_t ap_num = 0;
|
uint16_t ap_num = 0;
|
||||||
esp_wifi_scan_get_ap_num(&ap_num);
|
esp_wifi_scan_get_ap_num(&ap_num);
|
||||||
wifi_ap_record_t *ap_list = heap_caps_calloc(ap_num, sizeof(wifi_ap_record_t), MALLOC_CAP_SPIRAM);
|
wifi_ap_record_t *ap_list = heap_caps_calloc(ap_num, sizeof(wifi_ap_record_t), MALLOC_CAP_DEFAULT);
|
||||||
if (!ap_list)
|
if (!ap_list)
|
||||||
{
|
{
|
||||||
return send_error_response(req, 500, "Memory allocation failed");
|
return send_error_response(req, 500, "Memory allocation failed");
|
||||||
@@ -164,7 +164,7 @@ esp_err_t api_wifi_config_handler(httpd_req_t *req)
|
|||||||
if (is_valid(pw))
|
if (is_valid(pw))
|
||||||
{
|
{
|
||||||
size_t pwlen = strlen(pw->valuestring);
|
size_t pwlen = strlen(pw->valuestring);
|
||||||
char *masked = heap_caps_malloc(pwlen + 1, MALLOC_CAP_SPIRAM);
|
char *masked = heap_caps_malloc(pwlen + 1, MALLOC_CAP_DEFAULT);
|
||||||
if (masked)
|
if (masked)
|
||||||
{
|
{
|
||||||
memset(masked, '*', pwlen);
|
memset(masked, '*', pwlen);
|
||||||
@@ -338,7 +338,7 @@ esp_err_t api_light_mode_handler(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.data.settings.value.int_value = -1; // Unbekannter Modus
|
msg.data.settings.value.int_value = -1; // Unknown mode
|
||||||
}
|
}
|
||||||
message_manager_post(&msg, pdMS_TO_TICKS(100));
|
message_manager_post(&msg, pdMS_TO_TICKS(100));
|
||||||
}
|
}
|
||||||
@@ -445,7 +445,7 @@ esp_err_t api_wled_config_post_handler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "POST /api/wled/config");
|
ESP_LOGI(TAG, "POST /api/wled/config");
|
||||||
|
|
||||||
char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_SPIRAM);
|
char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_DEFAULT);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return send_error_response(req, 500, "Memory allocation failed");
|
return send_error_response(req, 500, "Memory allocation failed");
|
||||||
int total = 0, ret;
|
int total = 0, ret;
|
||||||
@@ -545,7 +545,7 @@ esp_err_t api_schema_get_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
ESP_LOGI(TAG, "Requested schema: %s", filename);
|
ESP_LOGI(TAG, "Requested schema: %s", filename);
|
||||||
|
|
||||||
// Schema-Datei lesen
|
// Read schema file
|
||||||
char path[128];
|
char path[128];
|
||||||
snprintf(path, sizeof(path), "%s", filename);
|
snprintf(path, sizeof(path), "%s", filename);
|
||||||
|
|
||||||
@@ -560,11 +560,11 @@ esp_err_t api_schema_get_handler(httpd_req_t *req)
|
|||||||
return httpd_resp_sendstr(req, "");
|
return httpd_resp_sendstr(req, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gesamtlänge berechnen
|
// Calculate total length
|
||||||
size_t total_len = 0;
|
size_t total_len = 0;
|
||||||
for (int i = 0; i < line_count; ++i)
|
for (int i = 0; i < line_count; ++i)
|
||||||
total_len += strlen(lines[i]) + 1;
|
total_len += strlen(lines[i]) + 1;
|
||||||
char *csv = heap_caps_malloc(total_len + 1, MALLOC_CAP_SPIRAM);
|
char *csv = heap_caps_malloc(total_len + 1, MALLOC_CAP_DEFAULT);
|
||||||
char *p = csv;
|
char *p = csv;
|
||||||
for (int i = 0; i < line_count; ++i)
|
for (int i = 0; i < line_count; ++i)
|
||||||
{
|
{
|
||||||
@@ -607,7 +607,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req)
|
|||||||
ESP_LOGI(TAG, "Extracted filename: %s", filename);
|
ESP_LOGI(TAG, "Extracted filename: %s", filename);
|
||||||
|
|
||||||
// Dynamically read POST body (like api_wled_config_post_handler)
|
// Dynamically read POST body (like api_wled_config_post_handler)
|
||||||
char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_SPIRAM);
|
char *buf = heap_caps_malloc(MAX_BODY_SIZE, MALLOC_CAP_DEFAULT);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Memory allocation failed for POST body");
|
ESP_LOGE(TAG, "Memory allocation failed for POST body");
|
||||||
@@ -634,7 +634,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req)
|
|||||||
if (total > 0 && buf[total - 1] != '\n')
|
if (total > 0 && buf[total - 1] != '\n')
|
||||||
line_count++; // last line without \n
|
line_count++; // last line without \n
|
||||||
|
|
||||||
char **lines = (char **)heap_caps_malloc(line_count * sizeof(char *), MALLOC_CAP_SPIRAM);
|
char **lines = (char **)heap_caps_malloc(line_count * sizeof(char *), MALLOC_CAP_DEFAULT);
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
char *saveptr = NULL;
|
char *saveptr = NULL;
|
||||||
char *line = strtok_r(buf, "\n", &saveptr);
|
char *line = strtok_r(buf, "\n", &saveptr);
|
||||||
@@ -642,7 +642,7 @@ esp_err_t api_schema_post_handler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
// Ignore empty lines
|
// Ignore empty lines
|
||||||
if (line[0] != '\0')
|
if (line[0] != '\0')
|
||||||
lines[idx++] = heap_caps_strdup(line, MALLOC_CAP_SPIRAM);
|
lines[idx++] = heap_caps_strdup(line, MALLOC_CAP_DEFAULT);
|
||||||
line = strtok_r(NULL, "\n", &saveptr);
|
line = strtok_r(NULL, "\n", &saveptr);
|
||||||
}
|
}
|
||||||
int actual_count = idx;
|
int actual_count = idx;
|
||||||
@@ -961,7 +961,7 @@ esp_err_t api_captive_portal_handler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Captive portal detection: %s", req->uri);
|
ESP_LOGI(TAG, "Captive portal detection: %s", req->uri);
|
||||||
|
|
||||||
// captive.html direkt ausliefern (Status 200, text/html)
|
// Serve captive.html directly (status 200, text/html)
|
||||||
const char *base_path = CONFIG_API_SERVER_STATIC_FILES_PATH;
|
const char *base_path = CONFIG_API_SERVER_STATIC_FILES_PATH;
|
||||||
char filepath[256];
|
char filepath[256];
|
||||||
snprintf(filepath, sizeof(filepath), "%s/captive.html", base_path);
|
snprintf(filepath, sizeof(filepath), "%s/captive.html", base_path);
|
||||||
@@ -970,7 +970,7 @@ esp_err_t api_captive_portal_handler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "captive.html not found: %s", filepath);
|
ESP_LOGE(TAG, "captive.html not found: %s", filepath);
|
||||||
httpd_resp_set_status(req, "500 Internal Server Error");
|
httpd_resp_set_status(req, "500 Internal Server Error");
|
||||||
httpd_resp_sendstr(req, "Captive Portal nicht verfügbar");
|
httpd_resp_sendstr(req, "Captive portal not available");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
httpd_resp_set_type(req, "text/html");
|
httpd_resp_set_type(req, "text/html");
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ esp_err_t add_light_item(const char time[5], uint8_t red, uint8_t green, uint8_t
|
|||||||
uint8_t brightness, uint8_t saturation)
|
uint8_t brightness, uint8_t saturation)
|
||||||
{
|
{
|
||||||
// Allocate memory for a new node in PSRAM.
|
// Allocate memory for a new node in PSRAM.
|
||||||
light_item_node_t *new_node = (light_item_node_t *)heap_caps_malloc(sizeof(light_item_node_t), MALLOC_CAP_SPIRAM);
|
light_item_node_t *new_node = (light_item_node_t *)heap_caps_malloc(sizeof(light_item_node_t), MALLOC_CAP_DEFAULT);
|
||||||
if (new_node == NULL)
|
if (new_node == NULL)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory in PSRAM for new light_item_node_t.");
|
ESP_LOGE(TAG, "Failed to allocate memory for new light_item_node_t.");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,8 +372,7 @@ void start_simulation_task(void)
|
|||||||
{
|
{
|
||||||
stop_simulation_task();
|
stop_simulation_task();
|
||||||
|
|
||||||
simulation_config_t *config =
|
simulation_config_t *config = (simulation_config_t *)heap_caps_malloc(sizeof(simulation_config_t), 0);
|
||||||
(simulation_config_t *)heap_caps_malloc(sizeof(simulation_config_t), MALLOC_CAP_SPIRAM);
|
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory for simulation config.");
|
ESP_LOGE(TAG, "Failed to allocate memory for simulation config.");
|
||||||
|
|||||||
Reference in New Issue
Block a user