mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 12:50:53 +00:00
Documentation
This commit is contained in:
@@ -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"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user