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

callback for boot notification #232

Merged
merged 4 commits into from
Oct 31, 2023
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
3 changes: 3 additions & 0 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ struct Callbacks {
///
std::function<void(const CiString<50>& event_type, const std::optional<CiString<255>>& tech_info)>
security_event_callback;

/// @brief Callback for when a bootnotification response is received
std::optional<std::function<void(const ocpp::v201::RegistrationStatusEnum& reg_status)>> boot_notification_callback;
};

/// \brief Class implements OCPP2.0.1 Charging Station
Expand Down
8 changes: 7 additions & 1 deletion lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ bool Callbacks::all_callbacks_valid() const {
this->validate_network_profile_callback.value() != nullptr) and
(!this->configure_network_connection_profile_callback.has_value() or
this->configure_network_connection_profile_callback.value() != nullptr) and
(!this->time_sync_callback.has_value() or this->time_sync_callback.value() != nullptr);
(!this->time_sync_callback.has_value() or this->time_sync_callback.value() != nullptr) and
(!this->boot_notification_callback.has_value() or this->boot_notification_callback.value() != nullptr);
}

ChargePoint::ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure,
Expand Down Expand Up @@ -1444,6 +1445,11 @@ void ChargePoint::handle_boot_notification_response(CallResult<BootNotificationR
},
retry_interval);
}

if (this->callbacks.boot_notification_callback.has_value()) {
// call the registered boot notification callback
callbacks.boot_notification_callback.value()(this->registration_status);
}
}

void ChargePoint::handle_set_variables_req(Call<SetVariablesRequest> call) {
Expand Down