Mesh and webserver

asma-moh
Posts: 4
Joined: Sat Aug 12, 2023 8:09 am

Mesh and webserver

Postby asma-moh » Wed Aug 23, 2023 8:05 am

err3.JPG
err3.JPG (121.38 KiB) Viewed 754 times
err2.JPG
err2.JPG (49.16 KiB) Viewed 754 times
err1.JPG
err1.JPG (41.48 KiB) Viewed 754 times
Hi!
I want to program an ESP_IDF project that enable communication between 2 esp32 using mesh networking.Additionally, I want to run a web server on parent node to allow users to send on or off command to manage the LEDs of the child nodes.

To achive this, I have combined internal_communication mesh example from ESP_IDf Github repository with my web server code. However, both the mesh example and web server code utilize Wi-Fi and attempt to set the esp32 device in station mode, as well as register various handler and handler instaces.

I encounter an error while running this code. It has problem in "esp_event_loop_create_default<>" function and can't connect to hotspot, router, and reset after seconds.I attach logs images.

This is my code in Github repository too: https://github.com/as-moh-nok/internal_communication4

web server session that use Wi-Fi:

Code: Select all

void connect_wifi(void)
{
    s_wifi_event_group = xEventGroupCreate();

    ESP_ERROR_CHECK(esp_netif_init());

    ESP_ERROR_CHECK(esp_event_loop_create_default());
    esp_netif_create_default_wifi_sta();

    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));

    esp_event_handler_instance_t instance_any_id;
    esp_event_handler_instance_t instance_got_ip;
    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
                                                        ESP_EVENT_ANY_ID,
                                                        &event_handler,
                                                        NULL,
                                                        &instance_any_id));
                                                     
mesh session:

Code: Select all

 //ESP_ERROR_CHECK(esp_netif_init());
    /*  event initialization */
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    /*  create network interfaces for mesh (only station instance saved for further manipulation, soft AP instance ignored */
   ESP_ERROR_CHECK(esp_netif_create_default_wifi_mesh_netifs(&netif_sta, NULL));
    /*  wifi initialization */
    wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&config));
     ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL));
    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
    ESP_ERROR_CHECK(esp_wifi_start());
    /*  mesh initialization */
    ESP_ERROR_CHECK(esp_mesh_init());
    //#ifdef MESH_FIX_ROOT
    //ESP_ERROR_CHECK(esp_mesh_fix_root(0));
    //#endif
    ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL));
    /*  set mesh topology */
Can you solve my problem?
Thanks!

Who is online

Users browsing this forum: No registered users and 109 guests