fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
818d962
gram
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 { 25public : 26typedef struct _ConfigHeader { 27size_t config_size = 0 ; 28uint32_t config_crc = 0 ; 29 }ConfigHeader ; 30 31Persistence (); 32 ~Persistence (); 33 34bool SaveConfig (Config & config ); 35bool LoadConfig (Config & config ); 36bool CheckSavedConfig (); 37size_t LoadConfigRaw (& out ,bool validate = true); 38 39static constexpr size_t config_offset = sizeof (ConfigHeader ); 40 41private : 42static constexpr char config_filename []= "config.bin" ; 43 44bool CheckSavedConfig (File & config_file ); 45}; 46 47extern Persistence persistence ; 48 49#endif