Commit | Line | Data |
---|---|---|
fa16d389 S |
1 | # OCPP2 Mock Server |
2 | ||
dd4588bb | 3 | This project includes an Open Charge Point Protocol (OCPP) version 2.0.1 mock server implemented in Python. |
f937c172 | 4 | https://github.com/mobilityhouse/ocpp/blob/master/ocpp/v201/enums.py |
fa16d389 S |
5 | |
6 | ## Prerequisites | |
7 | ||
c11be92a | 8 | This project requires Python 3.7+ and [poetry](https://python-poetry.org/) to install the required packages: |
f937c172 S |
9 | ```shell |
10 | pip install poetry | |
11 | ``` | |
12 | then | |
dd4588bb | 13 | |
ac96356c | 14 | ```shell |
c11be92a | 15 | poetry install |
fa16d389 S |
16 | ``` |
17 | ||
f937c172 | 18 | |
fa16d389 S |
19 | ## Running the Server |
20 | ||
21 | To start the server, run the `server.py` script: | |
22 | ||
ac96356c | 23 | ```shell |
3a89ffcb | 24 | poetry run task server |
fa16d389 | 25 | ``` |
f937c172 | 26 | or |
fa16d389 | 27 | |
f937c172 S |
28 | ```shell |
29 | poetry run task server --request GetBaseReport --period 5 | |
30 | ``` | |
fa16d389 S |
31 | The server will start listening for connections on port 9000. |
32 | ||
33 | ## Overview of the Server Scripts | |
34 | ||
35 | ### Server.py | |
36 | ||
4c69efea | 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 messages, most of which return a dummy response. |
fa16d389 | 38 | |
4c69efea | 39 | The server script uses the `websockets` and `ocpp` libraries to facilitate the implementation. |
fa16d389 | 40 | |
ac96356c JB |
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 | ||
fa16d389 S |
55 | ## Note |
56 | ||
c11be92a | 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. |
fa16d389 S |
58 | |
59 | For reference: | |
60 | https://github.com/mobilityhouse/ocpp |