NOCPP is a modular C# toolkit designed for developing and testing custom communication protocols. It includes a JSON Schema-to-C# class generator, a core protocol class library, and a device simulator to streamline your development and testing workflow.
NOCPP/
├── ClassGenerator # Convert JSON Schema to C# classes
├── NOCPP # Core communication protocol logic
├── Simulator # Simulate communication for testing
├── LICENSE
└── README.md
- Converts JSON Schema into strongly-typed C# classes
- Supports attributes, nullable types, and naming conventions
- Defines the protocol packet structure and logic
- Serialization and deserialization utilities
- Checksum validation, command routing, and error handling
- Simulates sending and receiving protocol packets
- Useful for testing device interactions or server behavior
- .NET 8 or later
- Visual Studio 2022
The ProtocolLib project provides the core logic for handling OCPP-style messages over WebSocket connections. It is designed to be modular, extensible, and simulator-friendly.
- Represents a generic OCPP message structure.
- Allows users to register custom action handlers to process specific message types dynamically.
Key Features:
- Parse incoming JSON messages
- Register and invoke custom handlers based on message actions
Message message = new Message();
HandleResult handleRes;
string message_received = "[2,\"ffebbfae-138c-446e-8d87-c2d6b3ae3f66\",\"BootNotification\",{\"chargePointVendor\":\"NOCPP\",\"chargePointModel\":\"SingleSocketCharger\",\"chargePointSerialNumber\":null,\"chargeBoxSerialNumber\":null,\"firmwareVersion\":null,\"iccid\":null,\"imsi\":null,\"meterType\":null,\"meterSerialNumber\":null}]";
handleRes = await message.Handler(message_received);
- A class that defines the structure of the three OCPP message types.
- Provides static methods or constants to generate/validate specific message formats.
BootNotificationRequest bootNotificationRequest = new BootNotificationRequest()
{
ChargePointModel = "SingleSocketCharger",
ChargePointVendor = "NOCPP"
};
Call call_boot = new Call()
{
UniqueId = Guid.NewGuid().ToString(),
Action = "BootNotification",
Payload = Utility.CalssToJsonElement(bootNotificationRequest)
};
- Lightweight WebSocket server and client implementations based on System.Net.WebSockets.
- Intended for testing and simulating OCPP communication flows.
CancellationTokenSource ctsCS = new CancellationTokenSource();
CentralSystem cs = new CentralSystem("http://localhost:54321/", "1.6", ctsCS.Token);
cs.StartAsync();
cs.OnMessageReceived = async message => { await CS_AutoRun(message, cs); };
This project is still in its early stage — I basically just thought of it and started building it. There's no code review, no unit tests, and no stability tests... but hey, it works! 🤩
It's also my first time writing a C# class library and publishing a project on GitHub. I'm not a professional C# developer, so the library might not be super stable.
If you find any issues or have suggestions, feel free to open an issue or contact me via email at [email protected]
.
That said, this is just a side project, so I may not be able to respond immediately — thanks for your understanding!
And finally, if you find this project useful, go ahead and use it under the license. Hope you enjoy it!