Skip to content
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

Better handling with state change callback #62

Merged
merged 1 commit into from
Oct 31, 2022
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
21 changes: 15 additions & 6 deletions glue-lwip/lwip-git.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ static void netif_sta_status_callback (struct netif* netif)
if (netif_default == netif)
netif_set_default(NULL);
}

netif_status_changed(netif);
}

static void netif_init_common (struct netif* netif)
Expand Down Expand Up @@ -389,7 +391,7 @@ static err_t netif_init_ap (struct netif* netif)

netif->name[0] = 'a';
netif->name[1] = 'p';
netif->status_callback = NULL; // esp-netif-ap is made up by esp
netif->status_callback = netif_status_changed;

netif_init_common(netif);

Expand Down Expand Up @@ -503,19 +505,26 @@ void esp2glue_netif_set_up1down0 (int netif_idx, int up1_or_down0)
struct netif* netif = &netif_git[netif_idx];
if (up1_or_down0)
{
// netif is brought UP

netif_set_link_up(netif);
//netif_set_up(netif); // unwanted call to netif_sta_status_callback()

// We are called more often that it should by FW at boot time,
// there is no need to uselessly shake the network interface:
// netif_set_up(netif); <-- unwanted call to netif_sta_status_callback()
netif->flags |= NETIF_FLAG_UP;
#if ARDUINO
if (!netif_enabled[netif_idx])
//if (!netif_enabled[netif_idx])
{
netif_enabled[netif_idx] = 1;
netif_status_changed(netif);
//netif_status_changed(netif) was here but is now called from lwIP by netif->status_callback()
}
#endif
}
else
{
// netif is pulled DOWN

// stop dhcp client (if started)
dhcp_release_and_stop(netif);

Expand All @@ -532,10 +541,10 @@ void esp2glue_netif_set_up1down0 (int netif_idx, int up1_or_down0)
if (netif_default == &netif_git[netif_idx])
netif_set_default(NULL);
#if ARDUINO
if (netif_enabled[netif_idx])
//if (netif_enabled[netif_idx])
{
netif_enabled[netif_idx] = 0;
netif_status_changed(netif);
//netif_status_changed(netif) was here but is now called from lwIP by netif->status_callback()
}
#endif
}
Expand Down