Documentation

This commit is contained in:
2025-01-04 20:00:02 -05:00
parent caa8a434c5
commit 1dc1e3a48f

View File

@@ -55,6 +55,22 @@ ESP-NOW is used to communicate data between Controller and Receiver.
Since ESP-NOW uses wireless module, Wi-Fi needs to be initialized before configuring ESP-NOW. Since ESP-NOW uses wireless module, Wi-Fi needs to be initialized before configuring ESP-NOW.
```C
/* WiFi is required to run ESPNOW */
static void wifi_init(void)
{
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); // Keep configurations in RAM
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA)); // Do not change WiFi device mode
ESP_ERROR_CHECK( esp_wifi_start());
ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE)); // Both sender & receiver must be on the same channel
}
```
The main function contains lines of code that initialize wireless, ESP-NOW, specify configuration variables, and start recurring task.
```C ```C
#include "esp_wifi.h" #include "esp_wifi.h"