Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hdw-nvs.h
Go to the documentation of this file.
1
43
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#include "linked_list.h"
53
54//==============================================================================
55// Defines
56//==============================================================================
57
58#define NVS_PART_NAME_MAX_SIZE 16
59#define NVS_KEY_NAME_MAX_SIZE 16
60#define NVS_NAMESPACE_NAME "storage"
61
62//==============================================================================
63// Function Prototypes
64//==============================================================================
65
66bool initNvs(bool firstTry);
67bool deinitNvs(void);
68bool eraseNvs(void);
69bool readNvs32(const char* key, int32_t* outVal);
70bool writeNvs32(const char* key, int32_t val);
71bool readNamespaceNvs32(const char* namespace, const char* key, int32_t* outVal);
72bool writeNamespaceNvs32(const char* namespace, const char* key, int32_t val);
73bool readNvsBlob(const char* key, void* out_value, size_t* length);
74bool writeNvsBlob(const char* key, const void* value, size_t length);
75bool readNamespaceNvsBlob(const char* namespace, const char* key, void* out_value, size_t* length);
76bool writeNamespaceNvsBlob(const char* namespace, const char* key, const void* value, size_t length);
77bool eraseNvsKey(const char* key);
78bool eraseNamespaceNvsKey(const char* namespace, const char* key);
79bool readNvsStats(nvs_stats_t* outStats);
80bool readAllNvsEntryInfos(nvs_stats_t* outStats, nvs_entry_info_t* outEntryInfos, size_t* numEntryInfos);
81bool readNamespaceNvsEntryInfos(const char* namespace, nvs_stats_t* outStats, nvs_entry_info_t* outEntryInfos,
82 size_t* numEntryInfos);
83bool nvsNamespaceInUse(const char* namespace);
84void getNvsKeys(const char* namespace, list_t* list);
85
86#endif
bool eraseNamespaceNvsKey(const char *namespace, const char *key)
Delete the value with the given key from NVS.
Definition hdw-nvs.c:487
bool eraseNvsKey(const char *key)
Delete the value with the given key from NVS.
Definition hdw-nvs.c:475
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:168
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:587
bool readNvsStats(nvs_stats_t *outStats)
Read info about used memory in NVS.
Definition hdw-nvs.c:556
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:339
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:407
bool writeNvs32(const char *key, int32_t val)
Write a 32 bit value to NVS with a given string key.
Definition hdw-nvs.c:155
bool eraseNvs(void)
Erase and re-initialize the nonvolatile storage.
Definition hdw-nvs.c:103
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:309
bool readNvs32(const char *key, int32_t *outVal)
Read a 32 bit value from NVS with a given string key.
Definition hdw-nvs.c:143
void getNvsKeys(const char *namespace, list_t *list)
Fill a given list_t with all the NVS string keys for the given namespace.
Definition hdw-nvs.c:657
bool deinitNvs(void)
Deinitialize NVS.
Definition hdw-nvs.c:93
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:605
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:322
bool nvsNamespaceInUse(const char *namespace)
Quickly return whether or not any entries exist in a given NVS namespace.
Definition hdw-nvs.c:700
bool initNvs(bool firstTry)
Initialize the nonvolatile storage.
Definition hdw-nvs.c:36
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:236
A doubly linked list with pointers to the first and last nodes.
Definition linked_list.h:87