11#include " WebServer.h"
2+ #include " SerialOut.h"
3+
4+ #include < ESP8266WiFi.h>
5+ #include < FS.h>
6+ #include < WiFiUdp.h>
27
38WebServerClass::WebServerClass (int port = 80 ) : ESP8266WebServer(port)
49{
@@ -13,7 +18,7 @@ void WebServerClass::init()
1318{
1419 if (!SPIFFS .begin ())
1520 {
16- Serial. println (" [Storage] Couldn't mount file system." );
21+ PRINTLN (" [Storage] Couldn't mount file system." );
1722 return ;
1823 }
1924
@@ -60,7 +65,7 @@ void WebServerClass::init()
6065 {
6166 if (!handleFileRead (uri ()))
6267 {
63- Serial. println (" [Storage] Couldn't find file at \' " + uri () + " \' " + " ." );
68+ PRINTLN (" [Storage] Couldn't find file at \' " + uri () + " \' " + " ." );
6469 send (404 , " text/plain" , " Oops, file not found!" );
6570 }
6671 });
@@ -105,7 +110,7 @@ String WebServerClass::getContentType(String filename)
105110
106111bool WebServerClass::handleFileRead (String path)
107112{
108- Serial. println (" [Storage] File read: " + path);
113+ PRINTLN_VERBOSE (" [Storage] File read: " + path);
109114
110115 webserverBusy = true ;
111116 if (path.endsWith (" /" )) path += " index.htm" ;
@@ -141,7 +146,7 @@ void WebServerClass::handleFileUpload()
141146 String filename = _upload.filename ;
142147 if (!filename.startsWith (" /" ))
143148 filename = " /" + filename;
144- Serial. println (" [Storage] Uploading file: " + filename);
149+ PRINTLN (" [Storage] Uploading file: " + filename);
145150
146151 fsUploadFile = SPIFFS .open (filename, " w" );
147152 filename = String ();
@@ -155,7 +160,7 @@ void WebServerClass::handleFileUpload()
155160 {
156161 if (fsUploadFile)
157162 fsUploadFile.close ();
158- Serial. println (" [Storage] Received total: " + formatBytes (_upload.totalSize ));
163+ PRINTLN (" [Storage] Received total: " + formatBytes (_upload.totalSize ));
159164 }
160165}
161166
@@ -165,7 +170,7 @@ void WebServerClass::handleFileDelete()
165170 return send (500 , " text/plain" , " BAD ARGS" );
166171
167172 String path = arg (0 );
168- Serial. println (" [Storage] Deleting file: " + path);
173+ PRINTLN (" [Storage] Deleting file: " + path);
169174
170175 if (path == " /" )
171176 return send (500 , " text/plain" , " BAD PATH" );
@@ -184,7 +189,7 @@ void WebServerClass::handleFileCreate()
184189 return send (500 , " text/plain" , " BAD ARGS" );
185190
186191 String path = arg (0 );
187- Serial. println (" [Storage] Creating file: " + path);
192+ PRINTLN (" [Storage] Creating file: " + path);
188193
189194 if (path == " /" )
190195 return send (500 , " text/plain" , " BAD PATH" );
@@ -240,7 +245,7 @@ void WebServerClass::handleUpdate()
240245 {
241246 Serial.setDebugOutput (true );
242247 WiFiUDP::stopAll ();
243- Serial. printf (" Update: %s\n " , _upload.filename .c_str ());
248+ PRINTF (" Update: %s\n " , _upload.filename .c_str ());
244249 uint32_t maxSketchSpace = (ESP .getFreeSketchSpace () - 0x1000 ) & 0xFFFFF000 ;
245250 if (!Update.begin (maxSketchSpace))
246251 {
@@ -257,7 +262,7 @@ void WebServerClass::handleUpdate()
257262 {
258263 if (Update.end (true ))
259264 {
260- Serial. printf (" Update Success: %u\n Rebooting...\n " , _upload.totalSize );
265+ PRINTF (" Update Success: %u\n Rebooting...\n " , _upload.totalSize );
261266 }
262267 else
263268 {
@@ -268,4 +273,4 @@ void WebServerClass::handleUpdate()
268273 yield ();
269274}
270275
271- WebServerClass WebServer (80 );
276+ WebServerClass WebServer (80 );
0 commit comments