Skip to content

Commit

Permalink
writing security profile to device model on init websocket and connec…
Browse files Browse the repository at this point in the history
…ted callback

Signed-off-by: pietfried <[email protected]>
  • Loading branch information
Pietfried committed Oct 12, 2023
1 parent 7f349e5 commit f5e1975
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,24 @@ void ChargePoint::init_websocket() {
return;
}

const auto& security_profile_cv = ControllerComponentVariables::SecurityProfile;
if (security_profile_cv.variable.has_value()) {
this->device_model->set_read_only_value(security_profile_cv.component, security_profile_cv.variable.value(),
AttributeEnum::Actual,
std::to_string(network_connection_profile.value().securityProfile));
}

this->websocket = std::make_unique<Websocket>(connection_options, this->evse_security, this->logging);
this->websocket->register_connected_callback([this](const int security_profile) {
this->message_queue->resume();
this->websocket_connection_status = WebsocketConnectionStatusEnum::Connected;

const auto& security_profile_cv = ControllerComponentVariables::SecurityProfile;
if (security_profile_cv.variable.has_value()) {
this->device_model->set_read_only_value(security_profile_cv.component, security_profile_cv.variable.value(),
AttributeEnum::Actual, std::to_string(security_profile));
}

if (this->registration_status == RegistrationStatusEnum::Accepted) {
// handle offline threshold
// Get the current time point using steady_clock
Expand Down
3 changes: 2 additions & 1 deletion lib/ocpp/v201/device_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ SetVariableStatusEnum DeviceModel::set_value(const Component& component, const V
SetVariableStatusEnum DeviceModel::set_read_only_value(const Component& component, const Variable& variable,
const AttributeEnum& attribute_enum, const std::string& value) {

if (component == ControllerComponents::AuthCacheCtrlr or component == ControllerComponents::LocalAuthListCtrlr) {
if (component == ControllerComponents::AuthCacheCtrlr or component == ControllerComponents::LocalAuthListCtrlr or
component == ControllerComponents::SecurityCtrlr) {
return this->set_value_internal(component, variable, attribute_enum, value, true);
}
throw std::invalid_argument("Not allowed to set read only value for component " + component.name.get());
Expand Down

0 comments on commit f5e1975

Please sign in to comment.