@@ -13,6 +13,10 @@ WebSockets.ino
1313static const int webSocketsStackSize = 1024 * 20 ;
1414
1515const char * const image_png = " image/png" ;
16+ const char * const text_css = " text/css" ;
17+ const char * const text_html = " text/html" ;
18+ const char * const text_javascript = " text/javascript" ;
19+ const char * const text_plain = " text/plain" ;
1620
1721// ----------------------------------------
1822// New types
@@ -78,6 +82,40 @@ const GET_PAGE_HANDLER webSocketsPages[] =
7882
7983 // Add special pages above this line
8084
85+ // Page icon
86+ WEB_PAGE ( 2 , " /favicon.ico" , text_plain, favicon_ico),
87+
88+ // Fonts
89+ WEB_PAGE ( 3 , " /src/fonts/icomoon.eot" , text_plain, icomoon_eot),
90+ WEB_PAGE ( 4 , " /src/fonts/icomoon.svg" , text_plain, icomoon_svg),
91+ WEB_PAGE ( 5 , " /src/fonts/icomoon.ttf" , text_plain, icomoon_ttf),
92+ WEB_PAGE ( 6 , " /src/fonts/icomoon.woof" , text_plain, icomoon_woof),
93+
94+ // Battery icons
95+ WEB_PAGE ( 7 , " /src/BatteryBlank.png" , image_png, batteryBlank_png),
96+ WEB_PAGE ( 8 , " /src/Battery0.png" , image_png, battery0_png),
97+ WEB_PAGE ( 9 , " /src/Battery1.png" , image_png, battery1_png),
98+ WEB_PAGE (10 , " /src/Battery2.png" , image_png, battery2_png),
99+ WEB_PAGE (11 , " /src/Battery3.png" , image_png, battery3_png),
100+ WEB_PAGE (12 , " /src/Battery0_Charging.png" , image_png, battery0_Charging_png),
101+ WEB_PAGE (13 , " /src/Battery1_Charging.png" , image_png, battery1_Charging_png),
102+ WEB_PAGE (14 , " /src/Battery2_Charging.png" , image_png, battery2_Charging_png),
103+ WEB_PAGE (15 , " /src/Battery3_Charging.png" , image_png, battery3_Charging_png),
104+
105+ // Bootstrap
106+ WEB_PAGE (16 , " /src/bootstrap.bundle.min.js" , text_javascript, bootstrap_bundle_min_js),
107+ WEB_PAGE (17 , " /src/bootstrap.min.js" , text_javascript, bootstrap_min_js),
108+
109+ // Java script
110+ WEB_PAGE (18 , " /src/jquery-3.6.0.min.js" , text_javascript, jquery_js),
111+ WEB_PAGE (19 , " /src/main.js" , text_javascript, main_js),
112+
113+ // Style sheets
114+ WEB_PAGE (20 , " /src/bootstrap.min.css" , text_css, bootstrap_min_css),
115+ WEB_PAGE (21 , " /src/style.css" , text_css, style_css),
116+
117+ // Add pages above this line
118+ WEB_PAGE (22 , " /" , text_html, index_html),
81119};
82120
83121#define WEB_SOCKETS_SPECIAL_PAGES 2
@@ -702,6 +740,10 @@ bool webSocketsStart(void)
702740 config.server_port = 81 ;
703741 config.stack_size = webSocketsStackSize;
704742
743+ // Set the number of URI handlers
744+ config.max_uri_handlers = WEB_SOCKETS_TOTAL_PAGES + 16 ;
745+ config.max_resp_headers = config.max_uri_handlers ;
746+
705747 // Start the httpd server
706748 if (settings.debugWebServer == true )
707749 systemPrintf (" webSockets starting on port: %d\r\n " , config.server_port );
@@ -730,6 +772,8 @@ bool webSocketsStart(void)
730772 {
731773 do
732774 {
775+ int i;
776+
733777 if (settings.debugWebServer == true )
734778 systemPrintln (" webSockets registering page handlers" );
735779
@@ -752,6 +796,13 @@ bool webSocketsStart(void)
752796 if (!webSocketsRegisterPageHandler (&webSocketsPage))
753797 break ;
754798
799+ // Register the main pages
800+ for (i = WEB_SOCKETS_SPECIAL_PAGES; i < WEB_SOCKETS_TOTAL_PAGES; i++)
801+ if (!webSocketsRegisterPageHandler (&webSocketsPages[i]._page ))
802+ break ;
803+ if (i < WEB_SOCKETS_TOTAL_PAGES)
804+ break ;
805+
755806 // The web server is ready to handle incoming requests
756807 if (settings.debugWebServer )
757808 systemPrintf (" webSockets successfully started\r\n " );
0 commit comments