ESPHome 2026.8.1
Loading...
Searching...
No Matches
preferences.h
Go to the documentation of this file.
1#pragma once
2#ifdef USE_ZEPHYR
3#ifdef CONFIG_SETTINGS
4
6#include <zephyr/settings/settings.h>
7#include <vector>
8
9namespace esphome::zephyr {
10
11class ZephyrPreferences final : public PreferencesMixin<ZephyrPreferences> {
12 public:
14 void open();
16 return this->make_preference(length, type);
17 }
20 bool load_from_key(uint32_t type, uint8_t *data, size_t len);
21 bool sync();
22 bool reset();
23
24 protected:
26 std::vector<ZephyrPreferenceBackend *> backends_;
27
28 static int load_setting(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg);
29 static int export_settings(int (*cb)(const char *name, const void *value, size_t val_len));
30};
31
33
34} // namespace esphome::zephyr
35
36DECLARE_PREFERENCE_ALIASES(esphome::zephyr::ZephyrPreferences)
37
38#endif // CONFIG_SETTINGS
39#endif // USE_ZEPHYR
CRTP mixin providing type-safe template make_preference<T>() helpers.
bool load_from_key(uint32_t type, uint8_t *data, size_t len)
One-shot read of a stored preference by key, without allocating or registering a backend.
ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)
Definition preferences.h:15
static int load_setting(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg)
std::vector< ZephyrPreferenceBackend * > backends_
Definition preferences.h:26
ZephyrPreferenceBackend * find_backend_(uint32_t type)
static int export_settings(int(*cb)(const char *name, const void *value, size_t val_len))
uint16_t type
const void size_t len
Definition hal.h:64
static void uint32_t
uint16_t length
Definition tt21100.cpp:0