36 lines
714 B
C++
36 lines
714 B
C++
#include "app_networking.hpp"
|
|
|
|
#include "esp_event.h"
|
|
#include "esp_netif.h"
|
|
#include "esp_wifi.h"
|
|
#include "esp_now.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
}
|
|
|
|
namespace App
|
|
{
|
|
|
|
void setupWifi()
|
|
{
|
|
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_STA));
|
|
ESP_ERROR_CHECK(esp_wifi_start());
|
|
ESP_ERROR_CHECK(esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE));
|
|
}
|
|
|
|
void setupEspNow()
|
|
{
|
|
ESP_ERROR_CHECK(esp_now_init());
|
|
// ESP_ERROR_CHECK(esp_now_set_pmk(nullptr));
|
|
}
|
|
|
|
} |