ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
charge_point_configuration.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
3#ifndef OCPP_V16_CHARGE_POINT_CONFIGURATION_HPP
4#define OCPP_V16_CHARGE_POINT_CONFIGURATION_HPP
5
6#include <mutex>
7#include <set>
8
9#include <ocpp/common/support_older_cpp_versions.hpp>
10#include <ocpp/v16/ocpp_types.hpp>
11#include <ocpp/v16/types.hpp>
12
13namespace ocpp {
14namespace v16 {
15
18private:
19 json config;
20 json custom_schema;
21 json internal_schema;
22 fs::path user_config_path;
23
24 std::set<SupportedFeatureProfiles> supported_feature_profiles;
25 std::map<Measurand, std::vector<Phase>> supported_measurands;
26 std::map<SupportedFeatureProfiles, std::set<MessageType>> supported_message_types_from_charge_point;
27 std::map<SupportedFeatureProfiles, std::set<MessageType>> supported_message_types_from_central_system;
28 std::set<MessageType> supported_message_types_sending;
29 std::set<MessageType> supported_message_types_receiving;
30 std::recursive_mutex configuration_mutex;
31
32 std::vector<MeasurandWithPhase> csv_to_measurand_with_phase_vector(std::string csv);
33 bool validate_measurands(const json& config);
34 bool measurands_supported(std::string csv);
35 json get_user_config();
36 void setInUserConfig(std::string profile, std::string key, json value);
37 void init_supported_measurands();
38
39 bool isConnectorPhaseRotationValid(std::string str);
40
41 bool checkTimeOffset(const std::string& offset);
42
43public:
44 ChargePointConfiguration(const std::string& config, const fs::path& ocpp_main_path,
45 const fs::path& user_config_path);
46
47 // Internal config options
48 std::string getChargePointId();
49 KeyValue getChargePointIdKeyValue();
50 std::string getCentralSystemURI();
51 void setCentralSystemURI(std::string ocpp_uri);
52 KeyValue getCentralSystemURIKeyValue();
53 std::string getChargeBoxSerialNumber();
54 KeyValue getChargeBoxSerialNumberKeyValue();
55 CiString<20> getChargePointModel();
56 KeyValue getChargePointModelKeyValue();
57 std::optional<CiString<25>> getChargePointSerialNumber();
58 std::optional<KeyValue> getChargePointSerialNumberKeyValue();
59 CiString<20> getChargePointVendor();
60 KeyValue getChargePointVendorKeyValue();
61 CiString<50> getFirmwareVersion();
62 KeyValue getFirmwareVersionKeyValue();
63 std::optional<CiString<20>> getICCID();
64 std::optional<KeyValue> getICCIDKeyValue();
65 std::optional<CiString<20>> getIMSI();
66 std::optional<KeyValue> getIMSIKeyValue();
67 std::optional<CiString<25>> getMeterSerialNumber();
68 std::optional<KeyValue> getMeterSerialNumberKeyValue();
69 std::optional<CiString<25>> getMeterType();
70 std::optional<KeyValue> getMeterTypeKeyValue();
71 int32_t getWebsocketReconnectInterval();
72 KeyValue getWebsocketReconnectIntervalKeyValue();
73 bool getAuthorizeConnectorZeroOnConnectorOne();
74 KeyValue getAuthorizeConnectorZeroOnConnectorOneKeyValue();
75 bool getLogMessages();
76 KeyValue getLogMessagesKeyValue();
77 std::vector<std::string> getLogMessagesFormat();
78 KeyValue getLogMessagesFormatKeyValue();
79 bool getLogRotation();
80 KeyValue getLogRotationKeyValue();
81 bool getLogRotationDateSuffix();
82 KeyValue getLogRotationDateSuffixKeyValue();
83 uint64_t getLogRotationMaximumFileSize();
84 KeyValue getLogRotationMaximumFileSizeKeyValue();
85 uint64_t getLogRotationMaximumFileCount();
86 KeyValue getLogRotationMaximumFileCountKeyValue();
87 std::vector<ChargingProfilePurposeType> getSupportedChargingProfilePurposeTypes();
88 KeyValue getSupportedChargingProfilePurposeTypesKeyValue();
89 std::vector<ChargingProfilePurposeType> getIgnoredProfilePurposesOffline();
90 std::optional<KeyValue> getIgnoredProfilePurposesOfflineKeyValue();
91 bool setIgnoredProfilePurposesOffline(const std::string& ignored_profile_purposes_offline);
92 int32_t getMaxCompositeScheduleDuration();
93 KeyValue getMaxCompositeScheduleDurationKeyValue();
94 std::optional<int32_t> getCompositeScheduleDefaultLimitAmps();
95 std::optional<KeyValue> getCompositeScheduleDefaultLimitAmpsKeyValue();
96 void setCompositeScheduleDefaultLimitAmps(int32_t limit_amps);
97 std::optional<int32_t> getCompositeScheduleDefaultLimitWatts();
98 std::optional<KeyValue> getCompositeScheduleDefaultLimitWattsKeyValue();
99 void setCompositeScheduleDefaultLimitWatts(int32_t limit_watts);
100 std::optional<int32_t> getCompositeScheduleDefaultNumberPhases();
101 std::optional<KeyValue> getCompositeScheduleDefaultNumberPhasesKeyValue();
102 void setCompositeScheduleDefaultNumberPhases(int32_t number_phases);
103 std::optional<int32_t> getSupplyVoltage();
104 std::optional<KeyValue> getSupplyVoltageKeyValue();
105 void setSupplyVoltage(int32_t supply_voltage);
106 std::string getSupportedCiphers12();
107 KeyValue getSupportedCiphers12KeyValue();
108 std::string getSupportedCiphers13();
109 KeyValue getSupportedCiphers13KeyValue();
110 bool getUseSslDefaultVerifyPaths();
111 KeyValue getUseSslDefaultVerifyPathsKeyValue();
112 bool getVerifyCsmsCommonName();
113 KeyValue getVerifyCsmsCommonNameKeyValue();
114 bool getVerifyCsmsAllowWildcards();
115 void setVerifyCsmsAllowWildcards(bool verify_csms_allow_wildcards);
116 KeyValue getVerifyCsmsAllowWildcardsKeyValue();
117 bool getUseTPM();
118 bool getUseTPMSeccLeafCertificate();
119 std::string getSupportedMeasurands();
120 KeyValue getSupportedMeasurandsKeyValue();
121 int getMaxMessageSize();
122 KeyValue getMaxMessageSizeKeyValue();
123
124 bool getEnableTLSKeylog();
125 std::string getTLSKeylogFile();
126
127 int32_t getRetryBackoffRandomRange();
128 void setRetryBackoffRandomRange(int32_t retry_backoff_random_range);
129 KeyValue getRetryBackoffRandomRangeKeyValue();
130
131 int32_t getRetryBackoffRepeatTimes();
132 void setRetryBackoffRepeatTimes(int32_t retry_backoff_repeat_times);
133 KeyValue getRetryBackoffRepeatTimesKeyValue();
134
135 int32_t getRetryBackoffWaitMinimum();
136 void setRetryBackoffWaitMinimum(int32_t retry_backoff_wait_minimum);
137 KeyValue getRetryBackoffWaitMinimumKeyValue();
138
139 std::set<MessageType> getSupportedMessageTypesSending();
140 std::set<MessageType> getSupportedMessageTypesReceiving();
141
142 std::string getWebsocketPingPayload();
143 KeyValue getWebsocketPingPayloadKeyValue();
144
145 int32_t getWebsocketPongTimeout();
146 KeyValue getWebsocketPongTimeoutKeyValue();
147
148 std::optional<std::string> getHostName();
149 std::optional<KeyValue> getHostNameKeyValue();
150
151 std::optional<std::string> getIFace();
152 std::optional<KeyValue> getIFaceKeyValue();
153
154 std::optional<bool> getQueueAllMessages();
155 std::optional<KeyValue> getQueueAllMessagesKeyValue();
156
157 std::optional<std::string> getMessageTypesDiscardForQueueing();
158 std::optional<KeyValue> getMessageTypesDiscardForQueueingKeyValue();
159
160 std::optional<int> getMessageQueueSizeThreshold();
161 std::optional<KeyValue> getMessageQueueSizeThresholdKeyValue();
162
163 // Core Profile - optional
164 std::optional<bool> getAllowOfflineTxForUnknownId();
165 void setAllowOfflineTxForUnknownId(bool enabled);
166 std::optional<KeyValue> getAllowOfflineTxForUnknownIdKeyValue();
167
168 // Core Profile - optional
169 std::optional<bool> getAuthorizationCacheEnabled();
170 void setAuthorizationCacheEnabled(bool enabled);
171 std::optional<KeyValue> getAuthorizationCacheEnabledKeyValue();
172
173 // Core Profile
174 bool getAuthorizeRemoteTxRequests();
175 void setAuthorizeRemoteTxRequests(bool enabled);
176 KeyValue getAuthorizeRemoteTxRequestsKeyValue();
177
178 // Core Profile - optional
179 std::optional<int32_t> getBlinkRepeat();
180 void setBlinkRepeat(int32_t blink_repeat);
181 std::optional<KeyValue> getBlinkRepeatKeyValue();
182
183 // Core Profile
184 int32_t getClockAlignedDataInterval();
185 void setClockAlignedDataInterval(int32_t interval);
186 KeyValue getClockAlignedDataIntervalKeyValue();
187
188 // Core Profile
189 int32_t getConnectionTimeOut();
190 void setConnectionTimeOut(int32_t timeout);
191 KeyValue getConnectionTimeOutKeyValue();
192
193 // Core Profile
194 std::string getConnectorPhaseRotation();
195 void setConnectorPhaseRotation(std::string connector_phase_rotation);
196 KeyValue getConnectorPhaseRotationKeyValue();
197
198 // Core Profile - optional
199 std::optional<int32_t> getConnectorPhaseRotationMaxLength();
200 std::optional<KeyValue> getConnectorPhaseRotationMaxLengthKeyValue();
201
202 // Core Profile
203 int32_t getGetConfigurationMaxKeys();
204 KeyValue getGetConfigurationMaxKeysKeyValue();
205
206 // Core Profile
207 int32_t getHeartbeatInterval();
208 void setHeartbeatInterval(int32_t interval);
209 KeyValue getHeartbeatIntervalKeyValue();
210
211 // Core Profile - optional
212 std::optional<int32_t> getLightIntensity();
213 void setLightIntensity(int32_t light_intensity);
214 std::optional<KeyValue> getLightIntensityKeyValue();
215
216 // Core Profile
217 bool getLocalAuthorizeOffline();
218 void setLocalAuthorizeOffline(bool local_authorize_offline);
219 KeyValue getLocalAuthorizeOfflineKeyValue();
220
221 // Core Profile
222 bool getLocalPreAuthorize();
223 void setLocalPreAuthorize(bool local_pre_authorize);
224 KeyValue getLocalPreAuthorizeKeyValue();
225
226 // Core Profile - optional
227 std::optional<int32_t> getMaxEnergyOnInvalidId();
228 void setMaxEnergyOnInvalidId(int32_t max_energy);
229 std::optional<KeyValue> getMaxEnergyOnInvalidIdKeyValue();
230
231 // Core Profile
232 std::string getMeterValuesAlignedData();
233 bool setMeterValuesAlignedData(std::string meter_values_aligned_data);
234 KeyValue getMeterValuesAlignedDataKeyValue();
235 std::vector<MeasurandWithPhase> getMeterValuesAlignedDataVector();
236
237 // Core Profile - optional
238 std::optional<int32_t> getMeterValuesAlignedDataMaxLength();
239 std::optional<KeyValue> getMeterValuesAlignedDataMaxLengthKeyValue();
240
241 // Core Profile
242 std::string getMeterValuesSampledData();
243 bool setMeterValuesSampledData(std::string meter_values_sampled_data);
244 KeyValue getMeterValuesSampledDataKeyValue();
245 std::vector<MeasurandWithPhase> getMeterValuesSampledDataVector();
246
247 // Core Profile - optional
248 std::optional<int32_t> getMeterValuesSampledDataMaxLength();
249 std::optional<KeyValue> getMeterValuesSampledDataMaxLengthKeyValue();
250
251 // Core Profile
252 int32_t getMeterValueSampleInterval();
253 void setMeterValueSampleInterval(int32_t interval);
254 KeyValue getMeterValueSampleIntervalKeyValue();
255
256 // Core Profile - optional
257 std::optional<int32_t> getMinimumStatusDuration();
258 void setMinimumStatusDuration(int32_t minimum_status_duration);
259 std::optional<KeyValue> getMinimumStatusDurationKeyValue();
260
261 // Core Profile
262 int32_t getNumberOfConnectors();
263 KeyValue getNumberOfConnectorsKeyValue();
264
265 // Reservation Profile
266 std::optional<bool> getReserveConnectorZeroSupported();
267 std::optional<KeyValue> getReserveConnectorZeroSupportedKeyValue();
268
269 // Core Profile
270 int32_t getResetRetries();
271 void setResetRetries(int32_t retries);
272 KeyValue getResetRetriesKeyValue();
273
274 // Core Profile
275 bool getStopTransactionOnEVSideDisconnect();
276 void setStopTransactionOnEVSideDisconnect(bool stop_transaction_on_ev_side_disconnect);
277 KeyValue getStopTransactionOnEVSideDisconnectKeyValue();
278
279 // Core Profile
280 bool getStopTransactionOnInvalidId();
281 void setStopTransactionOnInvalidId(bool stop_transaction_on_invalid_id);
282 KeyValue getStopTransactionOnInvalidIdKeyValue();
283
284 // Core Profile
285 std::string getStopTxnAlignedData();
286 bool setStopTxnAlignedData(std::string stop_txn_aligned_data);
287 KeyValue getStopTxnAlignedDataKeyValue();
288
289 // Core Profile - optional
290 std::optional<int32_t> getStopTxnAlignedDataMaxLength();
291 std::optional<KeyValue> getStopTxnAlignedDataMaxLengthKeyValue();
292
293 // Core Profile
294 std::string getStopTxnSampledData();
295 bool setStopTxnSampledData(std::string stop_txn_sampled_data);
296 KeyValue getStopTxnSampledDataKeyValue();
297
298 // Core Profile - optional
299 std::optional<int32_t> getStopTxnSampledDataMaxLength();
300 std::optional<KeyValue> getStopTxnSampledDataMaxLengthKeyValue();
301
302 // Core Profile
303 std::string getSupportedFeatureProfiles();
304 KeyValue getSupportedFeatureProfilesKeyValue();
305 std::set<SupportedFeatureProfiles> getSupportedFeatureProfilesSet();
306
307 // Core Profile - optional
308 std::optional<int32_t> getSupportedFeatureProfilesMaxLength();
309 std::optional<KeyValue> getSupportedFeatureProfilesMaxLengthKeyValue();
310
311 // Core Profile
312 int32_t getTransactionMessageAttempts();
313 void setTransactionMessageAttempts(int32_t attempts);
314 KeyValue getTransactionMessageAttemptsKeyValue();
315
316 // Core Profile
317 int32_t getTransactionMessageRetryInterval();
318 void setTransactionMessageRetryInterval(int32_t retry_interval);
319 KeyValue getTransactionMessageRetryIntervalKeyValue();
320
321 // Core Profile
322 bool getUnlockConnectorOnEVSideDisconnect();
323 void setUnlockConnectorOnEVSideDisconnect(bool unlock_connector_on_ev_side_disconnect);
324 KeyValue getUnlockConnectorOnEVSideDisconnectKeyValue();
325
326 // Core Profile - optional
327 std::optional<int32_t> getWebsocketPingInterval();
328 void setWebsocketPingInterval(int32_t websocket_ping_interval);
329 std::optional<KeyValue> getWebsocketPingIntervalKeyValue();
330
331 // Core Profile end
332
333 // SmartCharging Profile
334 int32_t getChargeProfileMaxStackLevel();
335 KeyValue getChargeProfileMaxStackLevelKeyValue();
336
337 // SmartCharging Profile
338 std::string getChargingScheduleAllowedChargingRateUnit();
339 KeyValue getChargingScheduleAllowedChargingRateUnitKeyValue();
340 std::vector<ChargingRateUnit> getChargingScheduleAllowedChargingRateUnitVector();
341
342 // SmartCharging Profile
343 int32_t getChargingScheduleMaxPeriods();
344 KeyValue getChargingScheduleMaxPeriodsKeyValue();
345
346 // SmartCharging Profile - optional
347 std::optional<bool> getConnectorSwitch3to1PhaseSupported();
348 std::optional<KeyValue> getConnectorSwitch3to1PhaseSupportedKeyValue();
349
350 // SmartCharging Profile
351 int32_t getMaxChargingProfilesInstalled();
352 KeyValue getMaxChargingProfilesInstalledKeyValue();
353
354 // SmartCharging Profile end
355
356 // Security profile - optional
357 std::optional<bool> getAdditionalRootCertificateCheck();
358 std::optional<KeyValue> getAdditionalRootCertificateCheckKeyValue();
359
360 // Security profile - optional
361 std::optional<std::string> getAuthorizationKey();
362 void setAuthorizationKey(std::string authorization_key);
363 std::optional<KeyValue> getAuthorizationKeyKeyValue();
364
365 // Security profile - optional
366 std::optional<int32_t> getCertificateSignedMaxChainSize();
367 std::optional<KeyValue> getCertificateSignedMaxChainSizeKeyValue();
368
369 // Security profile - optional
370 std::optional<int32_t> getCertificateStoreMaxLength();
371 std::optional<KeyValue> getCertificateStoreMaxLengthKeyValue();
372
373 // Security profile - optional
374 std::optional<std::string> getCpoName();
375 void setCpoName(std::string cpo_name);
376 std::optional<KeyValue> getCpoNameKeyValue();
377
378 // // Security profile - optional in ocpp but mandatory websocket connection
379 int32_t getSecurityProfile();
380 void setSecurityProfile(int32_t security_profile);
381 KeyValue getSecurityProfileKeyValue();
382
383 // // Security profile - optional with default
384 bool getDisableSecurityEventNotifications();
385 void setDisableSecurityEventNotifications(bool disable_security_event_notifications);
386 KeyValue getDisableSecurityEventNotificationsKeyValue();
387
388 // Local Auth List Management Profile
389 bool getLocalAuthListEnabled();
390 void setLocalAuthListEnabled(bool local_auth_list_enabled);
391 KeyValue getLocalAuthListEnabledKeyValue();
392
393 // Local Auth List Management Profile
394 int32_t getLocalAuthListMaxLength();
395 KeyValue getLocalAuthListMaxLengthKeyValue();
396
397 // Local Auth List Management Profile
398 int32_t getSendLocalListMaxLength();
399 KeyValue getSendLocalListMaxLengthKeyValue();
400
401 // PnC
402 bool getISO15118PnCEnabled();
403 void setISO15118PnCEnabled(const bool iso15118_pnc_enabled);
404 KeyValue getISO15118PnCEnabledKeyValue();
405
406 std::optional<bool> getCentralContractValidationAllowed();
407 void setCentralContractValidationAllowed(const bool central_contract_validation_allowed);
408 std::optional<KeyValue> getCentralContractValidationAllowedKeyValue();
409
410 std::optional<int32_t> getCertSigningWaitMinimum();
411 void setCertSigningWaitMinimum(const int32_t cert_signing_wait_minimum);
412 std::optional<KeyValue> getCertSigningWaitMinimumKeyValue();
413
414 std::optional<int32_t> getCertSigningRepeatTimes();
415 void setCertSigningRepeatTimes(const int32_t cert_signing_repeat_times);
416 std::optional<KeyValue> getCertSigningRepeatTimesKeyValue();
417
418 bool getContractValidationOffline();
419 void setContractValidationOffline(const bool contract_validation_offline);
420 KeyValue getContractValidationOfflineKeyValue();
421
422 int32_t getOcspRequestInterval();
423 void setOcspRequestInterval(const int32_t ocsp_request_interval);
424 KeyValue getOcspRequestIntervalKeyValue();
425
426 std::optional<std::string> getSeccLeafSubjectCommonName();
427 void setSeccLeafSubjectCommonName(const std::string& secc_leaf_subject_common_name);
428 std::optional<KeyValue> getSeccLeafSubjectCommonNameKeyValue();
429
430 std::optional<std::string> getSeccLeafSubjectCountry();
431 void setSeccLeafSubjectCountry(const std::string& secc_leaf_subject_country);
432 std::optional<KeyValue> getSeccLeafSubjectCountryKeyValue();
433
434 std::optional<std::string> getSeccLeafSubjectOrganization();
435 void setSeccLeafSubjectOrganization(const std::string& secc_leaf_subject_organization);
436 std::optional<KeyValue> getSeccLeafSubjectOrganizationKeyValue();
437
438 std::optional<std::string> getConnectorEvseIds();
439 void setConnectorEvseIds(const std::string& connector_evse_ids);
440 std::optional<KeyValue> getConnectorEvseIdsKeyValue();
441
442 std::optional<bool> getAllowChargingProfileWithoutStartSchedule();
443 void setAllowChargingProfileWithoutStartSchedule(const bool allow);
444 std::optional<KeyValue> getAllowChargingProfileWithoutStartScheduleKeyValue();
445
446 int32_t getWaitForStopTransactionsOnResetTimeout();
447 void setWaitForStopTransactionsOnResetTimeout(const int32_t wait_for_stop_transactions_on_reset_timeout);
448 KeyValue getWaitForStopTransactionsOnResetTimeoutKeyValue();
449
450 // California Pricing Requirements
451 bool getCustomDisplayCostAndPriceEnabled();
452 KeyValue getCustomDisplayCostAndPriceEnabledKeyValue();
453
454 std::optional<uint32_t> getPriceNumberOfDecimalsForCostValues();
455 std::optional<KeyValue> getPriceNumberOfDecimalsForCostValuesKeyValue();
456
457 std::optional<std::string> getDefaultPriceText(const std::string& language);
458 ConfigurationStatus setDefaultPriceText(const CiString<50>& key, const CiString<500>& value);
459 KeyValue getDefaultPriceTextKeyValue(const std::string& language);
460 std::optional<std::vector<KeyValue>> getAllDefaultPriceTextKeyValues();
461
462 std::optional<std::string> getDefaultPrice();
463 ConfigurationStatus setDefaultPrice(const std::string& value);
464 std::optional<KeyValue> getDefaultPriceKeyValue();
465
466 std::optional<std::string> getDisplayTimeOffset();
467 ConfigurationStatus setDisplayTimeOffset(const std::string& offset);
468 std::optional<KeyValue> getDisplayTimeOffsetKeyValue();
469
470 std::optional<std::string> getNextTimeOffsetTransitionDateTime();
471 ConfigurationStatus setNextTimeOffsetTransitionDateTime(const std::string& date_time);
472 std::optional<KeyValue> getNextTimeOffsetTransitionDateTimeKeyValue();
473
474 std::optional<std::string> getTimeOffsetNextTransition();
475 ConfigurationStatus setTimeOffsetNextTransition(const std::string& offset);
476 std::optional<KeyValue> getTimeOffsetNextTransitionKeyValue();
477
478 std::optional<bool> getCustomIdleFeeAfterStop();
479 void setCustomIdleFeeAfterStop(const bool& value);
480 std::optional<KeyValue> getCustomIdleFeeAfterStopKeyValue();
481
482 std::optional<bool> getCustomMultiLanguageMessagesEnabled();
483 std::optional<KeyValue> getCustomMultiLanguageMessagesEnabledKeyValue();
484
485 std::optional<std::string> getMultiLanguageSupportedLanguages();
486 std::optional<KeyValue> getMultiLanguageSupportedLanguagesKeyValue();
487
488 std::optional<std::string> getLanguage();
489 void setLanguage(const std::string& language);
490 std::optional<KeyValue> getLanguageKeyValue();
491
492 // custom
493 std::optional<KeyValue> getCustomKeyValue(CiString<50> key);
494 ConfigurationStatus setCustomKey(CiString<50> key, CiString<500> value, bool force);
495
496 std::optional<KeyValue> get(CiString<50> key);
497
498 std::vector<KeyValue> get_all_key_value();
499
500 ConfigurationStatus set(CiString<50> key, CiString<500> value);
501};
502
503} // namespace v16
504} // namespace ocpp
505
506#endif // OCPP_V16_CHARGE_POINT_CONFIGURATION_HPP
contains the configuration of the charge point
Definition: charge_point_configuration.hpp:17
Definition: ocpp_types.hpp:83