ESP-MESH without a router
Re: ESP-MESH without a router
I found that an approach is to use the MESH-LITE
Re: ESP-MESH without a router
Hellow, how you manage to set a mesh without router in automode with this? i did this an i get:Snedig wrote: ↑Sat Apr 04, 2020 3:31 pmHi,
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):This returns " mesh: [MANUAL]designated as root and router is not set".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));
My mesh_send commands look like this:This all works perfectly fine when a router is connected, but not at all when I do not have a router connected.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); }
I would be thankful for any tips as I'm banging my head against the wall at the moment..
Code: Select all
I (941) mesh: [CONFIG]invalid router settings, ssid_len:0, ssid:, bssid:00:00:00:00:00:00
ESP_ERROR_CHECK failed: esp_err_t 0x4008 (ESP_ERR_MESH_ARGUMENT) at 0x42009fdc
file: "./main/mesh_main.c" line 469
func: app_main
expression: esp_mesh_set_config(&cfg)
-
- Posts: 4
- Joined: Fri Aug 16, 2024 9:01 am
Re: ESP-MESH without a router
Hello there, here is the answer... Yes it is possible to setup esp-wifi-mesh without a router, but Self-organized network, wont work for ROOT node, ie the mesh network cant set root because there is no router to connect to.. so we have to set root esp and node esp manually, here is the code snippet for root esp
node esp
and also mesh event handler when MESH_EVENT_PARENT_CONNECTED didnt get trigger on root
- 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));
- // ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR));
- // ESP_ERROR_CHECK(esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_LR));
- ESP_ERROR_CHECK(esp_wifi_start());
- ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(80)); // Set TX power to 20.5 dBm (maximum)
- /* gets this esp mac address, to prevent sending message to itself */
- esp_wifi_get_mac(WIFI_IF_STA, my_address.addr);
- /* 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));
- /* set mesh topology */
- ESP_ERROR_CHECK(esp_mesh_set_topology(MESH_TOPO_TREE));
- /* set mesh max layer according to the topology */
- ESP_ERROR_CHECK(esp_mesh_set_max_layer(6));
- ESP_ERROR_CHECK(esp_mesh_set_vote_percentage(1));
- ESP_ERROR_CHECK(esp_mesh_set_xon_qsize(128));
- /* Disable mesh PS function */
- ESP_ERROR_CHECK(esp_mesh_disable_ps());
- ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
- /* set this esp as root node*/
- ESP_ERROR_CHECK(esp_mesh_set_type(MESH_ROOT));
- mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
- /* mesh ID */
- memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
- /* router */
- cfg.channel = 0;
- /* mesh softAP */
- ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(WIFI_AUTH_WPA_WPA2_PSK));
- cfg.mesh_ap.max_connection = 6;
- cfg.mesh_ap.nonmesh_max_connection = 0;
- 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_LOGE("MESH", "mesh starts successfully, heap:%" PRId32 ", %s<%d>%s, ps:%d", 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());
- #if (ENABLE_TCP_DISABLE_SERIAL == 1)
- server.begin();
- server.setNoDelay(true);
- #else
- serialFlushRx();
- #endif
- esp_mesh_comm_p2p_start();
- 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));
- /* Set the maximum Wi-Fi TX power */
- //ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(80)); // Set TX power to 20.5 dBm (maximum)
- 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());
- ESP_ERROR_CHECK(esp_wifi_set_max_tx_power(80)); // Set TX power to 20.5 dBm (maximum)
- /* 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));
- /* set mesh topology */
- ESP_ERROR_CHECK(esp_mesh_set_topology(MESH_TOPO_TREE));
- //ESP_ERROR_CHECK(esp_mesh_set_topology(MESH_TOPO_CHAIN));
- /* set mesh max layer according to the topology */
- ESP_ERROR_CHECK(esp_mesh_set_max_layer(6));
- ESP_ERROR_CHECK(esp_mesh_set_vote_percentage(1));
- ESP_ERROR_CHECK(esp_mesh_set_xon_qsize(128));
- /* Disable mesh PS function */
- ESP_ERROR_CHECK(esp_mesh_disable_ps());
- ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
- /* set this esp as node*/
- ESP_ERROR_CHECK(esp_mesh_set_type(MESH_IDLE));
- mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
- /* mesh ID */
- memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
- /* router */
- cfg.channel = 0;
- /* informs this esp that root is already set */
- ESP_ERROR_CHECK(esp_mesh_fix_root(true));
- /* mesh softAP */
- ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(WIFI_AUTH_WPA_WPA2_PSK));
- cfg.mesh_ap.max_connection = 6;
- cfg.mesh_ap.nonmesh_max_connection = 0;
- 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_LOGE("MESH", "mesh starts successfully, heap:%" PRId32 ", %s<%d>%s, ps:%d", 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());
- serialFlushRx();
Who is online
Users browsing this forum: Baidu [Spider], Baldhead and 146 guests