Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable CentralSystemURI for OCPP1.6 #393

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion config/v16/profile_schemas/Internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"CentralSystemURI": {
"type": "string",
"readOnly": true,
"readOnly": false,
"minLength": 1
},
"ChargeBoxSerialNumber": {
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v16/charge_point_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ChargePointConfiguration {
std::string getChargePointId();
KeyValue getChargePointIdKeyValue();
std::string getCentralSystemURI();
void setCentralSystemURI(std::string central_system_uri);
KeyValue getCentralSystemURIKeyValue();
std::string getChargeBoxSerialNumber();
KeyValue getChargeBoxSerialNumberKeyValue();
Expand Down
16 changes: 15 additions & 1 deletion lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <boost/algorithm/string/split.hpp>

#include <ocpp/common/schemas.hpp>
#include <ocpp/common/websocket/websocket_uri.hpp>
#include <ocpp/v16/charge_point_configuration.hpp>
#include <ocpp/v16/types.hpp>

Expand Down Expand Up @@ -214,6 +215,9 @@ std::string ChargePointConfiguration::getChargePointId() {
std::string ChargePointConfiguration::getCentralSystemURI() {
return this->config["Internal"]["CentralSystemURI"];
}
void ChargePointConfiguration::setCentralSystemURI(std::string central_system_uri) {
this->setInUserConfig("Internal", "CentralSystemURI", central_system_uri);
}
std::string ChargePointConfiguration::getChargeBoxSerialNumber() {
return this->config["Internal"]["ChargeBoxSerialNumber"];
}
Expand Down Expand Up @@ -324,7 +328,7 @@ KeyValue ChargePointConfiguration::getChargePointIdKeyValue() {
KeyValue ChargePointConfiguration::getCentralSystemURIKeyValue() {
KeyValue kv;
kv.key = "CentralSystemURI";
kv.readonly = true;
kv.readonly = false;
kv.value.emplace(this->getCentralSystemURI());
return kv;
}
Expand Down Expand Up @@ -2401,6 +2405,16 @@ std::vector<KeyValue> ChargePointConfiguration::get_all_key_value() {
}

ConfigurationStatus ChargePointConfiguration::set(CiString<50> key, CiString<500> value) {
if (key == "CentralSystemURI") {
try {
Uri::parse_and_validate(value.get(), this->getChargePointId(), this->getSecurityProfile());
} catch (const std::invalid_argument& e) {
// given CentralSystemURI is not valid
return ConfigurationStatus::Rejected;
}
this->setCentralSystemURI(value.get());
return ConfigurationStatus::RebootRequired;
}
if (key == "AllowOfflineTxForUnknownId") {
if (this->getAllowOfflineTxForUnknownId() == std::nullopt) {
return ConfigurationStatus::NotSupported;
Expand Down