@@ -33,16 +33,15 @@ static const char *const webServerStateNames[] = {
3333// Macros
3434// ----------------------------------------
3535
36- #define GET_PAGE (page, type, data ) \
37- webServer->on (page, HTTP_GET, []() { \
38- String length; \
39- if (settings.debugWebServer == true ) \
40- Serial.printf (" WebServer: Sending %s (%p, %d bytes)\r\n " , \
41- page, (void *)data, sizeof (data)); \
42- webServer->sendHeader (" Content-Encoding" , " gzip" ); \
43- length = String (sizeof (data)); \
44- webServer->sendHeader (" Content-Length" , length.c_str ()); \
45- webServer->send_P (200 , type, (const char *)data, sizeof (data)); \
36+ #define GET_PAGE (page, type, data ) \
37+ webServer->on (page, HTTP_GET, []() { \
38+ String length; \
39+ if (settings.debugWebServer == true ) \
40+ Serial.printf (" WebServer: Sending %s (%p, %d bytes)\r\n " , page, (void *)data, sizeof (data)); \
41+ webServer->sendHeader (" Content-Encoding" , " gzip" ); \
42+ length = String (sizeof (data)); \
43+ webServer->sendHeader (" Content-Length" , length.c_str ()); \
44+ webServer->send_P (200 , type, (const char *)data, sizeof (data)); \
4645 });
4746
4847// ----------------------------------------
@@ -64,7 +63,7 @@ static int last_ws_fd;
6463
6564static TaskHandle_t updateWebServerTaskHandle;
6665static const uint8_t updateWebServerTaskPriority = 0 ; // 3 being the highest, and 0 being the lowest
67- static const int webServerTaskStackSize = 4096 ; // Needs to be large enough to hold the file manager file list
66+ static const int webServerTaskStackSize = 4096 ; // Needs to be large enough to hold the file manager file list
6867static const int webSocketStackSize = 8192 ;
6968
7069// Inspired by:
@@ -953,13 +952,12 @@ bool webServerAssignResources(int httpPort = 80)
953952
954953 // Starts task for updating webServer with handleClient
955954 if (task.updateWebServerTaskRunning == false )
956- xTaskCreate (
957- updateWebServerTask,
958- " UpdateWebServer" , // Just for humans
959- webServerTaskStackSize, // Stack Size - needs to be large enough to hold the file manager list
960- nullptr , // Task input parameter
961- updateWebServerTaskPriority,
962- &updateWebServerTaskHandle); // Task handle
955+ xTaskCreate (updateWebServerTask,
956+ " UpdateWebServer" , // Just for humans
957+ webServerTaskStackSize, // Stack Size - needs to be large enough to hold the file manager list
958+ nullptr , // Task input parameter
959+ updateWebServerTaskPriority,
960+ &updateWebServerTaskHandle); // Task handle
963961
964962 if (settings.debugWebServer == true )
965963 systemPrintln (" Web Server: Started" );
@@ -1027,7 +1025,7 @@ void webServerReleaseResources()
10271025
10281026 online.webServer = false ;
10291027
1030- webServerStopSockets (); // Release socket resources
1028+ webServerStopSockets (); // Release socket resources
10311029
10321030 if (webServer != nullptr )
10331031 {
@@ -1060,8 +1058,7 @@ void webServerStopSockets()
10601058 // Stop the httpd server
10611059 esp_err_t status = httpd_stop (wsserver);
10621060 if (status != ESP_OK)
1063- systemPrintf (" ERROR: wsserver failed to stop, status: %s!\r\n " ,
1064- esp_err_to_name (status));
1061+ systemPrintf (" ERROR: wsserver failed to stop, status: %s!\r\n " , esp_err_to_name (status));
10651062 wsserver = nullptr ;
10661063 }
10671064}
@@ -1312,25 +1309,34 @@ static esp_err_t ws_handler(httpd_req_t *req)
13121309 }
13131310 if (settings.debugWebServer == true )
13141311 {
1315- const char * pktType;
1312+ const char *pktType;
13161313 size_t length = ws_pkt.len ;
13171314 switch (ws_pkt.type )
13181315 {
1319- default : pktType = nullptr ; break ;
1320- case HTTPD_WS_TYPE_CONTINUE: pktType = " HTTPD_WS_TYPE_CONTINUE" ; break ;
1321- case HTTPD_WS_TYPE_TEXT: pktType = " HTTPD_WS_TYPE_TEXT" ; break ;
1322- case HTTPD_WS_TYPE_BINARY: pktType = " HTTPD_WS_TYPE_BINARY" ; break ;
1323- case HTTPD_WS_TYPE_CLOSE: pktType = " HTTPD_WS_TYPE_CLOSE" ; break ;
1324- case HTTPD_WS_TYPE_PING: pktType = " HTTPD_WS_TYPE_PING" ; break ;
1325- case HTTPD_WS_TYPE_PONG: pktType = " HTTPD_WS_TYPE_PONG" ; break ;
1316+ default :
1317+ pktType = nullptr ;
1318+ break ;
1319+ case HTTPD_WS_TYPE_CONTINUE:
1320+ pktType = " HTTPD_WS_TYPE_CONTINUE" ;
1321+ break ;
1322+ case HTTPD_WS_TYPE_TEXT:
1323+ pktType = " HTTPD_WS_TYPE_TEXT" ;
1324+ break ;
1325+ case HTTPD_WS_TYPE_BINARY:
1326+ pktType = " HTTPD_WS_TYPE_BINARY" ;
1327+ break ;
1328+ case HTTPD_WS_TYPE_CLOSE:
1329+ pktType = " HTTPD_WS_TYPE_CLOSE" ;
1330+ break ;
1331+ case HTTPD_WS_TYPE_PING:
1332+ pktType = " HTTPD_WS_TYPE_PING" ;
1333+ break ;
1334+ case HTTPD_WS_TYPE_PONG:
1335+ pktType = " HTTPD_WS_TYPE_PONG" ;
1336+ break ;
13261337 }
1327- systemPrintf (" Packet: %p, %d bytes, type: %d%s%s%s\r\n " ,
1328- ws_pkt.payload ,
1329- length,
1330- ws_pkt.type ,
1331- pktType ? " (" : " " ,
1332- pktType ? pktType : " " ,
1333- pktType ? " )" : " " );
1338+ systemPrintf (" Packet: %p, %d bytes, type: %d%s%s%s\r\n " , ws_pkt.payload , length, ws_pkt.type ,
1339+ pktType ? " (" : " " , pktType ? pktType : " " , pktType ? " )" : " " );
13341340 if (length > 0x40 )
13351341 length = 0x40 ;
13361342 dumpBuffer (ws_pkt.payload , length);
@@ -1379,7 +1385,7 @@ static const httpd_uri_t ws = {.uri = "/ws",
13791385// ----------------------------------------
13801386// Display the HTTPD configuration
13811387// ----------------------------------------
1382- void httpdDisplayConfig (struct httpd_config * config)
1388+ void httpdDisplayConfig (struct httpd_config *config)
13831389{
13841390 systemPrintf (" httpd_config object:\r\n " );
13851391 systemPrintf (" %10d: task_priority\r\n " , config->task_priority );
@@ -1445,8 +1451,7 @@ bool websocketServerStart(void)
14451451 }
14461452
14471453 // Display the failure to start
1448- systemPrintf (" ERROR: wsserver failed to start, status: %s!\r\n " ,
1449- esp_err_to_name (status));
1454+ systemPrintf (" ERROR: wsserver failed to start, status: %s!\r\n " , esp_err_to_name (status));
14501455 return false ;
14511456}
14521457
0 commit comments