From 7b597839db2f558ba86e124468f4e5942e17f53f Mon Sep 17 00:00:00 2001 From: Mahdi Dadashi Date: Wed, 18 Jan 2023 15:55:06 +0330 Subject: [PATCH 1/2] Update AuthentLocalList.cpp In case of a full update this is the version number of the full list. In case of a differential update it is the version number of the list after the update has been applied. SHALL NOT be -1 or 0 as these have a special meaning in GetLocalListVersion.conf --- src/chargepoint/authent/AuthentLocalList.cpp | 56 ++++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/chargepoint/authent/AuthentLocalList.cpp b/src/chargepoint/authent/AuthentLocalList.cpp index 7a5d91db..e032f11f 100644 --- a/src/chargepoint/authent/AuthentLocalList.cpp +++ b/src/chargepoint/authent/AuthentLocalList.cpp @@ -124,8 +124,7 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req // Check local list activation if (m_ocpp_config.localAuthListEnabled()) { - // Check local list version - if (request.listVersion > m_local_list_version) + if (request.listVersion > 0) { // Check update list size if (request.localAuthorizationList.size() <= m_ocpp_config.sendLocalListMaxLength()) @@ -135,26 +134,50 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req if (request.updateType == UpdateType::Full) { success = performFullUpdate(request.localAuthorizationList); - } - else - { - success = performPartialUpdate(request.localAuthorizationList); - } - if (success) - { - response.status = UpdateStatus::Accepted; + if (success) + { + response.status = UpdateStatus::Accepted; - // Update local list version - m_local_list_version = request.listVersion; - if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version))) + // Update local list version + m_local_list_version = request.listVersion; + if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version))) + { + LOG_ERROR << "Unable to save authent local list version"; + } + } + else { - LOG_ERROR << "Unable to save authent local list version"; + response.status = UpdateStatus::Failed; } } else { - response.status = UpdateStatus::Failed; + // Check local list version + if (request.listVersion > m_local_list_version) + { + success = performPartialUpdate(request.localAuthorizationList); + if (success) + { + response.status = UpdateStatus::Accepted; + + // Update local list version + m_local_list_version = request.listVersion; + if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version))) + { + LOG_ERROR << "Unable to save authent local list version"; + } + } + else + { + response.status = UpdateStatus::Failed; + } + } + else + { + response.status = UpdateStatus::VersionMismatch; + } } + } else { @@ -163,7 +186,8 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req } else { - response.status = UpdateStatus::VersionMismatch; + response.status = UpdateStatus::Failed; + } } else From 8fad4a28dd46f188bf37fa30dc26a9f3b968eebc Mon Sep 17 00:00:00 2001 From: Mahdi Dadashi Date: Wed, 18 Jan 2023 15:56:21 +0330 Subject: [PATCH 2/2] Update StatusManager.cpp In the case the ChangeAvailability.req contains ConnectorId = 0, the status change applies to the Charge Point and all Connectors. --- src/chargepoint/status/StatusManager.cpp | 43 ++++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/chargepoint/status/StatusManager.cpp b/src/chargepoint/status/StatusManager.cpp index c756cecb..94fce6ae 100644 --- a/src/chargepoint/status/StatusManager.cpp +++ b/src/chargepoint/status/StatusManager.cpp @@ -363,20 +363,43 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r unsigned int connector_id = request.connectorId; if (m_connectors.isValid(connector_id)) { - // Notify request - response.status = m_events_handler.changeAvailabilityRequested(connector_id, request.type); - if (response.status == AvailabilityStatus::Accepted) - { - // Update status - ChargePointStatus status = ChargePointStatus::Unavailable; - if (request.type == AvailabilityType::Operative) + //In the case the ChangeAvailability.req contains ConnectorId = 0, the status change applies to the Charge Point and all Connectors. + if(connector_id == 0) + { + for(unsigned int i=0;i <= m_connectors.getCount();i++) { - status = ChargePointStatus::Available; + response.status = m_events_handler.changeAvailabilityRequested(i, request.type); + if (response.status == AvailabilityStatus::Accepted) + { + // Update status + ChargePointStatus status = ChargePointStatus::Unavailable; + if (request.type == AvailabilityType::Operative) + { + status = ChargePointStatus::Available; + } + m_worker_pool.run([this, i, status] { updateConnectorStatus(i, status); }); + } + + LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status); } - m_worker_pool.run([this, connector_id, status] { updateConnectorStatus(connector_id, status); }); } + else + { + // Notify request + response.status = m_events_handler.changeAvailabilityRequested(connector_id, request.type); + if (response.status == AvailabilityStatus::Accepted) + { + // Update status + ChargePointStatus status = ChargePointStatus::Unavailable; + if (request.type == AvailabilityType::Operative) + { + status = ChargePointStatus::Available; + } + m_worker_pool.run([this, connector_id, status] { updateConnectorStatus(connector_id, status); }); + } - LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status); + LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status); + } ret = true; } else