Hi,
When using wifi mesh i been having som issues with "esp_mesh_recv". After running for a hour or two I start to receive the same packets first twice and then more then twice. Right now im running 1 root + 9 child devices. After rebooting child that has the issue it goes away(But comes back later). From the fixed root node im sending a package to each device with 1 second delay between packages.
Here is the code for setting up child device:
void mesh_init(){
is_running = true;
// 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_CHAIN));
/* 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_disable_ps());
ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(60));
ESP_ERROR_CHECK(esp_mesh_allow_root_conflicts(false));
/* Set mesh device type */
esp_mesh_set_type(MESH_IDLE);
/* Set fixed root in the mesh network */
esp_mesh_fix_root(1);
/* Create default mesh config */
mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT();
/* mesh ID */
memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6);
/* router config */
/* NO ROUTER CONFIG */
cfg.channel = 0;
/* mesh softAP config */
ESP_ERROR_CHECK(esp_mesh_set_ap_authmode(CONFIG_MESH_AP_AUTHMODE));
cfg.mesh_ap.max_connection = CONFIG_MESH_AP_CONNECTIONS;
const char * pswd = "mypswd1234";
memcpy((uint8_t *) &cfg.mesh_ap.password, pswd, strlen(pswd));
ESP_ERROR_CHECK(esp_mesh_set_config(&cfg));
//esp_mesh_send_block_time(2000);
ESP_ERROR_CHECK(esp_mesh_set_xon_qsize(128));
/* mesh start */
ESP_ERROR_CHECK(esp_mesh_start());
if(mesh_rx_task_handle != NULL)
esp_restart();
mesh_rx_task_handle = xTaskCreateStatic(
mesh_rx_task,
"MESH_RX",
STACK_SIZE,
NULL,
5/*configMAX_PRIORITIES - 1*/,
task_stack,
&rx_task_buffer
);
}
And here is the task that receives
static void mesh_rx_task(void *arg)
{
esp_err_t err;
int flag = 0;
ADOPTED_DEVICE_t device;
mesh_data_t data;
data.data = (uint8_t*)&device;
mesh_addr_t from;
uint32_t rx_msg_count = 0;
TickType_t last_tick = 0;
uint8_t zero_tick_counter = 0;
uint8_t tick_ok_counter = 0;
while (is_running) {
data.size = sizeof(ADOPTED_DEVICE_t);
err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0); // WAITING HERE 5 MINUTES
if (err != ESP_OK || !data.size) {
ESP_LOGE(MESH_TAG, "%s", esp_err_to_name(err));
ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size);
continue;
}
TickType_t tick_now = xTaskGetTickCount();
uint32_t tick_between_msg = (tick_now - last_tick);
last_tick = tick_now;
ESP_LOGI(MESH_TAG, "MSG_COUNT_LOCAL: %lu\tMSG_COUNT_REMOTE: %lu\tTicks between: %lu", ++rx_msg_count,
device.msg_count, tick_between_msg);
if(tick_between_msg < 10){
tick_ok_counter = 0;
if(++zero_tick_counter > 10){
eeprom_mesh_tick_bug();
reboot_module = 0x55;
}
}else
tick_ok_counter++;
if(tick_ok_counter > 20){
tick_ok_counter = 0;
zero_tick_counter = 0;
}
if(data.size == sizeof(ADOPTED_DEVICE_t)){
ClearError(); // This function will only clear a led thats connected
led_blink_once();
}
}
ESP_LOGE(MESH_TAG, "RX TASK SHUTDOWN");
vTaskDelete(NULL);
}
esp_mesh_recv duplicated package
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 25 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.