56#pragma region Members stored on Flash
121#pragma region singleton
149#pragma region Flash Access Functions
155 Serial.println(
"Loading lockState");
158 char buf[numberOfBytes];
163 File file = SPIFFS.open(
"/lockSt.bin",
"r");
165 Serial.println(
"Loading lockState failed");
170 readOk = file.readBytes(buf, numberOfBytes) == numberOfBytes;
191 src +=
sizeof(time_t);
193 memcpy(&
endDate, src,
sizeof(time_t));
194 src +=
sizeof(time_t);
197 src +=
sizeof(uint32_t);
206 Serial.println(
"Saving lockState");
208 File file = SPIFFS.open(
"/lockSt.bin",
"w");
216 file.write((uint8_t*)&
startDate,
sizeof(time_t));
217 file.write((uint8_t*)&
endDate,
sizeof(time_t));
223 Serial.println(
"Saved lockState");
227#pragma region getter / setter
251#pragma region displayTimePassed
274#pragma region displayTimeLeft
297#pragma region startDate
320#pragma region endDate
343#pragma region numberOfFailedSessions
366#pragma region temperatureString
389#pragma region cachedEndDate
411#pragma region cleaningEndDate
433#pragma region lastUpdateTime
Singleton class managing the current lock state. The class also automatically saves the lock state to...
Definition: LockState.h:23
static void setStartDate(const time_t &startDate)
Set the Start Date.
Definition: LockState.h:311
static const time_t & getEndDate()
Get the End Date.
Definition: LockState.h:325
uint8_t enumBaseType
Enum basetype used for saving to the flash.
Definition: LockState.h:29
DisplayTimeLeft
States for the selection how the time left should be displayed.
Definition: LockState.h:47
Mode
Current mode of the safe.
Definition: LockState.h:35
void loadData()
Loads the current state of the object to the flash.
Definition: LockState.h:154
static const Mode & getMode()
Get the mode.
Definition: LockState.h:233
static const uint32_t & getNumberOfFailedSessions()
Get the number of failed sessions.
Definition: LockState.h:348
static void setLastUpdateTime(const time_t &lastUpdateTime)
Set the time of the last update over the emlalock api.
Definition: LockState.h:447
time_t cachedEndDate
chache for the end date of the session which is currently configured. This value won't be saved to th...
Definition: LockState.h:106
static const DisplayTimePassed & getDisplayTimePassed()
Get how the time passed should be displayed.
Definition: LockState.h:256
static void setCachedEndDate(const time_t &cachedEndDate)
Set the Cached End Date.
Definition: LockState.h:403
void saveData()
Saves the current state of the object to the flash.
Definition: LockState.h:205
static void setEndDate(const time_t &endDate)
Set the End Date.
Definition: LockState.h:334
static void setTemperatureString(const String &temperatureString)
Set the temperature string.
Definition: LockState.h:380
static const time_t & getCachedEndDate()
Get the Cached End Date.
Definition: LockState.h:394
String temperatureString
temperature string
Definition: LockState.h:91
static const String & getTemperatureString()
Get the temperature string.
Definition: LockState.h:371
time_t startDate
start date of the current session
Definition: LockState.h:79
uint32_t numberOfFailedSessions
The number of failed session.
Definition: LockState.h:97
std::mutex mtx
mutex used to synchronize the data access
Definition: LockState.h:54
static const time_t & getLastUpdateTime()
Get the time of the last update over the emlalock api.
Definition: LockState.h:438
static void setNumberOfFailedSessions(const uint32_t &numberOfFailedSessions)
Set the number of failed sessions.
Definition: LockState.h:357
static void setMode(const Mode &mode)
Set the mode.
Definition: LockState.h:242
static const time_t & getCleaningEndDate()
Get the End Date of the current cleaning opening (or 0)
Definition: LockState.h:416
DisplayTimePassed displayTimePassed
how the passed time should be displayed
Definition: LockState.h:67
static LockState & getSingleton()
Get the singleton instance.
Definition: LockState.h:143
static void setDisplayTimePassed(const DisplayTimePassed &displayTimePassed)
Set how the time passed should be displayed.
Definition: LockState.h:265
time_t endDate
end date of the current session
Definition: LockState.h:85
DisplayTimeLeft displayTimeLeft
how the passed time should be displayed
Definition: LockState.h:73
time_t cleaningEndDate
end date of the current cleaning opening or 0 if not opened for cleaning. This value won't be saved t...
Definition: LockState.h:113
static void setDisplayTimeLeft(const DisplayTimeLeft &displayTimeLeft)
Set how the time left should be displayed.
Definition: LockState.h:288
static void setCleaningEndDate(const time_t &cleaningEndDate)
Set the End Date of the current cleaning opening.
Definition: LockState.h:425
time_t lastUpdateTime
time of the last update
Definition: LockState.h:119
static const time_t & getStartDate()
Get the Start Date.
Definition: LockState.h:302
Mode mode
The mode.
Definition: LockState.h:61
LockState()
Constructs the lock state by trying to reading the state from flash.
Definition: LockState.h:126
static const DisplayTimeLeft & getDisplayTimeLeft()
Get how the time left should be displayed.
Definition: LockState.h:279
DisplayTimePassed
States for the selection how the passed time should be displayed.
Definition: LockState.h:41
static void executeWithoutInterrupts(std::function< void(void)> f)
Execute the passed function without interrupts.
Definition: UsedInterrupts.h:58
Definition: EmlaLockApi.h:21