Skip to content

Commit aa5f7e1

Browse files
committed
Add commands to clear logs
[ESP999]ERROR for error logs, [ESP999]INFO for info logs, [ESP999]STATUS for status logs, [ESP999]ALL for all logs,
1 parent afa0edd commit aa5f7e1

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

esp8266/command.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ void COMMAND::execute_command(int cmd,String cmd_params)
9595
Serial.print("\r\n");
9696
}
9797
break;
98+
case 999:
99+
if (cmd_params=="ERROR")
100+
{
101+
web_interface->error_msg.clear();
102+
}
103+
else if (cmd_params=="INFO")
104+
{
105+
web_interface->info_msg.clear();
106+
}
107+
else if (cmd_params=="STATUS")
108+
{
109+
web_interface->status_msg.clear();
110+
}
111+
else if (cmd_params=="ALL")
112+
{
113+
web_interface->error_msg.clear();
114+
web_interface->status_msg.clear();
115+
web_interface->info_msg.clear();
116+
}
117+
break;
98118
//default:
99119

100120
}

esp8266/data/printer.tpl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,27 @@ $INCLUDE[header.inc]$
3737
<tr><td><table width="100%"><tr><td width="auto"><label>Command:</label></td>
3838
<td width="100%"><input class="form-control" id="cmd" type="text" style="width: 100%;"></td>
3939
<td width="auto"><input type="button" class="btn btn-primary" value="Send" onclick="Sendcustomcommand();"></td></tr></table></td></tr>
40-
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Info:</label></td><td width=100% id="infomsg" class="text-info"></td></tr></table></tr>
41-
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Error:</label></td><td width=100% id="errormsg" class="text-info"></td></tr></table></tr>
42-
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Status:</label></td><td width=100% id="statusmsg" class="text-info"></td></tr></table></tr>
40+
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Info:</label><br>
41+
<center><table><tr><td><div class="btnimg" onclick="if(confirm('Clear Info log ?'))Sendcommand('[ESP999]INFO');">
42+
<svg height="20" width="20" viewBox="0 0 40 40" >";
43+
<circle cx="20" cy="20" r="17" stroke="black" stroke-width="1" fill="red" />
44+
<line x1="11" y1="11" x2="29" y2="29" style="stroke:white;stroke-width:6" />
45+
<line x1="29" y1="11" x2="11" y2="29" style="stroke:white;stroke-width:6" /></svg></div></td></tr></table></center>
46+
</td><td width=100% id="infomsg" class="text-info"></td></tr></table></tr>
47+
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Error:</label><br>
48+
<center><table><tr><td><div class="btnimg" onclick="if(confirm('Clear Error log ?'))Sendcommand('[ESP999]ERROR');">
49+
<svg height="20" width="20" viewBox="0 0 40 40" >";
50+
<circle cx="20" cy="20" r="17" stroke="black" stroke-width="1" fill="red" />
51+
<line x1="11" y1="11" x2="29" y2="29" style="stroke:white;stroke-width:6" />
52+
<line x1="29" y1="11" x2="11" y2="29" style="stroke:white;stroke-width:6" /></svg></div></td></tr></table></center>
53+
</td><td width=100% id="errormsg" class="text-info"></td></tr></table></tr>
54+
<tr><td><hr></td></tr><tr><td><table><tr><td><label>Status:</label><br>
55+
<center><table><tr><td><div class="btnimg" onclick="if(confirm('Clear Status log ?'))Sendcommand('[ESP999]STATUS');">
56+
<svg height="20" width="20" viewBox="0 0 40 40" >";
57+
<circle cx="20" cy="20" r="17" stroke="black" stroke-width="1" fill="red" />
58+
<line x1="11" y1="11" x2="29" y2="29" style="stroke:white;stroke-width:6" />
59+
<line x1="29" y1="11" x2="11" y2="29" style="stroke:white;stroke-width:6" /></svg></div></td></tr></table></center>
60+
</td><td width=100% id="statusmsg" class="text-info"></td></tr></table></tr>
4361
<tr><td><hr></td></tr><tr><td><table><tr><td class="btnimg" onclick="Sendcommand('M24');">
4462
<svg width="40" height="40" viewBox="0 0 40 40"><circle cx="20" cy="20" r="18" stroke="black" stroke-width="2" fill="white" /><polygon points="15,10 30,20 15,30" fill:"white" stroke:"white" stroke-width:"1" /></svg></td>
4563
<td class="btnimg" onclick="Sendcommand('M25');"><svg width="40" height="40" viewBox="0 0 40 40"> <circle cx="20" cy="20" r="18" stroke="black" stroke-width="2" fill="white" />

esp8266/webinterface.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern "C" {
3232
#include <FS.h>
3333
#include "LinkedList.h"
3434
#include "storestrings.h"
35+
#include "command.h"
3536

3637
#ifdef SSDP_FEATURE
3738
#include <ESP8266SSDP.h>
@@ -3091,6 +3092,25 @@ void handle_web_command()
30913092
Serial.println(scmd);
30923093
//give an ack - we need to be polite, right ?
30933094
web_interface->WebServer.send(200,"text/plain","Ok");
3095+
//if it is for ESP module [ESPXXX]<parameter>
3096+
int ESPpos = scmd.indexOf("[ESP");
3097+
if (ESPpos>-1)
3098+
{//is there the second part?
3099+
int ESPpos2 = scmd.indexOf("]",ESPpos);
3100+
if (ESPpos2>-1)
3101+
{ //Split in command and parameters
3102+
String cmd_part1=scmd.substring(ESPpos+4,ESPpos2);
3103+
String cmd_part2="";
3104+
//is there space for parameters?
3105+
if (ESPpos2<scmd.length())
3106+
{
3107+
cmd_part2=scmd.substring(ESPpos2+1);
3108+
}
3109+
//if command is a valid number then execute command
3110+
if(cmd_part1.toInt()!=0)COMMAND::execute_command(cmd_part1.toInt(),cmd_part2);
3111+
//if not is not a valid [ESPXXX] command
3112+
}
3113+
}
30943114
}
30953115
}
30963116

page5.png

1.48 KB
Loading

0 commit comments

Comments
 (0)