From 6c20a210f9e3140bc86350d7c73314d92c04d9e4 Mon Sep 17 00:00:00 2001 From: bogdan Date: Sun, 4 Feb 2024 17:53:53 +0200 Subject: [PATCH] fixed content type for dynamic resources, added for test modem command with callback --- src/FileServer.c | 4 ++++ src/GSMTransport.c | 8 +++++++- src/HTTPServer.c | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/FileServer.c b/src/FileServer.c index cde44b1..0c0f4c0 100644 --- a/src/FileServer.c +++ b/src/FileServer.c @@ -70,6 +70,10 @@ static esp_err_t set_content_type_from_file(httpd_req_t *req, { return httpd_resp_set_type(req, "font/woff2"); } + else if (IS_FILE_EXT(filename, ".json")) + { + return httpd_resp_set_type(req, "application/json"); + } /* This is a limited set only */ /* For any other type always set as plain text */ return httpd_resp_set_type(req, "text/plain"); diff --git a/src/GSMTransport.c b/src/GSMTransport.c index 6b38cc4..c22581c 100644 --- a/src/GSMTransport.c +++ b/src/GSMTransport.c @@ -331,9 +331,15 @@ void ModemSendAT(char *cmd, char *resp, int timeout) ESP_LOGI(TAG, "Response:%s", resp); } +esp_err_t cmd_cb(uint8_t* data, int len) +{ + ESP_LOGI(TAG, "Response:%*s", len, data); + return ESP_OK; +} + void ModemSendSMS(void) { - +esp_modem_command(dce, "atd", &cmd_cb, 3000); } #endif diff --git a/src/HTTPServer.c b/src/HTTPServer.c index 456374f..5e675a1 100644 --- a/src/HTTPServer.c +++ b/src/HTTPServer.c @@ -147,6 +147,10 @@ static esp_err_t set_content_type_from_file(httpd_req_t *req, { return httpd_resp_set_type(req, "font/woff2"); } + else if (IS_FILE_EXT(filename, ".json")) + { + return httpd_resp_set_type(req, "application/json"); + } /* This is a limited set only */ /* For any other type always set as plain text */ return httpd_resp_set_type(req, "text/plain");