Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions src/chargepoint/authent/AuthentLocalList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
{
Expand All @@ -163,7 +186,8 @@ bool AuthentLocalList::handleMessage(const ocpp::messages::SendLocalListReq& req
}
else
{
response.status = UpdateStatus::VersionMismatch;
response.status = UpdateStatus::Failed;

}
}
else
Expand Down
43 changes: 33 additions & 10 deletions src/chargepoint/status/StatusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I didn't handled this case.

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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For connector 0, I would have done it differently : I would have notified the user application of a change availability request on connector 0 only. If the request has been accepted, I would have change the status of all the connectors.
By doing this, I would have only 1 status for my response to the Central System reflecting the overall change availability request status of the connectors.

if (response.status == AvailabilityStatus::Accepted)
{
// Update status
ChargePointStatus status = ChargePointStatus::Unavailable;
if (request.type == AvailabilityType::Operative)
{
status = ChargePointStatus::Available;
}
m_worker_pool.run<void>([this, i, status] { updateConnectorStatus(i, status); });
}

LOG_INFO << "Change availability " << AvailabilityStatusHelper.toString(response.status);
}
m_worker_pool.run<void>([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<void>([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
Expand Down