ocpp-kit

Version differences

The two dozen places where OCPP 1.6J, 2.0.1 and 2.1 genuinely disagree — framing, error-code spelling, authentication, transaction retries, compression — and how each is modelled.

Supporting three versions is mostly not about three sets of types. It is about the places where the versions genuinely disagree, and where averaging them produces something conformant to none of them. This page is the list, with where each one lives in the code.

Framing

1.6J2.0.12.1Where
Subprotocolocpp1.6ocpp2.0.1ocpp2.1Version::subprotocol
Message types2, 3, 42, 3, 4+ 5 CALLRESULTERROR, 6 SENDMessageTypeId::is_defined_in
Unknown message type numberignore the message (§4.1.3)ignore the message (§4.1; §4.4's answer removed by the edition 4 errata)ignore the message (§4.1)FrameError::is_ignorable
Unreadable MessageIdno ruleanswer with id "-1"answer with id "-1"MessageId::unreadable
One outstanding CALLSHOULD NOTSHALL NOTSHALL NOTInboundConcurrency
SEND exempt from that rule––yes (§4.2.4)Engine::pump

The 2.0.1 → 2.1 change in §4.4 is easy to miss: 2.0.1 requires an answer to an unknown message type, and 2.1 changed it back to silence.

Error codes

Meaning1.6J2.0.1 / 2.1
Payload syntactically incorrectFormationViolationFormatViolation
Occurrence constraint violatedOccurenceConstraintViolation (one r, as printed)OccurrenceConstraintViolation
Not a valid RPC request(not defined) → GenericErrorRpcFrameworkError
Unsupported message type number(not defined) → GenericErrorMessageTypeNotSupported (deprecated; never sent, still parsed)

ErrorCode::as_wire(version) produces the right spelling; ErrorCode::parse accepts every spelling on every version, because peers mix them up.

Security

1.6 (Security Whitepaper ed. 2)2.x
Basic-auth passwordAuthorizationKey, a hexadecimal string; the decoded octets are the passwordBasicAuthPassword, sent as UTF-8, at least 16 characters, ceiling between 40 and 64 (A00.FR.205)
Identity must not contain :yesyes (A00.FR.204)
Profiles1, 2, 31, 2, 3 (Part 2 §A 1.3 Table 12)

BasicAuthPassword::for_version builds the right one; getting this wrong is a silent authentication failure that looks like a network problem.

Transactions

1.62.x
MessagesStartTransaction, MeterValues, StopTransactionTransactionEvent
Retry attemptsTransactionMessageAttemptsOCPPCommCtrlr.MessageAttempts[TransactionEvent]
Retry intervalTransactionMessageRetryIntervalMessageAttemptInterval[TransactionEvent]
Schedulelinear: interval × preceding transmissions (§3.7.1)the same
Orderingstrictly chronological; later transaction messages wait (§3.7)the same
Sequence numbersnoneseqNo, strictly increasing
Transaction idassigned by the CSMS, in StartTransaction.confassigned by the station, and unique across reboots (E01.FR.08)
Start / stopimplementation-defined ("cable in and authorized", by convention)TxStartPoint / TxStopPoint, each a set that behaves as a disjunction (E01, E06)
Charging pointconnectorId; there are no EVSEsevseId, with an optional connectorId under it
Charging stateonly through StatusNotificationtransactionInfo.chargingState
Signed meter valuesthe 2.x object serialized into a SignedData sample's value string (OCA note §3.2.1)SampledValue.signedMeterValue, typed

The last three are why the version-agnostic model reports a 1.6 connector as a connector rather than passing it off as an EVSE, and why reading a signed meter value is protocol knowledge rather than a field access.

Both versions are linear, not exponential, and both apply only to transaction-related messages. actions::is_transaction_related is the single place that knows which those are.

The ordering rule is easy to miss and easy to get wrong: 1.6 §3.7 says "the delivery of new transaction-related messages SHALL wait until the queue has been emptied", so a transaction message waiting out its retry interval blocks every later one — while a message that is not transaction-related is explicitly allowed to overtake the queue, "so that customers are not kept waiting". The engine implements both halves.

Compression

2.1 Part 4 §3.4 Table 2 makes RFC 7692 permessage-deflate required for a CSMS and a Local Controller, and optional (but recommended) for a Charging Station. 1.6J §5.1 recommends against compression; 2.0.1 is silent. Version::supports_compression reports it, and the WebSocket layer implements it.

That one table is why this crate has its own WebSocket implementation: a library that does not implement RFC 7692 is required to reject the RSV1 bit a compressed message sets, and none of the general-purpose Rust crates offer a way round it.

Beyond the schemas

Two catalogues live in Part 2 — Appendices rather than in any schema, and both differ from 1.6's equivalents: the standardized security events with their criticality, and the standardized components and variables of the device model, which 1.6 does not have at all (it has flat configuration keys instead). Both are available as ocpp_kit::standard, and 1.6's keys as station::configuration.

Schema-level

2.0.1 and 2.1 share 128 schema files by name, and 95 of them changed — across 58 actions, including Authorize, TransactionEvent, SetChargingProfile, ReserveNow, TriggerMessage and NotifyEVChargingNeeds. That is why the crate generates separate type sets per version rather than sharing a "2.x" set: sharing would silently mis-validate 2.0.1 across three quarters of the surface the two versions look like they have in common.

Most differences are small, which is what makes them dangerous: ClearCacheResponse differs only in StatusInfoType.additionalInfo going from maxLength 512 to 1024 — invisible in review, and it rejects a conforming 2.1 station. cargo xtask schema-diff derives these numbers from the vendored schemas and --check fails the build when they move.

2.1 adds 27 actions over 2.0.1 — AFRRSignal, BatterySwap, the DER Control block, the Tariff and Cost block, periodic event streams — and three functional blocks: Q (Bidirectional Power Transfer), R (DER Control) and S (Battery Swapping).

1.6 schema quirks the generator handles

  • The 1.6 schemas name almost nothing: enumerations and nested objects are inline. The generator carries a table giving each one the name the 1.6 specification itself uses, and fails if a schema contains an inline type the table does not cover.
  • The schemas leave meterValue and sampledValue unbounded where the specification's tables say 1..* (§6.31, §7.33). The generator applies those bounds as cited schema patches, and fails once a schema states them itself.
  • There is no Hertz. §7.31: "OCPP 1.6 does not have a UnitOfMeasure for frequency, the UnitOfMeasure for any SampledValue with measurand: Frequency is Hertz" — implied, never sent — and the OCA schemas list none; a station that sends "unit":"Hertz" anyway is an undefined enum value — rejected strictly, kept as UnknownValue leniently.
  • The 1.6 core schemas are JSON Schema draft-04, where 20000.0 is not an integer. The lenient preset repairs it; strict decoding refuses it, as the schema does. Every 2.x schema is draft-06, where it is.

Edit this page on GitHub