From e25cca86f19b0c21b41448a43b47c8c0586f11c1 Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Tue, 3 May 2022 20:09:04 +0200 Subject: [PATCH] cleanup storage --- ESPFirewall/lib/Firewall/src/Storage.hpp | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/ESPFirewall/lib/Firewall/src/Storage.hpp b/ESPFirewall/lib/Firewall/src/Storage.hpp index d4f853a..1f44da4 100644 --- a/ESPFirewall/lib/Firewall/src/Storage.hpp +++ b/ESPFirewall/lib/Firewall/src/Storage.hpp @@ -3,7 +3,6 @@ #ifdef ESP32 #include "Preferences.h" -#include "SPIFFS.h" #elif defined(ESP8266) #include "EEPROM.h" #endif @@ -14,13 +13,16 @@ namespace fw { class Storage { + public: + Storage(); + ~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 + // 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; @@ -28,19 +30,14 @@ namespace fw const uint16_t eeprom_rules_head = 10; #endif void setup_eeprom(); - uint16_t eeprom_rule_position(uint8_t); + uint16_t eeprom_rule_position(uint8_t key); 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(); + uint8_t retrieve_settings_value(const char *key); + void store_settings_value(const char *key, const uint8_t new_amount); + firewall_rule_t *retrieve_firewall_rule(const uint8_t key); + void store_all_firewall_rules(firewall_rule_t *rule_head); + void store_firewall_rule(firewall_rule_t *rule_ptr); }; }