Skip to content

Commit 272b1fc

Browse files
authored
Merge pull request #102 from c-jimenez/fix/local_list_change_availability
Fix local list version management and change availability management when connector id = 0
2 parents f862215 + 52d3af0 commit 272b1fc

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

src/chargepoint/authent/AuthentLocalList.cpp

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
124124
// Check local list activation
125125
if (m_ocpp_config.localAuthListEnabled())
126126
{
127-
// Check local list version
128-
if (request.listVersion > m_local_list_version)
127+
if (request.listVersion > 0)
129128
{
130129
// Check update list size
131130
if (request.localAuthorizationList.size() <= m_ocpp_config.sendLocalListMaxLength())
@@ -135,25 +134,48 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
135134
if (request.updateType == UpdateType::Full)
136135
{
137136
success = performFullUpdate(request.localAuthorizationList);
138-
}
139-
else
140-
{
141-
success = performPartialUpdate(request.localAuthorizationList);
142-
}
143-
if (success)
144-
{
145-
response.status = UpdateStatus::Accepted;
137+
if (success)
138+
{
139+
response.status = UpdateStatus::Accepted;
146140

147-
// Update local list version
148-
m_local_list_version = request.listVersion;
149-
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
141+
// Update local list version
142+
m_local_list_version = request.listVersion;
143+
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
144+
{
145+
LOG_ERROR << "Unable to save authent local list version";
146+
}
147+
}
148+
else
150149
{
151-
LOG_ERROR << "Unable to save authent local list version";
150+
response.status = UpdateStatus::Failed;
152151
}
153152
}
154153
else
155154
{
156-
response.status = UpdateStatus::Failed;
155+
// Check local list version
156+
if (request.listVersion > m_local_list_version)
157+
{
158+
success = performPartialUpdate(request.localAuthorizationList);
159+
if (success)
160+
{
161+
response.status = UpdateStatus::Accepted;
162+
163+
// Update local list version
164+
m_local_list_version = request.listVersion;
165+
if (!m_internal_config.setKey(LOCAL_LIST_VERSION_KEY, std::to_string(m_local_list_version)))
166+
{
167+
LOG_ERROR << "Unable to save authent local list version";
168+
}
169+
}
170+
else
171+
{
172+
response.status = UpdateStatus::Failed;
173+
}
174+
}
175+
else
176+
{
177+
response.status = UpdateStatus::VersionMismatch;
178+
}
157179
}
158180
}
159181
else
@@ -163,7 +185,7 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
163185
}
164186
else
165187
{
166-
response.status = UpdateStatus::VersionMismatch;
188+
response.status = UpdateStatus::Failed;
167189
}
168190
}
169191
else

src/chargepoint/status/StatusManager.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,23 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r
373373
{
374374
status = ChargePointStatus::Available;
375375
}
376-
m_worker_pool.run<void>([this, connector_id, status] { updateConnectorStatus(connector_id, status); });
376+
377+
// In the case the ChangeAvailability.req contains ConnectorId = 0, the status change applies to the Charge Point and all Connectors.
378+
if (connector_id == 0)
379+
{
380+
for (unsigned int i = 0; i <= m_connectors.getCount(); i++)
381+
{
382+
m_worker_pool.run<void>([this, i, status] { updateConnectorStatus(i, status); });
383+
}
384+
}
385+
else
386+
{
387+
m_worker_pool.run<void>([this, connector_id, status] { updateConnectorStatus(connector_id, status); });
388+
}
377389
}
378390

379391
LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status);
392+
380393
ret = true;
381394
}
382395
else

0 commit comments

Comments
 (0)