Moved to lvgl 9.4 because 9.5 has removed runtime xml support.
Made basic example of editing xml layout from backend.
This commit is contained in:
@@ -60,14 +60,14 @@ internal esp_err_t api_devices_layout_handler(httpd_req_t *req)
|
||||
cJSON *mac_item = cJSON_GetObjectItem(body, "mac");
|
||||
cJSON *xml_item = cJSON_GetObjectItem(body, "xml");
|
||||
|
||||
if (!cJSON_IsString(mac_item) || strlen(mac_item->valuestring) == 0)
|
||||
if (!cJSON_IsString(mac_item) || !mac_item->valuestring || strlen(mac_item->valuestring) == 0)
|
||||
{
|
||||
cJSON_Delete(body);
|
||||
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "Missing 'mac'");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (!cJSON_IsString(xml_item))
|
||||
if (!cJSON_IsString(xml_item) || !xml_item->valuestring)
|
||||
{
|
||||
cJSON_Delete(body);
|
||||
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "Missing 'xml'");
|
||||
@@ -75,10 +75,10 @@ internal esp_err_t api_devices_layout_handler(httpd_req_t *req)
|
||||
}
|
||||
|
||||
bool ok = update_device_layout(mac_item->valuestring, xml_item->valuestring);
|
||||
cJSON_Delete(body);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
cJSON_Delete(body);
|
||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "Device not found");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -86,6 +86,8 @@ internal esp_err_t api_devices_layout_handler(httpd_req_t *req)
|
||||
ESP_LOGI(kTagDeviceLayout, "Updated layout for %s (%zu bytes)", mac_item->valuestring,
|
||||
strlen(xml_item->valuestring));
|
||||
|
||||
cJSON_Delete(body);
|
||||
|
||||
httpd_resp_sendstr(req, "{\"status\":\"ok\"}");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user