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

39 lines
669 B
C++
Raw Normal View History

2022-04-10 20:46:54 +02:00
#include "theSecrets.h"
2022-04-24 18:28:41 +02:00
#include "theCerts.h"
2022-04-23 23:36:44 +02:00
#ifdef ESP32
2022-04-24 12:48:01 +02:00
#include "WiFi.h"
2022-04-23 23:36:44 +02:00
#elif defined(ESP8266)
2022-04-24 12:48:01 +02:00
#include "ESP8266WiFi.h"
2022-04-23 23:36:44 +02:00
#endif
2022-04-24 00:13:20 +02:00
#include "Firewall.hpp"
2022-04-20 07:58:06 +02:00
2022-04-24 00:13:20 +02:00
fw::Firewall *firewall;
2022-04-10 20:46:54 +02:00
void setup_wifi()
{
2022-04-23 23:36:44 +02:00
Serial.begin(115200);
2022-04-10 20:46:54 +02:00
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, psk);
2022-04-23 23:36:44 +02:00
Serial.printf("Attempting to connect to WPA SSID: %s\n", ssid);
2022-04-21 16:10:31 +02:00
while (WiFi.status() != WL_CONNECTED)
2022-04-10 20:46:54 +02:00
{
2022-04-23 23:36:44 +02:00
Serial.print('.');
delay(1000);
2022-04-10 20:46:54 +02:00
}
2022-04-23 23:36:44 +02:00
Serial.println();
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
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-24 18:28:41 +02:00
firewall = new fw::Firewall(cert, key, username, password, 8080);
2022-04-10 14:38:03 +02:00
}
void loop()
{
2022-04-24 00:13:20 +02:00
firewall->handle_api_client();
2022-04-10 14:38:03 +02:00
}