ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
preference_backend.h
Go to the documentation of this file.
1#pragma once
2#ifdef USE_LIBRETINY
3
5
6#include <cstddef>
7#include <cstdint>
8
9// Forward declare FlashDB types to avoid pulling in flashdb.h
10// NOLINTBEGIN(readability-identifier-naming)
11struct fdb_kvdb;
12struct fdb_blob;
13// NOLINTEND(readability-identifier-naming)
14
15namespace esphome::libretiny {
16
18 public:
19 bool save(const uint8_t *data, size_t len);
20 bool load(uint8_t *data, size_t len);
21 bool sync();
22
24 struct fdb_kvdb *db;
25 struct fdb_blob *blob;
26#ifdef USE_LIBRETINY_RTC_PREFERENCES
27 // storage: rtc lives under its own FlashDB name prefix, so the database can drop every rtc entry
28 // at once after a boot that RTC memory would not have survived
29 bool rtc{false};
30 bool is_rtc() const { return this->rtc; }
31#else
32 static constexpr bool is_rtc() { return false; }
33#endif
34};
35
38
39} // namespace esphome::libretiny
40
41namespace esphome {
42using PreferenceBackend = libretiny::LibreTinyPreferenceBackend;
43} // namespace esphome
44
45#endif // USE_LIBRETINY
bool load(uint8_t *data, size_t len)
bool save(const uint8_t *data, size_t len)
LibreTinyPreferences * get_preferences()
const void size_t len
Definition hal.h:68
esp32::ESP32PreferenceBackend PreferenceBackend
static void uint32_t