@@ -270,6 +270,66 @@ void ChargePointConfiguration::init_supported_measurands() {
270270 }
271271}
272272
273+ void ChargePointConfiguration::setChargepointInformationProperty (json& user_config, const std::string& key,
274+ const std::optional<std::string>& value) {
275+ // std::nullopt value leaves the current value untouched
276+ if (value.has_value ()) {
277+ this ->config [" Internal" ][key] = value.value ();
278+ user_config[" Internal" ][key] = value.value ();
279+ }
280+ }
281+
282+ void ChargePointConfiguration::setChargepointInformation (const std::string& chargePointVendor,
283+ const std::string& chargePointModel,
284+ const std::optional<std::string>& chargePointSerialNumber,
285+ const std::optional<std::string>& chargeBoxSerialNumber,
286+ const std::optional<std::string>& firmwareVersion) {
287+ // load current persistent configuration from disk
288+ json user_config = this ->get_user_config ();
289+
290+ this ->config [" Internal" ][" ChargePointVendor" ] = chargePointVendor;
291+ user_config[" Internal" ][" ChargePointVendor" ] = chargePointVendor;
292+
293+ this ->config [" Internal" ][" ChargePointModel" ] = chargePointModel;
294+ user_config[" Internal" ][" ChargePointModel" ] = chargePointModel;
295+
296+ setChargepointInformationProperty (user_config, " ChargePointSerialNumber" , chargePointSerialNumber);
297+ setChargepointInformationProperty (user_config, " ChargeBoxSerialNumber" , chargeBoxSerialNumber);
298+ setChargepointInformationProperty (user_config, " FirmwareVersion" , firmwareVersion);
299+
300+ // save the changes back
301+ std::ofstream ofs (this ->user_config_path .c_str ());
302+ ofs << user_config << std::endl;
303+ ofs.close ();
304+ }
305+
306+ void ChargePointConfiguration::setChargepointModemInformation (const std::optional<std::string>& ICCID,
307+ const std::optional<std::string>& IMSI) {
308+ // load current persistent configuration from disk
309+ json user_config = this ->get_user_config ();
310+
311+ setChargepointInformationProperty (user_config, " ICCID" , ICCID);
312+ setChargepointInformationProperty (user_config, " IMSI" , IMSI);
313+
314+ // save the changes back
315+ std::ofstream ofs (this ->user_config_path .c_str ());
316+ ofs << user_config << std::endl;
317+ ofs.close ();
318+ }
319+ void ChargePointConfiguration::setChargepointMeterInformation (const std::optional<std::string>& meterSerialNumber,
320+ const std::optional<std::string>& meterType) {
321+ // load current persistent configuration from disk
322+ json user_config = this ->get_user_config ();
323+
324+ setChargepointInformationProperty (user_config, " MeterSerialNumber" , meterSerialNumber);
325+ setChargepointInformationProperty (user_config, " MeterType" , meterType);
326+
327+ // save the changes back
328+ std::ofstream ofs (this ->user_config_path .c_str ());
329+ ofs << user_config << std::endl;
330+ ofs.close ();
331+ }
332+
273333// Internal config options
274334std::string ChargePointConfiguration::getChargePointId () {
275335 return this ->config [" Internal" ][" ChargePointId" ];
0 commit comments