7 #include "CrcIButton.h"
8 #include "EepromBase.h"
26 EepromBase::counter +=
size();
56 EEPROM.put (m_eem, m_data);
57 EEPROM.write (m_eem +
sizeof (T), m_crc.value ());
58 #if defined(ESP32) || defined(ESP8266)
59 return EEPROM.commit();
72 bool load (
const T &defaultData = T()) {
74 EEPROM.get (m_eem, m_data);
75 uint8_t crc = EEPROM.read (m_eem +
sizeof (T));
78 if (m_crc.value () != crc) {
90 inline uint16_t
size()
const {
91 return sizeof (T) +
sizeof (m_crc);
122 operator const T &()
const {
165 return m_data == rhs.m_data;
172 return ! (*
this == rhs);
179 m_crc.update (m_data);
iButton CRC template class
EEPROM memory storage management class.
CRC-controlled EEPROM memory storage template class.
EepromSecureData()
Construct a new Eeprom Secure Data object.
const T * operator&() const
Overloaded cast operator to const T.
T & operator=(const T &t)
Overloaded assignment operator from T.
const T & data() const
Get the data object as const.
uint16_t size() const
Get the size of the object with CRC.
bool load(const T &defaultData=T())
Load data from EEPROM memory with CRC check.
~EepromSecureData()
Destroy the Eeprom Secure Data object.
EepromSecureData(const T &data)
Construct a new Eeprom Secure Data object with initial data.
bool save()
Save data to EEPROM memory with CRC.
bool operator==(const EepromSecureData &rhs) const
Overloaded equality operator.
T * operator&()
Overloaded cast operator to T *.
bool operator!=(const EepromSecureData &rhs) const
Overloaded not-equality operator.
T & data()
Get the data object.