This repository has been archived on 2024-10-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
esp-firewall/ESPFirewall/lib/Firewall/src/Storage.hpp

48 lines
1.1 KiB
C++

#ifndef ESP32_STORAGE_HPP
#define ESP32_STORAGE_HPP
#ifdef ESP32
#include "Preferences.h"
#include "SPIFFS.h"
#elif defined(ESP8266)
#include "EEPROM.h"
#endif
#include "Utils.hpp"
namespace fw
{
class Storage
{
private:
#ifdef ESP32
Preferences memory;
#elif defined(ESP8266)
const uint16_t eeprom_size = 1000;
const uint8_t security_number = 93;
const uint16_t eeprom_settings_head = 0;
const uint16_t eeprom_amout_of_rules_head = eeprom_settings_head + 1;
const uint16_t eeprom_rules_head = 10;
#endif
ok_t mount_spiffs();
void setup_eeprom();
uint16_t eeprom_rule_position(uint8_t);
protected:
uint8_t retrieve_settings_value(const char *);
void store_settings_value(const char *, const uint8_t);
firewall_rule_t *retrieve_firewall_rule(const uint8_t);
void store_all_firewall_rules(firewall_rule_t *);
void store_firewall_rule(firewall_rule_t *);
// httpsserver::SSLCert *retrieve_certificate();
// void store_certificate(httpsserver::SSLCert *);
public:
Storage();
~Storage();
};
}
#endif