Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Files at this revision

API Documentation at this revision

Comitter:
nixnax
Date:
Sun Aug 13 11:27:25 2017 +0000
Parent:
128:e5958d143e9d
Child:
130:45ee0d648a72
Commit message:
Fixed debug print. Added a space to number in GET /x so there is number separation when using curl.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Aug 13 02:18:18 2017 +0000
+++ b/main.cpp	Sun Aug 13 11:27:25 2017 +0000
@@ -46,6 +46,7 @@
 
 // here we define the OPTIONAL, second debug serial port for the various target boards
 // insert your target board's port here if it's not in yet - if it works, please send it to me - thanks!!!
+// note - if you enable this, some packets may initially be missed which will cause some retransmits
 #ifdef SERIAL_PORT_MONITOR_YES
 #if defined(TARGET_LPC1768)
 Serial xx(p9, p10); // Second serial port on LPC1768 - not required to run, if you get compile error here, change #define SERIAL_PORT_MONITOR_YES to #define SERIAL_PORT_MONITOR_NO
@@ -665,10 +666,10 @@
 // we end up here if we enter the following javascript in a web browser console: x = new WebSocket("ws://172.10.10.2");
 int webSocketHandler(char * dataStart)
 {
-    if (v0) putsWhileCheckingInput("WebSocket Request\n");
     int n=0; // byte counter
     char * key = strstr(dataStart, "Sec-WebSocket-Key: "); // search for the key in the payload
     if (key != NULL) {
+        if (v0) putsWhileCheckingInput("WebSocket Request\n");
         char challenge [70];
         strncpy(challenge,key+19,70); // a local buffer
         *strchr(challenge,'\r')=0; // insert null so we can use sprintf
@@ -744,7 +745,7 @@
             n=n+sprintf(n+dataStart, "<script>setTimeout(function(){location.reload();},10);</script><body>%d</body>",ppp.httpPageCount);
 #else
             // /x is a very short page, in fact, it is only a decimal number showing the http Page count
-            n=n+sprintf(n+dataStart,"%d",ppp.httpPageCount); // not really valid html but fast - most browsers and curl are ok with it
+            n=n+sprintf(n+dataStart,"%d ",ppp.httpPageCount); // not really valid html but fast - most browsers and curl are ok with it
 #endif
 #endif
         } else {