Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

OCPP Charge Point Implementation. More...

Data Structures

union  ocpp_io_value
 OCPP user callback notification/request of input/output values union member should be accessed with enum value ocpp_notify_reason correspondingly. More...
struct  ocpp_cp_info
 Parameters for ocpp_init information about Charge Point (CP) all are string literal except num_of_con. More...
struct  ocpp_tls_credentials
 TLS credentials information of the central system (CS). More...
struct  ocpp_cs_info
 Parameters for ocpp_init information about central system (CS). More...

Macros

#define CISTR50   50
 Max length of string literals e.g idtag.

Typedefs

typedef void * ocpp_session_handle_t
 Parameters opaque session handle for ocpp_* API.
typedef int(* ocpp_user_notify_callback_t) (enum ocpp_notify_reason reason, union ocpp_io_value *io, void *user_data)
 Asynchronous event notification callback registered by the application.

Enumerations

enum  ocpp_auth_status {
  OCPP_AUTH_INVALID , OCPP_AUTH_ACCEPTED , OCPP_AUTH_BLOCKED , OCPP_AUTH_EXPIRED ,
  OCPP_AUTH_CONCURRENT_TX
}
 OCPP IdTag authorization status in result to ocpp request authorization. More...
enum  ocpp_cp_status {
  OCPP_CP_STATUS_AVAILABLE , OCPP_CP_STATUS_PREPARING , OCPP_CP_STATUS_CHARGING , OCPP_CP_STATUS_SUSPENDED_EVSE ,
  OCPP_CP_STATUS_SUSPENDED_EV , OCPP_CP_STATUS_FINISHING , OCPP_CP_STATUS_RESERVED , OCPP_CP_STATUS_UNAVAILABLE ,
  OCPP_CP_STATUS_FAULTED
}
 OCPP charge point status reported in StatusNotification. More...
enum  ocpp_cp_error_code {
  OCPP_CP_ERR_NO_ERROR , OCPP_CP_ERR_CONNECTOR_LOCK_FAILURE , OCPP_CP_ERR_EV_COMMUNICATION_ERROR , OCPP_CP_ERR_GROUND_FAILURE ,
  OCPP_CP_ERR_HIGH_TEMPERATURE , OCPP_CP_ERR_INTERNAL_ERROR , OCPP_CP_ERR_LOCAL_LIST_CONFLICT , OCPP_CP_ERR_OTHER_ERROR ,
  OCPP_CP_ERR_OVER_CURRENT_FAILURE , OCPP_CP_ERR_OVER_VOLTAGE , OCPP_CP_ERR_POWER_METER_FAILURE , OCPP_CP_ERR_POWER_SWITCH_FAILURE ,
  OCPP_CP_ERR_READER_FAILURE , OCPP_CP_ERR_RESET_FAILURE , OCPP_CP_ERR_UNDER_VOLTAGE , OCPP_CP_ERR_WEAK_SIGNAL
}
 OCPP charge point error code reported in StatusNotification. More...
enum  ocpp_notify_reason {
  OCPP_USR_GET_METER_VALUE , OCPP_USR_START_CHARGING , OCPP_USR_STOP_CHARGING , OCPP_USR_UNLOCK_CONNECTOR ,
  OCPP_USR_RESET , OCPP_USR_CHANGE_AVAILABILITY , OCPP_USR_DATA_TRANSFER
}
enum  ocpp_reset_type { OCPP_RESET_HARD , OCPP_RESET_SOFT }
 OCPP reset type requested by central system. More...
enum  ocpp_req_status {
  OCPP_REQ_ACCEPTED , OCPP_REQ_REJECTED , OCPP_REQ_SCHEDULED , OCPP_REQ_UNKNOWN_VENDOR_ID ,
  OCPP_REQ_UNKNOWN_MESSAGE_ID
}
 Reply status the application sets for a central system request. More...
enum  ocpp_availability_type { OCPP_AVAILABILITY_INOPERATIVE , OCPP_AVAILABILITY_OPERATIVE }
 OCPP availability type requested in ChangeAvailability. More...
