When a GET-request arrives, a handler replies with a string:
Code: Select all
// GET request handler (pseudo code)
static esp_err_t basic_auth_get_handler(httpd_req_t *req) {
…
// Send a string reply
httpd_resp_send(“some string”)); //etc.
}
In my case however, the string is stored on an sdCard. So I want to do something like
Code: Select all
// GET request handler (pseudo-code)
static esp_err_t basic_auth_get_handler(httpd_req_t *req) {
…
// Fetch reply-string from sd-card
myString = read_sdcard()
httpd_resp_send(myString)); //etc.
}
To solve this, I am thinking to use a mutex to co-ordinate reads/writes. Something like:
Code: Select all
//GET request handler (pseudo-code)
static esp_err_t basic_auth_get_handler(httpd_req_t *req) {
…
// Use a mutex to safely access sdCard.
if (xSemaphoreTake(myMutex, portMAX_DELAY) == pdTRUE) {
myString = read_sd_card(myFile)
xSemaphoreGive(myMutex);
}
httpd_resp_send(myString)); // etc
}
FreeRTOS say " xSemaphoreTake() must not be called from an ISR“
I don’t know how Espressif’s http server works ‘under the hood’.
Can I be confident that basic_auth_get_handler() isn’t an ISR?
thanks for any advice