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/SourceCode/arduino/src/main.cpp

34 lines
681 B
C++
Raw Normal View History

2022-04-18 22:56:30 +02:00
#include "Arduino.h"
2022-04-10 20:46:54 +02:00
#include "theSecrets.h"
2022-04-18 22:56:30 +02:00
#include "WiFi.h"
2022-04-10 20:46:54 +02:00
#include "Firewall.h"
#include "esp32-hal-log.h"
const char *esp_ip_address;
ESPFirewall *firewall;
void setup_wifi()
{
2022-04-18 17:35:52 +02:00
uint8_t max_retries = 10;
2022-04-18 13:11:02 +02:00
uint8_t retries = 1;
2022-04-10 20:46:54 +02:00
log_i("Attempting to connect to WPA SSID: %s", ssid);
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(1000);
2022-04-18 13:11:02 +02:00
log_i("Connecting... (%i/%i)", retries++, max_retries);
2022-04-10 20:46:54 +02:00
}
esp_ip_address = WiFi.localIP().toString().c_str();
log_i("Connected, IP Address: %s", esp_ip_address);
}
2022-04-10 14:38:03 +02:00
void setup()
{
2022-04-10 15:55:42 +02:00
setup_wifi();
2022-04-10 20:46:54 +02:00
firewall = new ESPFirewall;
2022-04-10 14:38:03 +02:00
}
void loop()
{
}