mirror of
				https://github.com/alexandrebobkov/ESP-Nodes.git
				synced 2025-10-31 01:08:14 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			836 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			836 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include "freertos/FreeRTOS.h"
 | |
| #include "esp_wifi.h"
 | |
| #include "esp_now.h"
 | |
| #include "esp_netif.h"
 | |
| #include "esp_mac.h"
 | |
| #include "common.h"
 | |
| 
 | |
| 
 | |
| /* WiFi should start before using 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) );
 | |
|     ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) );
 | |
|     ESP_ERROR_CHECK( esp_wifi_start());
 | |
|     ESP_ERROR_CHECK( esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
 | |
| 
 | |
| #if CONFIG_ESPNOW_ENABLE_LONG_RANGE
 | |
|     ESP_ERROR_CHECK( esp_wifi_set_protocol(ESPNOW_WIFI_IF, WIFI_PROTOCOL_11B|WIFI_PROTOCOL_11G|WIFI_PROTOCOL_11N|WIFI_PROTOCOL_LR) );
 | |
| #endif
 | |
| } |