Skip to content

OCPP 1.6 native stack #68739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,7 @@ Networking:
files-exclude:
- doc/connectivity/networking/api/gptp.rst
- doc/connectivity/networking/api/ieee802154.rst
- doc/connectivity/networking/api/ocpp.rst
- doc/connectivity/networking/api/wifi.rst
- include/zephyr/net/gptp.h
- include/zephyr/net/ieee802154*.h
Expand All @@ -2582,6 +2583,7 @@ Networking:
- samples/net/gptp/
- samples/net/sockets/coap_*/
- samples/net/lwm2m_client/
- samples/net/ocpp/
- samples/net/wifi/
- samples/net/dhcpv4_client/
- subsys/net/buf*.c
Expand All @@ -2591,10 +2593,12 @@ Networking:
- subsys/net/lib/coap/
- subsys/net/lib/config/ieee802154*
- subsys/net/lib/lwm2m/
- subsys/net/lib/ocpp/
- subsys/net/lib/tls_credentials/
- subsys/net/lib/dhcpv4/
- tests/net/dhcpv4/
- tests/net/ieee802154/
- tests/net/lib/ocpp/
- tests/net/wifi/
labels:
- "area: Networking"
Expand Down Expand Up @@ -2764,6 +2768,17 @@ Networking:
tests:
- net.ieee802154

"Networking: OCPP":
status: maintained
maintainers:
- ssekar15
files:
- samples/net/ocpp/
- subsys/net/lib/ocpp/
- tests/net/lib/ocpp/
labels:
- "area: OCPP"

"Networking: OpenThread":
status: maintained
maintainers:
Expand Down Expand Up @@ -4928,3 +4943,12 @@ zbus:
- "area: Linkable Loadable Extensions"
tests:
- llext

"West project: json-c":
status: maintained
maintainers:
- parthitce
files:
- modules/json-c/
labels:
- "area: JSON"
110 changes: 110 additions & 0 deletions doc/connectivity/networking/api/ocpp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
.. _ocpp_interface:

Open Charge Point Protocol (OCPP)
#################################

.. contents::
:local:
:depth: 2

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. OCPP is a
`standard <https://openchargealliance.org/protocols/open-charge-point-protocol/>`_
defined by The Open Charge Alliance and goal is to offer a uniform solution for
the method of communication between charge point and central system. With this
protocol it is possible to connect any central system with any charge point,
regardless of the vendor

Zephyr provides an OCPP Charge Point (CP) library built on top of websocket API
with payload in json format. The library can be enabled with
:kconfig:option:`CONFIG_OCPP` Kconfig option. Currently OCPP 1.6 with basic
core profile is supported.

OCPP charge point (CP) require a Central System (CS) server to connect, an open
source SteVe server shall be setup locally for devlopment purpose, See
`SteVe server <https://github.com/steve-community/steve/blob/master/README.md>`_
for more information about the setup.

The Zephyr OCPP CP library implements the following items:

* engine to process socket connectivity and events
* OCPP core functions to frame/parse payload, user notification for OCPP events,
heartbeat notification

Sample usage
************

Init ocpp library with overall CP and CS information. Prior to init an OCPP
library, a network interface should be ready using ethernet or wifi or modem.
A filled CP, CS structure and user callback needs to be passed in ocpp_init.

.. code-block:: c

static int user_notify_cb(ocpp_notify_reason_t reason,
ocpp_io_value_t *io,
void *user_data)
{

switch (reason) {
case OCPP_USR_GET_METER_VALUE:
...
break;

case OCPP_USR_START_CHARGING:
...
break;

...
...
}

/* OCPP configuration */
ocpp_cp_info_t cpi = { "basic", "zephyr", .num_of_con = 1};
ocpp_cs_info_t csi = {"192.168.1.3", /* ip address */
"/steve/websocket/CentralSystemService/zephyr",
8180,
AF_INET};

ret = ocpp_init(&cpi, &csi, user_notify_cb, NULL);

A unique session must open for each physical connector before any ocpp
transcation API call.

.. code-block:: c

ocpp_session_handle_t sh = NULL;
ret = ocpp_session_open(&sh);

idtag is EV user's authentication token which should match with list on CS.
Authorize request must call to ensure validity of idtag (if charging request
originate from local CP) before start energy transfer to EV.

.. code-block:: c

ocpp_auth_status_t status;
ret = ocpp_authorize(sh, idtag, &status, 500);

On successful, authorization status is available in status.

Apart from local CP, charging request may originate from CS is notified to user
in callback with OCPP_USR_START_CHARGING, here authorize request call is
optional. When the CS is ready to provide power to EV, a start transaction
is notified to CS with meter reading and connector id using ocpp_start_transaction.

.. code-block:: c

const int idcon = 1;
const int mval = 25; //meter reading in wh
ret = ocpp_start_transaction(sh, mval, idcon, 200);

Once the start transaction is success, user callback is invoked to get meter
readings from the library. callback should be not be hold for longer time.

API Reference
*************

.. doxygengroup:: ocpp_api
1 change: 1 addition & 0 deletions doc/connectivity/networking/api/protocols.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Protocols
lwm2m
mqtt
mqtt_sn
ocpp
tftp
Loading
Loading