Fork for fixes

Revision:
19:58e840279555
Parent:
13:95c00132cd98
--- a/TcpClient.cpp	Wed Jul 22 20:37:24 2020 +0000
+++ b/TcpClient.cpp	Thu Sep 24 21:14:56 2020 +0000
@@ -274,9 +274,9 @@
 #ifdef UIPETHERNET_DEBUG_CLIENT
         printf
         (
-            "UIPClient.write: writePacket(%d) pos: %d, buf[%d-%d]\r\n",
-            u->packets_out[p],
-            u->out_pos,
+            "TcpClient.write: writePacket(%d) pos: %d, buf[%d-%d]\r\n",
+            data->packets_out[p],
+            data->out_pos,
             size - remain,
             remain
         );
@@ -478,25 +478,28 @@
  */
 void uipclient_appcall()
 {
+#ifdef UIPETHERNET_DEBUG_CLIENT
+        printf("uipclient_appcall why ? : %d\r\n",uip_flags);
+#endif
     uint16_t            send_len = 0;
     uip_userdata_t*     u = (uip_userdata_t*)uip_conn->appstate;
     if (!u && uip_connected())
     {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-        printf("UIPClient uip_connected\r\n");
-        UIPClient::_dumpAllData();
+        printf("uipclient_appcall uip_connected\r\n");
+        TcpClient::_dumpAllData();
 #endif
         u = (uip_userdata_t*)TcpClient::_allocateData();
         if (u) {
             uip_conn->appstate = u;
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("UIPClient allocated state: %d", u->state);
+            printf("uipclient_appcall allocated state: %d", u->state);
 #endif
         }
 
 #ifdef UIPETHERNET_DEBUG_CLIENT
         else
-            printf("UIPClient allocation failed\r\n");
+            printf("uipclient_appcall allocation failed\r\n");
 #endif
     }
 
@@ -504,7 +507,7 @@
         if (uip_newdata())
         {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("UIPClient uip_newdata, uip_len: %d\r\n", uip_len);
+            printf("uipclient_appcall uip_newdata, uip_len: %d\r\n", uip_len);
 #endif
             if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED))) {
                 for (uint8_t i = 0; i < UIP_SOCKET_NUMPACKETS; i++) {
@@ -541,8 +544,8 @@
         if (uip_closed() || uip_timedout())
         {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("UIPClient uip_closed\r\n");
-            UIPClient::_dumpAllData();
+            printf("uipclient_appcall uip_closed\r\n");
+            TcpClient::_dumpAllData();
 #endif
             // drop outgoing packets not sent yet:
 
@@ -556,8 +559,8 @@
 
             // disassociate appdata.
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("after UIPClient uip_closed\r\n");
-            UIPClient::_dumpAllData();
+            printf("after uipclient_appcall uip_closed\r\n");
+            TcpClient::_dumpAllData();
 #endif
             uip_conn->appstate = NULL;
             goto finish;
@@ -566,15 +569,16 @@
         if (uip_acked())
         {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("UIPClient uip_acked\r\n");
+            printf("uipclient_appcall uip_acked\r\n");
 #endif
             TcpClient::_eatBlock(&u->packets_out[0]);
+            uip_len = 0;
         }
 
         if (uip_poll() || uip_rexmit())
         {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            //printf("UIPClient uip_poll\r\n");
+            //printf("uipclient_appcall uip_poll\r\n");
 #endif
             if (u->packets_out[0] != NOBLOCK) {
                 if (u->packets_out[1] == NOBLOCK) {
@@ -609,8 +613,8 @@
         if (u->state & UIP_CLIENT_CLOSE)
         {
 #ifdef UIPETHERNET_DEBUG_CLIENT
-            printf("UIPClient state UIP_CLIENT_CLOSE\r\n");
-            UIPClient::_dumpAllData();
+            printf("uipclient_appcall state UIP_CLIENT_CLOSE\r\n");
+            TcpClient::_dumpAllData();
 #endif
             if (u->packets_out[0] == NOBLOCK) {
                 u->state = 0;
@@ -618,7 +622,7 @@
                 uip_close();
 #ifdef UIPETHERNET_DEBUG_CLIENT
                 printf("no blocks out -> free userdata\r\n");
-                UIPClient::_dumpAllData();
+                TcpClient::_dumpAllData();
 #endif
             }
             else {
@@ -730,7 +734,7 @@
  * @param
  * @retval
  */
-void UIPClient::_dumpAllData()
+void TcpClient::_dumpAllData()
 {
     for (uint8_t i = 0; i < UIP_CONNS; i++) {
         printf("UIPClient::all_data[%d], state:%d packets_in: ", i, all_data[i].state);