File syn_ocpp.h¶
FileList > proto > syn_ocpp.h
Go to the source code of this file
Open Charge Point Protocol over JSON (OCPP-J 1.6 / 2.0.1) Dual-Role Engine. More...
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_OCPP_ChargePointInfo Charge Point information for BootNotification. |
| struct | SYN_OCPP_Client OCPP Client instance state (EVSE Role). |
| struct | SYN_OCPP_DisplayMessage OCPP 2.1 Customer Display Message Structure. |
| struct | SYN_OCPP_MeterValues Meter Values reading structure. |
| struct | SYN_OCPP_Server OCPP Server instance state (CSMS Central System Role). |
Public Types¶
| Type | Name |
|---|---|
| typedef void(* | SYN_OCPP_AuthorizationHandler Authorization response callback. |
| enum | SYN_OCPP_AuthorizationStatus OCPP Authorization Status Enumeration. |
| enum | SYN_OCPP_ChargePointStatus OCPP Connector Status Enumeration (OCPP 1.6 / 2.0.1 / 2.1). |
| typedef void(* | SYN_OCPP_RegistrationHandler Registration response callback. |
| enum | SYN_OCPP_RegistrationStatus OCPP Registration Status Enumeration. |
| typedef bool(* | SYN_OCPP_RemoteStartHandler Remote Start Transaction handler callback. |
| typedef bool(* | SYN_OCPP_RemoteStopHandler Remote Stop Transaction handler callback. |
| typedef SYN_OCPP_AuthorizationStatus(* | SYN_OCPP_ServerAuthorizeHandler CSMS Server station authorize callback. |
| typedef SYN_OCPP_RegistrationStatus(* | SYN_OCPP_ServerBootHandler CSMS Server station boot callback. |
| typedef int32_t(* | SYN_OCPP_ServerStartTxHandler CSMS Server station start transaction callback. |
| typedef void(* | SYN_OCPP_StartTxHandler Start Transaction response callback. |
| enum | SYN_OCPP_V2GMode OCPP 2.1 ISO 15118-20 Bidirectional V2G Energy Transfer Control Mode. |
| enum | SYN_OCPP_Version Supported OCPP Protocol Versions. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_ocpp_format_authorize (SYN_OCPP_Client * client, const char * id_tag, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J Authorize.req Call frame. |
| SYN_Status | syn_ocpp_format_boot_notification (SYN_OCPP_Client * client, const SYN_OCPP_ChargePointInfo * info, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J BootNotification.req Call frame. |
| SYN_Status | syn_ocpp_format_call_error (const char * msg_id, const char * error_code, const char * error_description, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J CallError (MessageTypeId 4) response frame. |
| SYN_Status | syn_ocpp_format_display_message (SYN_OCPP_Client * client, const SYN_OCPP_DisplayMessage * msg, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP 2.1 Customer DisplayMessage Call frame. |
| SYN_Status | syn_ocpp_format_heartbeat (SYN_OCPP_Client * client, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J Heartbeat.req Call frame. |
| SYN_Status | syn_ocpp_format_meter_values (SYN_OCPP_Client * client, uint32_t connector_id, const SYN_OCPP_MeterValues * values, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J MeterValues.req Call frame. |
| SYN_Status | syn_ocpp_format_start_transaction (SYN_OCPP_Client * client, uint32_t connector_id, const char * id_tag, uint32_t meter_start_wh, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J StartTransaction.req Call frame. |
| SYN_Status | syn_ocpp_format_status_notification (SYN_OCPP_Client * client, uint32_t connector_id, SYN_OCPP_ChargePointStatus status, const char * error_code, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J StatusNotification.req Call frame. |
| SYN_Status | syn_ocpp_format_stop_transaction (SYN_OCPP_Client * client, int32_t transaction_id, uint32_t meter_stop_wh, const char * reason, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP-J StopTransaction.req Call frame. |
| SYN_Status | syn_ocpp_format_v2g_energy_transfer (SYN_OCPP_Client * client, SYN_OCPP_V2GMode mode, int32_t power_limit_w, char * out_buf, size_t max_len, size_t * out_len) Format an OCPP 2.1 ISO 15118-20 V2G Energy Transfer Request Call frame. |
| SYN_Status | syn_ocpp_init (SYN_OCPP_Client * client) Initialize an OCPP-J client instance. |
| SYN_Status | syn_ocpp_process_message (SYN_OCPP_Client * client, const char * in_buf, size_t in_len, char * out_resp, size_t max_resp_len, size_t * out_resp_len) Process an incoming OCPP-J JSON frame. |
| SYN_Status | syn_ocpp_server_format_remote_start (SYN_OCPP_Server * server, uint32_t connector_id, const char * id_tag, char * out_buf, size_t max_len, size_t * out_len) Format a RemoteStartTransaction.req Call frame from CSMS server to station. |
| SYN_Status | syn_ocpp_server_format_remote_stop (SYN_OCPP_Server * server, int32_t transaction_id, char * out_buf, size_t max_len, size_t * out_len) Format a RemoteStopTransaction.req Call frame from CSMS server to station. |
| SYN_Status | syn_ocpp_server_init (SYN_OCPP_Server * server) Initialize an OCPP CSMS Server instance. |
| SYN_Status | syn_ocpp_server_process_message (SYN_OCPP_Server * server, const char * in_buf, size_t in_len, char * out_resp, size_t max_resp_len, size_t * out_resp_len) Process incoming station request frame on CSMS server and generate response CallResult. |
| SYN_Status | syn_ocpp_server_set_callbacks (SYN_OCPP_Server * server, SYN_OCPP_ServerBootHandler boot_cb, SYN_OCPP_ServerAuthorizeHandler auth_cb, SYN_OCPP_ServerStartTxHandler start_tx_cb, void * user_ctx) Set event callbacks for OCPP CSMS Server. |
| SYN_Status | syn_ocpp_set_callbacks (SYN_OCPP_Client * client, SYN_OCPP_RegistrationHandler reg_cb, SYN_OCPP_AuthorizationHandler auth_cb, SYN_OCPP_StartTxHandler start_tx_cb, SYN_OCPP_RemoteStartHandler remote_start_cb, SYN_OCPP_RemoteStopHandler remote_stop_cb, void * user_ctx) Set event and remote command callbacks for OCPP client. |
| void | syn_ocpp_tick (SYN_OCPP_Client * client, uint32_t dt_ms, char * out_hb_buf, size_t max_len, size_t * out_len) Tick periodic Heartbeat timer for OCPP client. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_OCPP_ERROR_FORMATION_VIOLATION "FormationViolation" |
| define | SYN_OCPP_ERROR_GENERIC_ERROR "GenericError" |
| define | SYN_OCPP_ERROR_INTERNAL_ERROR "InternalError" |
| define | SYN_OCPP_ERROR_NOT_IMPLEMENTED "NotImplemented" |
| define | SYN_OCPP_ERROR_NOT_SUPPORTED "NotSupported" |
| define | SYN_OCPP_ERROR_OCCURRENCE_CONSTRAINT_VIOLATION "OccurenceConstraintViolation" |
| define | SYN_OCPP_ERROR_PROPERTY_CONSTRAINT_VIOLATION "PropertyConstraintViolation" |
| define | SYN_OCPP_ERROR_PROTOCOL_ERROR "ProtocolError" |
| define | SYN_OCPP_ERROR_SECURITY_ERROR "SecurityError" |
| define | SYN_OCPP_ERROR_TYPE_CONSTRAINT_VIOLATION "TypeConstraintViolation" |
| define | SYN_OCPP_MSG_TYPE_CALL 2U |
| define | SYN_OCPP_MSG_TYPE_CALLERROR 4U |
| define | SYN_OCPP_MSG_TYPE_CALLRESULT 3U |
| define | SYN_OCPP_SUBPROTOCOL_1_6 "ocpp1.6" |
| define | SYN_OCPP_SUBPROTOCOL_2_0_1 "ocpp2.0.1" |
| define | SYN_OCPP_SUBPROTOCOL_2_1 "ocpp2.1" |
Detailed Description¶
Implements a lightweight, zero-allocation OCPP-J protocol engine supporting both Charge Point (EVSE Client) and Central Management System (CSMS Server) roles.
Public Types Documentation¶
typedef SYN_OCPP_AuthorizationHandler¶
Authorization response callback.
typedef void(* SYN_OCPP_AuthorizationHandler) (const char *id_tag, SYN_OCPP_AuthorizationStatus status, void *user_ctx);
enum SYN_OCPP_AuthorizationStatus¶
OCPP Authorization Status Enumeration.
enum SYN_OCPP_AuthorizationStatus {
SYN_OCPP_AUTH_ACCEPTED = 0,
SYN_OCPP_AUTH_BLOCKED,
SYN_OCPP_AUTH_EXPIRED,
SYN_OCPP_AUTH_INVALID
};
enum SYN_OCPP_ChargePointStatus¶
OCPP Connector Status Enumeration (OCPP 1.6 / 2.0.1 / 2.1).
enum SYN_OCPP_ChargePointStatus {
SYN_OCPP_STATUS_AVAILABLE = 0,
SYN_OCPP_STATUS_PREPARING,
SYN_OCPP_STATUS_CHARGING,
SYN_OCPP_STATUS_SUSPENDED_EV,
SYN_OCPP_STATUS_SUSPENDED_EVSE,
SYN_OCPP_STATUS_FINISHING,
SYN_OCPP_STATUS_RESERVED,
SYN_OCPP_STATUS_UNAVAILABLE,
SYN_OCPP_STATUS_FAULTED
};
typedef SYN_OCPP_RegistrationHandler¶
Registration response callback.
typedef void(* SYN_OCPP_RegistrationHandler) (SYN_OCPP_RegistrationStatus status, uint32_t heartbeat_interval_sec, void *user_ctx);
enum SYN_OCPP_RegistrationStatus¶
OCPP Registration Status Enumeration.
enum SYN_OCPP_RegistrationStatus {
SYN_OCPP_REGISTRATION_ACCEPTED = 0,
SYN_OCPP_REGISTRATION_PENDING,
SYN_OCPP_REGISTRATION_REJECTED
};
typedef SYN_OCPP_RemoteStartHandler¶
Remote Start Transaction handler callback.
typedef bool(* SYN_OCPP_RemoteStartHandler) (uint32_t connector_id, const char *id_tag, void *user_ctx);
typedef SYN_OCPP_RemoteStopHandler¶
Remote Stop Transaction handler callback.
typedef SYN_OCPP_ServerAuthorizeHandler¶
CSMS Server station authorize callback.
typedef SYN_OCPP_AuthorizationStatus(* SYN_OCPP_ServerAuthorizeHandler) (const char *id_tag, void *user_ctx);
typedef SYN_OCPP_ServerBootHandler¶
CSMS Server station boot callback.
typedef SYN_OCPP_RegistrationStatus(* SYN_OCPP_ServerBootHandler) (const SYN_OCPP_ChargePointInfo *info, uint32_t *heartbeat_sec, void *user_ctx);
typedef SYN_OCPP_ServerStartTxHandler¶
CSMS Server station start transaction callback.
typedef int32_t(* SYN_OCPP_ServerStartTxHandler) (uint32_t connector_id, const char *id_tag, uint32_t meter_start_wh, void *user_ctx);
typedef SYN_OCPP_StartTxHandler¶
Start Transaction response callback.
typedef void(* SYN_OCPP_StartTxHandler) (int32_t transaction_id, SYN_OCPP_AuthorizationStatus status, void *user_ctx);
enum SYN_OCPP_V2GMode¶
OCPP 2.1 ISO 15118-20 Bidirectional V2G Energy Transfer Control Mode.
enum SYN_OCPP_Version¶
Supported OCPP Protocol Versions.
Public Functions Documentation¶
function syn_ocpp_format_authorize¶
Format an OCPP-J Authorize.req Call frame.
SYN_Status syn_ocpp_format_authorize (
SYN_OCPP_Client * client,
const char * id_tag,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.id_tagRFID tag string.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_boot_notification¶
Format an OCPP-J BootNotification.req Call frame.
SYN_Status syn_ocpp_format_boot_notification (
SYN_OCPP_Client * client,
const SYN_OCPP_ChargePointInfo * info,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.infoCharge point info.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_call_error¶
Format an OCPP-J CallError (MessageTypeId 4) response frame.
SYN_Status syn_ocpp_format_call_error (
const char * msg_id,
const char * error_code,
const char * error_description,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
msg_idUnique message identifier string to match Call request.error_codeError code string (e.g. SYN_OCPP_ERROR_NOT_IMPLEMENTED).error_descriptionOptional human-readable error description string.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_ocpp_format_display_message¶
Format an OCPP 2.1 Customer DisplayMessage Call frame.
SYN_Status syn_ocpp_format_display_message (
SYN_OCPP_Client * client,
const SYN_OCPP_DisplayMessage * msg,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.msgPointer to DisplayMessage structure.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_heartbeat¶
Format an OCPP-J Heartbeat.req Call frame.
SYN_Status syn_ocpp_format_heartbeat (
SYN_OCPP_Client * client,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_meter_values¶
Format an OCPP-J MeterValues.req Call frame.
SYN_Status syn_ocpp_format_meter_values (
SYN_OCPP_Client * client,
uint32_t connector_id,
const SYN_OCPP_MeterValues * values,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.connector_idConnector ID.valuesMeter readings pointer.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_start_transaction¶
Format an OCPP-J StartTransaction.req Call frame.
SYN_Status syn_ocpp_format_start_transaction (
SYN_OCPP_Client * client,
uint32_t connector_id,
const char * id_tag,
uint32_t meter_start_wh,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.connector_idConnector ID.id_tagRFID tag string.meter_start_whMeter reading in Wh.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_status_notification¶
Format an OCPP-J StatusNotification.req Call frame.
SYN_Status syn_ocpp_format_status_notification (
SYN_OCPP_Client * client,
uint32_t connector_id,
SYN_OCPP_ChargePointStatus status,
const char * error_code,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.connector_idConnector ID.statusStatus enum.error_codeError code string.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_stop_transaction¶
Format an OCPP-J StopTransaction.req Call frame.
SYN_Status syn_ocpp_format_stop_transaction (
SYN_OCPP_Client * client,
int32_t transaction_id,
uint32_t meter_stop_wh,
const char * reason,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.transaction_idActive transaction ID.meter_stop_whMeter reading in Wh.reasonReason string.out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_format_v2g_energy_transfer¶
Format an OCPP 2.1 ISO 15118-20 V2G Energy Transfer Request Call frame.
SYN_Status syn_ocpp_format_v2g_energy_transfer (
SYN_OCPP_Client * client,
SYN_OCPP_V2GMode mode,
int32_t power_limit_w,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.modeV2G control mode (Scheduled / Dynamic).power_limit_wPower limit in Watts (positive for charging, negative for discharging).out_bufOutput text buffer.max_lenBuffer capacity.out_lenPointer to store length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_init¶
Initialize an OCPP-J client instance.
Parameters:
clientPointer to client instance.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if client is NULL.
function syn_ocpp_process_message¶
Process an incoming OCPP-J JSON frame.
SYN_Status syn_ocpp_process_message (
SYN_OCPP_Client * client,
const char * in_buf,
size_t in_len,
char * out_resp,
size_t max_resp_len,
size_t * out_resp_len
)
Parameters:
clientPointer to client instance.in_bufIncoming text frame.in_lenFrame length.out_respOptional response buffer.max_resp_lenResponse capacity.out_resp_lenPointer to store response length.
Returns:
SYN_OK on success, error code on failure.
function syn_ocpp_server_format_remote_start¶
Format a RemoteStartTransaction.req Call frame from CSMS server to station.
SYN_Status syn_ocpp_server_format_remote_start (
SYN_OCPP_Server * server,
uint32_t connector_id,
const char * id_tag,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
serverPointer to server instance.connector_idTarget connector ID.id_tagTarget RFID tag string.out_bufOutput text buffer for JSON payload.max_lenCapacity of output buffer.out_lenPointer to store output byte count.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_ocpp_server_format_remote_stop¶
Format a RemoteStopTransaction.req Call frame from CSMS server to station.
SYN_Status syn_ocpp_server_format_remote_stop (
SYN_OCPP_Server * server,
int32_t transaction_id,
char * out_buf,
size_t max_len,
size_t * out_len
)
Parameters:
serverPointer to server instance.transaction_idActive transaction ID to stop.out_bufOutput text buffer for JSON payload.max_lenCapacity of output buffer.out_lenPointer to store output byte count.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_ocpp_server_init¶
Initialize an OCPP CSMS Server instance.
Parameters:
serverPointer to server instance.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if server is NULL.
function syn_ocpp_server_process_message¶
Process incoming station request frame on CSMS server and generate response CallResult.
SYN_Status syn_ocpp_server_process_message (
SYN_OCPP_Server * server,
const char * in_buf,
size_t in_len,
char * out_resp,
size_t max_resp_len,
size_t * out_resp_len
)
Parameters:
serverPointer to server instance.in_bufIncoming JSON frame from station.in_lenLength of incoming JSON frame.out_respOutput buffer for CallResult response frame.max_resp_lenCapacity of output response buffer.out_resp_lenPointer to store response byte count.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
function syn_ocpp_server_set_callbacks¶
Set event callbacks for OCPP CSMS Server.
SYN_Status syn_ocpp_server_set_callbacks (
SYN_OCPP_Server * server,
SYN_OCPP_ServerBootHandler boot_cb,
SYN_OCPP_ServerAuthorizeHandler auth_cb,
SYN_OCPP_ServerStartTxHandler start_tx_cb,
void * user_ctx
)
Parameters:
serverPointer to server instance.boot_cbStation registration callback.auth_cbRFID authorization callback.start_tx_cbStartTransaction callback.user_ctxUser context pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if server is NULL.
function syn_ocpp_set_callbacks¶
Set event and remote command callbacks for OCPP client.
SYN_Status syn_ocpp_set_callbacks (
SYN_OCPP_Client * client,
SYN_OCPP_RegistrationHandler reg_cb,
SYN_OCPP_AuthorizationHandler auth_cb,
SYN_OCPP_StartTxHandler start_tx_cb,
SYN_OCPP_RemoteStartHandler remote_start_cb,
SYN_OCPP_RemoteStopHandler remote_stop_cb,
void * user_ctx
)
Parameters:
clientPointer to client instance.reg_cbRegistration response callback.auth_cbAuthorization response callback.start_tx_cbStartTransaction response callback.remote_start_cbRemoteStart command callback.remote_stop_cbRemoteStop command callback.user_ctxUser context pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if client is NULL.
function syn_ocpp_tick¶
Tick periodic Heartbeat timer for OCPP client.
void syn_ocpp_tick (
SYN_OCPP_Client * client,
uint32_t dt_ms,
char * out_hb_buf,
size_t max_len,
size_t * out_len
)
Parameters:
clientPointer to client instance.dt_msElapsed time step in ms.out_hb_bufOutput heartbeat buffer.max_lenBuffer capacity.out_lenPointer to store length.
Macro Definition Documentation¶
define SYN_OCPP_ERROR_FORMATION_VIOLATION¶
Syntax formation violation
define SYN_OCPP_ERROR_GENERIC_ERROR¶
Generic error
define SYN_OCPP_ERROR_INTERNAL_ERROR¶
Internal error
define SYN_OCPP_ERROR_NOT_IMPLEMENTED¶
Action not implemented
define SYN_OCPP_ERROR_NOT_SUPPORTED¶
Action not supported
define SYN_OCPP_ERROR_OCCURRENCE_CONSTRAINT_VIOLATION¶
Field occurrence violation
define SYN_OCPP_ERROR_PROPERTY_CONSTRAINT_VIOLATION¶
Field property constraint violation
define SYN_OCPP_ERROR_PROTOCOL_ERROR¶
Protocol error
define SYN_OCPP_ERROR_SECURITY_ERROR¶
Security error
define SYN_OCPP_ERROR_TYPE_CONSTRAINT_VIOLATION¶
Data type constraint violation
define SYN_OCPP_MSG_TYPE_CALL¶
Client/Server Request Call
define SYN_OCPP_MSG_TYPE_CALLERROR¶
Error Response
define SYN_OCPP_MSG_TYPE_CALLRESULT¶
Success Response
define SYN_OCPP_SUBPROTOCOL_1_6¶
Official OCPP 1.6-J WebSocket Subprotocol
define SYN_OCPP_SUBPROTOCOL_2_0_1¶
Official OCPP 2.0.1 WebSocket Subprotocol
define SYN_OCPP_SUBPROTOCOL_2_1¶
Official OCPP 2.1 WebSocket Subprotocol
The documentation for this class was generated from the following file src/syntropic/proto/syn_ocpp.h