- add ajax /console/clear - fix #348

pull/458/head
Bartlomiej Zimon 7 years ago committed by Thorsten von Eicken
parent 03bea3dd2d
commit 9d5bfffc14
  1. 1
      esp-link/main.c
  2. 5
      html/console.html
  3. 9
      serial/console.c
  4. 1
      serial/console.h

@ -88,6 +88,7 @@ HttpdBuiltInUrl builtInUrls[] = {
{ "/log/reset", cgiReset, NULL }, { "/log/reset", cgiReset, NULL },
{ "/console/reset", ajaxConsoleReset, NULL }, { "/console/reset", ajaxConsoleReset, NULL },
{ "/console/baud", ajaxConsoleBaud, NULL }, { "/console/baud", ajaxConsoleBaud, NULL },
{ "/console/clear", ajaxConsoleClear, NULL },
{ "/console/fmt", ajaxConsoleFormat, NULL }, { "/console/fmt", ajaxConsoleFormat, NULL },
{ "/console/text", ajaxConsole, NULL }, { "/console/text", ajaxConsole, NULL },
{ "/console/send", ajaxConsoleSend, NULL }, { "/console/send", ajaxConsoleSend, NULL },

@ -91,7 +91,10 @@
$("#clear-button").addEventListener("click", function(e) { $("#clear-button").addEventListener("click", function(e) {
e.preventDefault(); e.preventDefault();
var co = $("#console"); var co = $("#console");
co.innerHTML = ""; ajaxSpin('POST', "/console/clear",
function(resp) { showNotification("uC buffer cleared"); co.innerHTML = ""; co.textEnd = 0;},
function(s, st) { showWarning("Error clearing buffer in uC"); }
);
}); });
ajaxJson('GET', "/console/baud", ajaxJson('GET', "/console/baud",

@ -59,6 +59,15 @@ ajaxConsoleReset(HttpdConnData *connData) {
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }
int ICACHE_FLASH_ATTR
ajaxConsoleClear(HttpdConnData *connData) {
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.
jsonHeader(connData, 200);
//reset buffer
console_rd = console_wr = console_pos = 0;
return HTTPD_CGI_DONE;
}
int ICACHE_FLASH_ATTR int ICACHE_FLASH_ATTR
ajaxConsoleBaud(HttpdConnData *connData) { ajaxConsoleBaud(HttpdConnData *connData) {
if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. if (connData->conn==NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up.

@ -7,6 +7,7 @@ void consoleInit(void);
void ICACHE_FLASH_ATTR console_write_char(char c); void ICACHE_FLASH_ATTR console_write_char(char c);
int ajaxConsole(HttpdConnData *connData); int ajaxConsole(HttpdConnData *connData);
int ajaxConsoleReset(HttpdConnData *connData); int ajaxConsoleReset(HttpdConnData *connData);
int ajaxConsoleClear(HttpdConnData *connData);
int ajaxConsoleBaud(HttpdConnData *connData); int ajaxConsoleBaud(HttpdConnData *connData);
int ajaxConsoleFormat(HttpdConnData *connData); int ajaxConsoleFormat(HttpdConnData *connData);
int ajaxConsoleSend(HttpdConnData *connData); int ajaxConsoleSend(HttpdConnData *connData);

Loading…
Cancel
Save