ESPHome 2026.11.0b6
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
23 struct fdb_kvdb *db;
24 struct fdb_blob *blob;
25#ifdef USE_LIBRETINY_RTC_PREFERENCES
26 // storage: rtc lives under its own FlashDB name prefix, so the database can drop every rtc entry
27 // at once after a boot that RTC memory would not have survived
28 bool rtc{false};
29 bool is_rtc() const { return this->rtc; }
30#else
31 static constexpr bool is_rtc() { return false; }
32#endif
33};
34
37
38} // namespace esphome::libretiny
39
40namespace esphome {
41using PreferenceBackend = libretiny::LibreTinyPreferenceBackend;
42} // namespace esphome
43
44#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