diff --git a/apps/esp32_lvgl/src/esp32_lvgl_arduino_app_registry.cpp b/apps/esp32_lvgl/src/esp32_lvgl_arduino_app_registry.cpp index 58d535f2..f9331171 100644 --- a/apps/esp32_lvgl/src/esp32_lvgl_arduino_app_registry.cpp +++ b/apps/esp32_lvgl/src/esp32_lvgl_arduino_app_registry.cpp @@ -32,7 +32,7 @@ ui::app_catalog_builder::FeatureFlags buildFeatureFlags() flags.include_extensions = true; flags.include_network = app::hasAppFacade() && chat::infra::isReticulumMeshProtocol( - app::configFacade().getConfig().mesh_protocol); + app::configFacade().readConfig().mesh_protocol); flags.include_walkie_talkie = platform::ui::walkie::is_supported(); flags.include_power_off = #if defined(ARDUINO_T_LORA_PAGER) diff --git a/apps/esp32_lvgl/src/esp32_lvgl_idf_app_facade_runtime.cpp b/apps/esp32_lvgl/src/esp32_lvgl_idf_app_facade_runtime.cpp index a55a0113..a3314c7a 100644 --- a/apps/esp32_lvgl/src/esp32_lvgl_idf_app_facade_runtime.cpp +++ b/apps/esp32_lvgl/src/esp32_lvgl_idf_app_facade_runtime.cpp @@ -1143,9 +1143,10 @@ class IdfAppFacadeRuntime final : public app::IAppFacade return ready; } - [[deprecated("Use beginConfigEdit() for configuration writes")]] app::AppConfig& getConfig() override { return config_; } + protected: const app::AppConfig& getConfig() const override { return config_; } + public: app::AppConfigEdit beginConfigEdit() override { return app::AppConfigEdit(&config_, diff --git a/apps/esp32_lvgl/src/esp32_lvgl_idf_app_registry.cpp b/apps/esp32_lvgl/src/esp32_lvgl_idf_app_registry.cpp index 0be24a4c..68b31a9a 100644 --- a/apps/esp32_lvgl/src/esp32_lvgl_idf_app_registry.cpp +++ b/apps/esp32_lvgl/src/esp32_lvgl_idf_app_registry.cpp @@ -204,7 +204,7 @@ ui::app_catalog_builder::FeatureFlags buildFeatureFlags() flags.include_extensions = ui::runtime::packs::is_supported(); flags.include_network = app::hasAppFacade() && chat::infra::isReticulumMeshProtocol( - app::configFacade().getConfig().mesh_protocol); + app::configFacade().readConfig().mesh_protocol); flags.include_walkie_talkie = platform::ui::walkie::is_supported(); #if defined(TRAIL_MATE_ESP_BOARD_T_DISPLAY_P4) flags.include_power_off = true; diff --git a/apps/esp32_lvgl/src/esp32_lvgl_startup_runtime.cpp b/apps/esp32_lvgl/src/esp32_lvgl_startup_runtime.cpp index d636334f..d2eac497 100644 --- a/apps/esp32_lvgl/src/esp32_lvgl_startup_runtime.cpp +++ b/apps/esp32_lvgl/src/esp32_lvgl_startup_runtime.cpp @@ -49,7 +49,7 @@ void applyPlatformRuntimeConfig(const Esp32LvglRuntimeConfig& config) return; } - const app::AppConfig& app_config = app::appFacade().getConfig(); + const app::AppConfig& app_config = app::appFacade().readConfig(); platform::ui::gps::set_enabled(app_config.gps_enabled); platform::ui::gps::set_collection_interval(app_config.gps_interval_ms); platform::ui::gps::set_power_strategy(app_config.gps_strategy); diff --git a/apps/nrf52_node/src/nrf52_node_app_facade_runtime.cpp b/apps/nrf52_node/src/nrf52_node_app_facade_runtime.cpp index 7afe2505..0f7e1c9a 100644 --- a/apps/nrf52_node/src/nrf52_node_app_facade_runtime.cpp +++ b/apps/nrf52_node/src/nrf52_node_app_facade_runtime.cpp @@ -294,11 +294,6 @@ const chat::runtime::SelfIdentityProvider* AppFacadeRuntime::identityProvider() return identity_bridge_.get(); } -app::AppConfig& AppFacadeRuntime::getConfig() -{ - return config_; -} - const app::AppConfig& AppFacadeRuntime::getConfig() const { return config_; diff --git a/apps/nrf52_node/src/nrf52_node_app_facade_runtime.h b/apps/nrf52_node/src/nrf52_node_app_facade_runtime.h index 633918e7..cd5c5df9 100644 --- a/apps/nrf52_node/src/nrf52_node_app_facade_runtime.h +++ b/apps/nrf52_node/src/nrf52_node_app_facade_runtime.h @@ -55,8 +55,10 @@ class AppFacadeRuntime final : public app::IAppBleFacade bool installMeshBackend(chat::MeshProtocol protocol, std::unique_ptr backend); - [[deprecated("Use beginConfigEdit() for configuration writes")]] app::AppConfig& getConfig() override; + protected: const app::AppConfig& getConfig() const override; + + public: chat::MeshProtocol getMeshProtocol() const override; void saveConfig() override; void saveConfig(app::AppConfigChangeSet changes) override; diff --git a/apps/nrf52_node/src/nrf52_node_startup_runtime.cpp b/apps/nrf52_node/src/nrf52_node_startup_runtime.cpp index e2f49ee9..af87fd23 100644 --- a/apps/nrf52_node/src/nrf52_node_startup_runtime.cpp +++ b/apps/nrf52_node/src/nrf52_node_startup_runtime.cpp @@ -66,7 +66,7 @@ void run() if (app_runtime_access::initialize()) { - auto& cfg = AppFacadeRuntime::instance().getConfig(); + const auto& cfg = AppFacadeRuntime::instance().readConfig(); ui_runtime::bindChatObservers(); (void)board.startGpsRuntime(cfg); platform::nrf52::debug_console::printf("%s startup app facade ok\n", target_board::kLogTag); diff --git a/modules/core_sys/include/app/app_facades.h b/modules/core_sys/include/app/app_facades.h index c96d3b3d..059a8a79 100644 --- a/modules/core_sys/include/app/app_facades.h +++ b/modules/core_sys/include/app/app_facades.h @@ -54,9 +54,9 @@ class IAppConfigFacade { public: virtual ~IAppConfigFacade() = default; - // Transitional compatibility only. New writes must use beginConfigEdit(). - [[deprecated("Use beginConfigEdit() for configuration writes")]] virtual AppConfig& getConfig() = 0; - virtual const AppConfig& getConfig() const = 0; + // Read-only configuration view. This is not a snapshot and does not + // acquire an edit lease. + [[nodiscard]] const AppConfig& readConfig() const { return getConfig(); } virtual AppConfigEdit beginConfigEdit() = 0; virtual void saveConfig() = 0; virtual void requestSaveConfig() { saveConfig(); } @@ -74,6 +74,11 @@ class IAppConfigFacade virtual chat::MeshProtocol getMeshProtocol() const = 0; virtual void getEffectiveUserInfo(char* out_long, std::size_t long_len, char* out_short, std::size_t short_len) const = 0; virtual bool switchMeshProtocol(chat::MeshProtocol protocol, bool persist = true) = 0; + + protected: + // Virtual storage hook for readConfig(). Consumers must use the explicit + // read-only API rather than accessing implementation storage directly. + virtual const AppConfig& getConfig() const = 0; }; class IAppMessagingFacade diff --git a/modules/ui_mono/src/runtime.cpp b/modules/ui_mono/src/runtime.cpp index b6442312..3a92880d 100644 --- a/modules/ui_mono/src/runtime.cpp +++ b/modules/ui_mono/src/runtime.cpp @@ -3119,12 +3119,12 @@ void Runtime::handleInput(InputAction action) if (item == RadioSettingItem::McChannelName) { openCompose(EditTarget::MeshCoreChannelName, - app()->getConfig().meshcore_config.activeMeshCoreChannel().name); + app()->readConfig().meshcore_config.activeMeshCoreChannel().name); } else if (item == RadioSettingItem::MtPrimaryKey) { char key_text[kKeyTextMax] = {}; - formatMeshtasticPrimaryKeyForEdit(app()->getConfig().meshtastic_config, + formatMeshtasticPrimaryKeyForEdit(app()->readConfig().meshtastic_config, key_text, sizeof(key_text)); openCompose(EditTarget::MeshtasticPrimaryKey, key_text); @@ -3132,7 +3132,7 @@ void Runtime::handleInput(InputAction action) else if (item == RadioSettingItem::McChannelKey) { char key_text[kKeyTextMax] = {}; - formatMeshCoreChannelKeyForEdit(app()->getConfig().meshcore_config, + formatMeshCoreChannelKeyForEdit(app()->readConfig().meshcore_config, key_text, sizeof(key_text)); openCompose(EditTarget::MeshCoreChannelKey, key_text); @@ -3492,7 +3492,7 @@ void Runtime::renderSleep() bool Runtime::mainMenuShowsDiscover() const { - return app() && app()->getConfig().mesh_protocol == chat::MeshProtocol::MeshCore; + return app() && app()->readConfig().mesh_protocol == chat::MeshProtocol::MeshCore; } bool Runtime::mainMenuShowsCompass() const @@ -3636,7 +3636,7 @@ void Runtime::renderChatList() const size_t item_index = start + i; const bool selected_row = (item_index == selected); char line[32] = {}; - const char* marker = app() ? protocolMarker(app()->getConfig().mesh_protocol) : ""; + const char* marker = app() ? protocolMarker(app()->readConfig().mesh_protocol) : ""; if (item_index == 0) { std::snprintf(line, sizeof(line), "+ NEW CHANNEL"); @@ -4592,7 +4592,7 @@ void Runtime::renderSettingsMenu() void Runtime::renderRadioSettings() { - const auto protocol = app()->getConfig().mesh_protocol; + const auto protocol = app()->readConfig().mesh_protocol; const size_t item_count = radioItemCount(); if (item_count == 0) { @@ -4605,7 +4605,7 @@ void Runtime::renderRadioSettings() drawTitleBar("PROTO", protocolShortLabel(protocol)); char value[40] = {}; - auto& cfg = app()->getConfig(); + const auto& cfg = app()->readConfig(); const int row_y = 12; const int row_h = std::max(1, text_renderer_.lineHeight()); const size_t visible = std::min(item_count, visibleRowsFrom(row_y, 4)); @@ -4703,14 +4703,14 @@ void Runtime::renderDeviceSettings() } #endif case DeviceSettingItem::Gps: - std::snprintf(line, sizeof(line), "GPS: %s", app()->getConfig().gps_enabled ? "ON" : "OFF"); + std::snprintf(line, sizeof(line), "GPS: %s", app()->readConfig().gps_enabled ? "ON" : "OFF"); break; case DeviceSettingItem::Sats: - std::snprintf(line, sizeof(line), "SATS: %s", gpsSatMaskLabel(app()->getConfig().gps_sat_mask)); + std::snprintf(line, sizeof(line), "SATS: %s", gpsSatMaskLabel(app()->readConfig().gps_sat_mask)); break; case DeviceSettingItem::GpsInterval: std::snprintf(line, sizeof(line), "GPS INT: %lus", - static_cast(app()->getConfig().gps_interval_ms / 1000UL)); + static_cast(app()->readConfig().gps_interval_ms / 1000UL)); break; case DeviceSettingItem::ScreenOff: { @@ -4841,7 +4841,7 @@ void Runtime::renderInfoPage() char long_name[24] = {}; char short_name[12] = {}; app()->getEffectiveUserInfo(long_name, sizeof(long_name), short_name, sizeof(short_name)); - const auto& cfg = app()->getConfig(); + const auto& cfg = app()->readConfig(); const auto battery = host_.battery_info_fn ? host_.battery_info_fn() : platform::ui::device::BatteryInfo{}; const auto gps = host_.gps_data_fn ? host_.gps_data_fn() : platform::ui::gps::GpsState{}; const auto ram = host_.ram_usage_fn ? host_.ram_usage_fn() : HostCallbacks::ResourceUsage{}; @@ -6038,7 +6038,7 @@ void Runtime::executeNewChatPageItem(size_t index) active_conversation_ = chat::ConversationId( index == 1U ? chat::ChannelId::SECONDARY : chat::ChannelId::PRIMARY, 0, - app()->getConfig().mesh_protocol); + app()->readConfig().mesh_protocol); if (!app()->getChatService().canSendToConversation(active_conversation_)) { showTransientPopup("NEW CHAT", "VIEW ONLY"); @@ -6059,7 +6059,7 @@ void Runtime::executeDiscoverPageItem(size_t index) showTransientPopup("DISCOVER", "APP NOT READY"); return; } - if (app()->getConfig().mesh_protocol != chat::MeshProtocol::MeshCore) + if (app()->readConfig().mesh_protocol != chat::MeshProtocol::MeshCore) { showTransientPopup("DISCOVER", "MESHCORE ONLY"); return; @@ -6152,7 +6152,7 @@ void Runtime::beginSettingPopup(Page owner, size_t index) setting_popup_active_ = true; setting_popup_owner_ = owner; setting_popup_index_ = index; - setting_popup_config_ = app()->getConfig(); + setting_popup_config_ = app()->readConfig(); #if !TRAILMATE_NRF52_BLE_DISABLED setting_popup_ble_enabled_ = app()->isBleEnabled(); #endif @@ -6188,7 +6188,7 @@ void Runtime::confirmSettingPopup() { sanitizeMeshtasticChannelNum(setting_popup_config_); const chat::MeshProtocol target_protocol = setting_popup_config_.mesh_protocol; - if (target_protocol != app()->getConfig().mesh_protocol) + if (target_protocol != app()->readConfig().mesh_protocol) { if (!app()->switchMeshProtocol(target_protocol, true)) { @@ -6196,7 +6196,7 @@ void Runtime::confirmSettingPopup() return; } - setting_popup_config_ = app()->getConfig(); + setting_popup_config_ = app()->readConfig(); radio_index_ = 0; char value[32] = {}; formatSettingPopupValue(value, sizeof(value)); @@ -7550,7 +7550,7 @@ void Runtime::formatProtocol(char* out, size_t out_len) const { return; } - std::snprintf(out, out_len, "%s", protocolShortLabel(app()->getConfig().mesh_protocol)); + std::snprintf(out, out_len, "%s", protocolShortLabel(app()->readConfig().mesh_protocol)); } void Runtime::formatNodeLabel(char* out, size_t out_len) const @@ -8087,7 +8087,7 @@ const chat::contacts::PeerDirectoryItem* Runtime::selectedNode() const size_t Runtime::nodeActionCount() const { - const bool meshtastic_mode = app() && app()->getConfig().mesh_protocol != chat::MeshProtocol::MeshCore; + const bool meshtastic_mode = app() && app()->readConfig().mesh_protocol != chat::MeshProtocol::MeshCore; return meshtastic_mode ? kNodeActionItemCount : (kNodeActionItemCount - 2U); } @@ -8212,12 +8212,12 @@ void Runtime::handleMeshtasticActionResult( const char* Runtime::nodeActionLabel(size_t index) const { const chat::contacts::PeerDirectoryItem* node = selectedNode(); - const bool meshtastic_mode = app() && app()->getConfig().mesh_protocol != chat::MeshProtocol::MeshCore; + const bool meshtastic_mode = app() && app()->readConfig().mesh_protocol != chat::MeshProtocol::MeshCore; const bool can_reply = node && app() && chat::infra::meshProtocolFromRaw( static_cast(node->protocol), - app()->getConfig().mesh_protocol) == - app()->getConfig().mesh_protocol; + app()->readConfig().mesh_protocol) == + app()->readConfig().mesh_protocol; switch (index) { case 0: @@ -8244,7 +8244,7 @@ void Runtime::executeNodeAction() auto* mesh = app() ? app()->getMeshAdapter() : nullptr; auto* contacts = app() ? &app()->getContactService() : nullptr; const chat::contacts::PeerDirectoryItem* node = selectedNode(); - const bool meshtastic_mode = app() && app()->getConfig().mesh_protocol != chat::MeshProtocol::MeshCore; + const bool meshtastic_mode = app() && app()->readConfig().mesh_protocol != chat::MeshProtocol::MeshCore; if (!node) { appendBootLog("node action na"); @@ -8267,8 +8267,8 @@ void Runtime::executeNodeAction() } const chat::MeshProtocol node_protocol = chat::infra::meshProtocolFromRaw(static_cast(node->protocol), - app()->getConfig().mesh_protocol); - if (node_protocol != app()->getConfig().mesh_protocol) + app()->readConfig().mesh_protocol); + if (node_protocol != app()->readConfig().mesh_protocol) { showTransientPopup("NODE", "VIEW ONLY"); return; diff --git a/modules/ui_shared/include/ui/screens/contacts/contacts_filter_profile.h b/modules/ui_shared/include/ui/screens/contacts/contacts_filter_profile.h index f6d98623..7221520d 100644 --- a/modules/ui_shared/include/ui/screens/contacts/contacts_filter_profile.h +++ b/modules/ui_shared/include/ui/screens/contacts/contacts_filter_profile.h @@ -18,12 +18,12 @@ namespace ui inline bool uses_reticulum_filter_profile() { - return chat::infra::isReticulumMeshProtocol(app::configFacade().getConfig().mesh_protocol); + return chat::infra::isReticulumMeshProtocol(app::configFacade().readConfig().mesh_protocol); } inline bool uses_meshcore_filter_profile() { - return app::configFacade().getConfig().mesh_protocol == chat::MeshProtocol::MeshCore; + return app::configFacade().readConfig().mesh_protocol == chat::MeshProtocol::MeshCore; } } // namespace ui diff --git a/modules/ui_shared/src/ui/presentation_sources/runtime_device_status_source.cpp b/modules/ui_shared/src/ui/presentation_sources/runtime_device_status_source.cpp index 98195603..5decd6d0 100644 --- a/modules/ui_shared/src/ui/presentation_sources/runtime_device_status_source.cpp +++ b/modules/ui_shared/src/ui/presentation_sources/runtime_device_status_source.cpp @@ -102,7 +102,7 @@ bool RuntimeDeviceStatusSource::buildDeviceStatusSnapshot( out.lora = ui::device::CapabilityDisplayState::Ready; out.storage = ui::device::CapabilityDisplayState::Ready; - const app::AppConfig& config = app::configFacade().getConfig(); + const app::AppConfig& config = app::configFacade().readConfig(); const chat::MeshProtocol protocol = config.mesh_protocol; const char* protocol_name = chat::infra::meshProtocolName(protocol); diff --git a/modules/ui_shared/src/ui/presentation_sources/runtime_mesh_status_source.cpp b/modules/ui_shared/src/ui/presentation_sources/runtime_mesh_status_source.cpp index 9cb3c7a7..0572b4f4 100644 --- a/modules/ui_shared/src/ui/presentation_sources/runtime_mesh_status_source.cpp +++ b/modules/ui_shared/src/ui/presentation_sources/runtime_mesh_status_source.cpp @@ -67,7 +67,7 @@ bool RuntimeMeshStatusSource::buildMeshStatusSnapshot( ui::copyText(out.protocol_label, chat::infra::meshProtocolName( - app::configFacade().getConfig().mesh_protocol)); + app::configFacade().readConfig().mesh_protocol)); #if TRAIL_MATE_ENABLE_BLE ui::copyText(out.radio_label, ble_linked ? "BLE linked" diff --git a/modules/ui_shared/src/ui/presentation_sources/runtime_settings_source.cpp b/modules/ui_shared/src/ui/presentation_sources/runtime_settings_source.cpp index 6ff6a13e..84f03840 100644 --- a/modules/ui_shared/src/ui/presentation_sources/runtime_settings_source.cpp +++ b/modules/ui_shared/src/ui/presentation_sources/runtime_settings_source.cpp @@ -56,7 +56,7 @@ bool RuntimeSettingsSource::buildSettingsSnapshot( ui::copyText(out.sections[0].options[0].key, "gps_enabled"); ui::copyText(out.sections[0].options[0].label, "GPS Enabled"); ui::copyText(out.sections[0].options[0].value_label, - app::configFacade().getConfig().gps_enabled ? "ON" : "OFF"); + app::configFacade().readConfig().gps_enabled ? "ON" : "OFF"); out.sections[0].options[0].control = ui::settings::SettingControlKind::Toggle; return true; diff --git a/modules/ui_shared/src/ui/screens/chat/chat_conversation_components.cpp b/modules/ui_shared/src/ui/screens/chat/chat_conversation_components.cpp index e9d3d8a5..159a4530 100644 --- a/modules/ui_shared/src/ui/screens/chat/chat_conversation_components.cpp +++ b/modules/ui_shared/src/ui/screens/chat/chat_conversation_components.cpp @@ -1217,7 +1217,7 @@ void ChatConversationScreen::refreshLocationMap() model.focus_point.lon = (min_lon + max_lon) / 2.0; model.map_source = layers.map_source; model.contour_enabled = layers.contour_enabled; - model.coord_system = app::configFacade().getConfig().map_coord_system; + model.coord_system = app::configFacade().readConfig().map_coord_system; if (point_count <= 1) { @@ -1355,7 +1355,7 @@ void ChatConversationScreen::createMessageItem(const ::ui::chat::MessageRow& row std::string sender; if (is_self) { - sender = app::configFacade().getConfig().short_name; + sender = app::configFacade().readConfig().short_name; if (sender.empty() && !row.sender_label.empty()) { sender = row.sender_label.c_str(); diff --git a/modules/ui_shared/src/ui/screens/chat/chat_page_runtime.cpp b/modules/ui_shared/src/ui/screens/chat/chat_page_runtime.cpp index be525ac9..db6f1135 100644 --- a/modules/ui_shared/src/ui/screens/chat/chat_page_runtime.cpp +++ b/modules/ui_shared/src/ui/screens/chat/chat_page_runtime.cpp @@ -262,7 +262,7 @@ void enter(const shell::Host* host, lv_obj_t* parent) set_default_group(prev_group); } - chat::ChannelId default_channel = (app::configFacade().getConfig().chat_channel == 1) + chat::ChannelId default_channel = (app::configFacade().readConfig().chat_channel == 1) ? chat::ChannelId::SECONDARY : chat::ChannelId::PRIMARY; auto& chat_service = app::messagingFacade().getChatService(); diff --git a/modules/ui_shared/src/ui/screens/chat/chat_protocol_support.cpp b/modules/ui_shared/src/ui/screens/chat/chat_protocol_support.cpp index db3c9acb..70fdac67 100644 --- a/modules/ui_shared/src/ui/screens/chat/chat_protocol_support.cpp +++ b/modules/ui_shared/src/ui/screens/chat/chat_protocol_support.cpp @@ -8,7 +8,7 @@ namespace chat::ui::support chat::MeshProtocol active_mesh_protocol() { - return app::configFacade().getConfig().mesh_protocol; + return app::configFacade().readConfig().mesh_protocol; } chat::MeshCapabilities active_mesh_capabilities() diff --git a/modules/ui_shared/src/ui/screens/chat/chat_ui_controller.cpp b/modules/ui_shared/src/ui/screens/chat/chat_ui_controller.cpp index 52f9ae86..a28d06c1 100644 --- a/modules/ui_shared/src/ui/screens/chat/chat_ui_controller.cpp +++ b/modules/ui_shared/src/ui/screens/chat/chat_ui_controller.cpp @@ -74,12 +74,12 @@ const char* channel_display_name(chat::MeshProtocol protocol, chat::ChannelId ch { if (protocol == chat::MeshProtocol::Meshtastic) { - return chat::meshtastic::channelName(app::configFacade().getConfig().meshtastic_config, + return chat::meshtastic::channelName(app::configFacade().readConfig().meshtastic_config, channel); } if (protocol == chat::MeshProtocol::MeshCore) { - const chat::MeshConfig& config = app::configFacade().getConfig().meshcore_config; + const chat::MeshConfig& config = app::configFacade().readConfig().meshcore_config; const chat::MeshCoreChannelConfig& channel_config = config.meshCoreChannel(chat::meshCoreChannelSlotFromId(channel)); if (channel_config.name[0] != '\0') diff --git a/modules/ui_shared/src/ui/screens/chat_watch/chat_message_list_components_watch.cpp b/modules/ui_shared/src/ui/screens/chat_watch/chat_message_list_components_watch.cpp index f4942873..06f9274d 100644 --- a/modules/ui_shared/src/ui/screens/chat_watch/chat_message_list_components_watch.cpp +++ b/modules/ui_shared/src/ui/screens/chat_watch/chat_message_list_components_watch.cpp @@ -22,7 +22,7 @@ const char* protocol_short_label(chat::MeshProtocol protocol) chat::MeshProtocol active_mesh_protocol() { - return app::configFacade().getConfig().mesh_protocol; + return app::configFacade().readConfig().mesh_protocol; } } // namespace diff --git a/modules/ui_shared/src/ui/screens/contacts/contacts_page_components.cpp b/modules/ui_shared/src/ui/screens/contacts/contacts_page_components.cpp index dffefc19..9903edd5 100644 --- a/modules/ui_shared/src/ui/screens/contacts/contacts_page_components.cpp +++ b/modules/ui_shared/src/ui/screens/contacts/contacts_page_components.cpp @@ -616,7 +616,7 @@ static bool get_broadcast_target_spec(int index, BroadcastTargetSpec* out) return false; } - const auto& cfg = app::appFacade().getConfig(); + const auto& cfg = app::appFacade().readConfig(); out->protocol = chat::MeshProtocol::Meshtastic; out->channel_index = static_cast(index); out->channel = (index == 1) ? chat::ChannelId::SECONDARY : chat::ChannelId::PRIMARY; @@ -643,7 +643,7 @@ static bool get_broadcast_target_spec(int index, BroadcastTargetSpec* out) { return false; } - const auto& cfg = app::appFacade().getConfig().meshcore_config; + const auto& cfg = app::appFacade().readConfig().meshcore_config; const uint8_t slot = static_cast(index); const chat::MeshCoreChannelConfig& channel = cfg.meshCoreChannel(slot); const bool has_key = @@ -660,14 +660,14 @@ static std::string format_broadcast_target_label(const BroadcastTargetSpec& spec { if (spec.protocol == chat::MeshProtocol::Meshtastic) { - return chat::meshtastic::channelName(app::appFacade().getConfig().meshtastic_config, + return chat::meshtastic::channelName(app::appFacade().readConfig().meshtastic_config, spec.channel); } if (chat::infra::isReticulumMeshProtocol(spec.protocol)) { return ::ui::i18n::tr("Primary Group"); } - const chat::MeshConfig& cfg = app::appFacade().getConfig().meshcore_config; + const chat::MeshConfig& cfg = app::appFacade().readConfig().meshcore_config; const chat::MeshCoreChannelConfig& channel = cfg.meshCoreChannel(spec.channel_index); const char* name = channel.name[0] != '\0' ? channel.name : nullptr; @@ -695,7 +695,7 @@ static std::string format_broadcast_target_status(const BroadcastTargetSpec& spe } if (spec.channel_index == 1) { - return chat::meshtastic::channelName(app::appFacade().getConfig().meshtastic_config, + return chat::meshtastic::channelName(app::appFacade().readConfig().meshtastic_config, spec.channel); } return spec.chat_supported ? ::ui::i18n::tr("Ready") : ::ui::i18n::tr("Slot"); @@ -704,7 +704,7 @@ static std::string format_broadcast_target_status(const BroadcastTargetSpec& spe { return ::ui::i18n::tr("Group destination"); } - const chat::MeshConfig& cfg = app::appFacade().getConfig().meshcore_config; + const chat::MeshConfig& cfg = app::appFacade().readConfig().meshcore_config; const chat::MeshCoreChannelConfig& channel = cfg.meshCoreChannel(spec.channel_index); if (!spec.enabled) @@ -3214,7 +3214,7 @@ static void on_team_conversation_back(void* /*user_data*/) lv_group_remove_all_objs(s_conv_group); set_default_group(s_conv_group); - const chat::MeshProtocol protocol = app::appFacade().getConfig().mesh_protocol; + const chat::MeshProtocol protocol = app::appFacade().readConfig().mesh_protocol; chat::ConversationId conv(chat::ChannelId::PRIMARY, 0, protocol); g_contacts_state.conversation_screen = new chat::ui::ChatConversationScreen(parent, conv); g_contacts_state.conversation_screen->setActionCallback(on_team_conversation_action, nullptr); diff --git a/modules/ui_shared/src/ui/screens/contacts/contacts_page_runtime.cpp b/modules/ui_shared/src/ui/screens/contacts/contacts_page_runtime.cpp index aed87c77..f8f1e697 100644 --- a/modules/ui_shared/src/ui/screens/contacts/contacts_page_runtime.cpp +++ b/modules/ui_shared/src/ui/screens/contacts/contacts_page_runtime.cpp @@ -368,7 +368,7 @@ bool node_matches_active_protocol(const chat::contacts::PeerDirectoryItem& node) { const chat::MeshProtocol active_protocol = chat::infra::normalizeMeshProtocol( - app::configFacade().getConfig().mesh_protocol); + app::configFacade().readConfig().mesh_protocol); if (chat::infra::isReticulumMeshProtocol(active_protocol)) { @@ -502,7 +502,7 @@ void merge_reticulum_directory_projection() { const chat::MeshProtocol active_protocol = chat::infra::normalizeMeshProtocol( - app::configFacade().getConfig().mesh_protocol); + app::configFacade().readConfig().mesh_protocol); if (!chat::infra::isReticulumMeshProtocol(active_protocol)) { return; @@ -573,7 +573,7 @@ void refresh_reticulum_groups_data() g_contacts_state.reticulum_group_list.clear(); const chat::MeshProtocol active_protocol = chat::infra::normalizeMeshProtocol( - app::configFacade().getConfig().mesh_protocol); + app::configFacade().readConfig().mesh_protocol); if (!chat::infra::isReticulumMeshProtocol(active_protocol)) { g_contacts_state.reticulum_group_storage_supported = false; @@ -749,7 +749,7 @@ void enter(const shell::Host* host, lv_obj_t* parent) "hydration_pending=%u\n", chat::infra::meshProtocolName( chat::infra::normalizeMeshProtocol( - app::configFacade().getConfig().mesh_protocol)), + app::configFacade().readConfig().mesh_protocol)), static_cast(g_contacts_state.contacts_list.size()), static_cast(g_contacts_state.nearby_list.size()), static_cast(g_contacts_state.reticulum_group_list.size()), diff --git a/modules/ui_shared/src/ui/screens/energy_sweep/energy_sweep_page_runtime.cpp b/modules/ui_shared/src/ui/screens/energy_sweep/energy_sweep_page_runtime.cpp index b865bd85..2be2d283 100644 --- a/modules/ui_shared/src/ui/screens/energy_sweep/energy_sweep_page_runtime.cpp +++ b/modules/ui_shared/src/ui/screens/energy_sweep/energy_sweep_page_runtime.cpp @@ -486,7 +486,7 @@ void apply_band_plan(float start_mhz, float end_mhz, float bw_khz) void setup_sweep_band_plan() { - const app::AppConfig& cfg = app::configFacade().getConfig(); + const app::AppConfig& cfg = app::configFacade().readConfig(); float start_mhz = kDefaultFreqStartMhz; float end_mhz = kDefaultFreqEndMhz; @@ -1288,7 +1288,7 @@ void setup_radio_context() s_radio = {}; setup_sweep_band_plan(); - const app::AppConfig& cfg = app::configFacade().getConfig(); + const app::AppConfig& cfg = app::configFacade().readConfig(); s_radio.bw_khz = s_band.bw_khz; if (cfg.mesh_protocol == chat::MeshProtocol::MeshCore) diff --git a/modules/ui_shared/src/ui/screens/gps/gps_page_runtime.cpp b/modules/ui_shared/src/ui/screens/gps/gps_page_runtime.cpp index f60dc0c9..346afdee 100644 --- a/modules/ui_shared/src/ui/screens/gps/gps_page_runtime.cpp +++ b/modules/ui_shared/src/ui/screens/gps/gps_page_runtime.cpp @@ -358,7 +358,7 @@ void sync_workspace_viewport_from_renderer() bool sync_workspace_center_from_screen() { - if (app::configFacade().getConfig().map_coord_system != 0) + if (app::configFacade().readConfig().map_coord_system != 0) { return false; } @@ -399,7 +399,7 @@ bool commit_pending_map_pan_from_screen() ::ui::widgets::map::Model build_map_model( const ::ui::map::MapWorkspaceSnapshot& snapshot) { - const auto& config = app::configFacade().getConfig(); + const auto& config = app::configFacade().readConfig(); ::ui::widgets::map::Model model{}; const bool has_viewport_center = has_valid_viewport_center(snapshot.viewport); @@ -460,7 +460,7 @@ bool format_current_gps_map_title(char* out, size_t out_len) char coord_buf[64]{}; ui_format_coords(gps.lat, gps.lng, - app::configFacade().getConfig().gps_coord_format, + app::configFacade().readConfig().gps_coord_format, coord_buf, sizeof(coord_buf)); if (coord_buf[0] == '\0') @@ -771,7 +771,7 @@ void rebuild_map_control_group() bool route_context_available() { - const auto& config = app::configFacade().getConfig(); + const auto& config = app::configFacade().readConfig(); return config.route_enabled && config.route_path[0] != '\0'; } @@ -817,7 +817,7 @@ bool route_path_looks_degraded(const std::string& path) bool resolve_configured_route_path(std::string& out_path, bool show_fail_toast) { auto& config_facade = app::configFacade(); - const auto& config = config_facade.getConfig(); + const auto& config = config_facade.readConfig(); if (!config.route_enabled || config.route_path[0] == '\0') { out_path.clear(); @@ -3291,7 +3291,7 @@ void center_map_on_self() { const auto result = map_workspace_model().centerOnSelf(); const auto snapshot = map_workspace_model().snapshot(); - const auto& config = app::configFacade().getConfig(); + const auto& config = app::configFacade().readConfig(); if (result.ok) { s_map_pan_x = 0; diff --git a/modules/ui_shared/src/ui/screens/network/network_page_shell.cpp b/modules/ui_shared/src/ui/screens/network/network_page_shell.cpp index c56af1d3..c3f7e628 100644 --- a/modules/ui_shared/src/ui/screens/network/network_page_shell.cpp +++ b/modules/ui_shared/src/ui/screens/network/network_page_shell.cpp @@ -1108,7 +1108,7 @@ bool reticulum_active() { return false; } - const app::AppConfig& config = app::configFacade().getConfig(); + const app::AppConfig& config = app::configFacade().readConfig(); return chat::infra::isReticulumMeshProtocol(config.mesh_protocol); } diff --git a/modules/ui_shared/src/ui/screens/node_info/node_info_page_components.cpp b/modules/ui_shared/src/ui/screens/node_info/node_info_page_components.cpp index 70844cee..23b70441 100644 --- a/modules/ui_shared/src/ui/screens/node_info/node_info_page_components.cpp +++ b/modules/ui_shared/src/ui/screens/node_info/node_info_page_components.cpp @@ -1080,7 +1080,7 @@ map_viewport::Model build_map_model(const map_viewport::GeoPoint& node_point, model.pan_x = pan_x + static_cast(metrics.focus_x) - (metrics.width / 2); model.pan_y = pan_y + static_cast(metrics.focus_y) - (metrics.height / 2); - const auto& cfg = app::configFacade().getConfig(); + const auto& cfg = app::configFacade().readConfig(); model.map_source = cfg.map_source; model.contour_enabled = cfg.map_contour_enabled; model.coord_system = cfg.map_coord_system; diff --git a/modules/ui_shared/src/ui/screens/settings/settings_page_components.cpp b/modules/ui_shared/src/ui/screens/settings/settings_page_components.cpp index 7b3f9fff..524bee96 100644 --- a/modules/ui_shared/src/ui/screens/settings/settings_page_components.cpp +++ b/modules/ui_shared/src/ui/screens/settings/settings_page_components.cpp @@ -1178,7 +1178,7 @@ static void refresh_reticulum_identity_fields_from_runtime() return; } app::IAppFacade& app_ctx = app::appFacade(); - refresh_reticulum_identity_fields(app_ctx, app_ctx.getConfig()); + refresh_reticulum_identity_fields(app_ctx, app_ctx.readConfig()); } static void float_to_text(float value, char* out, size_t out_len, uint8_t decimals = 2) @@ -1323,51 +1323,51 @@ static void reset_mesh_settings() } app_ctx.applyMeshConfig(); - g_settings.chat_protocol = static_cast(app_ctx.getConfig().mesh_protocol); - g_settings.chat_region = app_ctx.getConfig().meshtastic_config.region; + g_settings.chat_protocol = static_cast(app_ctx.readConfig().mesh_protocol); + g_settings.chat_region = app_ctx.readConfig().meshtastic_config.region; g_settings.chat_channel = 0; g_settings.chat_psk[0] = '\0'; - ::settings::ui::channel::sync_meshtastic_channel_fields(app_ctx.getConfig(), g_settings); - g_settings.net_use_preset = app_ctx.getConfig().meshtastic_config.use_preset; - g_settings.net_modem_preset = app_ctx.getConfig().meshtastic_config.modem_preset; - g_settings.net_tx_power = app_ctx.getConfig().activeMeshConfig().tx_power; - g_settings.net_hop_limit = app_ctx.getConfig().meshtastic_config.hop_limit; - const chat::MeshConfig& active_cfg = app_ctx.getConfig().activeMeshConfig(); + ::settings::ui::channel::sync_meshtastic_channel_fields(app_ctx.readConfig(), g_settings); + g_settings.net_use_preset = app_ctx.readConfig().meshtastic_config.use_preset; + g_settings.net_modem_preset = app_ctx.readConfig().meshtastic_config.modem_preset; + g_settings.net_tx_power = app_ctx.readConfig().activeMeshConfig().tx_power; + g_settings.net_hop_limit = app_ctx.readConfig().meshtastic_config.hop_limit; + const chat::MeshConfig& active_cfg = app_ctx.readConfig().activeMeshConfig(); g_settings.net_tx_enabled = active_cfg.tx_enabled; - g_settings.net_relay = app_ctx.getConfig().meshtastic_config.enable_relay; + g_settings.net_relay = app_ctx.readConfig().meshtastic_config.enable_relay; g_settings.net_duty_cycle = true; g_settings.net_channel_util = 0; g_settings.rt_bearer_policy = - reticulum_bearer_policy_to_value(app_ctx.getConfig().reticulumConfig().reticulum_interface_policy); - g_settings.rt_lora_enabled = app_ctx.getConfig().reticulumConfig().reticulum_lora_enabled; + reticulum_bearer_policy_to_value(app_ctx.readConfig().reticulumConfig().reticulum_interface_policy); + g_settings.rt_lora_enabled = app_ctx.readConfig().reticulumConfig().reticulum_lora_enabled; g_settings.rt_wifi_gateway_enabled = - app_ctx.getConfig().reticulumConfig().reticulum_wifi_gateway_enabled; + app_ctx.readConfig().reticulumConfig().reticulum_wifi_gateway_enabled; g_settings.rt_wifi_auto_connect = - app_ctx.getConfig().reticulumConfig().reticulum_wifi_auto_connect; + app_ctx.readConfig().reticulumConfig().reticulum_wifi_auto_connect; g_settings.rt_anonymous_peer = - app_ctx.getConfig().reticulumConfig().reticulum_anonymous_peer; + app_ctx.readConfig().reticulumConfig().reticulum_anonymous_peer; g_settings.rt_location_requests = - app_ctx.getConfig().reticulumConfig().reticulum_allow_location_requests; - g_settings.mt_mqtt_enabled = app_ctx.getConfig().meshtastic_mqtt_enabled; - g_settings.mt_mqtt_uplink = app_ctx.getConfig().meshtastic_mqtt_uplink_enabled; - g_settings.mt_mqtt_downlink = app_ctx.getConfig().meshtastic_mqtt_downlink_enabled; + app_ctx.readConfig().reticulumConfig().reticulum_allow_location_requests; + g_settings.mt_mqtt_enabled = app_ctx.readConfig().meshtastic_mqtt_enabled; + g_settings.mt_mqtt_uplink = app_ctx.readConfig().meshtastic_mqtt_uplink_enabled; + g_settings.mt_mqtt_downlink = app_ctx.readConfig().meshtastic_mqtt_downlink_enabled; copy_bounded(g_settings.mt_mqtt_host, sizeof(g_settings.mt_mqtt_host), - app_ctx.getConfig().meshtastic_mqtt_host); + app_ctx.readConfig().meshtastic_mqtt_host); std::snprintf(g_settings.mt_mqtt_port, sizeof(g_settings.mt_mqtt_port), "%u", - static_cast(app_ctx.getConfig().meshtastic_mqtt_port)); + static_cast(app_ctx.readConfig().meshtastic_mqtt_port)); copy_bounded(g_settings.mt_mqtt_root, sizeof(g_settings.mt_mqtt_root), - app_ctx.getConfig().meshtastic_mqtt_root); + app_ctx.readConfig().meshtastic_mqtt_root); copy_bounded(g_settings.mt_mqtt_user, sizeof(g_settings.mt_mqtt_user), - app_ctx.getConfig().meshtastic_mqtt_username); + app_ctx.readConfig().meshtastic_mqtt_username); copy_bounded(g_settings.mt_mqtt_pass, sizeof(g_settings.mt_mqtt_pass), - app_ctx.getConfig().meshtastic_mqtt_password); - g_settings.mc_region_preset = app_ctx.getConfig().meshcore_config.meshcore_region_preset; + app_ctx.readConfig().meshtastic_mqtt_password); + g_settings.mc_region_preset = app_ctx.readConfig().meshcore_config.meshcore_region_preset; static const char* kResetKeys[] = { "mesh_protocol", @@ -1499,7 +1499,7 @@ static void settings_load() bind_dynamic_option_storage_to_items(); auto& options = dynamic_options(); app::IAppFacade& app_ctx = app::appFacade(); - g_settings.chat_protocol = static_cast(app_ctx.getConfig().mesh_protocol); + g_settings.chat_protocol = static_cast(app_ctx.readConfig().mesh_protocol); if (kChatRegionOptionCount == 0) { @@ -1560,7 +1560,7 @@ static void settings_load() sizeof(g_settings.user_name), g_settings.short_name, sizeof(g_settings.short_name)); - const app::AppConfig& cfg = app_ctx.getConfig(); + const app::AppConfig& cfg = app_ctx.readConfig(); const chat::MeshConfig& mt_cfg = cfg.meshtastic_config; const chat::MeshConfig& mc_cfg = cfg.meshcore_config; const chat::MeshConfig& reticulum_cfg = cfg.reticulumConfig(); @@ -2356,7 +2356,7 @@ static void on_text_save_clicked(lv_event_t* e) uint8_t key[chat::kMeshtasticChannelKeyMaxLen] = {}; size_t parsed_key_len = 0; const size_t key_capacity = - (app_ctx.getConfig().mesh_protocol == chat::MeshProtocol::MeshCore) + (app_ctx.readConfig().mesh_protocol == chat::MeshProtocol::MeshCore) ? chat::kMeshCoreChannelKeyLen : chat::kMeshtasticChannelKeyMaxLen; if (!::settings::ui::channel::parse_psk(g_state.editing_item->text_value, @@ -3680,7 +3680,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_baud = static_cast(payload->value); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsInitProbeMs) { @@ -3701,7 +3701,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_probe_ms = static_cast(probe_ms); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsInitProfile) { @@ -3713,7 +3713,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_profile = static_cast(payload->value); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsInitRxm) { @@ -3725,7 +3725,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_rxm_policy = static_cast(payload->value); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsInitGnss) { @@ -3737,7 +3737,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_gnss_policy = static_cast(payload->value); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsInitNmea) { @@ -3749,7 +3749,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_init_nmea_policy = static_cast(payload->value); }); - gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.getConfig())); + gps_runtime::set_receiver_init_config(make_gps_receiver_init_config(app_ctx.readConfig())); } if (id == settings::ui::SettingId::GpsMode) { @@ -3761,7 +3761,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_mode = static_cast(payload->value); }); - gps_runtime::set_gnss_config(app_ctx.getConfig().gps_mode, app_ctx.getConfig().gps_sat_mask); + gps_runtime::set_gnss_config(app_ctx.readConfig().gps_mode, app_ctx.readConfig().gps_sat_mask); } if (id == settings::ui::SettingId::GpsSatMask) { @@ -3773,7 +3773,7 @@ static void on_option_clicked(lv_event_t* e) { config.gps_sat_mask = static_cast(payload->value); }); - gps_runtime::set_gnss_config(app_ctx.getConfig().gps_mode, app_ctx.getConfig().gps_sat_mask); + gps_runtime::set_gnss_config(app_ctx.readConfig().gps_mode, app_ctx.readConfig().gps_sat_mask); } if (id == settings::ui::SettingId::GpsStrategy) { @@ -4074,8 +4074,8 @@ static void on_option_clicked(lv_event_t* e) config.external_nmea_output_hz = static_cast(payload->value); }); - gps_runtime::set_external_nmea_config(app_ctx.getConfig().external_nmea_output_hz, - app_ctx.getConfig().external_nmea_sentence_mask); + gps_runtime::set_external_nmea_config(app_ctx.readConfig().external_nmea_output_hz, + app_ctx.readConfig().external_nmea_sentence_mask); } if (id == settings::ui::SettingId::ExternalNmeaSent) { @@ -4088,8 +4088,8 @@ static void on_option_clicked(lv_event_t* e) config.external_nmea_sentence_mask = static_cast(payload->value); }); - gps_runtime::set_external_nmea_config(app_ctx.getConfig().external_nmea_output_hz, - app_ctx.getConfig().external_nmea_sentence_mask); + gps_runtime::set_external_nmea_config(app_ctx.readConfig().external_nmea_output_hz, + app_ctx.readConfig().external_nmea_sentence_mask); } if (id == settings::ui::SettingId::TimezoneProfile) { diff --git a/modules/ui_shared/src/ui/screens/tracker/tracker_page_components.cpp b/modules/ui_shared/src/ui/screens/tracker/tracker_page_components.cpp index 7ac6cba1..00b73ce6 100644 --- a/modules/ui_shared/src/ui/screens/tracker/tracker_page_components.cpp +++ b/modules/ui_shared/src/ui/screens/tracker/tracker_page_components.cpp @@ -560,7 +560,7 @@ bool repair_degraded_active_route_from_list() { auto& state = g_tracker_state; app::IAppFacade& app_ctx = app::appFacade(); - const auto& cfg = app_ctx.getConfig(); + const auto& cfg = app_ctx.readConfig(); if (!cfg.route_enabled || cfg.route_path[0] == '\0') { return false; @@ -1310,7 +1310,7 @@ bool preview_model_fits_bounds(lv_obj_t* viewport_root, const auto layers = ::ui::widgets::map::current_layer_state(); model.map_source = layers.map_source; model.contour_enabled = layers.contour_enabled; - model.coord_system = app::configFacade().getConfig().map_coord_system; + model.coord_system = app::configFacade().readConfig().map_coord_system; model.zoom = ::ui::widgets::map::kDefaultZoom; model.focus_point.valid = bounds.valid; model.focus_point.lat = bounds.valid ? (bounds.min_lat + bounds.max_lat) / 2.0 : 0.0; @@ -3500,7 +3500,7 @@ void sync_active_route_from_config() { auto& state = g_tracker_state; app::IAppFacade& app_ctx = app::appFacade(); - const auto& cfg = app_ctx.getConfig(); + const auto& cfg = app_ctx.readConfig(); if (cfg.route_enabled && cfg.route_path[0] != '\0') { const char* base = strrchr(cfg.route_path, '/'); diff --git a/modules/ui_shared/src/ui/ui_status.cpp b/modules/ui_shared/src/ui/ui_status.cpp index 9a9116f8..59285188 100644 --- a/modules/ui_shared/src/ui/ui_status.cpp +++ b/modules/ui_shared/src/ui/ui_status.cpp @@ -150,7 +150,7 @@ StatusSnapshot collect_status() if (app::hasAppFacade()) { - const auto& cfg = app::configFacade().getConfig(); + const auto& cfg = app::configFacade().readConfig(); snap.route_active = cfg.route_enabled && (cfg.route_path[0] != '\0'); #if TRAIL_MATE_ENABLE_BLE && !defined(TRAIL_MATE_FINAL_IDF_NO_APP_FACADE) snap.ble_enabled = app::runtimeFacade().isBleEnabled(); diff --git a/modules/ui_shared/src/ui/widgets/map/map_viewport.cpp b/modules/ui_shared/src/ui/widgets/map/map_viewport.cpp index 56003387..2fa6b483 100644 --- a/modules/ui_shared/src/ui/widgets/map/map_viewport.cpp +++ b/modules/ui_shared/src/ui/widgets/map/map_viewport.cpp @@ -1159,7 +1159,7 @@ bool transform_geo_point(const GeoPoint& point, uint8_t coord_system, GeoPoint& LayerState current_layer_state() { - const auto& cfg = app::configFacade().getConfig(); + const auto& cfg = app::configFacade().readConfig(); LayerState state{}; state.map_source = sanitize_map_source(cfg.map_source); state.contour_enabled = cfg.map_contour_enabled; @@ -1187,14 +1187,14 @@ bool set_layer_map_source(uint8_t map_source, LayerNotice* out_notice) clear_layer_notice(out_notice); app::IAppConfigFacade& config_api = app::configFacade(); - const uint8_t previous = sanitize_map_source(config_api.getConfig().map_source); + const uint8_t previous = sanitize_map_source(config_api.readConfig().map_source); const uint8_t normalized = sanitize_map_source(map_source); const bool changed = previous != normalized; MAP_VIEWPORT_LOG("set_layer_map_source from=%u to=%u contour=%d changed=%d\n", static_cast(previous), static_cast(normalized), - config_api.getConfig().map_contour_enabled ? 1 : 0, + config_api.readConfig().map_contour_enabled ? 1 : 0, changed ? 1 : 0); if (changed) @@ -1228,13 +1228,13 @@ bool toggle_layer_contour(LayerNotice* out_notice) clear_layer_notice(out_notice); app::IAppConfigFacade& config_api = app::configFacade(); - const bool previous = config_api.getConfig().map_contour_enabled; + const bool previous = config_api.readConfig().map_contour_enabled; const bool enabled = !previous; MAP_VIEWPORT_LOG("toggle_layer_contour from=%d to=%d src=%u\n", previous ? 1 : 0, enabled ? 1 : 0, - static_cast(sanitize_map_source(config_api.getConfig().map_source))); + static_cast(sanitize_map_source(config_api.readConfig().map_source))); auto edit = config_api.beginConfigEdit(); if (!edit) diff --git a/platform/esp/arduino_common/include/app/app_context.h b/platform/esp/arduino_common/include/app/app_context.h index 5001b80e..6abe6878 100644 --- a/platform/esp/arduino_common/include/app/app_context.h +++ b/platform/esp/arduino_common/include/app/app_context.h @@ -118,16 +118,13 @@ class AppContext final : public IAppBleFacade } } - [[deprecated("Use beginConfigEdit() for configuration writes")]] AppConfig& getConfig() override - { - return config_; - } - + protected: const AppConfig& getConfig() const override { return config_; } + public: chat::MeshProtocol getMeshProtocol() const override { return config_.mesh_protocol; diff --git a/platform/esp/arduino_common/src/app_context_platform_bindings.cpp b/platform/esp/arduino_common/src/app_context_platform_bindings.cpp index 7acb613c..176e9c35 100644 --- a/platform/esp/arduino_common/src/app_context_platform_bindings.cpp +++ b/platform/esp/arduino_common/src/app_context_platform_bindings.cpp @@ -108,7 +108,7 @@ void init_track_recorder(const app::AppConfig& config) void deferred_storage_ready(app::IAppFacade& app_facade) { - const app::AppConfig& config = app_facade.getConfig(); + const app::AppConfig& config = app_facade.readConfig(); if (chat::infra::isReticulumMeshProtocol( chat::infra::normalizeMeshProtocol(config.mesh_protocol))) { diff --git a/platform/esp/arduino_common/src/app_runtime_support.cpp b/platform/esp/arduino_common/src/app_runtime_support.cpp index 3cfd441c..8a5f33e9 100644 --- a/platform/esp/arduino_common/src/app_runtime_support.cpp +++ b/platform/esp/arduino_common/src/app_runtime_support.cpp @@ -574,12 +574,12 @@ std::unique_ptr createBleManager(app::IAppBleFacade& app_facade { #if TRAIL_MATE_ENABLE_BLE std::unique_ptr ble_manager(new ble::BleManager(app_facade)); - if (app_facade.getConfig().ble_enabled && + if (app_facade.readConfig().ble_enabled && !mesh_mqtt::wantsStandaloneMode(app_facade)) { ble_manager->setEnabled(true); } - else if (app_facade.getConfig().ble_enabled) + else if (app_facade.readConfig().ble_enabled) { std::printf("[MQTT] BLE startup skipped for standalone mesh MQTT mode\n"); } diff --git a/platform/esp/arduino_common/src/ble/app_phone_facade.cpp b/platform/esp/arduino_common/src/ble/app_phone_facade.cpp index 635036d8..112f6f5c 100644 --- a/platform/esp/arduino_common/src/ble/app_phone_facade.cpp +++ b/platform/esp/arduino_common/src/ble/app_phone_facade.cpp @@ -155,7 +155,7 @@ void AppPhoneFacade::syncMeshtasticMqttProxySettings(const meshtastic_LocalModul phone::MeshtasticPhoneConfigSnapshot AppPhoneFacade::getMeshtasticPhoneConfig() const { - return platform::shared::ble_bridge::makeMeshtasticPhoneConfigSnapshot(app_.getConfig()); + return platform::shared::ble_bridge::makeMeshtasticPhoneConfigSnapshot(app_.readConfig()); } void AppPhoneFacade::setMeshtasticPhoneConfig(const phone::MeshtasticPhoneConfigSnapshot& config) @@ -171,7 +171,7 @@ void AppPhoneFacade::setMeshtasticPhoneConfig(const phone::MeshtasticPhoneConfig phone::MeshCorePhoneConfigSnapshot AppPhoneFacade::getMeshCorePhoneConfig() const { - return platform::shared::ble_bridge::makeMeshCorePhoneConfigSnapshot(app_.getConfig()); + return platform::shared::ble_bridge::makeMeshCorePhoneConfigSnapshot(app_.readConfig()); } void AppPhoneFacade::setMeshCorePhoneConfig(const phone::MeshCorePhoneConfigSnapshot& config) @@ -609,7 +609,7 @@ bool AppPhoneFacade::getTuningParams(phone::meshcore::MeshCorePhoneTuningParams* chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() { auto* adapter = app_.getMeshAdapter(); - if (!adapter || app_.getConfig().mesh_protocol != chat::MeshProtocol::MeshCore) + if (!adapter || app_.readConfig().mesh_protocol != chat::MeshProtocol::MeshCore) { return nullptr; } @@ -623,7 +623,7 @@ chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() const chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() const { auto* adapter = app_.getMeshAdapter(); - if (!adapter || app_.getConfig().mesh_protocol != chat::MeshProtocol::MeshCore) + if (!adapter || app_.readConfig().mesh_protocol != chat::MeshProtocol::MeshCore) { return nullptr; } diff --git a/platform/esp/arduino_common/src/chat/infra/mesh_mqtt_client_runtime.cpp b/platform/esp/arduino_common/src/chat/infra/mesh_mqtt_client_runtime.cpp index b45cccbe..50980249 100644 --- a/platform/esp/arduino_common/src/chat/infra/mesh_mqtt_client_runtime.cpp +++ b/platform/esp/arduino_common/src/chat/infra/mesh_mqtt_client_runtime.cpp @@ -199,11 +199,11 @@ class PlainMqttRuntime { if (app_context.getMeshProtocol() == chat::MeshProtocol::Meshtastic) { - return meshtasticMqttConfigured(app_context.getConfig()); + return meshtasticMqttConfigured(app_context.readConfig()); } if (app_context.getMeshProtocol() == chat::MeshProtocol::MeshCore) { - return meshCoreMqttConfigured(app_context.getConfig().meshcore_config); + return meshCoreMqttConfigured(app_context.readConfig().meshcore_config); } return false; } @@ -502,7 +502,7 @@ class PlainMqttRuntime void buildMeshtasticEffectiveConfig(app::IAppFacade& app_context, EffectiveConfig& out) { - const app::AppConfig& config = app_context.getConfig(); + const app::AppConfig& config = app_context.readConfig(); if (!meshtasticMqttConfigured(config)) { return; @@ -533,7 +533,7 @@ class PlainMqttRuntime void buildMeshCoreEffectiveConfig(app::IAppFacade& app_context, EffectiveConfig& out) { - const chat::MeshConfig& config = app_context.getConfig().meshcore_config; + const chat::MeshConfig& config = app_context.readConfig().meshcore_config; if (!meshCoreMqttConfigured(config)) { return; @@ -646,7 +646,7 @@ class PlainMqttRuntime chat::meshtastic::MtAdapter& mt) { chat::meshtastic::MtAdapter::MqttProxySettings settings; - const app::AppConfig& config = app_context.getConfig(); + const app::AppConfig& config = app_context.readConfig(); settings.enabled = config_.configured; settings.proxy_to_client_enabled = config_.configured; settings.encryption_enabled = false; diff --git a/platform/esp/arduino_common/src/chat/infra/meshtastic/mt_adapter.cpp b/platform/esp/arduino_common/src/chat/infra/meshtastic/mt_adapter.cpp index 81c2d5d7..2a3db90e 100644 --- a/platform/esp/arduino_common/src/chat/infra/meshtastic/mt_adapter.cpp +++ b/platform/esp/arduino_common/src/chat/infra/meshtastic/mt_adapter.cpp @@ -3268,7 +3268,7 @@ bool MtAdapter::sendNodeInfoTo(uint32_t dest, bool want_response, ChannelId chan (void)chat::runtime::resolveEffectiveSelfIdentity(identity_input, &identity); char user_id_override[16] = {}; - const app::AppConfig& cfg = app::configFacade().getConfig(); + const app::AppConfig& cfg = app::configFacade().readConfig(); if (cfg.aprs.self_enable && cfg.aprs.self_callsign[0] != '\0') { strncpy(user_id_override, cfg.aprs.self_callsign, sizeof(user_id_override) - 1); diff --git a/platform/esp/arduino_common/src/hostlink/hostlink_config_service.cpp b/platform/esp/arduino_common/src/hostlink/hostlink_config_service.cpp index a25b1f1e..18a7005f 100644 --- a/platform/esp/arduino_common/src/hostlink/hostlink_config_service.cpp +++ b/platform/esp/arduino_common/src/hostlink/hostlink_config_service.cpp @@ -35,7 +35,7 @@ bool build_status_payload(std::vector& out, uint8_t link_state, uint32_ { const platform::ui::device::BatteryInfo battery_info = platform::ui::device::battery_info(); app::IAppConfigFacade& config_api = app::configFacade(); - app::AppConfig& cfg = config_api.getConfig(); + const app::AppConfig& cfg = config_api.readConfig(); hostlink::bridge::AppRxStats stats = hostlink::bridge::get_app_rx_stats(); StatusPayloadSnapshot snapshot; @@ -95,7 +95,7 @@ bool apply_config(const uint8_t* data, size_t len, uint32_t* out_err) app::IAppConfigFacade& config_api = app::configFacade(); app::IAppMessagingFacade& messaging_api = app::messagingFacade(); - const app::AppConfig& current_config = config_api.getConfig(); + const app::AppConfig& current_config = config_api.readConfig(); const chat::MeshProtocol original_protocol = current_config.mesh_protocol; bool mesh_changed = false; bool net_changed = false; @@ -250,7 +250,7 @@ bool apply_config(const uint8_t* data, size_t len, uint32_t* out_err) if (chat_changed) { messaging_api.getChatService().switchChannel( - static_cast(config_api.getConfig().chat_channel)); + static_cast(config_api.readConfig().chat_channel)); } if (protocol_changed) { diff --git a/platform/esp/arduino_common/src/hostlink/hostlink_service.cpp b/platform/esp/arduino_common/src/hostlink/hostlink_service.cpp index e376b4b4..007e4a5a 100644 --- a/platform/esp/arduino_common/src/hostlink/hostlink_service.cpp +++ b/platform/esp/arduino_common/src/hostlink/hostlink_service.cpp @@ -44,7 +44,7 @@ constexpr uint8_t kCmdTxAppFlagTeamMgmtPlain = 1 << 1; uint8_t active_protocol_channel_limit() { - const chat::MeshProtocol protocol = app::appFacade().getConfig().mesh_protocol; + const chat::MeshProtocol protocol = app::appFacade().readConfig().mesh_protocol; if (protocol == chat::MeshProtocol::MeshCore) { return static_cast(chat::kMeshCoreChannelMaxCount); diff --git a/platform/esp/arduino_common/src/platform_ui_hostlink_runtime.cpp b/platform/esp/arduino_common/src/platform_ui_hostlink_runtime.cpp index ba2289ea..6c01da6a 100644 --- a/platform/esp/arduino_common/src/platform_ui_hostlink_runtime.cpp +++ b/platform/esp/arduino_common/src/platform_ui_hostlink_runtime.cpp @@ -13,7 +13,7 @@ namespace bool use_rnode_bridge() { - return app::appFacade().getConfig().mesh_protocol == chat::MeshProtocol::RNode; + return app::appFacade().readConfig().mesh_protocol == chat::MeshProtocol::RNode; } } // namespace diff --git a/platform/esp/arduino_common/src/platform_ui_settings_backup_runtime.cpp b/platform/esp/arduino_common/src/platform_ui_settings_backup_runtime.cpp index e56f6133..9e713f12 100644 --- a/platform/esp/arduino_common/src/platform_ui_settings_backup_runtime.cpp +++ b/platform/esp/arduino_common/src/platform_ui_settings_backup_runtime.cpp @@ -1165,7 +1165,7 @@ cJSON* create_backup_document() add_string(root, "firmware", ::platform::ui::device::firmware_version()); add_uint(root, "created_ms", uptime_ms()); - cJSON* app_config = create_app_config_json(facade.getConfig()); + cJSON* app_config = create_app_config_json(facade.readConfig()); if (!app_config) { cJSON_Delete(root); diff --git a/platform/esp/arduino_common/src/rnode_kiss/rnode_kiss_service.cpp b/platform/esp/arduino_common/src/rnode_kiss/rnode_kiss_service.cpp index 6519a692..9d636c3b 100644 --- a/platform/esp/arduino_common/src/rnode_kiss/rnode_kiss_service.cpp +++ b/platform/esp/arduino_common/src/rnode_kiss/rnode_kiss_service.cpp @@ -117,7 +117,7 @@ bool apply_live_config() return false; } - backend->applyConfig(app::appFacade().getConfig().reticulumConfig()); + backend->applyConfig(app::appFacade().readConfig().reticulumConfig()); return true; } @@ -248,7 +248,7 @@ void send_ready() void reply_current_config(uint8_t command) { - const chat::MeshConfig& cfg = app::appFacade().getConfig().reticulumConfig(); + const chat::MeshConfig& cfg = app::appFacade().readConfig().reticulumConfig(); switch (command) { case kCmdFrequency: diff --git a/platform/esp/arduino_common/src/walkie/walkie_service.cpp b/platform/esp/arduino_common/src/walkie/walkie_service.cpp index 93eedcf1..44cbb81e 100644 --- a/platform/esp/arduino_common/src/walkie/walkie_service.cpp +++ b/platform/esp/arduino_common/src/walkie/walkie_service.cpp @@ -789,7 +789,7 @@ bool start() std::printf("[WALKIE] acquire walkie runtime\n"); - auto& config = app::configFacade().getConfig(); + const auto& config = app::configFacade().readConfig(); float freq_mhz = chat::meshtastic::estimateFrequencyMhz(config.meshtastic_config.region, config.meshtastic_config.modem_preset); if (freq_mhz <= 0.0f) diff --git a/platform/esp/idf_common/src/ble_manager_stub.cpp b/platform/esp/idf_common/src/ble_manager_stub.cpp index f38120fa..93a43595 100644 --- a/platform/esp/idf_common/src/ble_manager_stub.cpp +++ b/platform/esp/idf_common/src/ble_manager_stub.cpp @@ -6,7 +6,7 @@ namespace ble { BleManager::BleManager(app::IAppBleFacade& ctx) - : ctx_(ctx), active_protocol_(ctx.getConfig().mesh_protocol) + : ctx_(ctx), active_protocol_(ctx.readConfig().mesh_protocol) { } diff --git a/platform/esp/idf_common/src/platform_ui_hostlink_runtime.cpp b/platform/esp/idf_common/src/platform_ui_hostlink_runtime.cpp index 835529ca..660da94c 100644 --- a/platform/esp/idf_common/src/platform_ui_hostlink_runtime.cpp +++ b/platform/esp/idf_common/src/platform_ui_hostlink_runtime.cpp @@ -12,7 +12,7 @@ namespace bool use_rnode_bridge() { - return app::appFacade().getConfig().mesh_protocol == chat::MeshProtocol::RNode; + return app::appFacade().readConfig().mesh_protocol == chat::MeshProtocol::RNode; } } // namespace diff --git a/platform/linux/common/include/app/linux_app_facade.h b/platform/linux/common/include/app/linux_app_facade.h index 2eb3d557..88b77d79 100644 --- a/platform/linux/common/include/app/linux_app_facade.h +++ b/platform/linux/common/include/app/linux_app_facade.h @@ -31,8 +31,10 @@ class MinimalLinuxAppFacade final : public ::app::IAppFacade void shutdown(); bool is_initialized() const noexcept; - [[deprecated("Use beginConfigEdit() for configuration writes")]] ::app::AppConfig& getConfig() override; + protected: const ::app::AppConfig& getConfig() const override; + + public: ::app::AppConfigEdit beginConfigEdit() override; void saveConfig() override; void saveConfig(::app::AppConfigChangeSet changes) override; diff --git a/platform/linux/common/src/app/linux_app_facade.cpp b/platform/linux/common/src/app/linux_app_facade.cpp index e8de87b0..a4ec93da 100644 --- a/platform/linux/common/src/app/linux_app_facade.cpp +++ b/platform/linux/common/src/app/linux_app_facade.cpp @@ -118,11 +118,6 @@ bool MinimalLinuxAppFacade::is_initialized() const noexcept return services_.isInitialized(); } -::app::AppConfig& MinimalLinuxAppFacade::getConfig() -{ - return services_.getConfig(); -} - const ::app::AppConfig& MinimalLinuxAppFacade::getConfig() const { return services_.getConfig(); diff --git a/platform/nrf52/arduino_common/src/ble/app_phone_facade.cpp b/platform/nrf52/arduino_common/src/ble/app_phone_facade.cpp index 836d8665..28219350 100644 --- a/platform/nrf52/arduino_common/src/ble/app_phone_facade.cpp +++ b/platform/nrf52/arduino_common/src/ble/app_phone_facade.cpp @@ -140,22 +140,22 @@ void AppPhoneFacade::syncMeshtasticMqttProxySettings(const meshtastic_LocalModul phone::MeshtasticPhoneConfigSnapshot AppPhoneFacade::getMeshtasticPhoneConfig() const { - return platform::shared::ble_bridge::makeMeshtasticPhoneConfigSnapshot(app_.getConfig()); + return platform::shared::ble_bridge::makeMeshtasticPhoneConfigSnapshot(app_.readConfig()); } void AppPhoneFacade::setMeshtasticPhoneConfig(const phone::MeshtasticPhoneConfigSnapshot& config) { - platform::shared::ble_bridge::applyMeshtasticPhoneConfigSnapshot(app_.getConfig(), config); + platform::shared::ble_bridge::applyMeshtasticPhoneConfigSnapshot(app_.readConfig(), config); } phone::MeshCorePhoneConfigSnapshot AppPhoneFacade::getMeshCorePhoneConfig() const { - return platform::shared::ble_bridge::makeMeshCorePhoneConfigSnapshot(app_.getConfig()); + return platform::shared::ble_bridge::makeMeshCorePhoneConfigSnapshot(app_.readConfig()); } void AppPhoneFacade::setMeshCorePhoneConfig(const phone::MeshCorePhoneConfigSnapshot& config) { - platform::shared::ble_bridge::applyMeshCorePhoneConfigSnapshot(app_.getConfig(), config); + platform::shared::ble_bridge::applyMeshCorePhoneConfigSnapshot(app_.readConfig(), config); } void AppPhoneFacade::saveConfig() @@ -576,7 +576,7 @@ bool AppPhoneFacade::setCustomVar(const char* key, const char* value) chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() { auto* adapter = app_.getMeshAdapter(); - if (!adapter || app_.getConfig().mesh_protocol != chat::MeshProtocol::MeshCore) + if (!adapter || app_.readConfig().mesh_protocol != chat::MeshProtocol::MeshCore) { return nullptr; } @@ -590,7 +590,7 @@ chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() const chat::meshcore::IMeshCoreBleBackend* AppPhoneFacade::meshCoreBackend() const { auto* adapter = app_.getMeshAdapter(); - if (!adapter || app_.getConfig().mesh_protocol != chat::MeshProtocol::MeshCore) + if (!adapter || app_.readConfig().mesh_protocol != chat::MeshProtocol::MeshCore) { return nullptr; }