diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 188fff21a..5bbcb7386 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -6,6 +6,8 @@ #include #include +using namespace std::literals::chrono_literals; + namespace ocpp { namespace v201 { @@ -511,10 +513,11 @@ void ChargePoint::init_websocket() { AttributeEnum::Actual, std::to_string(security_profile)); } - if (this->registration_status == RegistrationStatusEnum::Accepted) { + if (this->registration_status == RegistrationStatusEnum::Accepted and + this->time_disconnected.time_since_epoch() != 0s) { // handle offline threshold // Get the current time point using steady_clock - std::chrono::steady_clock::duration offline_duration = std::chrono::steady_clock::now() - time_disconnected; + auto offline_duration = std::chrono::steady_clock::now() - this->time_disconnected; // B04.FR.01 // If offline period exceeds offline threshold then send the status notification for all connectors @@ -539,6 +542,7 @@ void ChargePoint::init_websocket() { } } } + this->time_disconnected = std::chrono::time_point(); }); this->websocket->register_closed_callback( @@ -565,7 +569,7 @@ void ChargePoint::init_websocket() { } } // Get the current time point using steady_clock - time_disconnected = std::chrono::steady_clock::now(); + this->time_disconnected = std::chrono::steady_clock::now(); } if (!this->disable_automatic_websocket_reconnects) {