Fork for fixes

Revision:
11:647d53d146f1
Parent:
9:a156d3de5647
Child:
14:7648334eb41b
--- a/UdpSocket.cpp	Tue Aug 27 22:08:54 2019 +0000
+++ b/UdpSocket.cpp	Fri Aug 30 08:11:40 2019 +0000
@@ -60,9 +60,9 @@
         uip_udp_remove(_uip_udp_conn);
         _uip_udp_conn->appstate = NULL;
         _uip_udp_conn = NULL;
-        UipEthernet::ethernet->phy.freeBlock(appdata.packet_in);
-        UipEthernet::ethernet->phy.freeBlock(appdata.packet_next);
-        UipEthernet::ethernet->phy.freeBlock(appdata.packet_out);
+        UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_in);
+        UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_next);
+        UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_out);
         memset(&appdata, 0, sizeof(appdata));
     }
 }
@@ -109,7 +109,7 @@
 
     if (_uip_udp_conn) {
         if (appdata.packet_out == NOBLOCK) {
-            appdata.packet_out = UipEthernet::ethernet->phy.allocBlock(UIP_UDP_MAXPACKETSIZE);
+            appdata.packet_out = UipEthernet::ethernet->enc28j60Eth.allocBlock(UIP_UDP_MAXPACKETSIZE);
             appdata.out_pos = UIP_UDP_PHYH_LEN;
             if (appdata.packet_out != NOBLOCK)
                 return 1;
@@ -155,7 +155,7 @@
 {
     if (_uip_udp_conn && appdata.packet_out != NOBLOCK) {
         appdata.send = true;
-        UipEthernet::ethernet->phy.resizeBlock(appdata.packet_out, 0, appdata.out_pos);
+        UipEthernet::ethernet->enc28j60Eth.resizeBlock(appdata.packet_out, 0, appdata.out_pos);
         uip_udp_periodic_conn(_uip_udp_conn);
         if (uip_len > 0) {
             _send(&appdata);
@@ -176,7 +176,7 @@
 size_t UdpSocket::write(const uint8_t* buffer, size_t size)
 {
     if (appdata.packet_out != NOBLOCK) {
-        size_t  ret = UipEthernet::ethernet->phy.writePacket
+        size_t  ret = UipEthernet::ethernet->enc28j60Eth.writePacket
             (
                 appdata.packet_out,
                 appdata.out_pos,
@@ -201,7 +201,7 @@
         printf("udp parsePacket freeing previous packet: %d\r\n", appdata.packet_in);
     }
 #endif
-    UipEthernet::ethernet->phy.freeBlock(appdata.packet_in);
+    UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_in);
 
     appdata.packet_in = appdata.packet_next;
     appdata.packet_next = NOBLOCK;
@@ -212,7 +212,7 @@
     }
 #endif
 
-    int size = UipEthernet::ethernet->phy.blockSize(appdata.packet_in);
+    int size = UipEthernet::ethernet->enc28j60Eth.blockSize(appdata.packet_in);
 #ifdef UIPETHERNET_DEBUG_UDP
     if (appdata.packet_in != NOBLOCK) {
         printf(", size: %d\r\n", size);
@@ -225,7 +225,7 @@
 int UdpSocket::available()
 {
     UipEthernet::ethernet->tick();
-    return UipEthernet::ethernet->phy.blockSize(appdata.packet_in);
+    return UipEthernet::ethernet->enc28j60Eth.blockSize(appdata.packet_in);
 }
 
 // Read a single byte from the current packet
@@ -246,13 +246,13 @@
 {
     UipEthernet::ethernet->tick();
     if (appdata.packet_in != NOBLOCK) {
-        memaddress  read = UipEthernet::ethernet->phy.readPacket(appdata.packet_in, 0, buffer, len);
-        if (read == UipEthernet::ethernet->phy.blockSize(appdata.packet_in)) {
-            UipEthernet::ethernet->phy.freeBlock(appdata.packet_in);
+        memaddress  read = UipEthernet::ethernet->enc28j60Eth.readPacket(appdata.packet_in, 0, buffer, len);
+        if (read == UipEthernet::ethernet->enc28j60Eth.blockSize(appdata.packet_in)) {
+            UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_in);
             appdata.packet_in = NOBLOCK;
         }
         else
-            UipEthernet::ethernet->phy.resizeBlock(appdata.packet_in, read);
+            UipEthernet::ethernet->enc28j60Eth.resizeBlock(appdata.packet_in, read);
         return read;
     }
 
@@ -265,7 +265,7 @@
     UipEthernet::ethernet->tick();
     if (appdata.packet_in != NOBLOCK) {
         unsigned char   c;
-        if (UipEthernet::ethernet->phy.readPacket(appdata.packet_in, 0, &c, 1) == 1)
+        if (UipEthernet::ethernet->enc28j60Eth.readPacket(appdata.packet_in, 0, &c, 1) == 1)
             return c;
     }
 
@@ -276,7 +276,7 @@
 void UdpSocket::flush()
 {
     UipEthernet::ethernet->tick();
-    UipEthernet::ethernet->phy.freeBlock(appdata.packet_in);
+    UipEthernet::ethernet->enc28j60Eth.freeBlock(appdata.packet_in);
     appdata.packet_in = NOBLOCK;
 }
 
@@ -300,18 +300,18 @@
             if (data->packet_next == NOBLOCK) {
                 uip_udp_conn->rport = UDPBUF->srcport;
                 uip_ipaddr_copy(uip_udp_conn->ripaddr, UDPBUF->srcipaddr);
-                data->packet_next = UipEthernet::ethernet->phy.allocBlock(ntohs(UDPBUF->udplen) - UIP_UDPH_LEN);
+                data->packet_next = UipEthernet::ethernet->enc28j60Eth.allocBlock(ntohs(UDPBUF->udplen) - UIP_UDPH_LEN);
 
                 //if we are unable to allocate memory the packet is dropped. udp doesn't guarantee packet delivery
                 if (data->packet_next != NOBLOCK) {
                     //discard Linklevel and IP and udp-header and any trailing bytes:
-                    UipEthernet::ethernet->phy.copyPacket
+                    UipEthernet::ethernet->enc28j60Eth.copyPacket
                         (
                             data->packet_next,
                             0,
                             UipEthernet::inPacket,
                             UIP_UDP_PHYH_LEN,
-                            UipEthernet::ethernet->phy.blockSize(data->packet_next)
+                            UipEthernet::ethernet->enc28j60Eth.blockSize(data->packet_next)
                         );
 #ifdef UIPETHERNET_DEBUG_UDP
                     printf