3#ifndef OCPP_V16_CHARGE_POINT_HPP
4#define OCPP_V16_CHARGE_POINT_HPP
6#include <ocpp/common/cistring.hpp>
7#include <ocpp/common/evse_security.hpp>
8#include <ocpp/common/evse_security_impl.hpp>
9#include <ocpp/common/support_older_cpp_versions.hpp>
10#include <ocpp/v16/charge_point_state_machine.hpp>
11#include <ocpp/v16/ocpp_types.hpp>
12#include <ocpp/v16/smart_charging.hpp>
13#include <ocpp/v16/types.hpp>
15#include <ocpp/v16/messages/BootNotification.hpp>
16#include <ocpp/v16/messages/DataTransfer.hpp>
17#include <ocpp/v16/messages/GetConfiguration.hpp>
18#include <ocpp/v16/messages/GetDiagnostics.hpp>
19#include <ocpp/v16/messages/GetLog.hpp>
20#include <ocpp/v16/messages/SignedUpdateFirmware.hpp>
21#include <ocpp/v16/messages/UpdateFirmware.hpp>
24#include "ocpp/v16/messages/ChangeAvailability.hpp"
25#include <ocpp/v2/messages/Authorize.hpp>
26#include <ocpp/v2/messages/CertificateSigned.hpp>
27#include <ocpp/v2/messages/DeleteCertificate.hpp>
28#include <ocpp/v2/messages/Get15118EVCertificate.hpp>
29#include <ocpp/v2/messages/GetCertificateStatus.hpp>
30#include <ocpp/v2/messages/GetInstalledCertificateIds.hpp>
31#include <ocpp/v2/messages/InstallCertificate.hpp>
32#include <ocpp/v2/messages/SignCertificate.hpp>
33#include <ocpp/v2/messages/TriggerMessage.hpp>
42 std::unique_ptr<ChargePointImpl> charge_point;
74 explicit ChargePoint(
const std::string& config,
const fs::path& share_path,
const fs::path& user_config_path,
75 const fs::path& database_path,
const fs::path& sql_init_path,
const fs::path& message_log_path,
76 const std::shared_ptr<EvseSecurity> evse_security,
77 const std::optional<SecurityConfiguration> security_configuration = std::nullopt);
96 bool start(
const std::map<int, ChargePointStatus>& connector_status_map = {},
97 BootReasonEnum bootreason = BootReasonEnum::PowerUp,
98 const std::set<std::string>& resuming_session_ids = {});
106 bool restart(
const std::map<int, ChargePointStatus>& connector_status_map = {},
107 BootReasonEnum bootreason = BootReasonEnum::ApplicationReset);
146 const std::string& emaid,
const std::optional<std::string>& certificate,
147 const std::optional<std::vector<ocpp::v2::OCSPRequestData>>& iso15118_certificate_hash_data);
157 const std::string& iso15118_schema_version,
158 const ocpp::v2::CertificateActionEnum& certificate_action);
169 const std::optional<std::string>& data);
176 std::map<int32_t, ChargingSchedule>
185 std::map<int32_t, EnhancedChargingSchedule>
187 const ChargingRateUnit unit = ChargingRateUnit::A);
225 void on_session_started(int32_t connector,
const std::string& session_id,
const SessionStartedReason reason,
226 const std::optional<std::string>& session_logging_path);
244 void on_transaction_started(
const int32_t& connector,
const std::string& session_id,
const std::string& id_token,
245 const double meter_start, std::optional<int32_t> reservation_id,
246 const ocpp::DateTime& timestamp, std::optional<std::string> signed_meter_value);
261 std::optional<
CiString<20>> id_tag_end, std::optional<std::string> signed_meter_value);
315 const ocpp::FirmwareStatusNotification firmware_update_status);
348 const std::optional<bool>& critical = std::nullopt,
349 const std::optional<DateTime>& timestamp = std::nullopt);
407 const std::function<
void(
const std::string& id_token, std::vector<int32_t> referenced_connectors,
408 bool prevalidated)>& callback);
422 const std::function<ReservationStatus(int32_t reservation_id, int32_t connector,
ocpp::DateTime expiryDate,
517 const std::function<
void(
const int32_t connector,
519 const ocpp::v2::CertificateActionEnum& certificate_action)>& callback);
525 const std::function<
void(
const int32_t connector,
const std::string& session_id)>& callback);
531 const std::function<
void(
const int32_t connector,
const std::string& session_id,
const int32_t transaction_id)>&
538 const std::function<
void(
const int32_t connector,
const std::string& session_id,
const int32_t transaction_id,
539 const IdTagInfo& id_tag_info)>& callback);
547 const std::function<
void(
const KeyValue& key_value)>& callback);
559 const std::function<
void(
const std::string& type,
const std::string& tech_info)>& callback);
567 const std::function<ReservationCheckStatus(
const int32_t connector,
const std::string& id_token)>& callback);
574 session_cost_callback);
580 const std::function<
DataTransferResponse(
const std::vector<DisplayMessage>&)> set_display_message_callback);
Contains a DateTime implementation that can parse and create RFC 3339 compatible strings.
Definition: types.hpp:109
Contains a ChargePoint implementation compatible with OCPP-J 1.6.
Definition: charge_point.hpp:40
std::map< int32_t, ChargingSchedule > get_all_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit=ChargingRateUnit::A)
Calculates ChargingProfiles configured by the CSMS of all connectors from now until now + given durat...
Definition: charge_point.cpp:74
IdTagInfo authorize_id_token(CiString< 20 > id_token)
Authorizes the provided id_token against the central system, LocalAuthorizationList or AuthorizationC...
Definition: charge_point.cpp:49
void reset_state_machine(const std::map< int, ChargePointStatus > &connector_status_map)
void disconnect_websocket()
Disconnects the the websocket connection to the CSMS if it is connected.
Definition: charge_point.cpp:41
ConfigurationStatus set_custom_configuration_key(CiString< 50 > key, CiString< 500 > value)
Sets a custom configuration key.
Definition: charge_point.cpp:350
bool stop()
Stops the ChargePoint, stops timers, transactions and the message queue and disconnects from the webs...
Definition: charge_point.cpp:33
bool restart(const std::map< int, ChargePointStatus > &connector_status_map={}, BootReasonEnum bootreason=BootReasonEnum::ApplicationReset)
Restarts the ChargePoint if it has been stopped before. The ChargePoint is reinitialized,...
Definition: charge_point.cpp:29
void data_transfer_pnc_get_15118_ev_certificate(const int32_t connector_id, const std::string &exi_request, const std::string &iso15118_schema_version, const ocpp::v2::CertificateActionEnum &certificate_action)
Uses data transfer mechanism to get 15118 ev certificate from CSMS. This function can be called when ...
Definition: charge_point.cpp:60
bool start(const std::map< int, ChargePointStatus > &connector_status_map={}, BootReasonEnum bootreason=BootReasonEnum::PowerUp, const std::set< std::string > &resuming_session_ids={})
Starts the ChargePoint, initializes and connects to the Websocket endpoint and initializes a BootNoti...
Definition: charge_point.cpp:24
void connect_websocket()
Initializes the websocket and connects to CSMS if it is not yet connected.
Definition: charge_point.cpp:37
ocpp::v2::AuthorizeResponse data_transfer_pnc_authorize(const std::string &emaid, const std::optional< std::string > &certificate, const std::optional< std::vector< ocpp::v2::OCSPRequestData > > &iso15118_certificate_hash_data)
Uses data_transfer mechanism to authorize given emaid , certificate and iso15118_certificate_hash_dat...
Definition: charge_point.cpp:53
void set_message_queue_resume_delay(std::chrono::seconds delay)
Delay draining the message queue after reconnecting, so the CSMS can perform post-reconnect checks fi...
Definition: charge_point.cpp:354
GetConfigurationResponse get_configuration_key(const GetConfigurationRequest &request)
Gets the configured configuration key requested in the given request.
Definition: charge_point.cpp:346
std::optional< DataTransferResponse > data_transfer(const CiString< 255 > &vendorId, const std::optional< CiString< 50 > > &messageId, const std::optional< std::string > &data)
Allows the exchange of arbitrary data identified by a vendorId and messageId with a central system.
Definition: charge_point.cpp:68
void call_set_connection_timeout()
Calls the set_connection_timeout_callback that can be registered. This function is used to notify an ...
Definition: charge_point.cpp:45
std::map< int32_t, EnhancedChargingSchedule > get_all_enhanced_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit=ChargingRateUnit::A)
Calculates EnhancedChargingSchedule(s) configured by the CSMS of all connectors from now until now + ...
Definition: charge_point.cpp:80
ChargePoint(const std::string &config, const fs::path &share_path, const fs::path &user_config_path, const fs::path &database_path, const fs::path &sql_init_path, const fs::path &message_log_path, const std::shared_ptr< EvseSecurity > evse_security, const std::optional< SecurityConfiguration > security_configuration=std::nullopt)
The main entrypoint for libOCPP for OCPP 1.6.
Definition: charge_point.cpp:13
void register_unlock_connector_callback(const std::function< UnlockStatus(int32_t connector)> &callback)
registers a callback function that can be used to unlock the connector. In case a transaction is
Definition: charge_point.cpp:233
void register_get_15118_ev_certificate_response_callback(const std::function< void(const int32_t connector, const ocpp::v2::Get15118EVCertificateResponse &certificate_response, const ocpp::v2::CertificateActionEnum &certificate_action)> &callback)
registers a callback function that can be used to publish the response to a Get15118Certificate....
Definition: charge_point.cpp:291
void register_upload_logs_callback(const std::function< GetLogResponse(GetLogRequest req)> &callback)
registers a callback function that can be used to upload logfiles. This callback should trigger a pro...
Definition: charge_point.cpp:256
void register_all_connectors_unavailable_callback(const std::function< void()> &callback)
registers a callback function that is called when all connectors are set to unavailable....
Definition: charge_point.cpp:252
void register_set_system_time_callback(const std::function< void(const std::string &system_time)> &callback)
registers a callback function that can be used to set the system time.
Definition: charge_point.cpp:273
void register_generic_configuration_key_changed_callback(const std::function< void(const KeyValue &key_value)> &callback)
registers a callback function that can be used to react on changed configuration key and value....
Definition: charge_point.cpp:320
void register_is_reset_allowed_callback(const std::function< bool(const ResetType &reset_type)> &callback)
registers a callback function that can be used to check if a reset is allowed . The is_reset_allowed_...
Definition: charge_point.cpp:265
void register_disable_evse_callback(const std::function< bool(int32_t connector)> &callback)
registers a callback function that can be used to disable the evse. The disable_evse_callback is call...
Definition: charge_point.cpp:200
void register_pause_charging_callback(const std::function< bool(int32_t connector)> &callback)
registers a callback function that can be used to pause charging. The pause_charging_callback is call...
Definition: charge_point.cpp:204
void register_transaction_stopped_callback(const std::function< void(const int32_t connector, const std::string &session_id, const int32_t transaction_id)> &callback)
registers a callback function that is called when a StopTransaction.req message is sent by the charge...
Definition: charge_point.cpp:303
void register_session_cost_callback(const std::function< DataTransferResponse(const RunningCost &session_cost, const uint32_t number_of_decimals)> &session_cost_callback)
Registers a callback function for the session cost datatransfer message (California Pricing Requireme...
Definition: charge_point.cpp:335
void register_stop_transaction_callback(const std::function< bool(int32_t connector, Reason reason)> &callback)
registers a callback function that can be used to stop a transaction. Ths stop_transaction_callback i...
Definition: charge_point.cpp:218
void register_set_connection_timeout_callback(const std::function< void(int32_t connection_timeout)> &callback)
registers a callback function that can be used to set the authorization or plug in connection timeout...
Definition: charge_point.cpp:260
void register_boot_notification_response_callback(const std::function< void(const BootNotificationResponse &boot_notification_response)> &callback)
registers a callback function that can be used receive the BootNotificationResponse
Definition: charge_point.cpp:278
void register_resume_charging_callback(const std::function< bool(int32_t connector)> &callback)
registers a callback function that can be used to resume charging
Definition: charge_point.cpp:208
void register_reset_callback(const std::function< void(const ResetType &reset_type)> &callback)
registers a callback function that can be used to trigger a reset of the chargepoint....
Definition: charge_point.cpp:269
void register_provide_token_callback(const std::function< void(const std::string &id_token, std::vector< int32_t > referenced_connectors, bool prevalidated)> &callback)
registers a callback function that can be used to provide an id_token for the given referenced_connec...
Definition: charge_point.cpp:212
void register_signed_update_firmware_callback(const std::function< UpdateFirmwareStatusEnumType(const SignedUpdateFirmwareRequest msg)> &callback)
registers a callback function that can be used to trigger a signed firmware update....
Definition: charge_point.cpp:247
void register_connection_state_changed_callback(const std::function< void(bool is_connected)> &callback)
registers a callback function that can be used when the connection state to CSMS changes....
Definition: charge_point.cpp:287
void register_upload_diagnostics_callback(const std::function< GetLogResponse(const GetDiagnosticsRequest &request)> &callback)
registers a callback function that can be used to trigger an upload of diagnostics....
Definition: charge_point.cpp:237
void register_cancel_reservation_callback(const std::function< bool(int32_t reservation_id)> &callback)
registers a callback function that can be used to cancel a reservation on a connector....
Definition: charge_point.cpp:229
void register_update_firmware_callback(const std::function< void(const UpdateFirmwareRequest msg)> &callback)
registers a callback function that can be used to trigger a firmware update. This callback should tri...
Definition: charge_point.cpp:242
void register_reserve_now_callback(const std::function< ReservationStatus(int32_t reservation_id, int32_t connector, ocpp::DateTime expiryDate, CiString< 20 > idTag, std::optional< CiString< 20 > > parent_id)> &callback)
registers a callback function that can be used to reserve a connector for a idTag until a timeout is ...
Definition: charge_point.cpp:223
void register_security_event_callback(const std::function< void(const std::string &type, const std::string &tech_info)> &callback)
registers a callback function that can be used to react to a security event callback....
Definition: charge_point.cpp:325
void register_configuration_key_changed_callback(const CiString< 50 > &key, const std::function< void(const KeyValue &key_value)> &callback)
registers a callback function that can be used to react on changed configuration keys....
Definition: charge_point.cpp:315
void register_is_token_reserved_for_connector_callback(const std::function< ReservationCheckStatus(const int32_t connector, const std::string &id_token)> &callback)
registers a callback function that can be used to check, if the connector is reserved for the given i...
Definition: charge_point.cpp:330
void register_transaction_updated_callback(const std::function< void(const int32_t connector, const std::string &session_id, const int32_t transaction_id, const IdTagInfo &id_tag_info)> &callback)
registers a callback function that is called when a StartTransaction.conf message is received by the ...
Definition: charge_point.cpp:309
void register_set_display_message_callback(const std::function< DataTransferResponse(const std::vector< DisplayMessage > &)> set_display_message_callback)
Register a callback function for display messages (used in California Pricing Requirements)
Definition: charge_point.cpp:341
void register_data_transfer_callback(const CiString< 255 > &vendorId, const CiString< 50 > &messageId, const std::function< DataTransferResponse(const std::optional< std::string > &msg)> &callback)
Definition: charge_point.cpp:185
void register_enable_evse_callback(const std::function< bool(int32_t connector)> &callback)
registers a callback function that can be used to enable the evse. The enable_evse_callback is called...
Definition: charge_point.cpp:196
void register_transaction_started_callback(const std::function< void(const int32_t connector, const std::string &session_id)> &callback)
registers a callback function that is called when a StartTransaction.req message is sent by the charg...
Definition: charge_point.cpp:298
void register_signal_set_charging_profiles_callback(const std::function< void()> &callback)
registers a callback function that can be used to signal that the chargepoint received a SetChargingP...
Definition: charge_point.cpp:283
void on_error_cleared(int32_t connector, const std::string uuid)
This function should be called if an error with the given uuid has been cleared. If this leads to the...
Definition: charge_point.cpp:139
void on_log_status_notification(int32_t request_id, std::string log_status)
Chargepoint notifies about new log status log_status . This function should be called during a Diagno...
Definition: charge_point.cpp:147
void on_resume_charging(int32_t connector)
This function should be called when charging resumes on the given connector.
Definition: charge_point.cpp:131
void on_plugin_timeout(int32_t connector)
Notifies chargepoint that a ConnectionTimeout occured for the given connector . This function should ...
Definition: charge_point.cpp:172
void on_max_current_offered(int32_t connector, int32_t max_current)
Stores the given max_current for the given connector offered to the EV. This function can be called w...
Definition: charge_point.cpp:88
void on_transaction_stopped(const int32_t connector, const std::string &session_id, const Reason &reason, ocpp::DateTime timestamp, float energy_wh_import, std::optional< CiString< 20 > > id_tag_end, std::optional< std::string > signed_meter_value)
Notifies chargepoint that the transaction on the given connector with the given reason has been stopp...
Definition: charge_point.cpp:115
void on_error(int32_t connector, const ErrorInfo &error_info)
This function should be called if an error with the given error_info is present. This function will t...
Definition: charge_point.cpp:135
void on_transaction_started(const int32_t &connector, const std::string &session_id, const std::string &id_token, const double meter_start, std::optional< int32_t > reservation_id, const ocpp::DateTime ×tamp, std::optional< std::string > signed_meter_value)
Notifies chargepoint that a transaction at the given connector with the given parameters has been sta...
Definition: charge_point.cpp:107
void on_reservation_end(int32_t connector)
This function must be called when a reservation ends at the given connector.
Definition: charge_point.cpp:160
void on_suspend_charging_evse(int32_t connector, const std::optional< CiString< 50 > > info=std::nullopt)
This function should be called when EVSE indicates that it suspends charging on the given connector.
Definition: charge_point.cpp:127
void on_meter_values(int32_t connector, const Measurement &measurement)
Stores the given powermeter values for the given connector . This function can be called when a new m...
Definition: charge_point.cpp:84
void on_session_started(int32_t connector, const std::string &session_id, const SessionStartedReason reason, const std::optional< std::string > &session_logging_path)
Notifies chargepoint that a new session with the given session_id has been started at the given conne...
Definition: charge_point.cpp:96
void on_security_event(const CiString< 50 > &event_type, const std::optional< CiString< 255 > > &tech_info, const std::optional< bool > &critical=std::nullopt, const std::optional< DateTime > ×tamp=std::nullopt)
Notifies chargepoint that a SecurityEvent occurs. This will send a SecurityEventNotification....
Definition: charge_point.cpp:176
void on_reservation_start(int32_t connector)
This function must be called when a reservation is started at the given connector .
Definition: charge_point.cpp:156
void on_session_stopped(int32_t connector, const std::string &session_id)
Notifies chargepoint that a session has been stopped at the given connector. This function must be ca...
Definition: charge_point.cpp:103
void on_enabled(int32_t connector)
Notifies chargepoint that the connector is enabled . This function should be called when the connecto...
Definition: charge_point.cpp:164
void on_all_errors_cleared(int32_t connector)
Clears all previously reported errors at the same time for the given connector . This will clear a pr...
Definition: charge_point.cpp:143
ChangeAvailabilityResponse on_change_availability(const ChangeAvailabilityRequest &request)
Handles an internal ChangeAvailabilityRequest (in the same way as if it was emitted by the CSMS).
Definition: charge_point.cpp:181
void on_disabled(int32_t connector)
Notifies chargepoint that the connector is disabled . This function should be called when the connect...
Definition: charge_point.cpp:168
void on_firmware_update_status_notification(int32_t request_id, const ocpp::FirmwareStatusNotification firmware_update_status)
Chargepoint notifies about new firmware update status firmware_update_status . This function should b...
Definition: charge_point.cpp:151
void on_max_power_offered(int32_t connector, int32_t max_power)
Stores the given max_power for the given connector offered to the EV. This function can be called whe...
Definition: charge_point.cpp:92
void on_suspend_charging_ev(int32_t connector, const std::optional< CiString< 50 > > info=std::nullopt)
This function should be called when EV indicates that it suspends charging on the given connector.
Definition: charge_point.cpp:123
Definition: types.hpp:339
Definition: types.hpp:414
Contains a OCPP BootNotificationResponse message.
Definition: BootNotification.hpp:46
Contains a OCPP ChangeAvailability message.
Definition: ChangeAvailability.hpp:17
Contains a OCPP ChangeAvailabilityResponse message.
Definition: ChangeAvailability.hpp:37
Contains a OCPP DataTransfer message.
Definition: DataTransfer.hpp:19
Contains a OCPP DataTransferResponse message.
Definition: DataTransfer.hpp:40
Contains all relevant information to handle errros in OCPP1.6.
Definition: charge_point_state_machine.hpp:41
Contains a OCPP GetConfiguration message.
Definition: GetConfiguration.hpp:18
Contains a OCPP GetConfigurationResponse message.
Definition: GetConfiguration.hpp:37
Contains a OCPP GetDiagnostics message.
Definition: GetDiagnostics.hpp:18
Contains a OCPP GetLog message.
Definition: GetLog.hpp:19
Contains a OCPP GetLogResponse message.
Definition: GetLog.hpp:42
Definition: ocpp_types.hpp:20
Definition: ocpp_types.hpp:83
Contains a OCPP SignedUpdateFirmware message.
Definition: SignedUpdateFirmware.hpp:18
Contains a OCPP UpdateFirmware message.
Definition: UpdateFirmware.hpp:17
Contains a OCPP AuthorizeResponse message.
Definition: Authorize.hpp:41
Contains a OCPP Get15118EVCertificateResponse message.
Definition: Get15118EVCertificate.hpp:42