|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Core App UI setup including lock flow, menus, and status icon updates. More...
#include "AppUiInternal.h"#include "cdc_os_ui/AppUi.h"#include "cdc_os_ui/views/LockScreenView.h"#include "cdc_os_ui/views/PinChangeView.h"#include "cdc_os_ui/views/BlePairingPromptView.h"#include "cdc_os_ui/WifiHandlers.h"#include "cdc_os_ui/SettingsHandlers.h"#include "cdc_os_ui/SleepManager.h"#include "cdc_os_ui/HardwareInfo.h"#include "cdc_core/PinManager.h"#include "cdc_core/FactoryReset.h"#include "cdc_core/TropicSlotMap.h"#include "cdc_core/TropicStorage.h"#include "cdc_core/UsbManager.h"#include "cdc_core/Raii.h"#include "cdc_views/SliderView.h"#include "cdc_views/PinEntryView.h"#include "cdc_views/DateInputView.h"#include "cdc_views/TimeInputView.h"#include "plugin_manager/PluginListView.h"#include "plugin_manager/PluginManager.h"#include "cdc_hal/IDisplay.h"#include "cdc_hal/IKeypad.h"#include "cdc_hal/IPowerManager.h"#include "cdc_hal/ISleepController.h"#include "cdc_hal/ISecureElement.h"#include "cdc_hal/IWifiController.h"#include "cdc_hal/IBluetoothController.h"#include "cdc_hal/IRtc.h"#include "serial_cmd/SerialCmd.h"#include "nvs.h"#include <atomic>#include <cstdio>#include <cstring>#include <ctime>#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "freertos/semphr.h"#include "esp_timer.h"Go to the source code of this file.
Classes | |
| struct | cdc::ui::PendingPairing |
| struct | cdc::ui::FixedMenuEntry |
Namespaces | |
| namespace | cdc |
| namespace | cdc::ui |
| Centralized key-code constants for cdc_views. | |
Enumerations | |
| enum | cdc::ui::MainMenuFixed : uint8_t { cdc::ui::MM_PLUGINS , cdc::ui::MM_TOOLS , cdc::ui::MM_SETTINGS , cdc::ui::MAIN_MENU_FIXED_COUNT } |
| enum | cdc::ui::SettingsMenuIdx { cdc::ui::SETTINGS_IDX_BRIGHTNESS = 0 , cdc::ui::SETTINGS_IDX_LANGUAGE , cdc::ui::SETTINGS_IDX_TIMEZONE , cdc::ui::SETTINGS_IDX_AUTO_SLEEP , cdc::ui::SETTINGS_IDX_BADGE_TEXT , cdc::ui::SETTINGS_IDX_SET_DATE , cdc::ui::SETTINGS_IDX_SET_TIME , cdc::ui::SETTINGS_IDX_CHANGE_PIN , cdc::ui::SETTINGS_IDX_COUNT } |
| Index enum for the fixed settings menu. More... | |
Functions | |
| static uint8_t | cdc::ui::getPluginsIndex () |
| Returns main-menu index of the fixed "Plugins" item. | |
| static uint8_t | cdc::ui::getToolsIndex () |
| Returns main-menu index of the fixed "Tools" item. | |
| static uint8_t | cdc::ui::getSettingsIndex () |
| Returns main-menu index of the fixed "Settings" item. | |
| static uint8_t | cdc::ui::getMainMenuCount () |
| Returns effective main-menu item count including fixed entries. | |
| static void | cdc::ui::onUnlockRequested () |
| Starts unlock flow from lock screen. | |
| static bool | cdc::ui::onPinVerify (const char *pin) |
| Verifies entered PIN via PinManager. | |
| static void | cdc::ui::onPinSuccess () |
| Handles successful unlock and transitions to main menu. | |
| static void | cdc::ui::onMainMenuSelect (uint16_t index, void *userData) |
| Handles main-menu item selection. | |
| static void | cdc::ui::onToolsSelect (uint16_t index, void *userData) |
| Handles tools-menu item selection. | |
| static void | cdc::ui::onSettingsSelect (uint16_t index, void *userData) |
| Handles settings-menu item selection. | |
| static void | cdc::ui::onLanguageSelect (uint16_t index, void *userData) |
| Handles language-menu item selection. | |
| static void | cdc::ui::rebuildLanguageMenu () |
| Rebuilds the language picker from the overlay files present. | |
| static void | cdc::ui::rebuildMenuLabels () |
| Rebuilds labels for translatable menus after language change. | |
| static void | cdc::ui::onInactivityTimeout () |
| Callback invoked when inactivity timeout is reached. | |
| static void | cdc::ui::clearKeypadBuffer () |
| Drains buffered keypad events. | |
| void | cdc::ui::drawSignalBars (Gdey029T94 *gfx, int x, int y, int8_t rssi, bool inverted) |
| Draws RSSI signal bars using the shared lock-screen visual style. | |
| static void | cdc::ui::updateStatusIcon (StatusIcon icon, bool active, bool &last) |
| Updates a single boolean-driven status icon on the lock screen. | |
| static void | cdc::ui::updateBatteryIndicator () |
| Updates the battery percentage indicator on the lock screen. | |
| void | cdc::ui::updatePowerStatusIcons () |
| Synchronizes lock-screen status icons with current hardware state. | |
| static void | cdc::ui::updateLockScreenClock () |
| Updates lock-screen clock/date once per minute while lock screen is visible. | |
| static bool | cdc::ui::onDuressPinSet (const char *currentPin, const char *newPin) |
| PinChangeView change-callback for the duress-PIN setup flow. | |
| void | cdc::ui::showDuressPinSetup () |
| Opens the duress / self-destruct PIN setup wizard. | |
| static void | cdc::ui::performAntiBlockLock () |
| Anti-block instant lock: force the badge into a clean locked state. | |
| void | cdc::ui::rebuildMainMenu () |
| Rebuilds main menu entries including dynamically provided modules. | |
| static uint8_t | cdc::ui::toolsBluetoothIcon () |
| void | cdc::ui::rebuildToolsMenu () |
| Rebuilds tools menu entries including dynamic module tools. | |
| bool | cdc::ui::isBadgeLocked () |
| Returns whether the badge is currently locked (showing lock screen with no menu above). | |
| static void | cdc::ui::onBleNumericComparison (uint16_t connHandle, uint32_t passkey) |
| Numeric-comparison pairing request, invoked on the nimble_host task. | |
| static void | cdc::ui::onBlePairingRequestEvent (const core::Event &evt) |
| Main-task handler for a deferred numeric-comparison pairing request. | |
| void | cdc::ui::ui_init (const UiDeps &deps) |
| Initializes App UI, builds all core views, and wires callbacks. | |
| void | cdc::ui::ui_on_modules_ready () |
| Refreshes module-backed menus once module startup is complete. | |
| void | cdc::ui::ui_rebuild_menus () |
| Rebuilds dynamic UI menus. | |
| void | cdc::ui::prepareForBootloaderReset () |
| Puts the badge into a quiet pre-reset state. | |
| void | cdc::ui::ui_process (uint32_t nowMs) |
| Main UI tick: input processing, timeouts, status updates, and rendering. | |
Variables | |
| static constexpr uint8_t | cdc::ui::MAIN_MENU_MAX_ITEMS = 16 |
| Menu sizing and inactivity timeout constants. | |
| static constexpr uint8_t | cdc::ui::TOOLS_MAX_ITEMS = 16 |
| static constexpr uint32_t | cdc::ui::INACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 |
| static constexpr uint16_t | cdc::ui::MAX_LANGUAGES = 16 |
| Upper bound on languages shown in the picker (English + overlay files). | |
| static LockScreenView * | cdc::ui::s_lockScreen = nullptr |
| Static UI state and lazily constructed view pointers. | |
| static PinEntryView * | cdc::ui::s_pinEntry = nullptr |
| static ListView * | cdc::ui::s_mainMenu = nullptr |
| static ListView * | cdc::ui::s_toolsMenu = nullptr |
| static ListView * | cdc::ui::s_settingsMenu = nullptr |
| static SliderView * | cdc::ui::s_brightnessSlider = nullptr |
| static SliderView * | cdc::ui::s_sleepSlider = nullptr |
| static SliderView * | cdc::ui::s_timezoneSlider = nullptr |
| static ListView * | cdc::ui::s_languageMenu = nullptr |
| static DateInputView * | cdc::ui::s_dateInput = nullptr |
| static TimeInputView * | cdc::ui::s_timeInput = nullptr |
| static PinChangeView * | cdc::ui::s_pinChangeView = nullptr |
| static PinChangeView * | cdc::ui::s_duressPinView = nullptr |
| static BlePairingPromptView * | cdc::ui::s_pairingPrompt = nullptr |
| static cdc::plugin_manager::PluginListView * | cdc::ui::s_pluginListView = nullptr |
| static PendingPairing | cdc::ui::s_pendingPairing |
| static SemaphoreHandle_t | cdc::ui::s_blePendingMutex = nullptr |
| static UiDeps | cdc::ui::s_deps = {} |
| Runtime dependencies provided during ui_init. | |
| static ListItem | cdc::ui::s_mainMenuItems [MAIN_MENU_MAX_ITEMS] |
| Main-menu backing storage for module and fixed menu entries. | |
| static core::ModuleMenuItem | cdc::ui::s_mainMenuModuleItems [MAIN_MENU_MAX_ITEMS] |
| static uint8_t | cdc::ui::s_mainMenuPluginCount = 0 |
| static ListItem | cdc::ui::s_toolsItems [TOOLS_MAX_ITEMS] |
| Tools-menu backing storage for fixed and module entries. | |
| static core::ModuleMenuItem | cdc::ui::s_toolsModuleItems [TOOLS_MAX_ITEMS] |
| static uint8_t | cdc::ui::s_toolsModuleCount = 0 |
| static ListItem | cdc::ui::s_settingsItems [SETTINGS_IDX_COUNT] |
| Settings menu backing storage. | |
| static ListItem | cdc::ui::s_languageItems [MAX_LANGUAGES] |
| Language menu backing storage (filled dynamically from overlay files). | |
| static char | cdc::ui::s_languageCodes [MAX_LANGUAGES][8] |
| static uint16_t | cdc::ui::s_languageCount = 0 |
| static int8_t | cdc::ui::s_lastMinute = -1 |
| Last rendered minute for lock-screen clock throttling. | |
| static bool | cdc::ui::s_lastUsbConnected = false |
| Last known status-icon inputs to avoid redundant updates. | |
| static bool | cdc::ui::s_lastCharging = false |
| static bool | cdc::ui::s_lastWifiConnected = false |
| static bool | cdc::ui::s_lastBleEnabled = false |
| static bool | cdc::ui::s_lastBackgroundPlugin = false |
| static bool | cdc::ui::s_lastBatteryPresent = false |
| static constexpr uint32_t | cdc::ui::BATTERY_SAMPLE_INTERVAL_MS = 30000 |
| static uint32_t | cdc::ui::s_lastBatterySampleMs = 0 |
| static bool | cdc::ui::s_ignoreKeyUntilRelease = false |
| Prevents stale key events directly after unlock transition. | |
| static std::atomic< bool > | cdc::ui::s_antiBlockLockRequested {false} |
| static const FixedMenuEntry | cdc::ui::kToolsFixed [] |
| static constexpr uint8_t | cdc::ui::TOOLS_FIXED_COUNT |
Core App UI setup including lock flow, menus, and status icon updates.
Feature-specific menu logic lives in dedicated compilation units:
Definition in file AppUi.cpp.