Related issue39
[e-mobility-charging-stations-simulator.git] / tests / ocpp-server / README.md
1 # OCPP2 Mock Server
2
3 This project includes an Open Charge Point Protocol (OCPP) version 2.0.1 mock server implemented in Python.
4 https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/enums.py
5
6 ## Prerequisites
7
8 This project requires Python 3.7+ and [poetry](https://python-poetry.org/) to install the required packages:
9 ```shell
10 pip install poetry
11 ```
12 then
13
14 ```shell
15 poetry install
16 ```
17
18
19 ## Running the Server
20
21 To start the server, run the `server.py` script:
22
23 ```shell
24 poetry run task server
25 ```
26 or
27
28 ```shell
29 poetry run task server --request GetBaseReport --period 5
30 ```
31 The server will start listening for connections on port 9000.
32
33 ## Overview of the Server Scripts
34
35 ### Server.py
36
37 The server script waits for connections from clients. When a client connects, the server creates a new instance of the `ChargePoint` class. This class includes methods for handling various OCPP actions (`BootNotification`,`GetBaseReport`), most of which return a dummy response. The `GetBaseReport` method prints the received request and returns a simple confirmation message.
38
39 The server script uses the websockets and ocpp libraries to facilitate the WebSocket and OCPP communication.
40
41 ## Development
42
43 ### Code formatting
44
45 ```shell
46 poetry run task format
47 ```
48
49 ### Code linting
50
51 ```shell
52 poetry run task lint
53 ```
54
55 ## Note
56
57 Primarily, this software is intended for testing applications. The server script don't adhere to the full OCPP specifications and it is advised not to use them in a production environment without additional development.
58
59 For reference:
60 https://github.com/mobilityhouse/ocpp