config.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "nvs.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #ifdef __cplusplus
  9. }
  10. #endif
  11. #define DECLARE_SET_DEFAULT(t) void config_set_default_## t (const char *key, t value);
  12. #define DECLARE_GET_NUM(t) esp_err_t config_get_## t (const char *key, t * value);
  13. DECLARE_SET_DEFAULT(uint8_t);
  14. DECLARE_SET_DEFAULT(uint16_t);
  15. DECLARE_SET_DEFAULT(uint32_t);
  16. DECLARE_SET_DEFAULT(int8_t);
  17. DECLARE_SET_DEFAULT(int16_t);
  18. DECLARE_SET_DEFAULT(int32_t);
  19. DECLARE_GET_NUM(uint8_t);
  20. DECLARE_GET_NUM(uint16_t);
  21. DECLARE_GET_NUM(uint32_t);
  22. DECLARE_GET_NUM(int8_t);
  23. DECLARE_GET_NUM(int16_t);
  24. DECLARE_GET_NUM(int32_t);
  25. bool config_has_changes();
  26. void config_commit_to_nvs();
  27. void config_start_timer();
  28. void config_init();
  29. void * config_alloc_get_default(nvs_type_t type, const char *key, void * default_value, size_t blob_size);
  30. void config_delete_key(const char *key);
  31. void config_set_default(nvs_type_t type, const char *key, void * default_value, size_t blob_size);
  32. void * config_alloc_get(nvs_type_t nvs_type, const char *key) ;
  33. void * config_alloc_get_str(const char *key, char *lead, char *fallback);
  34. bool wait_for_commit();
  35. char * config_alloc_get_json(bool bFormatted);
  36. esp_err_t config_set_value(nvs_type_t nvs_type, const char *key, void * value);