Skip to content

Commit 391e440

Browse files
authored
fix(v16): Cache entry check and bump version (#1168)
Signed-off-by: Martin Litre <mnlitre@gmail.com>
1 parent 7f21794 commit 391e440

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22

33
project(ocpp
4-
VERSION 0.31.0
4+
VERSION 0.31.1
55
DESCRIPTION "A C++ implementation of the Open Charge Point Protocol"
66
LANGUAGES CXX
77
)

lib/ocpp/v16/charge_point_impl.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,34 +2246,32 @@ void ChargePointImpl::handleRemoteStartTransactionRequest(ocpp::Call<RemoteStart
22462246
bool ChargePointImpl::validate_against_cache_entries(CiString<20> id_tag) {
22472247
try {
22482248
const auto cache_entry_opt = this->database_handler->get_authorization_cache_entry(id_tag);
2249-
if (cache_entry_opt.has_value()) {
2250-
auto cache_entry = cache_entry_opt.value();
2251-
const auto expiry_date_opt = cache_entry.expiryDate;
2252-
2253-
if (cache_entry.status == AuthorizationStatus::Accepted) {
2254-
if (expiry_date_opt.has_value()) {
2255-
const auto expiry_date = expiry_date_opt.value();
2256-
if (expiry_date < ocpp::DateTime()) {
2257-
cache_entry.status = AuthorizationStatus::Expired;
2258-
try {
2259-
this->database_handler->insert_or_update_authorization_cache_entry(id_tag, cache_entry);
2260-
} catch (const QueryExecutionException& e) {
2261-
EVLOG_warning << "Could not insert or update authorization cache entry: " << e.what();
2262-
}
2263-
return false;
2264-
} else {
2265-
return true;
2266-
}
2267-
return false;
2268-
}
2269-
return true;
2270-
}
2249+
if (!cache_entry_opt.has_value()) {
2250+
return false;
2251+
}
2252+
auto cache_entry = cache_entry_opt.value();
2253+
const auto expiry_date_opt = cache_entry.expiryDate;
2254+
2255+
if (cache_entry.status != AuthorizationStatus::Accepted) {
2256+
return false;
2257+
}
2258+
if (!expiry_date_opt.has_value()) {
22712259
return true;
22722260
}
2261+
const auto expiry_date = expiry_date_opt.value();
2262+
if (expiry_date < ocpp::DateTime()) {
2263+
cache_entry.status = AuthorizationStatus::Expired;
2264+
try {
2265+
this->database_handler->insert_or_update_authorization_cache_entry(id_tag, cache_entry);
2266+
} catch (const QueryExecutionException& e) {
2267+
EVLOG_warning << "Could not insert or update authorization cache entry: " << e.what();
2268+
}
2269+
return false;
2270+
}
2271+
return true;
22732272
} catch (const QueryExecutionException& e) {
22742273
EVLOG_warning << "Could not fetch authorization cache entry: " << e.what();
22752274
}
2276-
return false;
22772275
}
22782276

22792277
void ChargePointImpl::handleRemoteStopTransactionRequest(ocpp::Call<RemoteStopTransactionRequest> call) {

0 commit comments

Comments
 (0)