examples: file_serving: add support for ESP32-S3, refactoring

* Move filesystem mounting code into a separate file to simplify the
  main source file.
* Clean up SDMMC and SDSPI related code. Move pin configuration into
  Kconfig.
* Use same base_path ('/data') for either SPIFFS or SD. Remove the
  check in file_server.c about the base path.
* Update README according to the changes above.
This commit is contained in:
Ivan Grokhotkov
2022-02-08 20:25:08 +01:00
parent eefb0442c9
commit c8d1737d57
12 changed files with 368 additions and 281 deletions

View File

@@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
/* HTTP File Server Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
@@ -443,16 +448,10 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
}
/* Function to start the file server */
esp_err_t start_file_server(const char *base_path)
esp_err_t example_start_file_server(const char *base_path)
{
static struct file_server_data *server_data = NULL;
/* Validate file storage base path */
if (!base_path || strcmp(base_path, "/spiffs") != 0) {
ESP_LOGE(TAG, "File server presently supports only '/spiffs' as base path");
return ESP_ERR_INVALID_ARG;
}
if (server_data) {
ESP_LOGE(TAG, "File server already started");
return ESP_ERR_INVALID_STATE;