Skip to content

Commit

Permalink
Merge branch 'EVerest:main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Afronut authored Sep 7, 2023
2 parents 73de47a + 3360cd6 commit 171bcfc
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 418 deletions.
20 changes: 16 additions & 4 deletions config/v201/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,28 @@
}
},
"LocalAuthListCtrlr": {
"BytesPerMessageSendLocalList": {
"variable_name": "BytesPerMessageSendLocalList",
"LocalAuthListCtrlrAvailable": {
"variable_name": "Available",
"attributes": {
"Actual": 42
"Actual": true
}
},
"LocalAuthListCtrlrEnabled": {
"variable_name": "Enabled",
"attributes": {
"Actual": false
}
},
"LocalAuthListCtrlrEntries": {
"variable_name": "Entries",
"attributes": {
"Actual": 42
"Actual": 0
}
},
"BytesPerMessageSendLocalList": {
"variable_name": "BytesPerMessageSendLocalList",
"attributes": {
"Actual": 5000
}
},
"ItemsPerMessageSendLocalList": {
Expand Down
18 changes: 18 additions & 0 deletions config/v201/init_core.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
-- Authorization cache --
CREATE TABLE IF NOT EXISTS AUTH_CACHE(
ID_TOKEN_HASH TEXT PRIMARY KEY NOT NULL,
ID_TOKEN_INFO TEXT NOT NULL
);

-- Availability --
CREATE TABLE IF NOT EXISTS AVAILABILITY(
EVSE_ID INT PRIMARY KEY NOT NULL,
CONNECTOR_ID INT,
Expand All @@ -16,3 +18,19 @@ CREATE TABLE IF NOT EXISTS TRANSACTION_QUEUE(
MESSAGE_ATTEMPTS INT NOT NULL,
MESSAGE_TIMESTAMP TEXT NOT NULL
);


-- Auth list --
CREATE TABLE IF NOT EXISTS AUTH_LIST_VERSION (
ID INT PRIMARY KEY NOT NULL,
VERSION INT
);

CREATE TABLE IF NOT EXISTS AUTH_LIST (
ID_TOKEN_HASH TEXT PRIMARY KEY NOT NULL,
ID_TOKEN_INFO TEXT NOT NULL
);

INSERT OR IGNORE INTO AUTH_LIST_VERSION (ID, VERSION) VALUES
(0, 0);

12 changes: 12 additions & 0 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <ocpp/v201/messages/ClearCache.hpp>
#include <ocpp/v201/messages/DataTransfer.hpp>
#include <ocpp/v201/messages/GetBaseReport.hpp>
#include <ocpp/v201/messages/GetLocalListVersion.hpp>
#include <ocpp/v201/messages/GetLog.hpp>
#include <ocpp/v201/messages/GetReport.hpp>
#include <ocpp/v201/messages/GetVariables.hpp>
Expand All @@ -31,6 +32,7 @@
#include <ocpp/v201/messages/RequestStartTransaction.hpp>
#include <ocpp/v201/messages/RequestStopTransaction.hpp>
#include <ocpp/v201/messages/Reset.hpp>
#include <ocpp/v201/messages/SendLocalList.hpp>
#include <ocpp/v201/messages/SetNetworkProfile.hpp>
#include <ocpp/v201/messages/SetVariables.hpp>
#include <ocpp/v201/messages/StatusNotification.hpp>
Expand Down Expand Up @@ -158,6 +160,12 @@ class ChargePoint : ocpp::ChargingStationBase {
MeterValue get_latest_meter_value_filtered(const MeterValue& meter_value, ReadingContextEnum context,
const ComponentVariable& component_variable);

///\brief Apply a local list request to the database if allowed
///
///\param request The local list request to apply
///\retval Accepted if applied, otherwise will return either Failed or VersionMismatch
SendLocalListStatusEnum apply_local_authorization_list(const SendLocalListRequest& request);

///
/// \brief Get evseid for the given transaction id.
/// \param transaction_id The transactionid
Expand Down Expand Up @@ -244,6 +252,10 @@ class ChargePoint : ocpp::ChargingStationBase {
// Functional Block C: Authorization
void handle_clear_cache_req(Call<ClearCacheRequest> call);

// Functional Block D: Local authorization list management
void handle_send_local_authorization_list_req(Call<SendLocalListRequest> call);
void handle_get_local_authorization_list_version_req(Call<GetLocalListVersionRequest> call);

// Functional Block E: Transaction
void handle_start_transaction_event_response(CallResult<TransactionEventResponse> call_result,
const int32_t evse_id, const IdToken& id_token);
Expand Down
31 changes: 31 additions & 0 deletions include/ocpp/v201/database_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class DatabaseHandler : public ocpp::common::DatabaseHandlerBase {
/// \brief Closes connection to database file
void close_connection();

// Authorization cache management

/// \brief Inserts cache entry
/// \param id_token_hash
/// \param id_token_info
Expand All @@ -56,10 +58,39 @@ class DatabaseHandler : public ocpp::common::DatabaseHandlerBase {
/// \return
bool clear_authorization_cache();

// Availability management

void insert_availability(const int32_t evse_id, std::optional<int32_t> connector_id,
const OperationalStatusEnum& operational_status, const bool replace);

OperationalStatusEnum get_availability(const int32_t evse_id, std::optional<int32_t> connector_id);

// Local authorization list management

/// \brief Inserts or updates the given \p version in the AUTH_LIST_VERSION table.
void insert_or_update_local_authorization_list_version(int32_t version);

/// \brief Returns the version in the AUTH_LIST_VERSION table.
int32_t get_local_authorization_list_version();

/// \brief Inserts or updates a local authorization list entry to the AUTH_LIST table.
void insert_or_update_local_authorization_list_entry(const IdToken& id_token, const IdTokenInfo& id_token_info);

/// \brief Inserts or updates a local authorization list entries \p local_authorization_list to the AUTH_LIST table.
void
insert_or_update_local_authorization_list(const std::vector<v201::AuthorizationData>& local_authorization_list);

/// \brief Deletes the authorization list entry with the given \p id_tag
void delete_local_authorization_list_entry(const IdToken& id_token);

/// \brief Returns the IdTagInfo of the given \p id_tag if it exists in the AUTH_LIST table, else std::nullopt.
std::optional<v201::IdTokenInfo> get_local_authorization_list_entry(const IdToken& id_token);

/// \brief Deletes all entries of the AUTH_LIST table.
bool clear_local_authorization_list();

/// \brief Get the number of entries currently in the authorization list
int32_t get_local_authorization_list_number_of_entries();
};

} // namespace v201
Expand Down
Loading

0 comments on commit 171bcfc

Please sign in to comment.