@@ -44,14 +44,14 @@ extern volatile uint64_t HAL_time_ms;
4444#define RX_BUF_SIZE 1024
4545
4646/* DHCP timeout: total time to wait for DHCP before static IP fallback.
47- * wolfIP's internal DHCP state machine only retries for ~8 seconds
48- * (DHCP_DISCOVER_RETRIES=3 × 2s timeout). After that it sets state to
47+ * wolfIP's internal DHCP state machine only retries for ~4 seconds
48+ * (DHCP_DISCOVER_RETRIES=1 x 2s timeout). After that it sets state to
4949 * DHCP_OFF and the UDP socket stops accepting unicast DHCP responses
5050 * (because DHCP_IS_RUNNING becomes false). We re-init periodically to
5151 * keep trying, but must space re-inits apart to avoid socket churn
5252 * (close/reopen loses in-flight responses). */
53- #define DHCP_TIMEOUT_MS 120000U /* 120s total before static fallback */
54- #define DHCP_REINIT_MS 15000U /* 15s between DHCP re-init attempts */
53+ #define DHCP_TIMEOUT_MS 30000U /* 30s total before static fallback */
54+ #define DHCP_REINIT_MS 10000U /* 10s between DHCP re-init attempts */
5555
5656static struct wolfIP * IPStack ;
5757static uint8_t rx_buf [RX_BUF_SIZE ];
@@ -703,12 +703,12 @@ int main(void)
703703#ifdef DHCP
704704 /* Non-blocking DHCP handling.
705705 *
706- * wolfIP's internal DHCP state machine gives up after ~8s
707- * (3 retries × 2s). When state goes to DHCP_OFF, the UDP
706+ * wolfIP's internal DHCP state machine gives up after ~4s
707+ * (1 retry x 2s). When state goes to DHCP_OFF, the UDP
708708 * socket stops accepting unicast DHCP responses (the
709709 * DHCP_IS_RUNNING check in udp_process fails).
710710 *
711- * We periodically re-init DHCP (every 15s ) to restart the
711+ * We periodically re-init DHCP (every 10s ) to restart the
712712 * state machine and keep the UDP socket accepting responses.
713713 * Must space re-inits apart to avoid socket churn (the
714714 * close/reopen cycle can lose in-flight responses). */
@@ -729,9 +729,9 @@ int main(void)
729729 printf ("DHCP assigned IP:\n" );
730730 } else {
731731 printf ("DHCP timeout, using static IP\n" );
732- ip = atoip4 ("192.168.12.11" );
733- nm = atoip4 ("255.255.255.0" );
734- gw = atoip4 ("192.168.12.1" );
732+ ip = atoip4 (WOLFIP_IP );
733+ nm = atoip4 (WOLFIP_NETMASK );
734+ gw = atoip4 (WOLFIP_GW );
735735 wolfIP_ipconfig_set (IPStack , ip , nm , gw );
736736 }
737737 printf (" IP: " ); uart_putip4 (ip ); printf ("\n" );
0 commit comments