CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
NvsEditModule.cpp File Reference

GUI module for browsing and deleting NVS entries. More...

#include "mod_nvsedit/NvsEditModule.h"
#include "cdc_core/ModuleRegistry.h"
#include "cdc_core/feature_flags.h"
#include "cdc_ui/ViewStack.h"
#include "cdc_views/ListView.h"
#include "cdc_views/ContextMenuView.h"
#include "cdc_views/ConfirmView.h"
#include "cdc_views/InfoView.h"
#include "cdc_views/ToastView.h"
#include "cdc_log.h"
#include "esp_attr.h"
#include "nvs_flash.h"
#include "nvs.h"
#include <cstring>
#include <cstdio>

Go to the source code of this file.

Namespaces

namespace  cdc
namespace  cdc::mod_nvsedit

Functions

static IViewcdc::mod_nvsedit::getNvsEditorView ()
 Returns the NVS editor entry view callback target.
static void cdc::mod_nvsedit::rebuildKeyListView ()
 Rebuilds key list labels into s_keyLabels and refreshes the key list view.
static bool cdc::mod_nvsedit::deleteEnabled ()
 Indicates whether destructive delete actions are enabled.
static void cdc::mod_nvsedit::showDeleteDisabled ()
 Shows a toast describing that delete actions are disabled.
static const char * cdc::mod_nvsedit::nvsTypeToString (nvs_type_t type)
 Converts NVS value type enum to a short display string.
static void cdc::mod_nvsedit::loadNamespaces ()
 Loads unique namespace names from the default NVS partition.
static void cdc::mod_nvsedit::loadKeys (const char *ns)
 Loads keys and types for one namespace.
static bool cdc::mod_nvsedit::deleteKey (const char *ns, const char *key)
 Deletes a single key from a namespace.
static bool cdc::mod_nvsedit::deleteNamespace (const char *ns)
 Deletes all keys in a namespace.
static void cdc::mod_nvsedit::formatValue (const char *ns, const char *key, nvs_type_t type, char *buf, size_t bufLen)
 Formats one NVS value into a readable preview string.
static void cdc::mod_nvsedit::onDeleteNamespace ()
 Deletes the currently selected namespace via context menu action.
static void cdc::mod_nvsedit::onDeleteKey ()
 Deletes the currently selected key via context menu action.
static void cdc::mod_nvsedit::showKeyListView (const char *ns)
 Shows key list view for the selected namespace.
static void cdc::mod_nvsedit::showValueView (const char *ns, const char *key, nvs_type_t type)
 Shows detailed value view for a selected key.
static void cdc::mod_nvsedit::onNamespaceSelect (uint16_t index, void *userData)
 Handles namespace list selection.
static void cdc::mod_nvsedit::onNamespaceMenu (uint16_t index, void *userData)
 Opens namespace context menu for selected item.
static void cdc::mod_nvsedit::showNamespaceListView ()
 Creates and shows the namespace list view.
static void cdc::mod_nvsedit::onKeySelect (uint16_t index, void *userData)
 Handles key selection and opens detailed value view.
static void cdc::mod_nvsedit::onKeyMenu (uint16_t index, void *userData)
 Opens key context menu for the selected key.
static void cdc::mod_nvsedit::onNvsEditorConfirm (void *userData)
 Confirm callback that opens namespace browser after warning dialog.
void mod_nvsedit_register ()
 Registers NVS editor initializer with module registry.

Variables

static const char * TAG = "NvsEdit"
static constexpr uint8_t cdc::mod_nvsedit::MAX_NAMESPACES = 32
 Upper bounds for list sizes and value preview buffers.
static constexpr uint8_t cdc::mod_nvsedit::MAX_KEYS = 48
static constexpr size_t cdc::mod_nvsedit::MAX_VALUE_DISPLAY = 256
static char cdc::mod_nvsedit::s_namespaces [MAX_NAMESPACES][16] = {}
 Runtime state for namespace/key browsing context.
static uint8_t cdc::mod_nvsedit::s_namespaceCount = 0
static char cdc::mod_nvsedit::s_selectedNamespace [16] = {}
static char cdc::mod_nvsedit::s_keys [MAX_KEYS][16] = {}
static nvs_type_t cdc::mod_nvsedit::s_keyTypes [MAX_KEYS] = {}
static uint8_t cdc::mod_nvsedit::s_keyCount = 0
static char cdc::mod_nvsedit::s_selectedKey [16] = {}
static ListViewcdc::mod_nvsedit::s_namespaceListView = nullptr
 Lazily created views and backing list item arrays.
static ListViewcdc::mod_nvsedit::s_keyListView = nullptr
static InfoViewcdc::mod_nvsedit::s_valueView = nullptr
static ListItem cdc::mod_nvsedit::s_namespaceItems [MAX_NAMESPACES]
static ListItem cdc::mod_nvsedit::s_keyItems [MAX_KEYS]
static ContextMenuItem cdc::mod_nvsedit::s_nsContextItems []
static ContextMenuItem cdc::mod_nvsedit::s_keyContextItems []
static char cdc::mod_nvsedit::s_keyLabels [MAX_KEYS][24]
 Persistent key label storage used by list items.
static char cdc::mod_nvsedit::s_valueBuffer [MAX_VALUE_DISPLAY]
static char cdc::mod_nvsedit::s_valueTitle [32]
static NvsEditModule cdc::mod_nvsedit::s_module
 Static module instance used by registration callback.

Detailed Description

GUI module for browsing and deleting NVS entries.

Definition in file NvsEditModule.cpp.

Function Documentation

◆ mod_nvsedit_register()

void mod_nvsedit_register ( )

Registers NVS editor initializer with module registry.

Definition at line 565 of file NvsEditModule.cpp.

References cdc::core::ModuleRegistry::instance(), and cdc::core::ModuleRegistry::registerInitializer().

Variable Documentation

◆ TAG

const char* TAG = "NvsEdit"
static

Definition at line 25 of file NvsEditModule.cpp.