OCPP charge point
Overview
Open Charge Point Protocol (OCPP) is an application protocol for communication between Charge Points (Electric vehicle (EV) charging stations) and a central management system, also known as a charging station network.
This ocpp sample application for Zephyr implements the OCPP library and establishes a connection to an Central System server using the web socket
The source code for this sample application can be found at: samples/net/ocpp.
Requirements
Linux machine
STM32 Discovery kit (32F769IDISCOVERY) or any network interface device
SteVe Demo Server (<https://github.com/steve-community/steve/blob/master/README.md>)
LAN for testing purposes (Ethernet)
Configuration
The sample application supports several configuration options that can be set via Kconfig:
CONFIG_NET_SAMPLE_OCPP_SERVER: OCPP central system server IP addressCONFIG_NET_SAMPLE_OCPP_PORT: OCPP central system server port numberCONFIG_NET_SAMPLE_OCPP_WS_PATH: WebSocket URL path.CONFIG_NET_SAMPLE_SNTP_SERVER: SNTP server IP address to get the time from networkCONFIG_NET_SAMPLE_OCPP_AUTH_USERNAMEandCONFIG_NET_SAMPLE_OCPP_AUTH_PASSWORD: credentials of the HTTP Basic authentication, sent to the central system whenCONFIG_OCPP_BASIC_AUTHis enabled. The username must be equal to the charge point identity, the last element ofCONFIG_NET_SAMPLE_OCPP_WS_PATH, and the password is the authorization key, of 16 to 40 printable characters by default. See HTTP Basic authentication for the rules of the OCPP 1.6 security whitepaper.
Generating keys and certificate for TLS (Optional):
Generate a ECDSA Private key using OpenSSL:
openssl ecparam -name prime256v1 -genkey -noout -out ec-priv.keyGenerate a self-signed certificate using OpenSSL:
openssl req -new -x509 -key ec-priv.key -days 3650 \ -subj "/CN=localhost" -outform PEM -out ec.crt
Building and Running
Build the ocpp sample application like this:
west build -b <board to use> samples/net/ocpp
The sample application is to built and tested on
west build -b stm32f769i_disco
west flash
The output of sample is:
*** Booting Zephyr OS build v3.6.0-rc1-37-g8c035d8f24cf ***
OCPP sample stm32f769i_disco
[00:00:02.642,000] <inf> net_dhcpv4: Received: 192.168.1.101
[00:00:02.642,000] <inf> main: net mgr cb
[00:00:02.642,000] <inf> main: Your address: 192.168.1.101
[00:00:02.642,000] <inf> main: Lease time: 86400 seconds
[00:00:02.642,000] <inf> main: Subnet: 255.255.255.0
[00:00:02.643,000] <inf> main: Router: 192.168.1.1
[00:00:07.011,000] <inf> main: cs server 122.165.245.213 8180
[00:00:07.011,000] <inf> main: IPv4 Address 122.165.245.213
[00:00:07.024,000] <inf> main: sntp succ since Epoch: 1707890823
[00:00:07.024,000] <inf> ocpp: upstream init
[00:00:07.025,000] <inf> ocpp: ocpp init success
[00:00:17.066,000] <inf> main: ocpp auth 0> idcon 1 status 1
[00:00:17.101,000] <inf> main: ocpp auth 0> idcon 2 status 1
[00:00:17.197,000] <inf> main: ocpp start charging connector id 1
[00:00:17.255,000] <inf> main: ocpp start charging connector id 2
[00:01:07.064,000] <inf> main: ocpp stop charging connector id 1
[00:01:08.063,000] <inf> main: ocpp stop charging connector id 2