Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/ocpp/v16/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <ocpp/v2/messages/SignCertificate.hpp>
#include <ocpp/v2/messages/TriggerMessage.hpp>

#include <optional>

Check notice on line 35 in include/ocpp/v16/charge_point.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/ocpp/v16/charge_point.hpp#L35

Include file: <optional> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace ocpp {
namespace v16 {
class ChargePointImpl;
Expand Down Expand Up @@ -81,6 +83,26 @@
/// @} // End constructors 1.6 group
/// @} // End chargepoint constructors topic

/// \brief Allow to update the ChargePoint core information which will be sent in BootNotification.req
/// While `vendor` and `model` strings are both required, all other values are optional.
/// Passing `std::nullopt` keeps the current existing value, i.e. does not touch the current
/// value at all, other strings replace the corresponding current value.
void update_chargepoint_information(const std::string& vendor, const std::string& model,
const std::optional<std::string>& serialnumber,
const std::optional<std::string>& chargebox_serialnumber,
const std::optional<std::string>& firmware_version);

/// \brief Allow to update the ChargePoint's modem information which will be sent in BootNotification.req
/// Passing `std::nullopt` keeps the current existing value, i.e. does not touch the current value at all.
/// Passing other strings replace the corresponding current value.
void update_modem_information(const std::optional<std::string>& iccid, const std::optional<std::string>& imsi);

/// \brief Allow to update the ChargePoint's meter information which will be sent in BootNotification.req
/// Passing `std::nullopt` keeps the current existing value, i.e. does not touch the current value at all,
/// other strings replace the corresponding current value.
void update_meter_information(const std::optional<std::string>& meter_serialnumber,
const std::optional<std::string>& meter_type);

/// \brief Initializes the ChargePoint and all of it's connectors, the state machine and message queue. This method
/// should be called if a more granular start of the process is necessary. Notably if it is necessary for the state
/// machine and the connectors (and their statuses) need to be updated prior to initiating connection with the CSMS.
Expand Down
13 changes: 12 additions & 1 deletion include/ocpp/v16/charge_point_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define OCPP_V16_CHARGE_POINT_CONFIGURATION_HPP

#include <mutex>
#include <optional>

Check notice on line 7 in include/ocpp/v16/charge_point_configuration.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/ocpp/v16/charge_point_configuration.hpp#L7

Include file: <optional> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <set>

#include <ocpp/common/support_older_cpp_versions.hpp>
Expand Down Expand Up @@ -40,10 +41,20 @@

bool checkTimeOffset(const std::string& offset);

void setChargepointInformationProperty(json& user_config, const std::string& key,
const std::optional<std::string>& value);

public:
ChargePointConfiguration(const std::string& config, const fs::path& ocpp_main_path,
const fs::path& user_config_path);

void setChargepointInformation(const std::string& chargePointVendor, const std::string& chargePointModel,
const std::optional<std::string>& chargePointSerialNumber,
const std::optional<std::string>& chargeBoxSerialNumber,
const std::optional<std::string>& firmwareVersion);
void setChargepointModemInformation(const std::optional<std::string>& ICCID,
const std::optional<std::string>& IMSI);
void setChargepointMeterInformation(const std::optional<std::string>& meterSerialNumber,
const std::optional<std::string>& meterType);
// Internal config options
std::string getChargePointId();
KeyValue getChargePointIdKeyValue();
Expand Down
14 changes: 14 additions & 0 deletions include/ocpp/v16/charge_point_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iostream>
#include <mutex>
#include <ocpp/common/support_older_cpp_versions.hpp>
#include <optional>
#include <set>

#include <everest/timer.hpp>
Expand Down Expand Up @@ -418,6 +419,19 @@ class ChargePointImpl : ocpp::ChargingStationBase {
~ChargePointImpl() {
}

/// \brief Allow to update the ChargePoint core information which will be sent in BootNotification.req
void update_chargepoint_information(const std::string& vendor, const std::string& model,
const std::optional<std::string>& serialnumber,
const std::optional<std::string>& chargebox_serialnumber,
const std::optional<std::string>& firmware_version);

/// \brief Allow to update the ChargePoint modem information
void update_modem_information(const std::optional<std::string>& iccid, const std::optional<std::string>& imsi);

/// \brief Allow to update the ChargePoint meter information
void update_meter_information(const std::optional<std::string>& meter_serialnumber,
const std::optional<std::string>& meter_type);

/// \brief Initializes the ChargePoint and all of it's connectors, the state machine and message queue. This method
/// should be called if a more granular start of the process is necessary. Notably if it is necessary for the state
/// machine and the connectors (and their statuses) need to be updated prior to initiating connection with the CSMS.
Expand Down
18 changes: 18 additions & 0 deletions lib/ocpp/v16/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ ChargePoint::ChargePoint(const std::string& config, const fs::path& share_path,

ChargePoint::~ChargePoint() = default;

void ChargePoint::update_chargepoint_information(const std::string& vendor, const std::string& model,
const std::optional<std::string>& serialnumber,
const std::optional<std::string>& chargebox_serialnumber,
const std::optional<std::string>& firmware_version) {
this->charge_point->update_chargepoint_information(vendor, model, serialnumber, chargebox_serialnumber,
firmware_version);
}

void ChargePoint::update_modem_information(const std::optional<std::string>& iccid,
const std::optional<std::string>& imsi) {
this->charge_point->update_modem_information(iccid, imsi);
}

void ChargePoint::update_meter_information(const std::optional<std::string>& meter_serialnumber,
const std::optional<std::string>& meter_type) {
this->charge_point->update_meter_information(meter_serialnumber, meter_type);
}

bool ChargePoint::init(const std::map<int, ChargePointStatus>& connector_status_map,
const std::set<std::string>& resuming_session_ids) {
return this->charge_point->init(connector_status_map, resuming_session_ids);
Expand Down
60 changes: 60 additions & 0 deletions lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,66 @@ void ChargePointConfiguration::init_supported_measurands() {
}
}

void ChargePointConfiguration::setChargepointInformationProperty(json& user_config, const std::string& key,
const std::optional<std::string>& value) {
// std::nullopt value leaves the current value untouched
if (value.has_value()) {
this->config["Internal"][key] = value.value();
user_config["Internal"][key] = value.value();
}
}

void ChargePointConfiguration::setChargepointInformation(const std::string& chargePointVendor,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add other properties of the BootNotification as well:

  • iccid
  • imsi
  • meterSerialNumber
  • meterType
  • chargeBoxSerialNumber

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will add as std::optional parameter

const std::string& chargePointModel,
const std::optional<std::string>& chargePointSerialNumber,
const std::optional<std::string>& chargeBoxSerialNumber,
const std::optional<std::string>& firmwareVersion) {
// load current persistent configuration from disk
json user_config = this->get_user_config();

this->config["Internal"]["ChargePointVendor"] = chargePointVendor;
user_config["Internal"]["ChargePointVendor"] = chargePointVendor;

this->config["Internal"]["ChargePointModel"] = chargePointModel;
user_config["Internal"]["ChargePointModel"] = chargePointModel;

setChargepointInformationProperty(user_config, "ChargePointSerialNumber", chargePointSerialNumber);
setChargepointInformationProperty(user_config, "ChargeBoxSerialNumber", chargeBoxSerialNumber);
setChargepointInformationProperty(user_config, "FirmwareVersion", firmwareVersion);

// save the changes back
std::ofstream ofs(this->user_config_path.c_str());
ofs << user_config << std::endl;
ofs.close();
}

void ChargePointConfiguration::setChargepointModemInformation(const std::optional<std::string>& ICCID,
const std::optional<std::string>& IMSI) {
// load current persistent configuration from disk
json user_config = this->get_user_config();

setChargepointInformationProperty(user_config, "ICCID", ICCID);
setChargepointInformationProperty(user_config, "IMSI", IMSI);

// save the changes back
std::ofstream ofs(this->user_config_path.c_str());
ofs << user_config << std::endl;
ofs.close();
}
void ChargePointConfiguration::setChargepointMeterInformation(const std::optional<std::string>& meterSerialNumber,
const std::optional<std::string>& meterType) {
// load current persistent configuration from disk
json user_config = this->get_user_config();

setChargepointInformationProperty(user_config, "MeterSerialNumber", meterSerialNumber);
setChargepointInformationProperty(user_config, "MeterType", meterType);

// save the changes back
std::ofstream ofs(this->user_config_path.c_str());
ofs << user_config << std::endl;
ofs.close();
}

// Internal config options
std::string ChargePointConfiguration::getChargePointId() {
return this->config["Internal"]["ChargePointId"];
Expand Down
18 changes: 18 additions & 0 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,24 @@ void ChargePointImpl::reset_pricing_triggers(const int32_t connector_number) {
}
}

void ChargePointImpl::update_chargepoint_information(const std::string& vendor, const std::string& model,
const std::optional<std::string>& serialnumber,
const std::optional<std::string>& chargebox_serialnumber,
const std::optional<std::string>& firmware_version) {
this->configuration->setChargepointInformation(vendor, model, serialnumber, chargebox_serialnumber,
firmware_version);
}

void ChargePointImpl::update_modem_information(const std::optional<std::string>& iccid,
const std::optional<std::string>& imsi) {
this->configuration->setChargepointModemInformation(iccid, imsi);
}

void ChargePointImpl::update_meter_information(const std::optional<std::string>& meter_serialnumber,
const std::optional<std::string>& meter_type) {
this->configuration->setChargepointMeterInformation(meter_serialnumber, meter_type);
}

bool ChargePointImpl::init(const std::map<int, ChargePointStatus>& connector_status_map,
const std::set<std::string>& resuming_session_ids) {
// push transaction messages including SecurityEventNotification.req onto the message queue
Expand Down