* DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the\r
* DHCP server on the network.\r
*/\r
- \r
+\r
#include "DHCPClientApp.h"\r
\r
#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__)\r
-/** Timer for managing the timeout period for a DHCP server to respond */\r
-struct timer DHCPTimer;\r
\r
/** Initialization function for the DHCP client. */\r
void DHCPClientApp_Init(void)\r
if (Connection != NULL)\r
{\r
uip_udp_appstate_t* const AppState = &Connection->appstate;\r
-\r
uip_udp_bind(Connection, HTONS(DHCPC_CLIENT_PORT));\r
+ \r
+ /* Set the initial client state */\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
- }\r
\r
- /* Set timeout period to half a second for a DHCP server to respond */\r
- timer_set(&DHCPTimer, CLOCK_SECOND / 2);\r
+ /* Set timeout period to half a second for a DHCP server to respond */\r
+ timer_set(&AppState->DHCPClient.Timeout, CLOCK_SECOND / 2);\r
+ }\r
}\r
\r
/** uIP stack application callback for the DHCP client. This function must be called each time the TCP/IP stack \r
uip_udp_send(AppDataSize);\r
\r
/* Reset the timeout timer, progress to next state */\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForOffer; \r
\r
break;\r
if (!(uip_newdata()))\r
{\r
/* Check if the DHCP timeout period has expired while waiting for a response */\r
- if (timer_expired(&DHCPTimer))\r
+ if (timer_expired(&AppState->DHCPClient.Timeout))\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
\r
break;\r
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_ROUTER, &AppState->DHCPClient.DHCPOffer_Data.GatewayIP);\r
DHCPClientApp_GetOption(AppData->Options, DHCP_OPTION_SERVER_ID, &AppState->DHCPClient.DHCPOffer_Data.ServerIP);\r
\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendRequest;\r
}\r
\r
uip_udp_send(AppDataSize);\r
\r
/* Reset the timeout timer, progress to next state */\r
- timer_reset(&DHCPTimer);\r
+ timer_reset(&AppState->DHCPClient.Timeout);\r
AppState->DHCPClient.CurrentState = DHCP_STATE_WaitForACK;\r
\r
break;\r
if (!(uip_newdata()))\r
{\r
/* Check if the DHCP timeout period has expired while waiting for a response */\r
- if (timer_expired(&DHCPTimer))\r
+ if (timer_expired(&AppState->DHCPClient.Timeout))\r
AppState->DHCPClient.CurrentState = DHCP_STATE_SendDiscover;\r
\r
break;\r