How everest/libocpp works
Project type and purpose
• This is a C++ library (“libocpp”) that implements the Open Charge Point Protocol (OCPP) versions 1.6, 2.0.1 and in-progress 2.1.
• It is not a standalone server or web app but a client-side library to be embedded into EV charging station firmware. It handles websocket connections, message dispatching, state machines, database persistence, and functional blocks per OCPP spec.
• The README confirms that it is intended to integrate with charging station firmware (e.g., via EVerest) and exchange messages with a CSMS (Charge Station Management System).
File structure
• Top-level:
• .ci/, run-docker(.sh) and Dockerfile scripts for CI/CD and containerized builds/tests.
• CMakeLists.txt and src/, lib/, include/ for source code.
• config/ directories contain JSON schemas, SQL migrations and default configs per OCPP version.
• src/code_generator/ contains Python scripts and Jinja templates that auto-generate message/enums/types C++ files.
• include/ocpp/{common,v16,v2,v21} and matching lib/ocpp/... implement protocol layers.
• tests/ contains unit and integration tests for common code, versioned modules, database migrations, and config validations.
• Key patterns:
• Modular layering per OCPP version (common core, version-specific subdirectory).
• Code generation step that processes schema definitions into C++ message classes/enums.
• CMake build orchestrates code generation, compiling headers and libraries, running tests and packaging.
README for additional insights
• The README explains supported feature profiles, CSMS compatibility and integration guidelines.
Components
a. Main components
1. Client Firmware (your EVSE firmware)
2. libocpp library layers:
• Code Generator
• Common Core (websocket, dispatcher, queue, logging, utils)
• Version Modules: v1.6, v2.0.1, v2.1
• Functional Blocks & Profile Handlers (e.g., Smart Charging, Security, Transactions)
• Database Handler & Migrations (SQLite or embedded DB)
3. External CSMS (over websocket)
4. Configuration Store (JSON schemas, profile configs)
5. CI/CD Pipeline & Docker Build
b. Relationships and interactions
• Firmware → libocpp API calls to send/receive OCPP messages
• libocpp Common Core opens and manages a WebSocket connection to a CSMS endpoint
• Message Dispatcher routes incoming JSON messages to version‐appropriate handlers
• Handlers drive state machines, call into Functional Blocks, and persist data via Database Handler
• Configuration & profile schemas loaded at startup to validate and parameterize behavior
• Code Generator reads JSON schemas/templates → emits C++ header/source before build
• CI/CD orchestrates: run code generator → build with CMake → run unit tests → package Docker image
c. Architectural patterns / design principles
• Layered architecture: separation of concerns between core protocol, versioned logic and application firmware
• Dependency inversion: firmware depends on abstract libocpp interfaces; version modules implement those
• Code generation as a compile‐time plugin pattern: automated generation of message classes reduces boilerplate
• Use of migration scripts to evolve embedded database schema
• Modular CMake build, Dockerized CI for reproducibility
d. Key technologies / frameworks
• C++17 (or later), CMake
• Python + Jinja2 for code generation
• WebSocket library (libwebsockets) for transport
• SQLite (or pluggable storage) via library’s database handler
• Unit test frameworks (probably Catch2 or GTest)
• Docker for containerized builds