OcppSharp 1.0.2
dotnet add package OcppSharp --version 1.0.2
NuGet\Install-Package OcppSharp -Version 1.0.2
<PackageReference Include="OcppSharp" Version="1.0.2" />
<PackageVersion Include="OcppSharp" Version="1.0.2" />
<PackageReference Include="OcppSharp" />
paket add OcppSharp --version 1.0.2
#r "nuget: OcppSharp, 1.0.2"
#:package OcppSharp@1.0.2
#addin nuget:?package=OcppSharp&version=1.0.2
#tool nuget:?package=OcppSharp&version=1.0.2
ocpp-sharp
An implementation of the Open Charge Point Protocol (OCPP) in C#.
Currently supported versions:
- Ocpp 1.6
- Ocpp 2.0.1
Table of contents
Installation
This project is published to NuGet under the name OcppSharp.
See the relevant nuget page for more information: https://www.nuget.org/packages/OcppSharp
Installation via the dotnet CLI:
dotnet add package OcppSharp
Or within the Visual Studio Package Manager Console (PMC):
PM> Install-Package OcppSharp
Dependencies
The library itself targets all dotnet versions from .NET 8 up to .NET 10
The example projects target .NET 8
Features
- C# classes for all messages of the OCPP-Protocol.
- Easy to set up server and event system for processing messages.
What it isn't
It's not a ready-to-go backend server. You still have to implement what happens once an OCPP-Message has been received and how respond accordingly.
Possible use cases
- Automating certain ocpp-communication
- Emulating a charge point
- Implementation of a basic backend server for charge points
Running the examples
A minimalistic client and server example can be found under /OcppSharp.Examples
Start the server:
cd ./OcppSharp.Examples/Server
dotnet run
And then a client:
cd ./OcppSharp.Examples/Client
dotnet run
The examples are preconfigured to connect to each other on localhost:8000
and exchange some example messages.
Basic server code
using OcppSharp.Server;
using OcppSharp.Protocol.Version16.RequestPayloads;
using OcppSharp.Protocol.Version16.ResponsePayloads;
using OcppSharp.Protocol;
namespace OcppApp;
public class Program
{
public static void Main(string[] args)
{
// Set up a server to listen on port 80
// Stations will be connecting to ws://<Hostname>/ocpp16/<Station ID>
using OcppSharpServer server = new("/ocpp16", [ProtocolVersion.OCPP16], 80);
server.RegisterHandler<BootNotificationRequest>((server, sender, request) =>
{
Console.WriteLine($"Received BootNotification! (Message ID = {request.FullRequest!.MessageId})");
Console.WriteLine($"Vendor: {request.ChargePointVendor}");
Console.WriteLine($"Serial Number: {request.ChargePointSerialNumber}");
// ...
// Always need to send a response
return new BootNotificationResponse()
{
CurrentTime = DateTime.Now,
Interval = 90 // Heartbeat Interval
};
});
server.Start();
Console.WriteLine("Server started!");
Console.ReadLine();
server.Stop();
}
}
Motivation
This project was part of a private OCPP-Backend project. It was then split up into its own project here.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.0)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.