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

MDF_EVENT_MWIFI_ROOT_GOT_IP event does not occur on root device #186

Closed
PavelLot opened this issue Dec 2, 2020 · 8 comments
Closed

MDF_EVENT_MWIFI_ROOT_GOT_IP event does not occur on root device #186

PavelLot opened this issue Dec 2, 2020 · 8 comments

Comments

@PavelLot
Copy link

PavelLot commented Dec 2, 2020

Environment

  • Development Kit: [ESP32-DevKitC]
  • Kit version (for WroverKit/PicoKit/DevKitC): [v4]
  • Core (if using chip or module): [ESP-WROOM-32U]
  • MDF version (git rev-parse --short HEAD to get the commit id.): 1c76187
  • Development Env: [Eclipse]
  • Operating System: [Windows]
  • Power Supply: [USB]

Problem Description

I found that sometimes when the root device goes offline, someone from the other child nodes on the network becomes the root node, but the MDF_EVENT_MWIFI_ROOT_GOT_IP event does not occur.
In this case, the esp_mesh_is_root method returns true.
Could there be conditions under which such behavior is possible?

@aresstokrat
Copy link

I also have such a problem. Sometimes after voting is done ROOT does't get IP.
I tried different routers, but problem still occur.

How can i debug this problem to find a solution?

@ravi-kashi
Copy link

ravi-kashi commented Dec 11, 2021

I face the same issue. Has this been worked up on? I don't know why this is not working and the ticket is closed?

git rev-parse --short HEAD 
cf50274 

I found this in sdkconfig
CONFIG_MWIFI_WAIVE_ROOT=y

I found this in mwifi.c

#ifdef CONFIG_MWIFI_WAIVE_ROOT

        case IP_EVENT_STA_GOT_IP: {
            mwifi_waive_root_timer_delete();
            mwifi_waive_root_timer_create();
            mdf_event_loop_send(MDF_EVENT_MWIFI_ROOT_GOT_IP, &s_event_info);
            break;
        }

#endif /**< CONFIG_MWIFI_WAIVE_ROOT */

@shenjun7
Copy link

Please update the following api, we will merge to the release version.
esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, esp_netif_t **p_netif_ap)
{
// Create "almost" default AP, with un-flagged DHCP server
esp_netif_inherent_config_t netif_cfg;
memcpy(&netif_cfg, ESP_NETIF_BASE_DEFAULT_WIFI_AP, sizeof(netif_cfg));
netif_cfg.flags &= ~ESP_NETIF_DHCP_SERVER;
esp_netif_config_t cfg_ap = {
.base = &netif_cfg,
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP,
};
esp_netif_t *netif_ap = esp_netif_new(&cfg_ap);
assert(netif_ap);
ESP_ERROR_CHECK(esp_netif_attach_wifi_ap(netif_ap));
ESP_ERROR_CHECK(esp_wifi_set_default_wifi_ap_handlers());

// ...and stop DHCP server to be compatible with former tcpip_adapter (to keep the ESP_NETIF_DHCP_STOPPED state)
ESP_ERROR_CHECK(esp_netif_dhcps_stop(netif_ap));

// Create "almost" default station, but with un-flagged DHCP client
memcpy(&netif_cfg, ESP_NETIF_BASE_DEFAULT_WIFI_STA, sizeof(netif_cfg));
// netif_cfg.flags &= ~ESP_NETIF_DHCP_CLIENT;
esp_netif_config_t cfg_sta = {
        .base = &netif_cfg,
        .stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA,
};
esp_netif_t *netif_sta = esp_netif_new(&cfg_sta);
assert(netif_sta);
ESP_ERROR_CHECK(esp_netif_attach_wifi_station(netif_sta));
ESP_ERROR_CHECK(esp_wifi_set_default_wifi_sta_handlers());

// ...and stop DHCP client (to be started separately if the station were promoted to root)
ESP_ERROR_CHECK(esp_netif_dhcpc_stop(netif_sta));

if (p_netif_sta) {
    *p_netif_sta = netif_sta;
}
if (p_netif_ap) {
    *p_netif_ap = netif_ap;
}
return ESP_OK;

}

@ravi-kashi
Copy link

ravi-kashi commented Dec 13, 2021

Thank you Shenjun7.

the only difference is // netif_cfg.flags &= ~ESP_NETIF_DHCP_CLIENT;
I now get a different error and even now the root task is not created.
E (9466) esp_netif_handlers: invalid static ip

@shenjun7
Copy link

This error does not affect the acquisition of ip. You can add esp_netif_dhcpc_stop(sta_netif) after the MDF_EVENT_MWIFI_PARENT_CONNECTED, and revert the above change.

    case MDF_EVENT_MWIFI_PARENT_CONNECTED:
        MDF_LOGI("Parent is connected on station interface");

        if (esp_mesh_is_root()) {
            esp_netif_dhcpc_stop(sta_netif);
            esp_netif_dhcpc_start(sta_netif);
        }

@ravi-kashi
Copy link

Thank you Shenjun7.
I made these changes and it is working. I also removed the

esp_netif_dhcpc_stop(sta_netif);

and checked. It is working all right. Appreciate the help!

@xinort
Copy link

xinort commented Apr 27, 2022

Thank you Shenjun7. I made these changes and it is working. I also removed the

esp_netif_dhcpc_stop(sta_netif);

and checked. It is working all right. Appreciate the help!

@ravi-kashi Hi, can you explain the changes you made? I'm experiencing this issue and the instructions from @shenjun7 aren't clear to me what changes need to be made in what file(s).

@piro-pp
Copy link

piro-pp commented Sep 19, 2022

Thank you Shenjun7. I made these changes and it is working. I also removed the
esp_netif_dhcpc_stop(sta_netif);
and checked. It is working all right. Appreciate the help!

@ravi-kashi Hi, can you explain the changes you made? I'm experiencing this issue and the instructions from @shenjun7 aren't clear to me what changes need to be made in what file(s).

It's the file esp-idf/components/esp_wifi/src/wifi_default.c around line 385. The only change is to outcomment the line "netif_cfg.flags &= ~ESP_NETIF_DHCP_CLIENT;"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants