A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

Revision:
29:39277bf2003d
Parent:
28:edc17eeb4142
Child:
36:900e24b27bfb
--- a/udp/dhcp.cpp	Mon Jul 24 15:27:36 2017 +0000
+++ b/udp/dhcp.cpp	Mon Aug 07 12:13:52 2017 +0000
@@ -50,11 +50,11 @@
 
 #define REPEAT_DELAY_TIME 60
 static uint32_t delayTime   = 10000000; //Reset whenever a message is sent and blocks another send until count exceeds REPEAT_DELAY_TIME
-static uint32_t elapsedTime = 0;        //Reset whenever an IP address request has been acknowledged 
+uint32_t DhcpElapsedTime = 0;        //Reset whenever an IP address request has been acknowledged 
 void DhcpTick()
 {
-    elapsedTime++;
-      delayTime++;
+    DhcpElapsedTime++;
+          delayTime++;
 }
 
 static uint8_t  dhcpMessageType = 0;
@@ -257,7 +257,7 @@
             Ip4AddressToString(yiaddr, sizeof(text), text);
             if (DEBUG) LogTimeF("DHCP <- ack ip %s\r\n", text);
             DhcpLocalIp = yiaddr;
-            elapsedTime = 0;
+            DhcpElapsedTime = 0;
             break;
         case DHCPNAK:
             Ip4AddressToString(yiaddr, sizeof(text), text);
@@ -274,11 +274,11 @@
 {    
     if (delayTime < REPEAT_DELAY_TIME) return DO_NOTHING; //Don't retry within the delay time
     
-    if (DhcpLocalIp && elapsedTime < (DhcpLeaseTime >> 1)) return 0; //Do nothing if have address and within T1
+    if (DhcpLocalIp && DhcpElapsedTime < (DhcpLeaseTime >> 1)) return 0; //Do nothing if have address and within T1
     
     *pSize = 0;
     
-    if (DhcpLocalIp && elapsedTime <  DhcpLeaseTime)
+    if (DhcpLocalIp && DhcpElapsedTime <  DhcpLeaseTime)
     {
         *pSize = sendRequest(pPacket, DHCPREQUEST, DhcpServer, DhcpLocalIp); //if within T2 then send request to the server - not broadcast
         return UNICAST_DHCP;