Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-nvs.h
Go to the documentation of this file.
1
44#ifndef _NVS_MANAGER_H_
45#define _NVS_MANAGER_H_
46
47#include <stdbool.h>
48#include <stdint.h>
49#include <stddef.h>
50
51#include "nvs.h"
52
53//==============================================================================
54// Defines
55//==============================================================================
56
57#define NVS_PART_NAME_MAX_SIZE 16
58#define NVS_KEY_NAME_MAX_SIZE 16
59#define NVS_NAMESPACE_NAME "storage"
61//==============================================================================
62// Function Prototypes
63//==============================================================================
64
65bool initNvs(bool firstTry);
66bool deinitNvs(void);
67bool eraseNvs(void);
68bool readNvs32(const char* key, int32_t* outVal);
69bool writeNvs32(const char* key, int32_t val);
70bool readNamespaceNvs32(const char* namespace, const char* key, int32_t* outVal);
71bool writeNamespaceNvs32(const char* namespace, const char* key, int32_t val);
72bool readNvsBlob(const char* key, void* out_value, size_t* length);
73bool writeNvsBlob(const char* key, const void* value, size_t length);
74bool readNamespaceNvsBlob(const char* namespace, const char* key, void* out_value, size_t* length);
75bool writeNamespaceNvsBlob(const char* namespace, const char* key, const void* value, size_t length);
76bool eraseNvsKey(const char* key);
77bool eraseNamespaceNvsKey(const char* namespace, const char* key);
78bool readNvsStats(nvs_stats_t* outStats);
79bool readAllNvsEntryInfos(nvs_stats_t* outStats, nvs_entry_info_t* outEntryInfos, size_t* numEntryInfos);
80bool readNamespaceNvsEntryInfos(const char* namespace, nvs_stats_t* outStats, nvs_entry_info_t* outEntryInfos,
81 size_t* numEntryInfos);
82bool nvsNamespaceInUse(const char* namespace);
83#endif
bool eraseNamespaceNvsKey(const char *namespace, const char *key)
Delete the value with the given key from NVS.
Definition hdw-nvs.c:477
bool eraseNvsKey(const char *key)
Delete the value with the given key from NVS.
Definition hdw-nvs.c:465
bool readNamespaceNvs32(const char *namespace, const char *key, int32_t *outVal)
Read a 32 bit value from NVS with a given string key.
Definition hdw-nvs.c:158
bool readAllNvsEntryInfos(nvs_stats_t *outStats, nvs_entry_info_t *outEntryInfos, size_t *numEntryInfos)
Read info about each used entry in the default NVS namespace. Typically, this should be called once w...
Definition hdw-nvs.c:577
bool readNvsStats(nvs_stats_t *outStats)
Read info about used memory in NVS.
Definition hdw-nvs.c:546
bool readNamespaceNvsBlob(const char *namespace, const char *key, void *out_value, size_t *length)
Read a blob from NVS with a given string key. Typically, this should be called once with NULL passed ...
Definition hdw-nvs.c:329
bool writeNamespaceNvsBlob(const char *namespace, const char *key, const void *value, size_t length)
Write a blob to NVS with a given string key.
Definition hdw-nvs.c:397
bool writeNvs32(const char *key, int32_t val)
Write a 32 bit value to NVS with a given string key.
Definition hdw-nvs.c:145
bool eraseNvs(void)
Erase and re-initialize the nonvolatile storage.
Definition hdw-nvs.c:93
bool readNvsBlob(const char *key, void *out_value, size_t *length)
Read a blob from NVS with a given string key. Typically, this should be called once with NULL passed ...
Definition hdw-nvs.c:299
bool readNvs32(const char *key, int32_t *outVal)
Read a 32 bit value from NVS with a given string key.
Definition hdw-nvs.c:133
bool deinitNvs(void)
Deinitialize NVS.
Definition hdw-nvs.c:83
bool readNamespaceNvsEntryInfos(const char *namespace, nvs_stats_t *outStats, nvs_entry_info_t *outEntryInfos, size_t *numEntryInfos)
Read info about each used entry in a specific NVS namespace. Typically, this should be called once wi...
Definition hdw-nvs.c:595
bool writeNvsBlob(const char *key, const void *value, size_t length)
Write a blob to NVS with a given string key.
Definition hdw-nvs.c:312
bool nvsNamespaceInUse(const char *namespace)
Quickly return whether or not any entries exist in a given NVS namespace.
Definition hdw-nvs.c:644
bool initNvs(bool firstTry)
Initialize the nonvolatile storage.
Definition hdw-nvs.c:26
bool writeNamespaceNvs32(const char *namespace, const char *key, int32_t val)
Write a 32 bit value to NVS with a given string key.
Definition hdw-nvs.c:226