Creating a mesh network without a router connected
Posted: Mon Jan 29, 2024 6:18 am
Hey!
I'm new to IDF and am transitioning over from the Arduino IDE. This is my first larger project here.
I'm trying to create a routerless mesh network where every sensor on the network will dump all messages published on the network to serial, where a python program will pick them up and parse them. Right now, I'm getting a few problems with this snipping in just initializing the mesh configuration.
from this, I get problems actually initializing the network, or if I swap the lines
I then get that the router configuration was not set correctly. Should I be using esp_mesh_set_self_organized? I was looking at this post
https://esp32.com/viewtopic.php?t=15022
And not getting very far. I'd genuinely appreciate a lecture or two on how this is done
Thanks!
I'm new to IDF and am transitioning over from the Arduino IDE. This is my first larger project here.
I'm trying to create a routerless mesh network where every sensor on the network will dump all messages published on the network to serial, where a python program will pick them up and parse them. Right now, I'm getting a few problems with this snipping in just initializing the mesh configuration.
Code: Select all
void initialize_mesh_network(){
// Initialize ESP-IDF components
ESP_ERROR_CHECK(esp_event_loop_create_default());
Serial.println("Event loop started");
// Wi-Fi configuration
wifi_init_config_t wifi_cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&wifi_cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
ESP_ERROR_CHECK(esp_wifi_start());
Serial.println("WiFi initialized");
// Mesh network configuration
mesh_cfg_t mesh_cfg = MESH_INIT_CONFIG_DEFAULT();
mesh_cfg.channel = 1;
memcpy((uint8_t *)&mesh_cfg.mesh_id, "BungleNet", strlen("BungleNet"));
mesh_cfg.mesh_ap.max_connection = 8; // Example max connections
memcpy((uint8_t *)&mesh_cfg.mesh_ap.password, "bungus", strlen("bungus"));
// // Explicitly indicate no router connection for a routerless setup
// mesh_cfg.router.ssid_len = 0;
// memset(mesh_cfg.router.ssid, 0, sizeof(mesh_cfg.router.ssid));
// memset(mesh_cfg.router.bssid, 0, sizeof(mesh_cfg.router.bssid));
ESP_ERROR_CHECK(esp_mesh_init());
ESP_ERROR_CHECK(esp_mesh_set_config(&mesh_cfg));
Serial.println("Mesh network configured");
ESP_ERROR_CHECK(esp_mesh_set_max_layer(25));
ESP_ERROR_CHECK(esp_mesh_start());
}
from this, I get problems actually initializing the network, or if I swap the lines
Code: Select all
ESP_ERROR_CHECK(esp_mesh_init());
ESP_ERROR_CHECK(esp_mesh_set_config(&mesh_cfg));
https://esp32.com/viewtopic.php?t=15022
And not getting very far. I'd genuinely appreciate a lecture or two on how this is done
Thanks!