API Reference

[中文]

This page collects the API reference generated from the System Core public headers.

System

Public header: #include "brookesia/system_core/system/system.hpp"

Header File

Classes

class System

Core Brookesia system runtime that owns apps, GUI access, timers, storage, and services.

System coordinates native and runtime applications, mounts their GUI resources, dispatches app lifecycle callbacks, and exposes storage, GUI, keyboard, dialog, and timer facilities through AppContext and service APIs.

Subclassed by esp_brookesia::system::super::System

Public Functions

System()

Create a core system runtime.

std::expected<void, std::string> init(Config config)

Initialize the system runtime with explicit configuration.

Parameters

config -- Runtime configuration. Ownership of gui_backend is transferred into the system.

Returns

Empty result on success, or an error string.

std::expected<void, std::string> start()

Start services, install configured apps, and enter the running state.

Returns

Empty result on success, or an error string.

void stop()

Stop running apps and services.

void deinit()

Release runtime resources after the system has stopped.

void process_timers()

Process pending timer events from the host event loop.

std::expected<AppId, std::string> install_runtime_app_package(std::string_view package_path, bool replace_existing = true)

Install a validated runtime application package from a local path.

Unsupported manifest fields are logged as warnings and do not stop installation. The package is staged and validated before activation.

Parameters
  • package_path -- Path to the BPK package.

  • replace_existing -- Whether an installed package with the same ID may be replaced.

Returns

The installed application ID, or an error string.

std::optional<std::string> app_support_error(AppId app_id) const

Return a platform support error for an installed app, or empty when supported.

std::expected<gui::DocumentId, std::string> system_gui_load_json(std::string_view root_path, std::string_view json, std::string_view resource_dir)

Parse a document tree that the caller already holds in memory.

root_path Absolute screen path inside the document, e.g. "/" or "/startup". json The document JSON. resource_dir Directory that relative asset paths inside the document resolve against. May be empty when every asset reference is absolute.

Public because a carrier that keeps its documents embedded in the firmware has no filesystem path to install an app from. The GUI performance and memory baseline harness (examples/system/perf_eval) parses the section 1.3 asset set this way, so the asset parse/load cost is measured without a VFS read in the measurement path. Installing a runtime app stays the normal route; this is the in-memory equivalent of AppGuiRuntime::load_json() for the case where there is no app and no path.

std::expected<void, std::string> system_gui_load_theme_file(std::string_view resource_dir, std::string_view path)

Register a theme document so loaded documents can resolve its styles.

Public for the same reason as system_gui_load_json(): a carrier that stages the theme files itself must register and activate one before loading any document, otherwise every named style reference resolves to nothing.

std::expected<void, std::string> system_gui_set_theme(std::string_view theme_id)

Activate a theme registered through system_gui_load_theme_file()

std::expected<gui::View, std::string> system_gui_mount_screen(gui::DocumentId document_id, std::string_view absolute_path, const gui::MountTarget &target = {})

Mount a screen from a loaded document, creating its widget tree.

Public for the same reason as system_gui_load_json(): a carrier holding its document tree in firmware image has no app to install, and the section 3.1 runtime object count only exists once a screen is mounted.

bool system_gui_unmount_screen(gui::DocumentId document_id, std::string_view absolute_path)

Tear a mounted screen down, and unload a document entirely.

Public for the same reason as system_gui_load_json() and system_gui_mount_screen(): the v1.8 section 3.3 zero-leak rule is defined over a Launch -> Navigate -> Back -> Unload/Destroy cycle, which a carrier cannot run without a way to undo what it did.

struct AppStartOptions
struct Config

Configuration used to initialize the core system runtime.

Public Members

std::unique_ptr<gui::IBackend> gui_backend

GUI backend implementation used by the system runtime.

void *gsp_panel = nullptr

Panel and touch for a GSP session. Leave both null for LVGL. They stay in use until the session has stopped.

std::shared_ptr<gui::gsp::DesktopDisplay> gsp_desktop_display

Desktop GSP display; leave empty for HAL panel and touch sessions.

std::function<std::optional<std::string>(const AppManifest&)> app_support_check

Optional platform preflight. A reason rejects launch while retaining the installed app.

gui::Environment environment

GUI and platform environment exposed to apps.

StorageConfig storage = {}

Storage roots and install target policy.

StartupOverlay startup_overlay = {}

Optional startup overlay configuration.

AppLaunchTransition app_launch_transition = {}

Optional app launch transition configuration.

std::string system_type = BROOKESIA_SYSTEM_CORE_DEFAULT_SYSTEM_TYPE

System type string exposed to services and applications.

bool start_service_manager = true

Whether the service manager should be started by System::start().

bool install_registered_apps = true

Whether statically registered native app providers should be installed.

bool install_package_apps = true

Whether package apps should be discovered from configured package roots.

bool enable_gui_view_debug = false

Whether GUI view debug metadata should be enabled at startup.

bool enable_gui_live_preview = false

Whether GUI live preview should be enabled at startup.

gui::LivePreviewOptions gui_live_preview_options = {}

Live preview options applied when startup live preview is enabled.

int32_t gui_live_preview_poll_interval_ms = 100

Poll interval used by startup live preview in milliseconds.

struct AppLaunchTransition

Optional launch transition shown when an app surface is being opened.

Public Members

bool enabled = false

