Update main.cpp
This commit is contained in:
parent
b2f13e3619
commit
1b7c452fee
1 changed files with 27 additions and 1 deletions
|
@ -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()
|
||||||
{
|
{
|
||||||
}
|
}
|
Reference in a new issue