enum  ocpp_meter_measurand {
  OCPP_OMM_CURRENT_FROM_EV , OCPP_OMM_CURRENT_TO_EV , OCPP_OMM_CURRENT_MAX_OFFERED_TO_EV , OCPP_OMM_ACTIVE_ENERGY_FROM_EV ,
  OCPP_OMM_ACTIVE_ENERGY_TO_EV , OCPP_OMM_REACTIVE_ENERGY_FROM_EV , OCPP_OMM_REACTIVE_ENERGY_TO_EV , OCPP_OMM_ACTIVE_POWER_FROM_EV ,
  OCPP_OMM_ACTIVE_POWER_TO_EV , OCPP_OMM_REACTIVE_POWER_FROM_EV , OCPP_OMM_REACTIVE_POWER_TO_EV , OCPP_OMM_POWERLINE_FREQ ,
  OCPP_OMM_POWER_FACTOR , OCPP_OMM_POWER_MAX_OFFERED_TO_EV , OCPP_OMM_FAN_SPEED , OCPP_OMM_CHARGING_PERCENT ,
  OCPP_OMM_TEMPERATURE , OCPP_OMM_VOLTAGE_AC_RMS , OCPP_OMM_END
}
 OCPP meter readings to be filled on user callback request from library. More...

Functions

int ocpp_init (struct ocpp_cp_info *cpi, struct ocpp_cs_info *csi, ocpp_user_notify_callback_t cb, void *user_data)
 OCPP library init.
int ocpp_session_open (ocpp_session_handle_t *hndl)
 API to request a new Session.
void ocpp_session_close (ocpp_session_handle_t hndl)
 API to close a Session.
int ocpp_authorize (ocpp_session_handle_t hndl, char *idtag, enum ocpp_auth_status *status, uint32_t timeout_ms)
 Authorize request call to CS to get validity of idtag.
int ocpp_start_transaction (ocpp_session_handle_t hndl, int meter_val, uint8_t conn_id, uint32_t timeout_ms)
 Notify transaction start to CS.
int ocpp_stop_transaction (ocpp_session_handle_t hndl, int meter_val, uint32_t timeout_ms)
 Notify transaction stopped to CS.
int ocpp_status_notification (ocpp_session_handle_t hndl, int conn_id, enum ocpp_cp_status status, enum ocpp_cp_error_code error, uint32_t timeout_ms)
 Notify connector status to CS via StatusNotification.

Detailed Description

OCPP Charge Point Implementation.

Since
4.3
Version
0.1.0
Note
The implementation assumes Websocket module is enabled.
By default the implementation uses OCPP version 1.6.

Macro Definition Documentation

◆ CISTR50

#define CISTR50   50

#include <zephyr/net/ocpp.h>

Max length of string literals e.g idtag.

Typedef Documentation

◆ ocpp_session_handle_t

typedef void* ocpp_session_handle_t

#include <zephyr/net/ocpp.h>

Parameters opaque session handle for ocpp_* API.

◆ ocpp_user_notify_callback_t

typedef int(* ocpp_user_notify_callback_t) (enum ocpp_notify_reason reason, union ocpp_io_value *io, void *user_data)

#include <zephyr/net/ocpp.h>

Asynchronous event notification callback registered by the application.

advised callback should not be hold for longer time to unblock the ocpp protocol stack/lib.

Only one callback runs at a time, but not always from the same thread. For a request whose io carries a status, the callback runs in the receive thread and the reply to the central system uses the status set by the user. No callback may call an ocpp API that waits for the central system, as the receive thread may be waiting for the callback to return and could not read that reply.

The reply to OCPP_USR_RESET is sent after the callback returns, so the reset must be done later from another thread, which for a soft reset also stops the running transactions first.

Parameters
[in]reasonfor callback invoked.
[in]ioreferred corresponding to reason.
[in]user_datapassed on ocpp_init.
Returns
0 or a negative error code (errno.h)

Enumeration Type Documentation

◆ ocpp_auth_status

#include <zephyr/net/ocpp.h>

OCPP IdTag authorization status in result to ocpp request authorization.

Enumerator
OCPP_AUTH_INVALID 

IdTag not valid.

OCPP_AUTH_ACCEPTED 

accepted, allowed to charge

OCPP_AUTH_BLOCKED 

blocked to charge

OCPP_AUTH_EXPIRED 

IdTag expired, not allowed to charge.

OCPP_AUTH_CONCURRENT_TX 

Parallel access of same IdTag.

◆ ocpp_availability_type

#include <zephyr/net/ocpp.h>

OCPP availability type requested in ChangeAvailability.

Enumerator
OCPP_AVAILABILITY_INOPERATIVE 

connector taken out of service

OCPP_AVAILABILITY_OPERATIVE 

connector put into service

◆ ocpp_cp_error_code

