ESP-MESH without a router

Snedig
Posts: 24
Joined: Sat Apr 04, 2020 3:18 pm

ESP-MESH without a router

Postby Snedig » Sat Apr 04, 2020 3:31 pm

Hi,

I am trying to set up a WiFi MESH-network without a router (root node will transmit information via onboard 4G), and I am using ESP-IDF to support chain topology.

I have managed to make the mesh connect nicely, nodes are recognized and the root is set based on external criteria (currently just a strap on a GPIO).

However, none of my messages seem to be received on any of the devices whatever I do.

The relevant parts of my code are:
Mesh init (all router settings commented out):

Code: Select all

mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
    /* mesh ID */
    memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
    /* 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));
This returns " mesh: [MANUAL]designated as root and router is not set".

My mesh_send commands look like this:

Code: Select all

//node send to root
err = esp_mesh_send(NULL, &data, MESH_DATA_P2P, NULL, 0);

//root send to nodes
for (i = 0; i < route_table_size; i++) {
err = esp_mesh_send(&route_table[i], &data, MESH_DATA_P2P, NULL, 0);
}
This all works perfectly fine when a router is connected, but not at all when I do not have a router connected.

I would be thankful for any tips as I'm banging my head against the wall at the moment.. :)

Snedig
Posts: 24
Joined: Sat Apr 04, 2020 3:18 pm

Re: ESP-MESH without a router

Postby Snedig » Sun Apr 12, 2020 6:49 am

I did figure this out, although I rewrote my whole program from scratch, so I'm a little bit unsure what the problem was.

I think I didn't successfully set esp_mesh_set_self_organized on the root node in the old program.

Magnetuz
Posts: 12
Joined: Thu Dec 31, 2020 8:39 am

Re: ESP-MESH without a router

Postby Magnetuz » Tue Jan 05, 2021 10:36 am

Hi Snedig.

Did you use the manual networking or the auto networking? I am trying the same with the manual networking but the scanning returns me just the "normal wifis" and no mesh from the node. So the node cannot join the mesh.

Thanks

Snedig
Posts: 24
Joined: Sat Apr 04, 2020 3:18 pm

Re: ESP-MESH without a router

Postby Snedig » Mon Mar 15, 2021 4:02 pm

Hi Magnetuz,

I found out that the manual networking does not work in chain topology, the networking IE info that is broadcast from the AP's is not the same size as for tree. I've made a Github issue for this.

For me, manual networking did work in tree topology, but for chain I had to do auto networking.

Magnetuz
Posts: 12
Joined: Thu Dec 31, 2020 8:39 am

Re: ESP-MESH without a router

Postby Magnetuz » Mon Mar 15, 2021 7:21 pm

Hi Snedig.

Would you have some code example of how you did the wifi/mesh configuration and the finish scan function for the manual networking? I am also using the tree topology, but I get no scan results for the softAP (the AP from the mesh network).

For the finish scan function, I am doing like this:
  1. for(int i = 0 ; i < ap_count ; i++) {
  2.     esp_mesh_scan_get_ap_ie_len(&ie_len);
  3.     esp_mesh_scan_get_ap_record(&pap_info, &assoc);
  4. ...
  5. }

I loop all the results and try to match a registered id/password. But this will provide me just the "normal" AP, like from routers and repeaters. The softAPs are never listed there. So when my ESP32 has just the mesh id/password, I cannot match to anything.

The workaround I am doing now is: if I cannot find any network in manual scannig, I switch the scan to automatic. At this mode, the ESP32 is able to connect to a mesh without any information regarding the router.

Thank you

Snedig
Posts: 24
Joined: Sat Apr 04, 2020 3:18 pm

Re: ESP-MESH without a router

Postby Snedig » Tue Mar 23, 2021 11:12 pm

For the tree topology, I am pretty sure I went with an unmodded example and it worked as expected.

Here's my entire code for MESH init that works for me with no router settings, beware, there may be some surplus stuff that isn't necessary, and it's no comment country, but it might give you a tip. My thought is that it's not doing esp_mesh_set_type(MESH_ROOT) on the root node and the esp_mesh_fix_root(true) for the nodes that is creating problems for you.

Code: Select all

esp_err_t mesh_enable(void) {
  esp_err_t err = ESP_OK;
  if (!mesh_on) {
    if (mesh_init_done == false) {
      ESP_LOGW(MESH_TAG, "Initializing mesh network");
    } else {
      ESP_LOGW(MESH_TAG, "Enabling mesh network");
    }
    if (mesh_init_done == false) {
      disableCore0WDT();
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_init());
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_loop_create_default());
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_create_default_wifi_mesh_netifs(&netif_sta, NULL));
      wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT();
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_init(&config));
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL));
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_storage(WIFI_STORAGE_RAM));
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_mode(WIFI_MODE_APSTA));
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_ps(WIFI_PS_NONE));
    }
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_country(&wifi_country));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_LR));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_start());
    uint8_t i = 72;
    while (esp_wifi_set_max_tx_power(i) == ESP_OK) {
      i++;
    }

    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_init());
    if (basic_settings.is_root) {
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_type(MESH_ROOT));
    } else {
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_fix_root(true));
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_group_id(&mesh_group_addr, 1));
    }
    if (mesh_init_done == false) {
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL));
    }
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_topology(MESH_TOPO_CHAIN));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_max_layer(mesh_settings.max_layer));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_vote_percentage(1));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_xon_qsize(16));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_disable_ps());
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_ap_assoc_expire(10));
    mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
    memcpy((uint8_t *)&cfg.mesh_id, mesh_settings.id, 6);
    cfg.channel = mesh_settings.channel;
    cfg.allow_channel_switch = true;
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_ap_authmode(mesh_settings.auth_mode));
    esp_mesh_set_ie_crypto_key(mesh_settings.crypt_key, strlen(mesh_settings.crypt_key));
    cfg.mesh_ap.max_connection = mesh_settings.max_conn;
    memcpy((uint8_t *)&cfg.mesh_ap.password, mesh_settings.ap_pass, strlen(mesh_settings.ap_pass));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_config(&cfg));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_start());
    if (mesh_init_done == false) {
      xTaskCreate(&get_message, "get_message", 9216, NULL, 5, &get_message_handle);
      ESP_LOGI(MESH_TAG, "Created mesh receive task");
      enableCore0WDT();
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_read_mac(mesh_self_addr.addr, 0));
    } else {
      ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_comm_p2p_start());
    }
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_self_organized(true, false));
    mesh_on = true;
    if (mesh_init_done == false) {
      if (esp_mesh_is_root()) {
        memcpy(&mesh_root_addr, &mesh_self_addr, sizeof(mesh_addr_t));
        memcpy(&node_status[0].address, &mesh_self_addr, sizeof(mesh_addr_t));
        node_status[0].exists = true;
        node_status[0].connected = true;
        node_status[0].current_version = SOFTWARE_VERSION;
        node_status[0].uptime = (uint32_t)(esp_timer_get_time() / 1000000ULL);
        node_status[0].mesh_layer = esp_mesh_get_layer();
      }
      mesh_init_done = true;
    }
    uint8_t wifi_protocol_ap;
    uint8_t wifi_protocol_sta;
    esp_wifi_get_protocol(WIFI_IF_AP, &wifi_protocol_ap);
    esp_wifi_get_protocol(WIFI_IF_STA, &wifi_protocol_sta);
    mesh_addr_t id;
    esp_mesh_get_id(&id);
    int8_t max_tx_power;
    esp_wifi_get_max_tx_power(&max_tx_power);

    ESP_LOGI(MESH_TAG, "Mesh starts successfully");
    ESP_LOGI(MESH_TAG, "Mesh type:                                  %s", (esp_mesh_is_root()) ? "Root" : "Node");
    ESP_LOGI(MESH_TAG, "Mesh ID:                       " MACSTR "", MAC2STR(id.addr));
    ESP_LOGI(MESH_TAG, "Station MAC:                   " MACSTR "", MAC2STR(mesh_self_addr.addr));
    ESP_LOGI(MESH_TAG, "Channel:                                       %d", cfg.channel);
    ESP_LOGI(MESH_TAG, "Max. connected stations:                       %d", cfg.mesh_ap.max_connection);
    ESP_LOGI(MESH_TAG, "STA protocol:                         %s%s%s%s", (wifi_protocol_sta == 1) ? "802.11b" : "", (wifi_protocol_sta == 2) ? "802.11g" : "", (wifi_protocol_sta == 4) ? "802.11n" : "", (wifi_protocol_sta == 8) ? "Long Range" : "");
    ESP_LOGI(MESH_TAG, "AP protocol:                          %s%s%s%s", (wifi_protocol_ap == 1) ? "802.11b" : "", (wifi_protocol_ap == 2) ? "802.11g" : "", (wifi_protocol_ap == 4) ? "802.11n" : "", (wifi_protocol_ap == 8) ? "Long Range" : "");
    ESP_LOGI(MESH_TAG, "Max. layer:                                  %d", esp_mesh_get_max_layer());
    ESP_LOGI(MESH_TAG, "Topology:                                  %s", (esp_mesh_get_topology()) ? "Chain" : "Tree");
    ESP_LOGI(MESH_TAG, "Root fixed:                                  %s", (esp_mesh_is_root_fixed()) ? "Yes" : "No");
    ESP_LOGI(MESH_TAG, "Power save enabled:                           %s", (esp_mesh_is_ps_enabled()) ? "Yes" : "No");
    ESP_LOGI(MESH_TAG, "Max. TX power:                          %.1f dBm", (float)max_tx_power * 0.25);
    ESP_LOGI(MESH_TAG, "Free heap:                                 %d", esp_get_free_heap_size());
    ESP_LOGI(MESH_TAG, "MF ID:      %s", basic_settings.mf_id);
    ESP_LOGI(MESH_TAG, "MF key:     %s", basic_settings.mf_key);
    ESP_LOGI(MESH_TAG, "MF chan:    %s", basic_settings.mf_channel);
  } else {
    ESP_LOGW(MESH_TAG, "Mesh network already enabled!");
  }
  return err;
}
Good luck!

leo_espressivo
Posts: 3
Joined: Thu Apr 29, 2021 2:43 pm

Re: ESP-MESH without a router

Postby leo_espressivo » Thu May 06, 2021 9:20 am

Hey just a small question, you just commented the router configuration lines to make it work without need to have a router? Because I want to do such thing, a ESP-MESH network that doesn't need a router, just some nodes orginized in tree topology, that can send and receive messages between them.

the-remote-engineer
Posts: 2
Joined: Wed May 12, 2021 3:39 am

Re: ESP-MESH without a router

Postby the-remote-engineer » Wed May 12, 2021 4:08 am

I'm also trying to build a routerless mesh network (using tree topology, with esp-idf v4.2). It seems that I have the network forming with a chosen root device, but I'm not getting messages through. Debug shows that devices are connecting. See below:
I (1882) wifi: new:<1,1>, old:<1,0>, ap:<1,1>, sta:<0,0>, prof:1
I (1892) wifi: station: 10:52:1c:66:98:60 join, AID=1, bgn, 40U
I (1892) wifi: new:<1,1>, old:<1,1>, ap:<1,1>, sta:<0,0>, prof:1
I (1902) wifi: station: 10:52:1c:69:48:00 join, AID=2, bgn, 40U
I (1912) mesh_main: <MESH_EVENT_PS_CHILD_DUTY>cidx:0, 10:52:1c:66:98:60, duty:12
I (1912) mesh_main: <MESH_EVENT_PS_CHILD_DUTY>cidx:1, 10:52:1c:69:48:00, duty:12
W (1922) mesh_main: <MESH_EVENT_ROUTING_TABLE_ADD>add 1, new:2, layer:1
I (1932) mesh_main: <MESH_EVENT_CHILD_CONNECTED>aid:1, 10:52:1c:66:98:60
W (1932) mesh_main: <MESH_EVENT_ROUTING_TABLE_ADD>add 1, new:3, layer:1
I (1942) mesh_main: <MESH_EVENT_CHILD_CONNECTED>aid:2, 10:52:1c:69:48:00
I'd like to start by sending JSON strings from the nodes to the root device. Instead of seeing the JSON strings, I'm getting this at the root debug:
I (9362) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (9362) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (9372) mesh: [RXQ]<max:128 = cfg:128 + extra:0>self:0, <max:128 = cfg:128 + extra:0>tods:0
I (10732) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (10732) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (10752) mesh: [RXQ]<max:128 = cfg:128 + extra:0>self:0, <max:128 = cfg:128 + extra:0>tods:0
I (11032) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (11032) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (11042) mesh: [RXQ]<max:128 = cfg:128 + extra:0>self:0, <max:128 = cfg:128 + extra:0>tods:0
I (11212) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (11212) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (11222) mesh: [RXQ]<max:128 = cfg:128 + extra:0>self:0, <max:128 = cfg:128 + extra:0>tods:0
I (12542) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (12542) mesh: [TXQ]<max:128>up(0, be:0), down(0, be:0), mgmt:0, xon(req:0, rsp:12), bcast:0, wnd(0, parent:00:00:00:00:00:00)
I (12552) mesh: [RXQ]<max:128 = cfg:128 + extra:0>self:0, <max:128 = cfg:128 + extra:0>tods:0
I am starting with the esp-idf/examples/mesh/internal_communication/ example.

This is the edited/added code I'm using. Is there anyone else trying to do the same, with some insight, or interested in working through this with me?

Code: Select all

// #define ROUTER_DEVICE  //uncomment for normal router linked mesh
#define ROOT_DEVICE         //uncomment for root device
// #define NODE_DEVICE     //uncomment for non-root devices

void root_task(void)
{
    ESP_LOGI(MESH_TAG, "ROOT TASK EVENT");

    // int recv_count = 0;
    esp_err_t err;

    mesh_addr_t from;
    mesh_data_t data;
    int flag = 0;

    data.data = rx_buf;
    data.size = RX_SIZE;
    data.proto = MESH_PROTO_JSON;
    data.tos = MESH_TOS_P2P;

    err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0);
    if (err == ESP_OK && data.size) {
        ESP_LOGW(MESH_TAG, "GOT MESSAGE FROM NODE "MACSTR" :%s", MAC2STR(from.addr), data.data);
    }else{
        ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size);
    }
}

void node_task(void)
{

    mesh_data_t data_out;
    uint8_t buffer[20] = "{\"Hello\":\"World\"}";
    data_out.data = buffer;
    data_out.size = sizeof(buffer);
    data_out.proto = MESH_PROTO_JSON;
    data_out.tos = MESH_TOS_P2P;  //with retransmission
    // data_out.tos = MESH_TOS_DEF;  //no retransmission

    ESP_LOGI(MESH_TAG, "NODE TASK EVENT %s", data_out.data);
    esp_mesh_send(NULL, &data_out, 0, NULL, 1);
}


void app_main(void)
{
    ESP_ERROR_CHECK(mesh_light_init());
    ESP_ERROR_CHECK(nvs_flash_init());


    /*  tcpip initialization */
    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));
