Skip to content

Commit b5f14a7

Browse files
committed
samples: net: ocpp: Charge Point test sample
A test sample for ocpp charge point with 2 connectors, central system steve server is used with test setup (public available) Signed-off-by: Saravanan Sekar <[email protected]>
1 parent 93e9ffc commit b5f14a7

File tree

6 files changed

+560
-0
lines changed

6 files changed

+560
-0
lines changed

samples/net/ocpp/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(ocpp)
7+
8+
target_sources(app PRIVATE src/main.c)

samples/net/ocpp/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Config options for OCPP sample application
2+
3+
# Copyright (c) 2025 Linumiz GmbH
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
mainmenu "OCPP sample application"
7+
config NET_SAMPLE_OCPP_SERVER
8+
string "OCPP server ip"
9+
help
10+
OCPP central system server ip address
11+
12+
config NET_SAMPLE_OCPP_PORT
13+
int "OCPP server port"
14+
help
15+
OCPP central system server port
16+
17+
config NET_SAMPLE_SNTP_SERVER
18+
string "SNTP server ip"
19+
help
20+
SNTP server ip to get the time from network
21+
22+
source "Kconfig.zephyr"

samples/net/ocpp/README.rst

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. zephyr:code-sample:: ocpp
2+
:name: OCPP charge point
3+
:relevant-api: ocpp_api
4+
5+
Implement an OCPP charge point that connects to a Central System server and
6+
simulates the meter readings.
7+
8+
Overview
9+
********
10+
11+
Open Charge Point Protocol (OCPP) is an application protocol for communication
12+
between Charge Points (Electric vehicle (EV) charging stations) and a central
13+
management system, also known as a charging station network.
14+
15+
This ocpp sample application for Zephyr implements the ocpp library
16+
and establishes a connection to an Central System server using the web socket
17+
18+
The source code for this sample application can be found at:
19+
:zephyr_file:`samples/net/ocpp`.
20+
21+
Requirements
22+
************
23+
24+
- Linux machine
25+
- STEM32 Discovery kit (32F769IDISCOVERY) or any network interface device
26+
- SteVe Demo Server (<https://github.com/steve-community/steve/blob/master/README.md>)
27+
- LAN for testing purposes (Ethernet)
28+
29+
Building and Running
30+
********************
31+
32+
Build the ocpp sample application like this:
33+
34+
.. zephyr-app-commands::
35+
:zephyr-app: samples/net/ocpp
36+
:board: <board to use>
37+
:goals: build
38+
:compact:
39+
40+
The sample application is to built and tested on
41+
42+
.. code-block:: console
43+
44+
west build -b stm32f769i_disco
45+
west flash
46+
47+
The output of sample is:
48+
49+
.. code-block:: console
50+
51+
*** Booting Zephyr OS build v3.6.0-rc1-37-g8c035d8f24cf ***
52+
OCPP sample stm32f769i_disco
53+
[00:00:02.642,000] <inf> net_dhcpv4: Received: 192.168.1.101
54+
[00:00:02.642,000] <inf> main: net mgr cb
55+
[00:00:02.642,000] <inf> main: Your address: 192.168.1.101
56+
[00:00:02.642,000] <inf> main: Lease time: 86400 seconds
57+
[00:00:02.642,000] <inf> main: Subnet: 255.255.255.0
58+
[00:00:02.643,000] <inf> main: Router: 192.168.1.1
59+
[00:00:07.011,000] <inf> main: cs server 122.165.245.213 8180
60+
[00:00:07.011,000] <inf> main: IPv4 Address 122.165.245.213
61+
[00:00:07.024,000] <inf> main: sntp succ since Epoch: 1707890823
62+
[00:00:07.024,000] <inf> ocpp: upstream init
63+
[00:00:07.025,000] <inf> ocpp: ocpp init success
64+
[00:00:17.066,000] <inf> main: ocpp auth 0> idcon 1 status 1
65+
[00:00:17.101,000] <inf> main: ocpp auth 0> idcon 2 status 1
66+
[00:00:17.197,000] <inf> main: ocpp start charging connector id 1
67+
[00:00:17.255,000] <inf> main: ocpp start charging connector id 2
68+
[00:01:07.064,000] <inf> main: ocpp stop charging connector id 1
69+
[00:01:08.063,000] <inf> main: ocpp stop charging connector id 2

samples/net/ocpp/prj.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# HTTP & Websocket
2+
CONFIG_HTTP_CLIENT=y
3+
CONFIG_WEBSOCKET_CLIENT=y
4+
5+
# Networking config
6+
CONFIG_NETWORKING=y
7+
CONFIG_NET_IPV4=y
8+
CONFIG_NET_IPV6=n
9+
CONFIG_NET_TCP=y
10+
CONFIG_NET_SOCKETS=y
11+
CONFIG_NET_SOCKETS_POLL_MAX=4
12+
CONFIG_NET_L2_ETHERNET=y
13+
CONFIG_ETH_DRIVER=y
14+
CONFIG_LOG=y
15+
CONFIG_NET_LOG=y
16+
17+
# OCPP
18+
CONFIG_OCPP=y
19+
20+
# Please set the server addresses when compiling the sample
21+
CONFIG_NET_SAMPLE_SNTP_SERVER=""
22+
CONFIG_NET_SAMPLE_OCPP_SERVER=""
23+
CONFIG_NET_SAMPLE_OCPP_PORT=8180
24+
25+
CONFIG_MAIN_STACK_SIZE=4096
26+
CONFIG_HEAP_MEM_POOL_SIZE=15000
27+
28+
CONFIG_JSON_LIBRARY=y
29+
CONFIG_PICOLIBC=y
30+
CONFIG_NET_ARP=y
31+
CONFIG_NET_UDP=y
32+
CONFIG_NET_DHCPV4=y
33+
CONFIG_NET_DHCPV4_OPTION_CALLBACKS=y
34+
CONFIG_TEST_RANDOM_GENERATOR=y
35+
36+
CONFIG_NET_TX_STACK_SIZE=2048
37+
CONFIG_NET_RX_STACK_SIZE=2048
38+
CONFIG_NET_PKT_RX_COUNT=28
39+
CONFIG_NET_BUF_RX_COUNT=60
40+
CONFIG_NET_MGMT=y
41+
CONFIG_NET_MGMT_EVENT=y
42+
43+
CONFIG_SNTP=y
44+
45+
CONFIG_ZBUS=y
46+
CONFIG_ZBUS_RUNTIME_OBSERVERS=y
47+
CONFIG_POSIX_API=y
48+
CONFIG_POSIX_CLOCK_SELECTION=y

samples/net/ocpp/sample.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
sample:
2+
description: OCPP sample application
3+
name: OCPP charge point
4+
common:
5+
harness: net
6+
tags:
7+
- net
8+
- ocpp
9+
10+
tests:
11+
sample.net.ocpp:
12+
platform_allow:
13+
- stm32f769i_disco
14+
tags:
15+
- net
16+
- ocpp

0 commit comments

Comments
 (0)