Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
79:f0fc1c19a550
Parent:
78:809c2631a5eb
Child:
80:753f5dd2e84e
--- a/main.cpp	Sun Jul 09 01:06:40 2017 +0000
+++ b/main.cpp	Sun Jul 09 20:55:45 2017 +0000
@@ -29,7 +29,7 @@
 
 // The #define below enables/disables a SECOND (optional) serial port that prints out interesting diagnostic messages.
 // Change to SERIAL_PORT_MONITOR_YES to enable diagnostics messages. You need to wire a second serial port to your mbed hardware to monitor this.
-#define SERIAL_PORT_MONITOR_NO /* or SERIAL_PORT_MONITOR_YES */
+#define SERIAL_PORT_MONITOR_NO /* or change to SERIAL_PORT_MONITOR_YES */
 
 #ifndef SERIAL_PORT_MONITOR_NO
 Serial xx(PC_10, PC_11); // Not required to run, if you get compile error here, change #define SERIAL_PORT_MONITOR_YES to #define SERIAL_PORT_MONITOR_NO
@@ -601,7 +601,7 @@
     int tcpDataSize = tcpSize - headerSizeTCP; // size of data block after TCP header
     
     unsigned int ack = (seqtcp[0]<<24)|(seqtcp[1]<<16)|(seqtcp[2]<<8)|(seqtcp[3]) + tcpDataSize;
-    //unsigned int seq = (acktcp[0]<<24)|(acktcp[1]<<16)|(acktcp[2]<<8)|(acktcp[3]);
+    unsigned int seq = (acktcp[0]<<24)|(acktcp[1]<<16)|(acktcp[2]<<8)|(acktcp[3]); // use their idea of our seq
     
 
 #define TCP_FLAG_ACK (1<<4)
@@ -621,13 +621,14 @@
     switch ( flagsTCP ) {
         case TCP_FLAG_ACK:
             if ( tcpDataSize != 1 ) return;
+            ack++;
         case TCP_FLAG_SYN:
             flagsOut = TCP_FLAG_SYN | TCP_FLAG_ACK; // something wants to connect - ack it
             ppp.seq = ppp.seq + 12345; // create a new sequence number (normally random)
-            ack++; // for SYN flag we have to increase sequence by 1
+            seq = ppp.seq; // create a new sequence number (normally random)
+            ack++; // for SYN flag we have to increase their sequence by 1
             break;
         case TCP_FLAG_ACK | TCP_FLAG_PSH:
-            ppp.seq = (acktcp[0]<<24)|(acktcp[1]<<16)|(acktcp[2]<<8)|(acktcp[3]); // use their idea of our seq
             flagsOut = TCP_FLAG_ACK | TCP_FLAG_FIN; // for every push we answer once AND close the link
             fastResponse = 1; // we can respond fast to a push
             if ( strncmp(dataStart, "GET ", 4) == 0) { // do we see an http GET command
@@ -647,7 +648,6 @@
             return; // ignore remaining packets
     }
     
-    unsigned int seq = ppp.seq;
 
     // The TCP flag handling is now done
     // Now we have to recalculate all the header sizes, swap IP address/port source and destination, and do the IP and TCP checksums
@@ -713,7 +713,6 @@
         // wait(0.2);
     }
     sendFrame(); // All done! Send the TCP packet
-    ppp.seq = ppp.seq + dataLen; // update our seq number
 }
 
 void dumpDataTCP()