Skip to content

Repository files navigation

SimpleOcppServer

A lightweight OCPP 1.6 Central System implementation built with .NET 8. It communicates with EV chargepoints over WebSockets and exposes a REST API for managing charging sessions, profiles, and configuration.

Architecture

The solution consists of three projects:

Project Description
SimpleOcppServer Main server — WebSocket listener, REST API, OCPP message handling
SimpleOcppServer.Messages Shared OCPP 1.6 message models (requests & responses)
SimpleOcppClient Simple test client that sends OCPP messages over WebSocket

Key Components

  • WebSocket server on port 8080 accepting chargepoint connections at ws://host:8080/ocpp/{chargepointId}
  • OCPP 1.6 message handlers — Authorize, BootNotification, Heartbeat, MeterValues, StartTransaction, StopTransaction, StatusNotification, ChargingProfile, CompositeSchedule, Configuration
  • REST API for external control and monitoring
  • MQTT integration for publishing events
  • MongoDB for persisting transactions and status
  • MediatR for in-process messaging between components

REST API

Method Route Description
GET /status Get the latest chargepoint status
GET /transactions Get the latest transactions
GET /configuration/{chargePointId} Get chargepoint configuration
GET /compositeSchedule/{chargePointId} Get composite schedule
POST /chargingProfile/{chargePointId} Set max amperage
POST /chargingProfile/{chargePointId}/clear Clear charging profiles

Prerequisites

  • .NET 8 SDK
  • MongoDB instance
  • MQTT broker (optional)

Configuration

Settings are in SimpleOcppServer/appsettings.json and can be overridden with environment variables:

{
  "MqttSettings": {
    "MqttIp": "192.168.1.5"
  },
  "AuthSettings": {
    "AllowedIdTags": "F6C0D248"
  }
}
Setting Description
MqttSettings:MqttIp IP address of the MQTT broker
AuthSettings:AllowedIdTags Comma-separated list of authorized RFID tags

Running

Local

cd SimpleOcppServer
dotnet run

The WebSocket server will start listening on http://+:8080/ocpp/.

Docker

Build and run with Docker:

docker build -t simpleocppserver .
docker run -p 8080:8080 simpleocppserver

Or use Docker Buildx Bake:

docker buildx bake

Test Client

A simple WebSocket test client is included:

cd SimpleOcppClient
dotnet run

It connects to ws://localhost:8080/ocpp/WS-1337 and sends sample OCPP messages.

About

A lightweight OCPP 1.6 Central System implementation built with .NET 8. It communicates with EV chargepoints over WebSockets and exposes a REST API for managing charging sessions, profiles, and configuration.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages