From 3bd8d08ce68797621d621e3a26d590ab1e11b39e Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Sun, 9 Jun 2024 09:38:43 +0300 Subject: [PATCH] Merge from main branch --- components/zh_espnow/version.txt | 2 +- components/zh_espnow/zh_espnow.c | 13 ++++++++++++- main/zh_gateway.h | 2 +- version.txt | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/zh_espnow/version.txt b/components/zh_espnow/version.txt index e6d5cb8..e4c0d46 100644 --- a/components/zh_espnow/version.txt +++ b/components/zh_espnow/version.txt @@ -1 +1 @@ -1.0.2 \ No newline at end of file +1.0.3 \ No newline at end of file diff --git a/components/zh_espnow/zh_espnow.c b/components/zh_espnow/zh_espnow.c index 0220c0b..cab7eba 100644 --- a/components/zh_espnow/zh_espnow.c +++ b/components/zh_espnow/zh_espnow.c @@ -62,11 +62,22 @@ esp_err_t zh_espnow_init(const zh_espnow_init_config_t *config) ESP_LOGE(TAG, "ESP-NOW initialization fail. WiFi channel."); return ESP_ERR_INVALID_ARG; } - if (esp_wifi_set_channel(_init_config.wifi_channel, WIFI_SECOND_CHAN_NONE) != ESP_OK) + esp_err_t err = esp_wifi_set_channel(_init_config.wifi_channel, WIFI_SECOND_CHAN_NONE); + if (err == ESP_ERR_WIFI_NOT_INIT || err == ESP_ERR_WIFI_NOT_STARTED) { ESP_LOGE(TAG, "ESP-NOW initialization fail. WiFi not initialized."); return ESP_ERR_WIFI_NOT_INIT; } + else if (err == ESP_FAIL) + { + uint8_t prim = 0; + wifi_second_chan_t sec = 0; + esp_wifi_get_channel(&prim, &sec); + if (prim != _init_config.wifi_channel) + { + ESP_LOGW(TAG, "ESP-NOW initialization warning. The device is connected to the router. Channel %d will be used for ESP-NOW.", prim); + } + } _event_group_handle = xEventGroupCreate(); _queue_handle = xQueueCreate(_init_config.queue_size, sizeof(_queue_t)); if (esp_now_init() != ESP_OK || esp_now_register_send_cb(_send_cb) != ESP_OK || esp_now_register_recv_cb(_recv_cb) != ESP_OK) diff --git a/main/zh_gateway.h b/main/zh_gateway.h index 4285a82..8bd1e7a 100755 --- a/main/zh_gateway.h +++ b/main/zh_gateway.h @@ -50,7 +50,7 @@ #define MAC_STR "%02X-%02X-%02X-%02X-%02X-%02X" #define ZH_MESSAGE_TASK_PRIORITY 2 // Prioritize the task of sending messages to the MQTT. -#define ZH_MESSAGE_STACK_SIZE 2048 // The stack size of the task of sending messages to the MQTT. +#define ZH_MESSAGE_STACK_SIZE 3072 // The stack size of the task of sending messages to the MQTT. #define ZH_SNTP_TASK_PRIORITY 2 // Prioritize the task to get the current time. #define ZH_SNTP_STACK_SIZE 2048 // The stack size of the task to get the current time. #define ZH_OTA_TASK_PRIORITY 3 // Prioritize the task of OTA updates. diff --git a/version.txt b/version.txt index afaf360..7f20734 100755 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1 \ No newline at end of file