#include <zephyr/net/ocpp.h>

OCPP charge point error code reported in StatusNotification.

Enumerator
OCPP_CP_ERR_NO_ERROR 

no error

OCPP_CP_ERR_CONNECTOR_LOCK_FAILURE 

connector lock failed

OCPP_CP_ERR_EV_COMMUNICATION_ERROR 

communication with EV lost

OCPP_CP_ERR_GROUND_FAILURE 

ground fault detected

OCPP_CP_ERR_HIGH_TEMPERATURE 

over temperature

OCPP_CP_ERR_INTERNAL_ERROR 

internal error

OCPP_CP_ERR_LOCAL_LIST_CONFLICT 

local list version conflict

OCPP_CP_ERR_OTHER_ERROR 

other error

OCPP_CP_ERR_OVER_CURRENT_FAILURE 

over current

OCPP_CP_ERR_OVER_VOLTAGE 

over voltage

OCPP_CP_ERR_POWER_METER_FAILURE 

power meter failure

OCPP_CP_ERR_POWER_SWITCH_FAILURE 

power switch failure

OCPP_CP_ERR_READER_FAILURE 

id reader failure

OCPP_CP_ERR_RESET_FAILURE 

reset failure

OCPP_CP_ERR_UNDER_VOLTAGE 

under voltage

OCPP_CP_ERR_WEAK_SIGNAL 

weak signal

◆ ocpp_cp_status

#include <zephyr/net/ocpp.h>

OCPP charge point status reported in StatusNotification.

Enumerator
OCPP_CP_STATUS_AVAILABLE 

connector available

OCPP_CP_STATUS_PREPARING 

preparing to charge

OCPP_CP_STATUS_CHARGING 

charging in progress

OCPP_CP_STATUS_SUSPENDED_EVSE 

charging suspended by EVSE

OCPP_CP_STATUS_SUSPENDED_EV 

charging suspended by EV

OCPP_CP_STATUS_FINISHING 

transaction finishing

OCPP_CP_STATUS_RESERVED 

connector reserved

OCPP_CP_STATUS_UNAVAILABLE 

connector not available

OCPP_CP_STATUS_FAULTED 

fault present

◆ ocpp_meter_measurand

#include <zephyr/net/ocpp.h>

OCPP meter readings to be filled on user callback request from library.

Enumerator
OCPP_OMM_CURRENT_FROM_EV 

current from EV, in A

OCPP_OMM_CURRENT_TO_EV 

current to EV, in A

OCPP_OMM_CURRENT_MAX_OFFERED_TO_EV 

maximum current offered to EV, in A

OCPP_OMM_ACTIVE_ENERGY_FROM_EV 

active energy from EV, in Wh

OCPP_OMM_ACTIVE_ENERGY_TO_EV 

active energy to EV, in Wh

OCPP_OMM_REACTIVE_ENERGY_FROM_EV 

reactive energy from EV, in varh

OCPP_OMM_REACTIVE_ENERGY_TO_EV 

reactive energy to EV, in varh

OCPP_OMM_ACTIVE_POWER_FROM_EV 

active power from EV, in W

OCPP_OMM_ACTIVE_POWER_TO_EV 

active power to EV, in W

OCPP_OMM_REACTIVE_POWER_FROM_EV 

reactive power from EV, in var

OCPP_OMM_REACTIVE_POWER_TO_EV 

reactive power to EV, in var

OCPP_OMM_POWERLINE_FREQ 

powerline frequency, in Hz

OCPP_OMM_POWER_FACTOR 

power factor of supply

OCPP_OMM_POWER_MAX_OFFERED_TO_EV 

maximum power offered to EV, in W

OCPP_OMM_FAN_SPEED 

fan speed, in rpm

OCPP_OMM_CHARGING_PERCENT 

charging percentage

OCPP_OMM_TEMPERATURE 

temperature inside charge point, in Celsius

OCPP_OMM_VOLTAGE_AC_RMS 

AC RMS supply voltage, in V.

OCPP_OMM_END 

◆ ocpp_notify_reason

#include <zephyr/net/ocpp.h>

Enumerator
OCPP_USR_GET_METER_VALUE 

User must fill the current reading.

OCPP_USR_START_CHARGING 

Process the start charging request as like idtag received from local e.g authorize etc.

OCPP_USR_STOP_CHARGING 

Process the stop charging sequence.

OCPP_USR_UNLOCK_CONNECTOR 

