diff --git a/main/gb_printer.c b/main/gb_printer.c
index b8ab8e3..1971d78 100644
--- a/main/gb_printer.c
+++ b/main/gb_printer.c
@@ -88,6 +88,15 @@
#define PR_PARAM_SIZE 4
#define PKT_RING_SIZE 4
+#define HTML_HEADER "" \
+ "
" \
+ "" \
+ "ESP32 GameBoy Printer" \
+ "" \
+ ""
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
@@ -268,15 +277,11 @@ CgiStatus cgi_del_all(HttpdConnData *conn)
goto err_out;
}
- httpdStartResponse(conn, 200);
- httpdHeader(conn, "Content-Type", "text/json");
- httpdEndHeaders(conn);
-
dir = opendir(IMGDIR);
if(dir == NULL){
ESP_LOGE(TAG, "[%s] opendir() failed", __func__);
result = -1;
- goto send_data;
+ goto send_reply;
}
while((ent = readdir(dir)) != NULL){
@@ -284,13 +289,32 @@ CgiStatus cgi_del_all(HttpdConnData *conn)
result = unlink(buff);
if(result != 0){
ESP_LOGE(TAG, "[%s] Unlink failed for %s", __func__, buff);
- goto send_data;
+ goto send_reply;
}
}
-send_data:
- snprintf(buff, sizeof(buff), "%s", result == 0 ? "true" : "false");
- httpdSend(conn, buff, -1);
+send_reply:
+ if(result == 0){
+ httpdRedirect(conn, "/index.tpl");
+ } else {
+ httpdStartResponse(conn, 500);
+ httpdHeader(conn, "Content-Type", "text/html");
+ httpdEndHeaders(conn);
+
+ httpdSend(conn, HTML_HEADER, -1);
+ httpdSend(conn, ""
+ "ESP32 Gameboy Printer
"
+ ""
+ "Error while deleting file ", -1);
+ httpdSend(conn, buff, -1);
+ httpdSend(conn, ".
"
+ "Go back"
+ "
"
+ "Retry"
+ "
"
+ ""
+ "", -1);
+ }
err_out:
if(dir != NULL){
@@ -302,11 +326,9 @@ err_out:
CgiStatus cgi_reset_seq(HttpdConnData *conn)
{
- char buff[128];
nvs_handle handle;
int result;
- buff[0] = '\0';
result = 0;
if(conn->isConnectionClosed){
@@ -323,15 +345,28 @@ CgiStatus cgi_reset_seq(HttpdConnData *conn)
nvs_close(handle);
send_reply:
- httpdStartResponse(conn, 200);
- httpdHeader(conn, "Content-Type", "text/json");
- httpdEndHeaders(conn);
+ if(result == ESP_OK){
+ httpdRedirect(conn, "/index.tpl");
+ } else {
+ httpdStartResponse(conn, 500);
+ httpdHeader(conn, "Content-Type", "text/html");
+ httpdEndHeaders(conn);
- snprintf(buff, sizeof(buff), "%s", result == ESP_OK ? "true" : "false");
- httpdSend(conn, buff, -1);
+ httpdSend(conn, HTML_HEADER, -1);
+ httpdSend(conn, ""
+ "ESP32 Gameboy Printer
"
+ ""
+ "Error resetting image sequence."
+ "
"
+ "Go back"
+ "
"
+ "Retry"
+ "
"
+ ""
+ "