Giter VIP home page Giter VIP logo

ocpp-sharp's Introduction

ocpp-sharp

An implementation of the Open Charge Point Protocol (OCPP) in C#.

Supported Versions:

  • Ocpp 1.6
  • Ocpp 2.0.1

Table of contents

Dependencies

  • Newtonsoft.Json
  • .NET 6

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 /ocpp-sharp.examples

Running the functionality test (Single test message communication on localhost):

cd ./ocpp-sharp.examples/server
dotnet run
cd ./ocpp-sharp.examples/client
dotnet run

Basic Server Code

using System;
using OcppSharp;
using OcppSharp.Server;
using OcppSharp.Protocol.Version16.RequestPayloads;
using OcppSharp.Protocol.Version16.ResponsePayloads;

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>
            OcppSharpServer server = new OcppSharpServer("/ocpp16", ProtocolVersion.OCPP16, 80);
            server.Log = null; // Disable console logging
            server.RegisterHandler<BootNotificationRequest>((server, sender, req) => {

                Console.WriteLine($"Received BootNotification! (Message ID = {req.FullRequest!.MessageId})");
                Console.WriteLine($"Vendor: {req.chargePointVendor}");
                Console.WriteLine($"Serial Number: {req.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.

ocpp-sharp's People

Contributors

fabyr avatar

Watchers

 avatar

ocpp-sharp's Issues

Sending a request to the charging station

Hello,

Thank you for your sample project. I was able to successfully establish a connection as shown in the screen visuals when I configured the settings of my charging station device according to your application.
resim

I couldn't fulfill my requests such as starting, stopping, and restarting conditions on the Server-connected Condition Device through a different application where I will be doing development. Could you please share sample code that I can use to perform these operations?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.