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
2022-05-02 20:49:05 +02:00

47 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)
// Storage per firewall rule is 42 Byte
// Space for 15 Rules is 630 Byte
// plus 10 byte for settings
const uint16_t eeprom_size = 640;
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
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 *);
public:
Storage();
~Storage();
};
}
#endif