supla-device
Loading...
Searching...
No Matches
simple_state.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_STORAGE_SIMPLE_STATE_H_
5#define SRC_SUPLA_STORAGE_SIMPLE_STATE_H_
6
7#include "state_storage_interface.h"
8
9namespace Supla {
10
11struct SectionPreamble;
12
14 public:
15 explicit SimpleState(Storage *storage, uint32_t offset);
17
18 void initSectionPreamble(SectionPreamble *preamble) override;
19
20 bool writeSectionPreamble() override;
21 bool initFromStorage() override;
22 void deleteAll() override;
23 bool prepareSaveState() override;
24 bool prepareSizeCheck() override;
25 bool prepareLoadState() override;
26 bool readState(unsigned char *, int) override;
27 bool writeState(const unsigned char *, int) override;
28 bool finalizeSaveState() override;
29 bool finalizeSizeCheck() override;
30 bool finalizeLoadState() override;
31
32 private:
33 uint32_t sectionOffset = 0;
34 uint32_t elementStateOffset = 0;
35 uint32_t elementStateSize = 0;
36 uint32_t stateSectionNewSize = 0;
37 uint32_t currentStateOffset = 0;
38 uint16_t storedCrc = 0; // CRC value stored in section preamble
39 uint16_t crc = 0; // value calculated on each save/read
40 bool elementStateCrcCValid = false;
41 bool dryRun = false;
42};
43
44} // namespace Supla
45#endif // SRC_SUPLA_STORAGE_SIMPLE_STATE_H_
Definition simple_state.h:13
Definition state_storage_interface.h:14
Definition storage.h:23
Definition storage.h:147