@@ -144,34 +144,33 @@ const char *lwip_get_ip_address(void)
144
144
int lwip_bringup (void )
145
145
{
146
146
// Check if we've already connected
147
- if (lwip_get_mac_address ()) {
148
- return 0 ;
149
- }
150
-
151
- // Set up network
152
- lwip_set_mac_address ();
147
+ if (!lwip_get_mac_address ()) {
148
+ // Set up network
149
+ lwip_set_mac_address ();
153
150
154
- sys_sem_new (& lwip_tcpip_inited , 0 );
155
- sys_sem_new (& lwip_netif_linked , 0 );
156
- sys_sem_new (& lwip_netif_up , 0 );
151
+ sys_sem_new (& lwip_tcpip_inited , 0 );
152
+ sys_sem_new (& lwip_netif_linked , 0 );
153
+ sys_sem_new (& lwip_netif_up , 0 );
157
154
158
- tcpip_init (lwip_tcpip_init_irq , NULL );
159
- sys_arch_sem_wait (& lwip_tcpip_inited , 0 );
155
+ tcpip_init (lwip_tcpip_init_irq , NULL );
156
+ sys_arch_sem_wait (& lwip_tcpip_inited , 0 );
160
157
161
- memset (& lwip_netif , 0 , sizeof lwip_netif );
162
- netif_add (& lwip_netif , 0 , 0 , 0 , NULL , eth_arch_enetif_init , tcpip_input );
163
- netif_set_default (& lwip_netif );
158
+ memset (& lwip_netif , 0 , sizeof lwip_netif );
159
+ netif_add (& lwip_netif , 0 , 0 , 0 , NULL , eth_arch_enetif_init , tcpip_input );
160
+ netif_set_default (& lwip_netif );
164
161
165
- netif_set_link_callback (& lwip_netif , lwip_netif_link_irq );
166
- netif_set_status_callback (& lwip_netif , lwip_netif_status_irq );
162
+ netif_set_link_callback (& lwip_netif , lwip_netif_link_irq );
163
+ netif_set_status_callback (& lwip_netif , lwip_netif_status_irq );
167
164
168
- // Connect to network
169
- eth_arch_enable_interrupts ();
170
- dhcp_start (& lwip_netif );
165
+ eth_arch_enable_interrupts ();
166
+ }
171
167
172
168
// Zero out socket set
173
169
lwip_arena_init ();
174
170
171
+ // Connect to the network
172
+ dhcp_start (& lwip_netif );
173
+
175
174
// Wait for an IP Address
176
175
u32_t ret = sys_arch_sem_wait (& lwip_netif_up , 15000 );
177
176
if (ret == SYS_ARCH_TIMEOUT ) {
@@ -183,12 +182,10 @@ int lwip_bringup(void)
183
182
184
183
void lwip_bringdown (void )
185
184
{
185
+ // Disconnect from the network
186
186
dhcp_release (& lwip_netif );
187
187
dhcp_stop (& lwip_netif );
188
-
189
- eth_arch_disable_interrupts ();
190
188
lwip_ip_addr [0 ] = '\0' ;
191
- lwip_mac_addr [0 ] = '\0' ;
192
189
}
193
190
194
191
0 commit comments