OCPP-RS
OCPP-RS is a Rust library for implementing the Open Charge Point Protocol (OCPP) in Rust.
it currently supports OCPP 1.6.
- Full implementation of OCPP 1.6 Protocol
- Currently most feature complete implementation of OCPP 1.6 in rust
- Batteries included, check packet parsing(to_message) serialization(from_message)
- Fuzzed tested (please read the comment on the call_result fuzzing)
- Inspired by a python ocpp library
Usage
In Cargo.toml, add the following dependency:
[]
= "0.1"
Particularities
Since the original OCPP 1.6 protocol does not contain a type field for CallResult, when parsing CallResultlt, you need to handle
Special cases where JSON payloads are ambiguous, like empty objects like: {}, these might get serialized as a EmptyResponse instead of the variant
you are waiting for like GetConfiguration.
Look at this file to see how to properly handle CallResults: valid_call_result.rs
Example
Receiving a payload from a client:
use ;
use ;
// Example incoming message
let incoming_text = "[2, \"19223201\", \"BootNotification\", { \"chargePointVendor\": \"VendorX\", \"chargePointModel\": \"SingleSocketCharger\" }]";
let incoming_message = to_message;
if let Ok = incoming_message
Sending a payload to a client:
use StartTransaction;
use ;
use IdTagInfo;
use ChargePointStatus;
use Message;
let response = CallResult;