cleanup storage
This commit is contained in:
parent
0768877ea8
commit
e25cca86f1
1 changed files with 11 additions and 14 deletions
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
#include "SPIFFS.h"
|
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#include "EEPROM.h"
|
#include "EEPROM.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,13 +13,16 @@ namespace fw
|
||||||
{
|
{
|
||||||
class Storage
|
class Storage
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
Storage();
|
||||||
|
~Storage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
Preferences memory;
|
Preferences memory;
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
// Storage per firewall rule is 42 Byte
|
// Storage per firewall rule is 42 Byte
|
||||||
// Space for 15 Rules is 630 Byte
|
// Space for 15 Rules is 630 Byte plus 10 byte for settings
|
||||||
// plus 10 byte for settings
|
|
||||||
const uint16_t eeprom_size = 640;
|
const uint16_t eeprom_size = 640;
|
||||||
const uint8_t security_number = 93;
|
const uint8_t security_number = 93;
|
||||||
const uint16_t eeprom_settings_head = 0;
|
const uint16_t eeprom_settings_head = 0;
|
||||||
|
@ -28,19 +30,14 @@ namespace fw
|
||||||
const uint16_t eeprom_rules_head = 10;
|
const uint16_t eeprom_rules_head = 10;
|
||||||
#endif
|
#endif
|
||||||
void setup_eeprom();
|
void setup_eeprom();
|
||||||
uint16_t eeprom_rule_position(uint8_t);
|
uint16_t eeprom_rule_position(uint8_t key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t retrieve_settings_value(const char *);
|
uint8_t retrieve_settings_value(const char *key);
|
||||||
void store_settings_value(const char *, const uint8_t);
|
void store_settings_value(const char *key, const uint8_t new_amount);
|
||||||
|
firewall_rule_t *retrieve_firewall_rule(const uint8_t key);
|
||||||
firewall_rule_t *retrieve_firewall_rule(const uint8_t);
|
void store_all_firewall_rules(firewall_rule_t *rule_head);
|
||||||
void store_all_firewall_rules(firewall_rule_t *);
|
void store_firewall_rule(firewall_rule_t *rule_ptr);
|
||||||
void store_firewall_rule(firewall_rule_t *);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Storage();
|
|
||||||
~Storage();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue