CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
cdc::mod_nvsedit Namespace Reference

Classes

class  NvsEditModule

Functions

static IViewgetNvsEditorView ()
 Returns the NVS editor entry view callback target.
static void rebuildKeyListView ()
 Rebuilds key list labels into s_keyLabels and refreshes the key list view.
static bool deleteEnabled ()
 Indicates whether destructive delete actions are enabled.
static void showDeleteDisabled ()
 Shows a toast describing that delete actions are disabled.
static const char * nvsTypeToString (nvs_type_t type)
 Converts NVS value type enum to a short display string.
static void loadNamespaces ()
 Loads unique namespace names from the default NVS partition.
static void loadKeys (const char *ns)
 Loads keys and types for one namespace.
static bool deleteKey (const char *ns, const char *key)
 Deletes a single key from a namespace.
static bool deleteNamespace (const char *ns)
 Deletes all keys in a namespace.
static void 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 onDeleteNamespace ()
 Deletes the currently selected namespace via context menu action.
static void onDeleteKey ()
 Deletes the currently selected key via context menu action.
static void showKeyListView (const char *ns)
 Shows key list view for the selected namespace.
static void showValueView (const char *ns, const char *key, nvs_type_t type)
 Shows detailed value view for a selected key.
static void onNamespaceSelect (uint16_t index, void *userData)
 Handles namespace list selection.
static void onNamespaceMenu (uint16_t index, void *userData)
 Opens namespace context menu for selected item.
static void showNamespaceListView ()
 Creates and shows the namespace list view.
static void onKeySelect (uint16_t index, void *userData)
 Handles key selection and opens detailed value view.
static void onKeyMenu (uint16_t index, void *userData)
 Opens key context menu for the selected key.
static void onNvsEditorConfirm (void *userData)
 Confirm callback that opens namespace browser after warning dialog.

Variables

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

Function Documentation

◆ deleteEnabled()

bool cdc::mod_nvsedit::deleteEnabled ( )
static

Indicates whether destructive delete actions are enabled.

Returns
true when feature flag permits deletes, otherwise false.

Definition at line 63 of file NvsEditModule.cpp.

References FEATURE_NVS_EDIT.

Referenced by cdc::mod_nvsedit::NvsEditModule::getMenuItems(), getNvsEditorView(), onDeleteKey(), onDeleteNamespace(), onKeyMenu(), onNamespaceMenu(), and onNvsEditorConfirm().

◆ deleteKey()

bool cdc::mod_nvsedit::deleteKey ( const char * ns,
const char * key )
static

Deletes a single key from a namespace.

Parameters
nsNamespace name.
keyKey name.
Returns
true on success, otherwise false.

Definition at line 158 of file NvsEditModule.cpp.

References LOG_I, and TAG.

Referenced by onDeleteKey().

◆ deleteNamespace()

bool cdc::mod_nvsedit::deleteNamespace ( const char * ns)
static

Deletes all keys in a namespace.

Parameters
nsNamespace name.
Returns
true on success, otherwise false.

Definition at line 179 of file NvsEditModule.cpp.

References LOG_I, and TAG.

Referenced by onDeleteNamespace().

◆ formatValue()

void cdc::mod_nvsedit::formatValue ( const char * ns,
const char * key,
nvs_type_t type,
char * buf,
size_t bufLen )
static

Formats one NVS value into a readable preview string.

Parameters
nsNamespace name.
keyKey name.
typeStored NVS type.
bufDestination text buffer.
bufLenSize of buf in bytes.

Definition at line 203 of file NvsEditModule.cpp.

Referenced by showValueView().

◆ getNvsEditorView()

IView * cdc::mod_nvsedit::getNvsEditorView ( )
static

Returns the NVS editor entry view callback target.

Opens privileged confirmation dialog before entering NVS editor view.

Returns
Always nullptr because the view is pushed asynchronously.

Definition at line 519 of file NvsEditModule.cpp.

References deleteEnabled(), onNvsEditorConfirm(), cdc::ui::showConfirm(), and cdc::ui::ConfirmView::WARNING.

Referenced by cdc::mod_nvsedit::NvsEditModule::getMenuItems().

◆ loadKeys()

void cdc::mod_nvsedit::loadKeys ( const char * ns)
static

Loads keys and types for one namespace.

Parameters
nsNamespace name.

Definition at line 129 of file NvsEditModule.cpp.

References LOG_I, MAX_KEYS, s_keyCount, s_keys, s_keyTypes, and TAG.

Referenced by onDeleteKey(), and showKeyListView().

◆ loadNamespaces()

void cdc::mod_nvsedit::loadNamespaces ( )
static

Loads unique namespace names from the default NVS partition.

Definition at line 98 of file NvsEditModule.cpp.

References LOG_I, MAX_NAMESPACES, s_namespaceCount, s_namespaces, and TAG.

Referenced by onDeleteNamespace(), and showNamespaceListView().

◆ nvsTypeToString()

const char * cdc::mod_nvsedit::nvsTypeToString ( nvs_type_t type)
static

Converts NVS value type enum to a short display string.

Parameters
typeNVS entry type.
Returns
String representation of the type.

Definition at line 79 of file NvsEditModule.cpp.

Referenced by rebuildKeyListView(), and showValueView().

◆ onDeleteKey()

◆ onDeleteNamespace()

void cdc::mod_nvsedit::onDeleteNamespace ( )
static

◆ onKeyMenu()

void cdc::mod_nvsedit::onKeyMenu ( uint16_t index,
void * userData )
static

Opens key context menu for the selected key.

Parameters
indexSelected key index.
userDataOptional callback user data.

Definition at line 438 of file NvsEditModule.cpp.

References deleteEnabled(), s_keyContextItems, s_keyCount, s_keys, s_selectedKey, cdc::ui::showContextMenu(), and showDeleteDisabled().

Referenced by showKeyListView().

◆ onKeySelect()

void cdc::mod_nvsedit::onKeySelect ( uint16_t index,
void * userData )
static

Handles key selection and opens detailed value view.

Parameters
indexSelected key index.
userDataOptional callback user data.

Definition at line 425 of file NvsEditModule.cpp.

References s_keyCount, s_keys, s_keyTypes, s_selectedKey, s_selectedNamespace, and showValueView().

Referenced by showKeyListView().

◆ onNamespaceMenu()

void cdc::mod_nvsedit::onNamespaceMenu ( uint16_t index,
void * userData )
static

Opens namespace context menu for selected item.

Parameters
indexSelected namespace index.
userDataOptional callback user data.

Definition at line 385 of file NvsEditModule.cpp.

References deleteEnabled(), s_namespaceCount, s_namespaces, s_nsContextItems, s_selectedNamespace, cdc::ui::showContextMenu(), and showDeleteDisabled().

Referenced by showNamespaceListView().

◆ onNamespaceSelect()

void cdc::mod_nvsedit::onNamespaceSelect ( uint16_t index,
void * userData )
static

Handles namespace list selection.

Parameters
indexSelected namespace index.
userDataOptional callback user data.

Definition at line 372 of file NvsEditModule.cpp.

References s_namespaceCount, s_namespaces, s_selectedNamespace, and showKeyListView().

Referenced by showNamespaceListView().

◆ onNvsEditorConfirm()

void cdc::mod_nvsedit::onNvsEditorConfirm ( void * userData)
static

Confirm callback that opens namespace browser after warning dialog.

Parameters
userDataOptional callback user data.

Definition at line 507 of file NvsEditModule.cpp.

References deleteEnabled(), showNamespaceListView(), and cdc::ui::showToastInfo().

Referenced by getNvsEditorView().

◆ rebuildKeyListView()

void cdc::mod_nvsedit::rebuildKeyListView ( )
static

Rebuilds key list labels into s_keyLabels and refreshes the key list view.

Rebuilds key list labels and refreshes the key list view.

Definition at line 453 of file NvsEditModule.cpp.

References nvsTypeToString(), s_keyCount, s_keyItems, s_keyLabels, s_keyListView, s_keys, s_keyTypes, and s_selectedNamespace.

Referenced by onDeleteKey(), and showKeyListView().

◆ showDeleteDisabled()

void cdc::mod_nvsedit::showDeleteDisabled ( )
static

Shows a toast describing that delete actions are disabled.

Definition at line 70 of file NvsEditModule.cpp.

References cdc::ui::showToastError().

Referenced by onDeleteKey(), onDeleteNamespace(), onKeyMenu(), and onNamespaceMenu().

◆ showKeyListView()

void cdc::mod_nvsedit::showKeyListView ( const char * ns)
static

Shows key list view for the selected namespace.

Creates and shows key list view for a namespace.

Parameters
nsNamespace name.

Definition at line 468 of file NvsEditModule.cpp.

References cdc::ui::ViewStack::instance(), loadKeys(), onKeyMenu(), onKeySelect(), cdc::ui::ViewStack::push(), rebuildKeyListView(), and s_keyListView.

Referenced by onNamespaceSelect().

◆ showNamespaceListView()

void cdc::mod_nvsedit::showNamespaceListView ( )
static

◆ showValueView()

void cdc::mod_nvsedit::showValueView ( const char * ns,
const char * key,
nvs_type_t type )
static

Shows detailed value view for a selected key.

Shows formatted value preview for one namespace key.

Parameters
nsNamespace name.
keyKey name.
typeNVS value type.

Definition at line 490 of file NvsEditModule.cpp.

References formatValue(), cdc::ui::ViewStack::instance(), nvsTypeToString(), cdc::ui::ViewStack::push(), s_valueBuffer, s_valueTitle, and s_valueView.

Referenced by onKeySelect().

Variable Documentation

◆ MAX_KEYS

uint8_t cdc::mod_nvsedit::MAX_KEYS = 48
staticconstexpr

Definition at line 38 of file NvsEditModule.cpp.

Referenced by loadKeys().

◆ MAX_NAMESPACES

uint8_t cdc::mod_nvsedit::MAX_NAMESPACES = 32
staticconstexpr

Upper bounds for list sizes and value preview buffers.

Definition at line 37 of file NvsEditModule.cpp.

Referenced by loadNamespaces().

◆ MAX_VALUE_DISPLAY

size_t cdc::mod_nvsedit::MAX_VALUE_DISPLAY = 256
staticconstexpr

Definition at line 39 of file NvsEditModule.cpp.

◆ s_keyContextItems

ContextMenuItem cdc::mod_nvsedit::s_keyContextItems[]
static
Initial value:
= {
{"Delete Key", onDeleteKey}
}
static void onDeleteKey()
Deletes the currently selected key via context menu action.

Definition at line 358 of file NvsEditModule.cpp.

Referenced by onKeyMenu().

◆ s_keyCount

uint8_t cdc::mod_nvsedit::s_keyCount = 0
static

Definition at line 49 of file NvsEditModule.cpp.

Referenced by loadKeys(), onDeleteKey(), onKeyMenu(), onKeySelect(), and rebuildKeyListView().

◆ s_keyItems

ListItem cdc::mod_nvsedit::s_keyItems[MAX_KEYS]
static

Definition at line 57 of file NvsEditModule.cpp.

Referenced by rebuildKeyListView().

◆ s_keyLabels

char cdc::mod_nvsedit::s_keyLabels[MAX_KEYS][24]
static

Persistent key label storage used by list items.

Definition at line 418 of file NvsEditModule.cpp.

Referenced by rebuildKeyListView().

◆ s_keyListView

ListView* cdc::mod_nvsedit::s_keyListView = nullptr
static

Definition at line 54 of file NvsEditModule.cpp.

Referenced by rebuildKeyListView(), and showKeyListView().

◆ s_keys

char cdc::mod_nvsedit::s_keys[MAX_KEYS][16] = {}
static

Definition at line 47 of file NvsEditModule.cpp.

Referenced by loadKeys(), onKeyMenu(), onKeySelect(), and rebuildKeyListView().

◆ s_keyTypes

nvs_type_t cdc::mod_nvsedit::s_keyTypes[MAX_KEYS] = {}
static

Definition at line 48 of file NvsEditModule.cpp.

Referenced by loadKeys(), onKeySelect(), and rebuildKeyListView().

◆ s_module

NvsEditModule cdc::mod_nvsedit::s_module
static

Static module instance used by registration callback.

Definition at line 558 of file NvsEditModule.cpp.

◆ s_namespaceCount

uint8_t cdc::mod_nvsedit::s_namespaceCount = 0
static

◆ s_namespaceItems

ListItem cdc::mod_nvsedit::s_namespaceItems[MAX_NAMESPACES]
static

Definition at line 56 of file NvsEditModule.cpp.

Referenced by onDeleteNamespace(), and showNamespaceListView().

◆ s_namespaceListView

ListView* cdc::mod_nvsedit::s_namespaceListView = nullptr
static

Lazily created views and backing list item arrays.

Definition at line 53 of file NvsEditModule.cpp.

Referenced by onDeleteNamespace(), and showNamespaceListView().

◆ s_namespaces

char cdc::mod_nvsedit::s_namespaces[MAX_NAMESPACES][16] = {}
static

Runtime state for namespace/key browsing context.

Definition at line 43 of file NvsEditModule.cpp.

Referenced by loadNamespaces(), onDeleteNamespace(), onNamespaceMenu(), onNamespaceSelect(), and showNamespaceListView().

◆ s_nsContextItems

ContextMenuItem cdc::mod_nvsedit::s_nsContextItems[]
static
Initial value:
= {
{"Delete NS", onDeleteNamespace}
}
static void onDeleteNamespace()
Deletes the currently selected namespace via context menu action.

Definition at line 354 of file NvsEditModule.cpp.

Referenced by onNamespaceMenu().

◆ s_selectedKey

char cdc::mod_nvsedit::s_selectedKey[16] = {}
static

Definition at line 50 of file NvsEditModule.cpp.

Referenced by onDeleteKey(), onKeyMenu(), and onKeySelect().

◆ s_selectedNamespace

char cdc::mod_nvsedit::s_selectedNamespace[16] = {}
static

◆ s_valueBuffer

char cdc::mod_nvsedit::s_valueBuffer[MAX_VALUE_DISPLAY]
static

Definition at line 481 of file NvsEditModule.cpp.

Referenced by showValueView().

◆ s_valueTitle

char cdc::mod_nvsedit::s_valueTitle[32]
static

Definition at line 482 of file NvsEditModule.cpp.

Referenced by showValueView().

◆ s_valueView

InfoView* cdc::mod_nvsedit::s_valueView = nullptr
static

Definition at line 55 of file NvsEditModule.cpp.

Referenced by showValueView().