Permalink
Browse files

Add uip_dhcp_shutdown() to uip_dhcp.h/.c; DHCP sample apps now shut D…

…HCP down when done with it.
  • Loading branch information...
GregEigsti committed Jul 13, 2010
1 parent a49ba55 commit 0724e9947822afc29500daad6e24b37fb85abaed
Showing with 22 additions and 5 deletions.
  1. +3 −0 examples/SocketAppDHCP/SocketAppDHCP.pde
  2. +12 −5 examples/WiFiScan/WiFiScan.pde
  3. +6 −0 uip_dhcp.c
  4. +1 −0 uip_dhcp.h
@@ -123,6 +123,9 @@ extern "C" {
Serial.println("DHCP NULL FALLBACK");
}
+ // Shut down DHCP
+ uip_dhcp_shutdown();
+
connectAndSendTCP = true;
}
@@ -296,6 +296,8 @@ extern "C" {
if(20 < udpRetry++) {
Serial.println("DHCP TIMEOUT FALLBACK");
+ // Shut down DHCP
+ uip_dhcp_shutdown();
phase = PHASEDNS;
}
}
@@ -347,12 +349,14 @@ extern "C" {
*/
void socket_app_appcall(void)
{
- //Serial.print("socket_app_appcall: ");
-
- if(uip_closed() || uip_timedout()) {
- Serial.println("CLEANUP");
+ if(uip_timedout()) {
+ Serial.println("TIMEDOUT");
+ phase = PHASECLEANUP;
+ return;
+ }
+ if(uip_closed()) {
+ Serial.println("CLOSED");
phase = PHASECLEANUP;
- uip_close();
return;
}
if(uip_poll()) {
@@ -466,6 +470,9 @@ extern "C" {
else {
Serial.println("DHCP NULL FALLBACK");
}
+
+ // Shut down DHCP
+ uip_dhcp_shutdown();
phase = PHASEDNS;
}
View
@@ -396,6 +396,12 @@ uip_dhcp_init(const void *mac_addr, int mac_len)
}
/*---------------------------------------------------------------------------*/
void
+uip_dhcp_shutdown()
+{
+ uip_udp_remove(s.conn);
+}
+/*---------------------------------------------------------------------------*/
+void
uip_dhcp_request(void)
{
u16_t ipaddr[2];
View
@@ -60,6 +60,7 @@ void uip_dhcp_init(const void *mac_addr, int mac_len);
void uip_dhcp_request(void);
char uip_dhcp_run();
void uip_dhcp_callback(const struct dhcp_state *s);
+void uip_dhcp_shutdown();
#endif /* __DHCP_H__ */

0 comments on commit 0724e99

Please sign in to comment.