fork/GramFirmware

git clone https://git.julia.blue/fork/GramFirmware

CarVacrebase to configurator818d962

gram
1.3 KiB49 linesraw
1/*
2 * This file is part of HayBox
3 * Copyright (C) 2024 Jonathan Haylett
4 *
5 * HayBox is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _CORE_PERSISTENCE_HPP
19#define _CORE_PERSISTENCE_HPP
20
21#include <LittleFS.h>
22#include <config.pb.h>
23
24class Persistence {
25  public:
26    typedef struct _ConfigHeader {
27        size_t config_size = 0;
28        uint32_t config_crc = 0;
29    } ConfigHeader;
30
31    Persistence();
32    ~Persistence();
33
34    bool SaveConfig(Config &config);
35    bool LoadConfig(Config &config);
36    bool CheckSavedConfig();
37    size_t LoadConfigRaw(Print &out, bool validate = true);
38
39    static constexpr size_t config_offset = sizeof(ConfigHeader);
40
41  private:
42    static constexpr char config_filename[] = "config.bin";
43
44    bool CheckSavedConfig(File &config_file);
45};
46
47extern Persistence persistence;
48
49#endif