This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
esp-firewall/ESPFirewall/src/main.cpp

31 lines
640 B
C++
Raw Normal View History

2022-04-10 20:46:54 +02:00
#include "theSecrets.h"
2022-04-18 22:56:30 +02:00
#include "WiFi.h"
#include "esp32API.hpp"
2022-04-20 07:58:06 +02:00
firewall::API *firewall_api;
2022-04-10 20:46:54 +02:00
void setup_wifi()
{
uint8_t max_retries = 5;
2022-04-18 13:11:02 +02:00
uint8_t retries = 1;
2022-04-21 15:16:54 +02:00
log_d("Attempting to connect to WPA SSID: %s", ssid);
2022-04-10 20:46:54 +02:00
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, psk);
2022-04-18 13:11:02 +02:00
while (WiFi.status() != WL_CONNECTED && retries <= max_retries)
2022-04-10 20:46:54 +02:00
{
delay(2000);
log_d("Connecting... (%i/%i)", retries++, max_retries);
2022-04-10 20:46:54 +02:00
}
2022-04-21 15:16:54 +02:00
log_i("IP Address: %s", WiFi.localIP().toString().c_str());
2022-04-10 20:46:54 +02:00
}
2022-04-10 14:38:03 +02:00
void setup()
{
2022-04-10 15:55:42 +02:00
setup_wifi();
2022-04-21 15:16:54 +02:00
firewall_api = new firewall::API(api_username, api_password, 8080);
2022-04-10 14:38:03 +02:00
}
void loop()
{
firewall_api->handle_clients();
2022-04-10 14:38:03 +02:00
}