dhcp restore last ip

This commit is contained in:
MartinValik
2018-08-28 10:28:35 +02:00
parent 18548d1e25
commit 3b88e84f9b
2 changed files with 25 additions and 0 deletions

View File

@ -844,6 +844,15 @@ dhcp_start(struct netif *netif)
}
#endif /* LWIP_DHCP_CHECK_LINK_UP */
#ifdef ESP_DHCP
// Try to restore last valid ip address obtained from DHCP server.
// If no valid ip is available, run dhcp_discover instead.
if(LWIP_DHCP_IP_ADDR_RESTORE()) {
dhcp_set_state(dhcp, DHCP_STATE_BOUND);
dhcp_network_changed(netif);
return ERR_OK;
}
#endif
/* (re)start the DHCP negotiation */
result = dhcp_discover(netif);
@ -1234,6 +1243,10 @@ dhcp_bind(struct netif *netif)
/* interface is used by routing now that an address is set */
/* Espressif add start. */
#ifdef ESP_DHCP
LWIP_DHCP_IP_ADDR_STORE();
#endif
if (dhcp->cb != NULL) {
#ifdef ESP_DHCP
dhcp->cb(netif);

View File

@ -895,6 +895,18 @@
* @}
*/
#ifndef LWIP_DHCP_IP_ADDR_RESTORE
#define LWIP_DHCP_IP_ADDR_RESTORE() 0
#endif
#ifndef LWIP_DHCP_IP_ADDR_STORE
#define LWIP_DHCP_IP_ADDR_STORE()
#endif
#ifndef LWIP_DHCP_IP_ADDR_ERASE
#define LWIP_DHCP_IP_ADDR_ERASE()
#endif
/*
------------------------------------
---------- AUTOIP options ----------