Page 1 of 1

Web Server with ESP-MESH

Posted: Tue Aug 20, 2019 11:17 pm
by RavenHawk
I would like to handle GET and POST requests in the root node of my mesh. I tried combining the example from protocols\http_server\simple with the ESP-MESH Internal Communication example. The response to GET requests stops once I uncomment the esp_mesh_start() function. Is it possible to combine these two functionalities? If so, how do I change my code? (I have just started with ESP-IDF, please keep in mind when using technical vocabulary). Thanks!

I put the whole code on pastebin: https://pastebin.com/NFWbJAJw. Here's the app_main:

Code: Select all

void app_main(void)
{
    static httpd_handle_t server = NULL;
    ESP_ERROR_CHECK(mesh_light_init());
    ESP_ERROR_CHECK(nvs_flash_init());
    tcpip_adapter_init();
    // ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
    // ESP_ERROR_CHECK(tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA));
    ESP_ERROR_CHECK(esp_event_loop_init(event_handler, &server));
    wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&config));
    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
    wifi_config_t wifi_config = {
        .sta = {
            .ssid = CONFIG_MESH_ROUTER_SSID,
            .password = CONFIG_MESH_ROUTER_PASSWD,
        },
    };
    ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
    ESP_ERROR_CHECK(esp_wifi_start());

    ESP_ERROR_CHECK(esp_mesh_init());
    ESP_ERROR_CHECK(esp_mesh_set_max_layer(CONFIG_MESH_MAX_LAYER));
    ESP_ERROR_CHECK(esp_mesh_set_vote_percentage(1));
    ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
#ifdef MESH_FIX_ROOT
    ESP_ERROR_CHECK(esp_mesh_fix_root(1));
#endif
    mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
    /* mesh ID */
    memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
    /* mesh event callback */
    cfg.event_cb = &mesh_event_handler;
    /* router */
    cfg.channel = CONFIG_MESH_CHANNEL;
    cfg.router.ssid_len = strlen(CONFIG_MESH_ROUTER_SSID);
    memcpy((uint8_t *) &cfg.router.ssid, CONFIG_MESH_ROUTER_SSID, cfg.router.ssid_len);
    memcpy((uint8_t *) &cfg.router.password, CONFIG_MESH_ROUTER_PASSWD,
           strlen(CONFIG_MESH_ROUTER_PASSWD));
    /* mesh softAP */
    ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE));
    cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS;
    memcpy((uint8_t *) &cfg.mesh_ap.password, CONFIG_MESH_AP_PASSWD,
           strlen(CONFIG_MESH_AP_PASSWD));
    ESP_ERROR_CHECK(esp_mesh_set_config(&cfg));
    /* mesh start */
    // ESP_ERROR_CHECK(esp_mesh_start());
    // ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d, %s\n",  esp_get_free_heap_size(),
    //          esp_mesh_is_root_fixed() ? "root fixed" : "root not fixed");
}

Re: Web Server with ESP-MESH

Posted: Mon Mar 01, 2021 10:30 am
by maagvin
Hi RavenHawk

Have you by any chance solved your problem concerning GET/POST requests in combination with an ESP-MESH network?

I would like to combine a large amount of esp32 together into a MESH-Network. Each ESP32 should serve as a webserver. I would like to connect a handheld device (i.e. tablet, smartphone) to the MESH-Network an call upon each individual esp32 with GET/POST requests. I am looking for examples and/or some input if this is actually possible.

Thanks for any kind of help, maybe others have some input too.

Cheers

Re: Web Server with ESP-MESH

Posted: Mon Mar 01, 2021 5:11 pm
by RavenHawk
maagvin wrote:
Mon Mar 01, 2021 10:30 am
Hi RavenHawk

Have you by any chance solved your problem concerning GET/POST requests in combination with an ESP-MESH network?

I would like to combine a large amount of esp32 together into a MESH-Network. Each ESP32 should serve as a webserver. I would like to connect a handheld device (i.e. tablet, smartphone) to the MESH-Network an call upon each individual esp32 with GET/POST requests. I am looking for examples and/or some input if this is actually possible.

Thanks for any kind of help, maybe others have some input too.

Cheers
I worked on this long time ago and forgot what I ended up doing. Mesh libraries and drivers have most likely been improved and working example sketches have probably changed. ESP-MESH is built on esp-idf using vanilla C, which I barely got into, as I mainly have experience with Arduino. You are free to look through my project logs and maybe find something useful there: https://hackaday.io/project/166868-my-a ... p-now-mesh