๐ OCPP Client
A lightweight, embedded-friendly Rust OCPP communication framework for building real charge points and CSMS integrations.
๐ Overview
OCPP Client is the communication layer of the Flowion Rust OCPP ecosystem, providing the networking and transport foundation required to build OCPP-enabled charge points and backend integrations.
The library handles the complexities of establishing and managing OCPP connections, including:
- Connection lifecycle management
- Transport handling
- Message routing
- Communication reliability
OCPP message types and protocol definitions are provided by ocpp-types, while OCPP Client focuses on the communication layer required to exchange messages between charge points and Charge Station Management Systems (CSMS).
Designed for both cloud/server environments and resource-constrained embedded systems, OCPP Client speaks WebSocket out of the box and compiles for no_std + alloc targets. An embassy-net-based transport and an STM32 board scaffold ship alongside it as experimental crates - see Supported Transports.
The library currently supports OCPP 1.6J, OCPP 2.0.1, and OCPP 2.1.
โจ Features
- ๐ฆ Native Rust implementation
- ๐ OCPP communication layer
- โก OCPP 1.6J support
- ๐ OCPP 2.0.1 support
- โก OCPP 2.1 support
- ๐ WebSocket transport
- ๐ Secure WebSocket (WSS)
- ๐
embassy-nettransport for embedded targets (experimental) - ๐ Connection lifecycle management
- ๐ Scheduled WebSocket keepalive with dead-peer detection
- ๐จ Message routing
- ๐งฉ Transport abstraction
- ๐ชถ Lightweight runtime
- ๐พ
no_stdsupport for embedded environments - ๐ฅ๏ธ
stdsupport enabled by default for desktop and server applications
๐ Supported Protocols
| Protocol | Status | Actions wired up |
|---|---|---|
| OCPP 1.6J | โ Supported | all 28 |
| OCPP 2.0.1 | โ Supported | all 64 |
| OCPP 2.1 | โ Supported | all 91 |
Every action defined by ocpp-types for each version has a
send_*/on_* method - tests/action_coverage.rs fails the build otherwise, so the table can't
drift. If a method you expect is missing, check CHANGELOG.md before filing an
issue: five actions were only wired up in 0.2.1, so a 0.2.0 build is missing
SecurityEventNotification (2.0.1) and TriggerMessage, SetDisplayMessage, GetDERControl,
SetDERControl, UpdateDynamicSchedule (2.1).
๐ Supported Transports
| Transport | Status |
|---|---|
| WebSocket | โ Supported |
| Secure WebSocket (WSS), incl. mutual TLS | โ Supported |
embassy-net (embedded, no_std + alloc) |
๐งช Experimental |
The embedded transport (crates/ocpp-transport-embassy-net) and the NUCLEO-H723ZG firmware
scaffold (crates/ocpp-board-stm32h723-nucleo) compile and fully link against the real
thumbv7em-none-eabihf target in CI, but neither has been run against real hardware or a real
CSMS, and the embedded transport has no TLS. Treat them as a starting point for a board bring-up
rather than a supported deployment path. Each crate's README states its exact status.
โ๏ธ Feature Flags
OCPP Client supports both standard Rust environments and embedded systems.
By default, the std feature is enabled:
[]
= "0.x"
For embedded targets or no_std environments:
[]
= { = "0.x", = false }
This lets the same OCPP communication core compile for resource-constrained devices as well as server-side applications. Embedded users supply their own Executor/Timer implementations (e.g. backed by embassy-executor/embassy-time) and a critical-section backend for their target.
๐๏ธ Architecture
OCPP Client separates protocol definitions from communication.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Application โ
โ Charge Point / CSMS Logic โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โ ocpp-charge-point โ
โ โ
โ Complete charge point firmware framework โ
โ Add hardware bindings and deploy โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โ ocpp-client โ
โ โ
โ OCPP communication runtime โ
โ Transport abstraction โ
โ WebSocket / embedded transports โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโ
โ
โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โ ocpp-types โ
โ โ
โ OCPP message types โ
โ Protocol models โ
โ Serialization โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Flowion OCPP Ecosystem
OCPP Client is designed as a modular building block within the Flowion Rust OCPP ecosystem.
Each project has a focused responsibility, allowing developers to choose the right level of abstraction for their application.
๐ฆ ocpp-types
OCPP protocol definitions and data models
ocpp-types provides the foundation for working with OCPP messages in Rust.
It contains:
- OCPP message types
- Protocol models
- Serialization and deserialization
- Version-specific protocol definitions
OCPP Client builds on top of ocpp-types to provide communication capabilities.
๐ ocpp-client
OCPP communication and transport layer
This repository provides the runtime required to connect OCPP-enabled systems.
It handles:
- Connection management
- Transport abstraction
- Message routing
- WebSocket communication
- Embedded-compatible transports
no_stdenvironments
It is designed to run in both:
- ๐ฅ๏ธ Server environments
- ๐ Embedded charge point environments
โก ocpp-charge-point
Complete charge point firmware framework
ocpp-charge-point provides a complete framework for building OCPP-enabled charge point firmware.
The goal is to make developing custom charging hardware as simple as implementing the required hardware bindings.
Developers provide hardware-specific implementations such as:
- GPIO control
- Contactor control
- Metering interfaces
- Connector handling
- LEDs and user interfaces
- Hardware drivers
while the framework handles:
- Charge point state management
- OCPP communication
- Charging workflows
- Backend communication
- Protocol integration
This allows manufacturers and developers to build custom OCPP-compatible chargers without implementing the complete protocol stack from scratch.
๐ฏ Use Cases
OCPP Client can be used for:
- ๐ Building EV charge point firmware
- ๐ญ Developing OCPP-enabled hardware
- ๐ฅ๏ธ Building CSMS integrations
- ๐งช Testing OCPP implementations
- ๐ Connecting embedded devices to charging platforms
- โก Creating custom charging solutions
- ๐ค Automated integration testing
๐ฆ Installation
Add the dependency to your Cargo.toml:
[]
= "0.x"
๐ Quick Example
use connect_1_6;
use HeartbeatRequest;
async
Use connect_2_0_1/connect_2_1 for those versions, or connect to negotiate whichever version
the server picks.
๐ Keepalive & WebSocketPingInterval
By default a client pings the CSMS every 60 seconds and, after two unanswered pings, drops the connection and redials. Without this a half-open link - a dropped NAT entry, a mobile connection that vanished without a FIN - is undetectable: the socket accepts writes and nothing ever comes back, and reconnect can't help because nothing reports the connection as closed.
use ;
use Duration;
let options = ConnectOptions ;
let client = connect_1_6.await?;
Set keepalive: KeepaliveBehavior::Disabled if the CSMS pings the charge point instead, or if the
deployment forbids unsolicited traffic.
This crate does not implement a device model, but it owns the ping timer, so it exposes the value for the layer that does:
| OCPP | Variable / key | Read | Write |
|---|---|---|---|
| 2.0.1 / 2.1 | OCPPCommCtrlr.WebSocketPingInterval (GetVariables/SetVariables) |
client.ping_interval() |
client.set_ping_interval(..) |
| 1.6 (security whitepaper) | WebSocketPingInterval (GetConfiguration/ChangeConfiguration) |
client.ping_interval() |
client.set_ping_interval(..) |
Both are non-async, so a GetVariables handler can call them directly. None maps to the
spec's 0 (disabled) in both directions, writes take effect immediately rather than after the
current interval finishes, and a write can enable pinging on a client that started with keepalive
disabled.
๐งช Testing
OCPP Client is designed for:
- Integration testing
- Charge point development
- Embedded testing
- CSMS validation
- Automated test environments
It can be combined with simulators and real charging hardware to validate complete OCPP workflows.
๐ฃ๏ธ Roadmap
Planned improvements:
- ๐ Additional embedded transports
- ๐ More examples
- ๐งช Expanded integration tests
- ๐ง Improved developer tooling
๐ค Contributing
Contributions are welcome!
You can help by:
- ๐ Reporting issues
- ๐ก Suggesting improvements
- ๐ Improving documentation
- ๐ง Submitting pull requests
๐ License
OCPP Client is dual licensed:
- MIT License
- Apache License 2.0
You may choose either license.
๐ข About Flowion
OCPP Client is developed by Flowion AB as part of our effort to make EV charging development more accessible through modern, open-source tooling.
Flowion builds software solutions for electric vehicle charging using open standards such as OCPP, helping developers and businesses build reliable and scalable charging infrastructure.
โญ Support the Project
If you find this library useful:
- โญ Star the repository
- ๐ Report issues
- ๐ก Suggest improvements
- ๐ค Contribute
Together we can make EV charging development easier and more accessible.