supla-device
Loading...
Searching...
No Matches
littlefs_config.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program 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 program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_STORAGE_LITTLEFS_CONFIG_H_
20#define SRC_SUPLA_STORAGE_LITTLEFS_CONFIG_H_
21
22#ifndef SUPLA_EXCLUDE_LITTLEFS_CONFIG
23
24#define SUPLA_LITTLEFS_CONFIG_BUF_SIZE 1024
25
26#include "key_value.h"
27
28namespace Supla {
29
30class LittleFsConfig : public KeyValue {
31 public:
32 explicit LittleFsConfig(int configMaxSize = SUPLA_LITTLEFS_CONFIG_BUF_SIZE);
33 virtual ~LittleFsConfig();
34 bool init() override;
35 void commit() override;
36 void removeAll() override;
37
38 bool getCustomCA(char* result, int maxSize) override;
39 int getCustomCASize() override;
40 bool setCustomCA(const char* customCA) override;
41
42 // override blob storage to use separate file for each value
43 bool setBlob(const char* key, const char* value, size_t blobSize) override;
44 bool getBlob(const char* key, char* value, size_t blobSize) override;
45
46 protected:
47 int getBlobSize(const char* key) override;
48 bool initLittleFs();
49 int configMaxSize = SUPLA_LITTLEFS_CONFIG_BUF_SIZE;
50};
51}; // namespace Supla
52
53#endif // SUPLA_EXCLUDE_LITTLEFS_CONFIG
54#endif // SRC_SUPLA_STORAGE_LITTLEFS_CONFIG_H_
Definition key_value.h:32