Skip to content

[nsapi] Fix issue with reconnecting the ethernet interface #2343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,34 +144,33 @@ const char *lwip_get_ip_address(void)
int lwip_bringup(void)
{
// Check if we've already connected
if (lwip_get_mac_address()) {
return 0;
}

// Set up network
lwip_set_mac_address();
if (!lwip_get_mac_address()) {
// Set up network
lwip_set_mac_address();

sys_sem_new(&lwip_tcpip_inited, 0);
sys_sem_new(&lwip_netif_linked, 0);
sys_sem_new(&lwip_netif_up, 0);
sys_sem_new(&lwip_tcpip_inited, 0);
sys_sem_new(&lwip_netif_linked, 0);
sys_sem_new(&lwip_netif_up, 0);

tcpip_init(lwip_tcpip_init_irq, NULL);
sys_arch_sem_wait(&lwip_tcpip_inited, 0);
tcpip_init(lwip_tcpip_init_irq, NULL);
sys_arch_sem_wait(&lwip_tcpip_inited, 0);

memset(&lwip_netif, 0, sizeof lwip_netif);
netif_add(&lwip_netif, 0, 0, 0, NULL, eth_arch_enetif_init, tcpip_input);
netif_set_default(&lwip_netif);
memset(&lwip_netif, 0, sizeof lwip_netif);
netif_add(&lwip_netif, 0, 0, 0, NULL, eth_arch_enetif_init, tcpip_input);
netif_set_default(&lwip_netif);

netif_set_link_callback (&lwip_netif, lwip_netif_link_irq);
netif_set_status_callback(&lwip_netif, lwip_netif_status_irq);
netif_set_link_callback (&lwip_netif, lwip_netif_link_irq);
netif_set_status_callback(&lwip_netif, lwip_netif_status_irq);

// Connect to network
eth_arch_enable_interrupts();
dhcp_start(&lwip_netif);
eth_arch_enable_interrupts();
}

// Zero out socket set
lwip_arena_init();

// Connect to the network
dhcp_start(&lwip_netif);

// Wait for an IP Address
u32_t ret = sys_arch_sem_wait(&lwip_netif_up, 15000);
if (ret == SYS_ARCH_TIMEOUT) {
Expand All @@ -183,12 +182,10 @@ int lwip_bringup(void)

void lwip_bringdown(void)
{
// Disconnect from the network
dhcp_release(&lwip_netif);
dhcp_stop(&lwip_netif);

eth_arch_disable_interrupts();
lwip_ip_addr[0] = '\0';
lwip_mac_addr[0] = '\0';
}


Expand Down