Skip to content

Commit

Permalink
calling set system time callback on bootnotification response and hea…
Browse files Browse the repository at this point in the history
…rtbeat

Signed-off-by: pietfried <pietgoempel@gmail.com>
  • Loading branch information
Pietfried committed Sep 5, 2023
1 parent 83533eb commit 57919de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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 @@ -1008,6 +1008,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 @@ -1027,6 +1031,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 @@ -1651,6 +1660,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

0 comments on commit 57919de

Please sign in to comment.