Version 1.0.3
Fixed bug with ESP-NOW channel setting when device is connected to router.
This commit is contained in:
parent
98efc65a52
commit
10a5837c8f
@ -1 +1 @@
|
||||
1.0.2
|
||||
1.0.3
|
13
zh_espnow.c
13
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user