Skip to content

Commit 0724e99

Browse files
committed
Add uip_dhcp_shutdown() to uip_dhcp.h/.c; DHCP sample apps now shut DHCP down when done with it.
1 parent a49ba55 commit 0724e99

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

examples/SocketAppDHCP/SocketAppDHCP.pde

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ extern "C" {
123123
Serial.println("DHCP NULL FALLBACK");
124124
}
125125

126+
// Shut down DHCP
127+
uip_dhcp_shutdown();
128+
126129
connectAndSendTCP = true;
127130
}
128131

examples/WiFiScan/WiFiScan.pde

+12-5
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ extern "C" {
296296

297297
if(20 < udpRetry++) {
298298
Serial.println("DHCP TIMEOUT FALLBACK");
299+
// Shut down DHCP
300+
uip_dhcp_shutdown();
299301
phase = PHASEDNS;
300302
}
301303
}
@@ -347,12 +349,14 @@ extern "C" {
347349
*/
348350
void socket_app_appcall(void)
349351
{
350-
//Serial.print("socket_app_appcall: ");
351-
352-
if(uip_closed() || uip_timedout()) {
353-
Serial.println("CLEANUP");
352+
if(uip_timedout()) {
353+
Serial.println("TIMEDOUT");
354+
phase = PHASECLEANUP;
355+
return;
356+
}
357+
if(uip_closed()) {
358+
Serial.println("CLOSED");
354359
phase = PHASECLEANUP;
355-
uip_close();
356360
return;
357361
}
358362
if(uip_poll()) {
@@ -466,6 +470,9 @@ extern "C" {
466470
else {
467471
Serial.println("DHCP NULL FALLBACK");
468472
}
473+
474+
// Shut down DHCP
475+
uip_dhcp_shutdown();
469476

470477
phase = PHASEDNS;
471478
}

uip_dhcp.c

+6
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ uip_dhcp_init(const void *mac_addr, int mac_len)
396396
}
397397
/*---------------------------------------------------------------------------*/
398398
void
399+
uip_dhcp_shutdown()
400+
{
401+
uip_udp_remove(s.conn);
402+
}
403+
/*---------------------------------------------------------------------------*/
404+
void
399405
uip_dhcp_request(void)
400406
{
401407
u16_t ipaddr[2];

uip_dhcp.h

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void uip_dhcp_init(const void *mac_addr, int mac_len);
6060
void uip_dhcp_request(void);
6161
char uip_dhcp_run();
6262
void uip_dhcp_callback(const struct dhcp_state *s);
63+
void uip_dhcp_shutdown();
6364

6465
#endif /* __DHCP_H__ */
6566

0 commit comments

Comments
 (0)