#ifdef ROOT_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_mode(WIFI_MODE_APSTA));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_ps(WIFI_PS_NONE));
#endif
#ifdef NODE_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_mode(WIFI_MODE_APSTA));
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_ps(WIFI_PS_NONE));
#endif    
    ESP_ERROR_CHECK(esp_wifi_start());


    /*  mesh initialization */
    ESP_ERROR_CHECK(esp_mesh_init());
    ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL));
#ifdef ROOT_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_type(MESH_ROOT));
#endif
#ifdef NODE_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_fix_root(true));
#endif    
    /*  set mesh topology */
    ESP_ERROR_CHECK(esp_mesh_set_topology(CONFIG_MESH_TOPOLOGY));
    /*  set mesh max layer according to the topology */
    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_xon_qsize(128));
#ifdef CONFIG_MESH_ENABLE_PS
    /* Enable mesh PS function */
    ESP_ERROR_CHECK(esp_mesh_enable_ps());
    /* better to increase the associate expired time, if a small duty cycle is set. */
    ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(60));
    /* better to increase the announce interval to avoid too much management traffic, if a small duty cycle is set. */
    ESP_ERROR_CHECK(esp_mesh_set_announce_interval(600, 3300));
#else
    /* Disable mesh PS function */
    ESP_ERROR_CHECK(esp_mesh_disable_ps());
    ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