Whether app launch transition rendering is enabled.

std::string root_path

GUI resource root containing the launch transition document.

std::string screen_path = "/app_launch"

Absolute screen path inside the launch transition document.

std::string surface_path = "/app_launch/surface"

Path of the app surface placeholder used by the transition.

std::string icon_path = "/app_launch/icon_box/icon_image"

Path of the app icon image in the transition document.

std::string fallback_label_path = "/app_launch/icon_box/fallback_label"

Path of the fallback label when an icon is not available.

gui::MountTarget target

GUI mount target used for the launch transition.

int32_t duration_ms = 220

Transition animation duration in milliseconds.

int32_t timeout_ms = 500

Maximum time to wait for app surface readiness.

int32_t final_icon_size = 96

Final app icon size in pixels.

struct StartupOverlay

Optional startup overlay shown while the system is preparing the shell.

Public Members

bool enabled = false

Whether startup overlay mounting is enabled.

std::string root_path

GUI resource root containing the startup overlay document.

std::string screen_path = "/startup"

Absolute screen path inside the startup overlay document.

gui::MountTarget target

GUI mount target used for the overlay.

int32_t min_present_ms = 16

Minimum duration in milliseconds before the overlay can be dismissed.

Application Interface

Public header: #include "brookesia/system_core/app/iapp.hpp"

Header File

Classes

class IApp

Base interface implemented by native applications hosted by Brookesia System.

Applications provide a manifest, optionally expose a GUI descriptor, and receive lifecycle, action, and timer callbacks from the system runtime.

Subclassed by esp_brookesia::app::app_store::AppStoreApp, esp_brookesia::app::files::FileManagerApp, esp_brookesia::app::settings::SettingsApp

Public Functions

virtual AppManifest get_manifest() const = 0

Get the static metadata used to identify and present the application.

Returns

Application manifest containing id, name, version, and launch metadata.

virtual AppGuiDescriptor get_gui_descriptor() const

Get the optional GUI resource descriptor for applications with a visual surface.

Returns

GUI descriptor; the default descriptor is empty for non-visual apps.

virtual std::span<const std::byte> gui_bundle() const

Compiled GSP deployable bytes when the GUI descriptor root is GspBundle.

The returned bytes must stay valid until the app is uninstalled. Core copies them into a Bundle and keeps that copy until the GSP session stops.

virtual const void *gui_runtime_config() const

Optional generated esp_gsp_config_t for an embedded GSP bundle.

Core uses this when the GUI root is a GSP bundle. The config and all referenced data must remain valid for the lifetime of the app object. Core retains the app until any deferred GSP cleanup has completed.

virtual std::expected<void, std::string> on_install(AppContext &context)

Called when the application package is installed into the system.

Parameters

context -- System context for package storage and service access.

Returns

Empty result on success, or an error string.

virtual void on_uninstall(AppContext &context)

Called before the application package is removed from the system.

Parameters

context -- System context for cleanup operations.

virtual std::expected<void, std::string> on_start(AppContext &context)

Called when the application is started.

Parameters

context -- Runtime context for GUI, timers, storage, and services.

Returns

Empty result on success, or an error string that aborts startup.

virtual std::expected<void, std::string> on_pause(AppContext &context)

Called when the application should suspend active work.

Parameters

context -- Runtime context for the running application.

Returns

Empty result on success, or an error string.

virtual std::expected<void, std::string> on_resume(AppContext &context)

Called when the application should resume after a pause.

Parameters

context -- Runtime context for the running application.

Returns

Empty result on success, or an error string.

virtual std::expected<void, std::string> on_stop(AppContext &context)

Called when the application is stopped.

Parameters

context -- Runtime context for releasing app resources.

Returns

Empty result on success, or an error string.

virtual std::expected<void, std::string> on_action(AppContext &context, std::string_view action)

Handle an action emitted by the application GUI or shell.

Parameters
  • context -- Runtime context for the running application.

  • action -- Action identifier registered by the application GUI.

Returns

Empty result on success, or an error string.

virtual std::expected<void, std::string> on_timer(AppContext &context, TimerId timer_id, std::string_view name)

Handle a timer event previously scheduled through the app context.

Parameters
  • context -- Runtime context for the running application.

  • timer_id -- Runtime timer identifier.

  • name -- Application-defined timer name.

Returns

Empty result on success, or an error string.

class IAppProvider

Factory interface registered by built-in or dynamically loaded application packages.

Subclassed by esp_brookesia::app::app_store::AppStoreAppProvider, esp_brookesia::app::files::FileManagerAppProvider, esp_brookesia::app::settings::SettingsAppProvider

Public Functions

virtual AppManifest get_manifest() const = 0

Get the manifest of the application created by this provider.

Returns

Application manifest used for discovery and installation.

virtual std::shared_ptr<IApp> create_app()

Create an application instance.

Returns

Shared application instance, or nullptr when the provider cannot instantiate it.

Macros

BROOKESIA_SYSTEM_CORE_APP_PROVIDER_REGISTER_WITH_SYMBOL(ProviderType, name, symbol_name)

Register an application provider with a stable plugin symbol.

Parameters
  • ProviderType -- Concrete provider type derived from IAppProvider.

  • name -- Provider name used by the plugin registry.

  • symbol_name -- Exported symbol name used for dynamic provider lookup.