Unlock mechanical connector of CP.

OCPP_USR_RESET 

Reset the charge point (hard or soft).

OCPP_USR_CHANGE_AVAILABILITY 

Change availability of a connector (operative/inoperative).

OCPP_USR_DATA_TRANSFER 

Vendor specific data received from central system (DataTransfer).

◆ ocpp_req_status

#include <zephyr/net/ocpp.h>

Reply status the application sets for a central system request.

Enumerator
OCPP_REQ_ACCEPTED 

request accepted

OCPP_REQ_REJECTED 

request rejected

OCPP_REQ_SCHEDULED 

ChangeAvailability applied after transaction.

OCPP_REQ_UNKNOWN_VENDOR_ID 

DataTransfer vendor id not known.

OCPP_REQ_UNKNOWN_MESSAGE_ID 

DataTransfer message id not known.

◆ ocpp_reset_type

#include <zephyr/net/ocpp.h>

OCPP reset type requested by central system.

Enumerator
OCPP_RESET_HARD 

full reboot of the charge point

OCPP_RESET_SOFT 

restart of the application only

Function Documentation

◆ ocpp_authorize()

int ocpp_authorize ( ocpp_session_handle_t hndl,
char * idtag,
enum ocpp_auth_status * status,
uint32_t timeout_ms )

#include <zephyr/net/ocpp.h>

Authorize request call to CS to get validity of idtag.

Parameters
[in]hndlsession handle
[in]idtag(string literal) to get authorize validity
[out]statusauthorization status
[in]timeout_mstimeout in msec
Returns
0 on success or a negative error code (errno.h) indicating reason of failure

◆ ocpp_init()

int ocpp_init ( struct ocpp_cp_info * cpi,
struct ocpp_cs_info * csi,
ocpp_user_notify_callback_t cb,
void * user_data )

#include <zephyr/net/ocpp.h>

OCPP library init.

Parameters
[in]cpiCharge Point information
[in]csiCentral System information
[in]cbuser register callback
[in]user_datasame reference will be passed on callback
Returns
0 on success or a negative error code (errno.h) indicating reason of failure
Note
Must be called before any other ocpp API

◆ ocpp_session_close()

void ocpp_session_close ( ocpp_session_handle_t hndl)

#include <zephyr/net/ocpp.h>

API to close a Session.

Parameters
[in]hndla handle received from session open

◆ ocpp_session_open()

int ocpp_session_open ( ocpp_session_handle_t * hndl)

#include <zephyr/net/ocpp.h>

API to request a new Session.

Parameters
[out]hndla valid opaque handle
Returns
0 on success or a negative error code (errno.h) indicating reason of failure
Note
Each connector should open unique session after ocpp_init and prior to anyother ocpp_* request message api

◆ ocpp_start_transaction()

int ocpp_start_transaction ( ocpp_session_handle_t hndl,
int meter_val,
uint8_t conn_id,
uint32_t timeout_ms )

#include <zephyr/net/ocpp.h>

Notify transaction start to CS.

Parameters
[in]hndlsession handle
[in]meter_valenergy meter reading of this connector in Wh
[in]conn_idconnector id should be > 0 and sequential number
[in]timeout_mstimeout in msec
Returns
: 0 on success EACCES - not authorized, should follow the stop charging process a negative error code (errno.h) indicating reason of failure

◆ ocpp_status_notification()

int ocpp_status_notification ( ocpp_session_handle_t hndl,
int conn_id,
enum ocpp_cp_status status,
enum ocpp_cp_error_code error,
uint32_t timeout_ms )

#include <zephyr/net/ocpp.h>

Notify connector status to CS via StatusNotification.

Parameters
[in]hndlsession handle
[in]conn_idconnector id, 0 refers to the charge point itself
[in]statusconnector status
[in]errorerror code, OCPP_CP_ERR_NO_ERROR if none
[in]timeout_mstimeout in msec
Returns
0 on success or a negative error code (errno.h) indicating reason of failure

◆ ocpp_stop_transaction()

int ocpp_stop_transaction ( ocpp_session_handle_t hndl,
int meter_val,
uint32_t timeout_ms )

#include <zephyr/net/ocpp.h>

Notify transaction stopped to CS.

Parameters
[in]hndlsession handle
[in]meter_valenergy meter reading of this connector in Wh
[in]timeout_mstimeout in msec
Returns
0 on success or a negative error code (errno.h) indicating reason of failure