#endif
    mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
    /* mesh ID */
    memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
    cfg.channel = CONFIG_MESH_CHANNEL;
#ifdef ROUTER_DEVICE
    /* 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));
#endif
    /* 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());


#ifdef ROOT_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_self_organized(true, false));
#endif
#ifdef NODE_DEVICE
    ESP_ERROR_CHECK_WITHOUT_ABORT(esp_mesh_set_self_organized(true, false));
#endif    


#ifdef CONFIG_MESH_ENABLE_PS
    /* set the device active duty cycle. (default:12, MESH_PS_DEVICE_DUTY_REQUEST) */
    ESP_ERROR_CHECK(esp_mesh_set_active_duty_cycle(CONFIG_MESH_PS_DEV_DUTY, CONFIG_MESH_PS_DEV_DUTY_TYPE));
    /* set the network active duty cycle. (default:12, -1, MESH_PS_NETWORK_DUTY_APPLIED_ENTIRE) */
    ESP_ERROR_CHECK(esp_mesh_set_network_duty_cycle(CONFIG_MESH_PS_NWK_DUTY, CONFIG_MESH_PS_NWK_DUTY_DURATION, CONFIG_MESH_PS_NWK_DUTY_RULE));
#endif
    ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d, %s<%d>%s, ps:%d\n",  esp_get_minimum_free_heap_size(),
             esp_mesh_is_root_fixed() ? "root fixed" : "root not fixed",
             esp_mesh_get_topology(), esp_mesh_get_topology() ? "(chain)":"(tree)", esp_mesh_is_ps_enabled());


#ifdef ROOT_DEVICE
        // mesh_status();
        // root_loop();
        while(1) {
            vTaskDelay(100 / portTICK_RATE_MS);
            root_task();
        }
#endif
#ifdef NODE_DEVICE
        // mesh_status();
        // node_loop();
        while(1) {
            vTaskDelay(1000 / portTICK_RATE_MS);
            node_task();
        }
#endif

}

scottc385
Posts: 1
Joined: Wed Nov 30, 2022 10:58 am

Re: ESP-MESH without a router

Postby scottc385 » Wed Nov 30, 2022 1:03 pm

Can anyone provide me with a working example of mesh WITHOUT a router? I would be happy to pay for a few hours of consulting time.
scottc385 at gmail

daniweb
Posts: 6
Joined: Fri Feb 16, 2024 9:12 am

Re: ESP-MESH without a router

Postby daniweb » Fri Feb 16, 2024 9:15 am

Did you manage it, can you share?
Tahnks in advance

Who is online

Users browsing this forum: twompark and 102 guests