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

Calling Set System time callback in OCPP1.6 #161

Merged
merged 1 commit into from
Sep 13, 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
1 change: 1 addition & 0 deletions include/ocpp/v16/charge_point_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class ChargePointImpl : ocpp::ChargingStationBase {
void handleStartTransactionResponse(CallResult<StartTransactionResponse> call_result);
void handleStopTransactionResponse(CallResult<StopTransactionResponse> call_result);
void handleUnlockConnectorRequest(Call<UnlockConnectorRequest> call);
void handleHeartbeatResponse(CallResult<HeartbeatResponse> call_result);

// smart charging profile
void handleSetChargingProfileRequest(Call<SetChargingProfileRequest> call);
Expand Down
15 changes: 15 additions & 0 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,10 @@ void ChargePointImpl::handle_message(const json& json_message, MessageType messa
this->handleGetLocalListVersionRequest(json_message);
break;

case MessageType::HeartbeatResponse:
this->handleHeartbeatResponse(json_message);
break;

default:
// TODO(kai): not implemented error?
break;
Expand All @@ -1078,6 +1082,11 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
switch (call_result.msg.status) {
case RegistrationStatus::Accepted: {
this->connection_state = ChargePointConnectionState::Booted;

if (this->set_system_time_callback != nullptr) {
this->set_system_time_callback(call_result.msg.currentTime.to_rfc3339());
}

// we are allowed to send messages to the central system
// activate heartbeat
this->update_heartbeat_interval();
Expand Down Expand Up @@ -1702,6 +1711,12 @@ void ChargePointImpl::handleUnlockConnectorRequest(ocpp::Call<UnlockConnectorReq
this->send<UnlockConnectorResponse>(call_result);
}

void ChargePointImpl::handleHeartbeatResponse(CallResult<HeartbeatResponse> call_result) {
if (this->set_system_time_callback != nullptr) {
this->set_system_time_callback(call_result.msg.currentTime.to_rfc3339());
}
}

void ChargePointImpl::handleSetChargingProfileRequest(ocpp::Call<SetChargingProfileRequest> call) {
EVLOG_debug << "Received SetChargingProfileRequest: " << call.msg << "\nwith messageId: " << call.uniqueId;

Expand Down