|
ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
|
Contains a ChargePoint implementation compatible with OCPP-J 1.6. More...
#include <charge_point_impl.hpp>
Public Member Functions | |
| ChargePointImpl (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) | |
| The main entrypoint for libOCPP for OCPP 1.6. More... | |
| bool | start (const std::map< int, ChargePointStatus > &connector_status_map, BootReasonEnum bootreason, const std::set< std::string > &resuming_session_ids) |
| Starts the ChargePoint, initializes and connects to the Websocket endpoint and initializes a BootNotification.req. More... | |
| bool | restart (const std::map< int, ChargePointStatus > &connector_status_map, BootReasonEnum bootreason) |
| Restarts the ChargePoint if it has been stopped before. The ChargePoint is reinitialized, connects to the websocket and starts to communicate OCPP messages again. More... | |
| void | reset_state_machine (const std::map< int, ChargePointStatus > &connector_status_map) |
Resets the internal state machine for the connectors using the given connector_status_map. More... | |
| bool | stop () |
| Stops the ChargePoint, stops timers, transactions and the message queue and disconnects from the websocket. | |
| void | connect_websocket () |
| Initializes the websocket and connects to CSMS if it is not yet connected. | |
| void | disconnect_websocket () |
| Disconnects the the websocket connection to the CSMS if it is connected. | |
| void | call_set_connection_timeout () |
| Calls the set_connection_timeout_callback that can be registered. This function is used to notify an Authorization mechanism about a changed ConnectionTimeout configuration key. | |
| IdTagInfo | authorize_id_token (CiString< 20 > id_token, const bool authorize_only_locally=false) |
Authorizes the provided id_token against the central system, LocalAuthorizationList or AuthorizationCache depending on the values of the ConfigurationKeys LocalPreAuthorize, LocalAuthorizeOffline, LocalAuthListEnabled and AuthorizationCacheEnabled. If authorize_only_locally is true, no Authorize.req will be sent to the CSMS but only LocalAuthorizationList and LocalAuthorizationCache will be used for the validation. More... | |
| 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_data locally or by requesting authorzation at CSMS. This function can be called when the authorization mechanism Plug&Charge is specified as part of the ISO15118 PaymentDetailsRequest. More... | |
| 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 the EVCC requests the update or installation of a contract certificate as part of the ISO15118 CertificateInstallRequest or CertificateUpdateRequest. More... | |
| 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. More... | |
| 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 duration_s and the given unit. More... | |
| 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 + given duration_s and the given unit . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s) that are enhanced by the stackLevel that was provided for the ChargingProfile. More... | |
| 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 meter value is present. More... | |
| 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 when the value for the maximum current for the connector changes. It will be used to report the Measurand Current_Offered if it is configured. More... | |
| 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 when the value for the maximum power for the connector changes. It will be used to report the Measurand Power_Offered if it is configured. More... | |
| 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 connector with the given reason . The logs of the session will be written into session_logging_path if present. This function must be called when first interaction with user or EV occurs. This can be a valid authorization or the connection of cable and/or EV to the given connector. More... | |
| 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 called when the EV disconnects from the given connector . More... | |
| 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 started. This function must be called at the point that all conditions for charging are met, for instance, EV is connected to Charge Point and user has been authorized. More... | |
| 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 stopped. This function must be called at the point where one of the preconditions for charging irrevocably becomes false, for instance when a user swipes to stop the transaction and the stop is authorized or if the EV disconnects. More... | |
| 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. More... | |
| 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. More... | |
| void | on_resume_charging (int32_t connector) |
This function should be called when charging resumes on the given connector. More... | |
| 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 trigger a StatusNotification.req containing the given error_info . It will change the present state of the state machine to faulted, in case the corresponding flag is set in the given error_info. This function can be called multiple times for different errors. Errors reported using this function stay active as long as they are cleared by on_error_cleared(). More... | |
| 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 fact that no other error is active anymore, this function will initiate a StatusNotification.req that reports the current state and no error. More... | |
| 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 previously reported "Faulted" state if present. More... | |
| 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 Diagnostics / Log upload to indicate the current log_status . More... | |
| 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 be called during a Firmware Update to indicate the current firmware_update_status . More... | |
| void | on_reservation_start (int32_t connector) |
This function must be called when a reservation is started at the given connector . More... | |
| void | on_reservation_end (int32_t connector) |
This function must be called when a reservation ends at the given connector. More... | |
| void | on_enabled (int32_t connector) |
Notifies chargepoint that the connector is enabled . This function should be called when the connector becomes functional and operational. More... | |
| void | on_disabled (int32_t connector) |
Notifies chargepoint that the connector is disabled . This function should be called when the connector becomes inoperative. More... | |
| void | on_plugin_timeout (int32_t connector) |
Notifies chargepoint that a ConnectionTimeout occured for the given connector . This function should be called when an EV is plugged in but the authorization is not present within the specified ConnectionTimeout. | |
| 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.req to the CSMS. More... | |
| ChangeAvailabilityResponse | on_change_availability (const ChangeAvailabilityRequest &request) |
| Handles an internal ChangeAvailabilityRequest (in the same way as if it was emitted by the CSMS). More... | |
| void | register_data_transfer_callback (const CiString< 255 > &vendorId, const CiString< 50 > &messageId, const std::function< DataTransferResponse(const std::optional< std::string > &msg)> &callback) |
| void | register_data_transfer_callback (const std::function< DataTransferResponse(const DataTransferRequest &request)> &callback) |
| 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 when a ChangeAvailaibility.req is received. More... | |
| 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 called when a ChangeAvailaibility.req is received. More... | |
| 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 called when the idTagInfo.status of a StartTransaction.conf is not Accepted More... | |
| void | register_resume_charging_callback (const std::function< bool(int32_t connector)> &callback) |
registers a callback function that can be used to resume charging More... | |
| 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_connectors to an authorization handler. prevalidated signals to the authorization handler that no further authorization is necessary. The provide_token_callback is called when a RemoteStartTransaction.req is received. More... | |
| 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 is called More... | |
| 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 reached. The reserve_now_callback is called when a ReserveNow.req is received. More... | |
| 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. Callback function should return false if the reservation could not be cancelled, else true . The cancel_reservation_callback is called when a CancelReservation.req is received More... | |
| 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 More... | |
| 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. This callback should trigger a process of a diagnostics upload using the given parameters of the request. This process should call the on_log_status_notification handler in order to update the status of the file upload. The upload_diagnostics_callback is called when a GetDiagnostics.req is received More... | |
| 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 trigger a process of a firmware update using the given parameters of the request. This process should call the on_firmware_update_status_notification handler in order to update the status of the update. The update_firmware_callback is called when a FirmwareUpdate.req is received More... | |
| 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. This callback should trigger a process of a signed firmware update using the given parameters of the request. This process should call the on_firmware_update_status_notification handler in order to update the status of the signed firmware update. The signed_update_firmware_callback is called when a SignedUpdateFirmware.req is received. More... | |
| 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. This can be used to then trigger the installation of the firmware update | |
| 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 process of a log upload using the given parameters of the request. This process should call the on_log_status_notification handler in order to update the status of the file upload. The upload_logs_callback is called when a GetLog.req is received More... | |
| 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. The set_connection_timeout_callback is called when the configuration key ConnectionTimeout has been changed by the CSMS. More... | |
| 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_callback is called when a Reset.req is received. More... | |
| 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. The reset_callback is called when a Reset.req is received and a previous execution of the is_reset_allowed_callback returned true More... | |
| 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. More... | |
| 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 More... | |
| 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 SetChargingProfile.req . The set_charging_profiles_callback is called when a SetChargingProfile.req is received and was accepted. The registered callback could make use of the get_all_composite_charging_schedules in order to retrieve the ChargingProfiles that have been set by the CSMS. More... | |
| 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. The connection_state_changed_callback is called when chargepoint has connected to or disconnected from the CSMS. More... | |
| 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.req wrapped in a DataTransfer.req . The get_15118_ev_certificate_response_callback is called after the response to a DataTransfer.req(Get15118EVCertificate) has been accepted. More... | |
| 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 chargepoint More... | |
| 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 chargepoint More... | |
| 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 CSMS. This includes the transactionId. More... | |
| 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. This callback is called when a configuration key has been changed by the CSMS More... | |
| 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. This callback is called when a configuration key and value has been changed by the CSMS, where no key based callback is assigned More... | |
| 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. This callback is called only if the SecurityEvent occured internally within libocpp | |
| 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 id_token. The is_token_reserved_for_connector_callback is called when a RemoteStartTransaction.req is received. More... | |
| void | register_session_cost_callback (const std::function< DataTransferResponse(const RunningCost &running_cost, const uint32_t number_of_decimals)> &session_cost_callback) |
| void | register_set_display_message_callback (const std::function< DataTransferResponse(const std::vector< DisplayMessage > &)> set_display_message_callback) |
| GetConfigurationResponse | get_configuration_key (const GetConfigurationRequest &request) |
Gets the configured configuration key requested in the given request. More... | |
| ConfigurationStatus | set_custom_configuration_key (CiString< 50 > key, CiString< 500 > value) |
| Sets a custom configuration key. More... | |
| 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 first. More... | |
Contains a ChargePoint implementation compatible with OCPP-J 1.6.
|
explicit |
The main entrypoint for libOCPP for OCPP 1.6.
| config | a nlohmann json config object that contains the libocpp 1.6 config. There are example configs that work with a SteVe installation running in Docker, for example: config/v16/config-docker.json |
| share_path | This path contains the following files and directories and is installed by the libocpp install target |
| user_config_path | this points to a "user config", which we call a configuration file that's merged with the config that's provided in the "config" parameter. Here you can add, remove and overwrite settings without modifying the config passed in the first parameter directly. This is also used by libocpp to persistently modify config entries that are changed by the CSMS that should persist across restarts |
| database_path | this points to the location of the sqlite database that libocpp uses to keep track of connector availability, the authorization cache and auth list, charging profiles and transaction data |
| sql_init_path | this points to the init.sql file which contains the database schema used by libocpp for its sqlite database |
| message_log_path | this points to the directory in which libocpp can put OCPP communication logfiles for debugging purposes. This behavior can be controlled by the "LogMessages" (set to true by default) and "LogMessagesFormat" (set to ["log", "html", "session_logging"] by default, "console" and "console_detailed" are also available) configuration keys in the "Internal" section of the config file. Please note that this is intended for debugging purposes only as it logs all communication, including authentication messages. |
| evse_security | Pointer to evse_security that manages security related operations |
| IdTagInfo ocpp::v16::ChargePointImpl::authorize_id_token | ( | CiString< 20 > | id_token, |
| const bool | authorize_only_locally = false |
||
| ) |
Authorizes the provided id_token against the central system, LocalAuthorizationList or AuthorizationCache depending on the values of the ConfigurationKeys LocalPreAuthorize, LocalAuthorizeOffline, LocalAuthListEnabled and AuthorizationCacheEnabled. If authorize_only_locally is true, no Authorize.req will be sent to the CSMS but only LocalAuthorizationList and LocalAuthorizationCache will be used for the validation.
| std::optional< DataTransferResponse > ocpp::v16::ChargePointImpl::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.
| vendorId | |
| messageId | |
| data |
| ocpp::v2::AuthorizeResponse ocpp::v16::ChargePointImpl::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_data locally or by requesting authorzation at CSMS. This function can be called when the authorization mechanism Plug&Charge is specified as part of the ISO15118 PaymentDetailsRequest.
| emaid | |
| certificate | contract certificate that the EVCC provides |
| iso15118_certificate_hash_data |
| void ocpp::v16::ChargePointImpl::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 the EVCC requests the update or installation of a contract certificate as part of the ISO15118 CertificateInstallRequest or CertificateUpdateRequest.
| connector_id | |
| exi_request | provided by the EVCC |
| iso15118_schema_version | provided by the EVCC |
| certificate_action | Install or Update |
| std::map< int32_t, ChargingSchedule > ocpp::v16::ChargePointImpl::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 duration_s and the given unit.
| duration_s | |
| unit | defaults to A |
| std::map< int32_t, EnhancedChargingSchedule > ocpp::v16::ChargePointImpl::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 + given duration_s and the given unit . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s) that are enhanced by the stackLevel that was provided for the ChargingProfile.
| duration_s | |
| unit | defaults to A |
| GetConfigurationResponse ocpp::v16::ChargePointImpl::get_configuration_key | ( | const GetConfigurationRequest & | request | ) |
Gets the configured configuration key requested in the given request.
| request | specifies the keys that should be returned. If empty or not set, all keys will be reported |
| void ocpp::v16::ChargePointImpl::on_all_errors_cleared | ( | int32_t | connector | ) |
Clears all previously reported errors at the same time for the given connector . This will clear a previously reported "Faulted" state if present.
| connector |
| ChangeAvailabilityResponse ocpp::v16::ChargePointImpl::on_change_availability | ( | const ChangeAvailabilityRequest & | request | ) |
Handles an internal ChangeAvailabilityRequest (in the same way as if it was emitted by the CSMS).
| request |
| void ocpp::v16::ChargePointImpl::on_disabled | ( | int32_t | connector | ) |
Notifies chargepoint that the connector is disabled . This function should be called when the connector becomes inoperative.
| connector |
| void ocpp::v16::ChargePointImpl::on_enabled | ( | int32_t | connector | ) |
Notifies chargepoint that the connector is enabled . This function should be called when the connector becomes functional and operational.
| connector |
| void ocpp::v16::ChargePointImpl::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 trigger a StatusNotification.req containing the given error_info . It will change the present state of the state machine to faulted, in case the corresponding flag is set in the given error_info. This function can be called multiple times for different errors. Errors reported using this function stay active as long as they are cleared by on_error_cleared().
| connector | |
| error_info | Additional information related to the error |
| void ocpp::v16::ChargePointImpl::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 fact that no other error is active anymore, this function will initiate a StatusNotification.req that reports the current state and no error.
| connector | |
| uuid | of a previously reported error. If uuid is not known, the event will be ignored |
| void ocpp::v16::ChargePointImpl::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 be called during a Firmware Update to indicate the current firmware_update_status .
| request_id | A request_id of -1 indicates a FirmwareStatusNotification.req, else a SignedFirmwareUpdateStatusNotification.req . |
| firmware_update_status | The firmware_update_status |
| void ocpp::v16::ChargePointImpl::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 Diagnostics / Log upload to indicate the current log_status .
| request_id | A request_id of -1 indicates a DiagnosticsStatusNotification.req, else a LogStatusNotification.req. |
| log_status | The log_status should be either be convertable to the ocpp::v16::UploadLogStatusEnumType enum or ocpp::v16::DiagnosticsStatus enum depending on the previous request, which could have been a DiagnosticsUpload.req or a GetLog.req (Security Whitepaper) |
| void ocpp::v16::ChargePointImpl::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 when the value for the maximum current for the connector changes. It will be used to report the Measurand Current_Offered if it is configured.
| connector | |
| max_current | in Amps |
| void ocpp::v16::ChargePointImpl::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 when the value for the maximum power for the connector changes. It will be used to report the Measurand Power_Offered if it is configured.
| connector | |
| max_power | in Watts |
| void ocpp::v16::ChargePointImpl::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 meter value is present.
| connector | |
| measurement | structure that can contain all kinds of measurands |
| void ocpp::v16::ChargePointImpl::on_reservation_end | ( | int32_t | connector | ) |
This function must be called when a reservation ends at the given connector.
| connector |
| void ocpp::v16::ChargePointImpl::on_reservation_start | ( | int32_t | connector | ) |
This function must be called when a reservation is started at the given connector .
| connector |
| void ocpp::v16::ChargePointImpl::on_resume_charging | ( | int32_t | connector | ) |
This function should be called when charging resumes on the given connector.
| connector |
| void ocpp::v16::ChargePointImpl::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 > & | timestamp = std::nullopt |
||
| ) |
Notifies chargepoint that a SecurityEvent occurs. This will send a SecurityEventNotification.req to the CSMS.
| event_type | type of the security event |
| tech_info | additional info of the security event |
| critical | if set this overwrites the default criticality recommended in the OCPP 1.6 security whitepaper. A critical security event is transmitted as a message to the CSMS, a non-critical one is just written to the security log |
| timestamp | when this security event occured, if absent the current datetime is assumed |
| void ocpp::v16::ChargePointImpl::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 connector with the given reason . The logs of the session will be written into session_logging_path if present. This function must be called when first interaction with user or EV occurs. This can be a valid authorization or the connection of cable and/or EV to the given connector.
| connector | |
| session_id | unique id of the session |
| reason | for the initiation of the session |
| session_logging_path | optional filesystem path to where the session log should be written |
| void ocpp::v16::ChargePointImpl::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 called when the EV disconnects from the given connector .
| connector | |
| session_id |
| void ocpp::v16::ChargePointImpl::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.
| connector | |
| info |
| void ocpp::v16::ChargePointImpl::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.
| connector | |
| info |
| void ocpp::v16::ChargePointImpl::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 & | timestamp, | ||
| std::optional< std::string > | signed_meter_value | ||
| ) |
Notifies chargepoint that a transaction at the given connector with the given parameters has been started. This function must be called at the point that all conditions for charging are met, for instance, EV is connected to Charge Point and user has been authorized.
| connector | |
| session_id | |
| id_token | that has been used to authorize the transaction |
| meter_start | start meter value in Wh |
| reservation_id | |
| timestamp | of the start of transaction |
| signed_meter_value | e.g. in OCMF format |
| void ocpp::v16::ChargePointImpl::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 stopped. This function must be called at the point where one of the preconditions for charging irrevocably becomes false, for instance when a user swipes to stop the transaction and the stop is authorized or if the EV disconnects.
| connector | |
| session_id | |
| reason | |
| timestamp | of the end of transaction |
| energy_wh_import | stop meter value in Wh |
| id_tag_end | |
| signed_meter_value | e.g. in OCMF format |
| void ocpp::v16::ChargePointImpl::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
| callback |
| void ocpp::v16::ChargePointImpl::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. Callback function should return false if the reservation could not be cancelled, else true . The cancel_reservation_callback is called when a CancelReservation.req is received
| callback |
| void ocpp::v16::ChargePointImpl::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. This callback is called when a configuration key has been changed by the CSMS
| key | the configuration key for which the callback is registered |
| callback | executed when this configuration key changed |
| void ocpp::v16::ChargePointImpl::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. The connection_state_changed_callback is called when chargepoint has connected to or disconnected from the CSMS.
| callback |
| void ocpp::v16::ChargePointImpl::register_data_transfer_callback | ( | const CiString< 255 > & | vendorId, |
| const CiString< 50 > & | messageId, | ||
| const std::function< DataTransferResponse(const std::optional< std::string > &msg)> & | callback | ||
| ) |
registers a callback function that can be used to receive a arbitrary data transfer for the given vendorId and messageId
| vendorId | |
| messageId | |
| callback |
| void ocpp::v16::ChargePointImpl::register_data_transfer_callback | ( | const std::function< DataTransferResponse(const DataTransferRequest &request)> & | callback | ) |
registers a callback function that can be used to handle arbitrary data transfers for all vendorId an messageId
| callback |
| void ocpp::v16::ChargePointImpl::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 called when a ChangeAvailaibility.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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 when a ChangeAvailaibility.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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. This callback is called when a configuration key and value has been changed by the CSMS, where no key based callback is assigned
| callback | executed when this configuration key changed |
| void ocpp::v16::ChargePointImpl::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.req wrapped in a DataTransfer.req . The get_15118_ev_certificate_response_callback is called after the response to a DataTransfer.req(Get15118EVCertificate) has been accepted.
| callback |
| void ocpp::v16::ChargePointImpl::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_callback is called when a Reset.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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 id_token. The is_token_reserved_for_connector_callback is called when a RemoteStartTransaction.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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 called when the idTagInfo.status of a StartTransaction.conf is not Accepted
| callback |
| void ocpp::v16::ChargePointImpl::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_connectors to an authorization handler. prevalidated signals to the authorization handler that no further authorization is necessary. The provide_token_callback is called when a RemoteStartTransaction.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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 reached. The reserve_now_callback is called when a ReserveNow.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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. The reset_callback is called when a Reset.req is received and a previous execution of the is_reset_allowed_callback returned true
| callback |
| void ocpp::v16::ChargePointImpl::register_resume_charging_callback | ( | const std::function< bool(int32_t connector)> & | callback | ) |
registers a callback function that can be used to resume charging
| callback |
| void ocpp::v16::ChargePointImpl::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. The set_connection_timeout_callback is called when the configuration key ConnectionTimeout has been changed by the CSMS.
| callback |
| void ocpp::v16::ChargePointImpl::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.
| callback |
| void ocpp::v16::ChargePointImpl::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 SetChargingProfile.req . The set_charging_profiles_callback is called when a SetChargingProfile.req is received and was accepted. The registered callback could make use of the get_all_composite_charging_schedules in order to retrieve the ChargingProfiles that have been set by the CSMS.
| callback |
| void ocpp::v16::ChargePointImpl::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. This callback should trigger a process of a signed firmware update using the given parameters of the request. This process should call the on_firmware_update_status_notification handler in order to update the status of the signed firmware update. The signed_update_firmware_callback is called when a SignedUpdateFirmware.req is received.
| callback |
| void ocpp::v16::ChargePointImpl::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 is called
| callback |
| void ocpp::v16::ChargePointImpl::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 chargepoint
| callback |
| void ocpp::v16::ChargePointImpl::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 chargepoint
| callback |
| void ocpp::v16::ChargePointImpl::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 CSMS. This includes the transactionId.
| callback |
| void ocpp::v16::ChargePointImpl::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
| callback |
| void ocpp::v16::ChargePointImpl::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 trigger a process of a firmware update using the given parameters of the request. This process should call the on_firmware_update_status_notification handler in order to update the status of the update. The update_firmware_callback is called when a FirmwareUpdate.req is received
| callback |
| void ocpp::v16::ChargePointImpl::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. This callback should trigger a process of a diagnostics upload using the given parameters of the request. This process should call the on_log_status_notification handler in order to update the status of the file upload. The upload_diagnostics_callback is called when a GetDiagnostics.req is received
| callback |
| void ocpp::v16::ChargePointImpl::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 process of a log upload using the given parameters of the request. This process should call the on_log_status_notification handler in order to update the status of the file upload. The upload_logs_callback is called when a GetLog.req is received
| callback |
| void ocpp::v16::ChargePointImpl::reset_state_machine | ( | const std::map< int, ChargePointStatus > & | connector_status_map | ) |
Resets the internal state machine for the connectors using the given connector_status_map.
| connector_status_map | state of connectors including connector 0 with reduced set of states (Available, Unavailable, Faulted) |
| bool ocpp::v16::ChargePointImpl::restart | ( | const std::map< int, ChargePointStatus > & | connector_status_map, |
| BootReasonEnum | bootreason | ||
| ) |
Restarts the ChargePoint if it has been stopped before. The ChargePoint is reinitialized, connects to the websocket and starts to communicate OCPP messages again.
| connector_status_map | initial state of connectors including connector 0 with reduced set of states (Available, Unavailable, Faulted). connector_status_map is empty, last availability states from the persistant storage will be used |
| bootreason | reason for calling the restart function |
| ConfigurationStatus ocpp::v16::ChargePointImpl::set_custom_configuration_key | ( | CiString< 50 > | key, |
| CiString< 500 > | value | ||
| ) |
Sets a custom configuration key.
| key | |
| value |
|
inline |
Delay draining the message queue after reconnecting, so the CSMS can perform post-reconnect checks first.
| delay | The delay period (seconds) |
| bool ocpp::v16::ChargePointImpl::start | ( | const std::map< int, ChargePointStatus > & | connector_status_map, |
| BootReasonEnum | bootreason, | ||
| const std::set< std::string > & | resuming_session_ids | ||
| ) |
Starts the ChargePoint, initializes and connects to the Websocket endpoint and initializes a BootNotification.req.
| connector_status_map | initial state of connectors including connector 0 with reduced set of states (Available, Unavailable, Faulted) |
| bootreason | reason for calling the start function |
| resuming_session_ids | can optionally contain active session ids from previous executions. If empty and libocpp has transactions in its internal database that have not been stopped yet, calling this function will initiate a StopTransaction.req for those transactions. If this vector contains session_ids this function will not stop transactions with this session_id even in case it has an internal database entry for this session and it hasnt been stopped yet. Its ignored if this vector contains session_ids that are unknown to libocpp. |