diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index 164f148a5..5b4ac03c0 100644 --- a/include/ocpp/v16/charge_point_impl.hpp +++ b/include/ocpp/v16/charge_point_impl.hpp @@ -245,6 +245,7 @@ class ChargePointImpl : ocpp::ChargingStationBase { void handleStartTransactionResponse(CallResult call_result); void handleStopTransactionResponse(CallResult call_result); void handleUnlockConnectorRequest(Call call); + void handleHeartbeatResponse(CallResult call_result); // smart charging profile void handleSetChargingProfileRequest(Call call); diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 7e56f8d9c..2e595cc9c 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -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; @@ -1078,6 +1082,11 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResultconnection_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(); @@ -1702,6 +1711,12 @@ void ChargePointImpl::handleUnlockConnectorRequest(ocpp::Callsend(call_result); } +void ChargePointImpl::handleHeartbeatResponse(CallResult 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 call) { EVLOG_debug << "Received SetChargingProfileRequest: " << call.msg << "\nwith messageId: " << call.uniqueId;