diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index ae441e2b..dc0f2886 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -1154,6 +1154,7 @@ void dhcps_start(struct netif *netif, ip4_addr_t ip) udp_bind(pcb_dhcps, &netif->ip_addr, DHCPS_SERVER_PORT); udp_recv(pcb_dhcps, handle_dhcp, NULL); + sys_timeout(1000, dhcps_coarse_tmr, NULL); #if DHCPS_DEBUG DHCPS_LOG("dhcps:dhcps_start->udp_recv function Set a receive callback handle_dhcp for UDP_PCB pcb_dhcps\n"); #endif @@ -1175,6 +1176,8 @@ void dhcps_stop(struct netif *netif) return; } + sys_untimeout(dhcps_coarse_tmr, NULL); + if (pcb_dhcps != NULL) { udp_disconnect(pcb_dhcps); udp_remove(pcb_dhcps); @@ -1267,6 +1270,11 @@ void dhcps_coarse_tmr(void) if (num_dhcps_pool > MAX_STATION_NUM) { kill_oldest_dhcps_pool(); } + + /*Do not restart timer when dhcp server is stopped*/ + if (pcb_dhcps != NULL) { + sys_timeout(1000, dhcps_coarse_tmr, NULL); + } } /****************************************************************************** diff --git a/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h b/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h index 10186fe7..6e3363b7 100644 --- a/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h +++ b/components/lwip/include/lwip/apps/dhcpserver/dhcpserver.h @@ -89,6 +89,7 @@ bool dhcp_search_ip_on_mac(u8_t *mac, ip4_addr_t *ip); void dhcps_dns_setserver(const ip_addr_t *dnsserver); ip4_addr_t dhcps_dns_getserver(); void dhcps_set_new_lease_cb(dhcps_cb_t cb); +void dhcps_coarse_tmr(void); #endif