Typed messages
All 39 / 64 / 91 actions for 1.6J, 2.0.1 and 2.1, generated from the official OCA JSON schemas and checked back against them on every CI run.
Layer 0 →OCPP 1.6J · 2.0.1 · 2.1
Typed messages for all 194 actions, a sans-I/O protocol engine, and production transports for charging stations, CSMS backends and local controllers — with the version differences modelled rather than averaged away.
cargo add ocpp-kit --features tokio,rustlsAll 39 / 64 / 91 actions for 1.6J, 2.0.1 and 2.1, generated from the official OCA JSON schemas and checked back against them on every CI run.
Layer 0 →CALL, CALLRESULT, CALLERROR, plus 2.1’s CALLRESULTERROR and SEND — with the error codes each version actually spells.
A pure state machine: no socket, no clock, no tasks. Every timing rule in OCPP is testable in microseconds, on Tokio, on embassy or in WebAssembly.
Charging station, CSMS and Part 4 chapter 6 local controller, on Tokio and rustls, with security profiles 0 (1.6 only) to 3 and network failover.
Device model, transaction rules, local authorization, composite schedules, and an idempotent CSMS transaction ledger. Components, not a framework.
Layer 4 →Security events with their criticality, 74 standardized components, 458 variables and the standardized reason codes — extracted from the specification, not transcribed.
Catalogues →use ocpp_kit::transport::{BasicAuthPassword, ClientTls, Handler, SecurityProfile, Station};
use ocpp_kit::{Version, v2_1};
async fn boot(handler: impl Handler) -> Result<(), Box<dyn std::error::Error>> {
let handle = Station::builder()
.identity("CS-0001")?
.url("wss://csms.example.com/ocpp")
// Part 4 §3.2 recommends that a 2.1 station also offer 2.0.1.
.versions([Version::V2_1, Version::V2_0_1])
.security_profile(SecurityProfile::TlsBasicAuth)
.password(BasicAuthPassword::utf8("a-sixteen-plus-character-secret")?)
.tls(ClientTls::with_webpki_roots()?)
.handler(handler)
.build()?
.spawn()?;
let boot = handle
.call(v2_1::BootNotificationRequest::new(
v2_1::ChargingStation::new("Model-1", "ACME"),
v2_1::BootReason::PowerUp,
))
.await?;
println!("{:?}, heartbeat every {}s", boot.status, boot.interval);
Ok(())
}BootNotification.OCPP has five distinct codes for five kinds of bad payload, and answering with the wrong one is a conformance failure. A missing member is an OccurrenceConstraintViolation; a string where an integer belongs is a TypeConstraintViolation; on 1.6 a format violation is spelled FormationViolation.
Every OCPP number is a decimal mantissa and scale, never an f64. A meter reporting 2935.600 kWh claims three decimals of resolution, and it goes back out as 2935.600; a session’s energy is the exact difference of two registers.
Under calibration law a customer may only be billed for the record the meter signed — which 1.6 hides inside a string and whose public-key field the specification and its own example message disagree about. Both shapes are read, and the record is carried verbatim.
Signed meter values →Every action’s request and response is round-tripped through pseudo-random schema-valid payloads and validated back against the official schema — over 9 000 round trips per test run.
How it is verified →Part 4 §3.4 makes RFC 7692 mandatory for a CSMS. No general-purpose Rust WebSocket crate implements it, so the frame layer is in this crate — checked against an independent implementation and fuzzed.
The WebSocket layer →The strict default is what the schemas say. A lenient policy additionally accepts offset-less timestamps, numeric strings and undefined enum values — via a repair loop that only runs after a strict parse has failed, and reports every repair it made.
Talking to real hardware →no_std + alloc for layers 0–4thumbv7em-none-eabihf, checked in CI#![forbid(unsafe_code)]With default features there is no async runtime, no TLS and no domain logic in your binary — just the types, the framing and the engine.