firmware-base/docs-c/core/App.md
2025-06-04 16:50:34 +02:00

3.0 KiB

title description keywords
App - Application Component The App class is the main application component that manages the lifecycle and interactions of all components in the system.
ESP32
App
Component
PlatformIO
ModbusRTU
embedded system

App

Path: src/App.cpp

Revision History: Initial documentation

The App class serves as the main application component responsible for managing the lifecycle and execution of all components in the system. It is derived from the Component base class and provides functionality for setting up, running the main loop, debugging, and retrieving information about the application and its components. The App acts as a container and orchestrator for all child components.

REQUIREMENTS

  • ESP32 microcontroller
  • PlatformIO build environment
  • C++17 support

PROVIDES

  • App class that manages the application lifecycle
  • Component management functionality
  • Component registration with Bridge for communication
  • Debugging infrastructure

FEATURES

  • Component management (adding, retrieving, and querying components)
  • Application lifecycle management (setup, loop)
  • Component setup and execution orchestration
  • Debug facilities with configurable intervals
  • Component registration with Bridge for communication
  • Component filtering by flags

DEPENDENCIES

graph TD
    App --> Component
    App --> Bridge
    App --> Vector
    App --> xtypes
    App --> xtimer

BEHAVIOUR

The App class follows a standard application lifecycle pattern:

graph TD
    Start[Start] --> Constructor[Constructor]
    Constructor --> Setup[Setup]
    Setup --> RegisterComponents[Register Components]
    RegisterComponents --> OnRun[onRun]
    OnRun --> Loop[Loop]
    Loop --> Debug[Debug if interval passed]
    Debug --> Loop
    Loop --> End[End]

TODOS

PERFORMANCE

  • Consider implementing component prioritization for the main loop
  • Optimize component lookup by ID using a hashmap instead of linear search
  • Implement a more efficient mechanism for component flag filtering

SECURITY

  • Implement component access control or validation mechanisms
  • Add proper error handling for component operations
  • Consider adding checks for component validity before operations

COMPLIANCE

  • Ensure memory management follows best practices for embedded systems
  • Validate that the application meets real-time requirements for industrial settings

RECOMMENDATIONS

  • Use the byId method to retrieve components when you know their IDs
  • Configure appropriate debug intervals based on the application's performance requirements
  • Group related components with similar flags for easier management
  • Implement a more structured approach for component initialization and dependency management
  • Consider implementing a component health monitoring system