introduce namespace
This commit is contained in:
parent
73533e5d15
commit
beddd88653
7 changed files with 459 additions and 415 deletions
|
@ -1,11 +1,26 @@
|
|||
#include "esp32Eeprom.hpp"
|
||||
|
||||
esp32Eeprom::esp32Eeprom(const uint16_t eeprom_size)
|
||||
namespace firewall
|
||||
{
|
||||
Storage::Storage(const uint16_t eeprom_size)
|
||||
{
|
||||
this->eeprom_size = eeprom_size;
|
||||
EEPROM.begin(this->eeprom_size);
|
||||
set_amount_of_firewall_rules(EEPROM.read(this->settings_head));
|
||||
log_i("Amount of Rules: %i", get_amount_of_firewall_rules());
|
||||
}
|
||||
|
||||
esp32Eeprom::~esp32Eeprom()
|
||||
Storage::~Storage()
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t Storage::get_amount_of_firewall_rules()
|
||||
{
|
||||
return this->amount_of_rules;
|
||||
}
|
||||
|
||||
void Storage::set_amount_of_firewall_rules(const uint8_t new_amount)
|
||||
{
|
||||
this->amount_of_rules = new_amount;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,30 @@
|
|||
#define ESP32_EEPROM_HPP
|
||||
|
||||
#include "EEPROM.h"
|
||||
#include "FirewallTypes.h"
|
||||
|
||||
class esp32Eeprom
|
||||
namespace firewall
|
||||
{
|
||||
class Storage
|
||||
{
|
||||
private:
|
||||
uint16_t eeprom_size;
|
||||
uint16_t settings_start = 0;
|
||||
uint16_t settings_head = settings_start;
|
||||
uint16_t rules_start = 1000;
|
||||
uint16_t rules_head = rules_start;
|
||||
uint16_t certificate_start = 3000;
|
||||
uint16_t certificate_head = certificate_start;
|
||||
|
||||
protected:
|
||||
uint8_t amount_of_rules;
|
||||
uint8_t get_amount_of_firewall_rules();
|
||||
void set_amount_of_firewall_rules(const uint8_t);
|
||||
|
||||
public:
|
||||
esp32Eeprom(const uint16_t);
|
||||
~esp32Eeprom();
|
||||
Storage(const uint16_t = 4000);
|
||||
~Storage();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "esp32Firewall.hpp"
|
||||
|
||||
namespace firewall
|
||||
{
|
||||
esp32Firewall::esp32Firewall()
|
||||
{
|
||||
this->setup_eeprom();
|
||||
|
@ -206,3 +208,4 @@ bool esp32Firewall::delete_rule_from_firewall(uint8_t key)
|
|||
this->eeprom_write_firewall_rules();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#define eeprom_start_firewall_rules 4
|
||||
|
||||
namespace firewall
|
||||
{
|
||||
class esp32Firewall
|
||||
{
|
||||
private:
|
||||
|
@ -38,5 +40,6 @@ public:
|
|||
esp32Firewall();
|
||||
~esp32Firewall();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "esp32FirewallAPI.hpp"
|
||||
|
||||
namespace firewall
|
||||
{
|
||||
esp32FirewallApi::esp32FirewallApi(const uint16_t port)
|
||||
{
|
||||
this->setup_certificate();
|
||||
|
@ -195,3 +197,4 @@ String esp32FirewallApi::construct_json_firewall()
|
|||
serializeJson(doc, response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
using namespace httpsserver;
|
||||
|
||||
namespace firewall
|
||||
{
|
||||
class esp32FirewallApi : public esp32Firewall
|
||||
{
|
||||
private:
|
||||
|
@ -37,5 +39,6 @@ public:
|
|||
~esp32FirewallApi();
|
||||
void handle_clients();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "theSecrets.h"
|
||||
#include "WiFi.h"
|
||||
|
||||
#include "esp32Firewall.hpp"
|
||||
#include "esp32FirewallAPI.hpp"
|
||||
#include "esp32Eeprom.hpp"
|
||||
|
||||
esp32FirewallApi *firewall_api;
|
||||
firewall::esp32FirewallApi *firewall_api;
|
||||
firewall::Storage *storage;
|
||||
|
||||
void setup_wifi()
|
||||
{
|
||||
|
@ -24,10 +25,11 @@ void setup_wifi()
|
|||
void setup()
|
||||
{
|
||||
setup_wifi();
|
||||
firewall_api = new esp32FirewallApi;
|
||||
// firewall_api = new esp32FirewallApi;
|
||||
storage = new firewall::Storage;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
firewall_api->handle_clients();
|
||||
// firewall_api->handle_clients();
|
||||
}
|
Reference in a new issue