Update main.cpp

This commit is contained in:
Florian Hoss 2022-07-20 16:55:52 +02:00
parent b2f13e3619
commit 1b7c452fee

View file

@ -2,6 +2,16 @@
#include "WiFi.h" #include "WiFi.h"
#include "theSecrets.h" #include "theSecrets.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include <lwip/netdb.h>
void connectToWifi() void connectToWifi()
{ {
WiFi.begin(ssid, psk); WiFi.begin(ssid, psk);
@ -34,13 +44,29 @@ void handle_wifi_events(WiFiEvent_t event, WiFiEventInfo_t info)
} }
} }
void setup() void setup_wifi()
{ {
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.onEvent(handle_wifi_events, ARDUINO_EVENT_MAX); WiFi.onEvent(handle_wifi_events, ARDUINO_EVENT_MAX);
connectToWifi(); connectToWifi();
} }
static void intercept_task(void *pvParameters)
{
Serial.println("Intercept");
vTaskDelete(NULL);
}
void setup()
{
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
Serial.begin(115200);
setup_wifi();
xTaskCreate(intercept_task, "intercept", 4096, (void *)AF_INET, 5, NULL);
}
void loop() void loop()
{ {
} }