diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index 29352442e6..394d6bb6c8 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 496cf55cd5..e61dcba624 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -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; @@ -1027,6 +1031,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(); @@ -1651,6 +1660,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;