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, serialization and deserialization is provided here
- No_std, should work fine on embedded devices that allow heap allocation with a global allocator
- Inspired by a python ocpp library
Usage
In Cargo.toml, add the following dependency:
[]
= "^0.2"
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: example
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 = deserialize_to_message;
if let Ok = incoming_message
Sending a payload to a client:
let response = CallResult;
let json = serialize_message?;
println!;
Contributing
Contributions are welcome! Common steps to contribute:
- Fork the repository and create a new branch.
- Make your changes or improvements.
- Open a pull request with a clear description.
- When adding/changing code, add/modify tests for what you have worked on.
Help is wanted to add more tests and fuzzing tests (e.g., using OSS-Fuzz), so feel free to jump in!
Roadmap
- OCPP 2.1 implementation is planned, no ETA, help needed.