Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter

- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
This commit is contained in:
Eric F
2026-06-08 00:38:27 -04:00
parent 468cfeaa50
commit d398a6ced2
7326 changed files with 1177561 additions and 7 deletions

View File

@@ -0,0 +1,55 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#include "Api.hpp"
using namespace data;
namespace methods {
RPCDataTypes::HelloResObj Api::hello() {
RPCDataTypes::HelloResObj res{};
// check if data is valid
const auto _chargerinfo = m_dataobj.chargerinfo.get_data();
if (not _chargerinfo.has_value()) {
throw std::runtime_error("Data is not valid");
}
res.charger_info = _chargerinfo.value();
res.authentication_required = is_authentication_required();
res.api_version = get_api_version();
res.everest_version = m_dataobj.everest_version;
if (m_authenticated.has_value()) {
res.authenticated = m_authenticated.value();
}
return res;
}
void Api::set_authentication_required(bool required) {
m_authentication_required = required;
}
bool Api::is_authentication_required() const {
return m_authentication_required;
}
void Api::set_api_version(const std::string& version) {
m_api_version = version;
}
const std::string& Api::get_api_version() const {
return m_api_version;
}
void Api::set_authenticated(bool authenticated) {
m_authenticated = authenticated;
}
bool Api::is_authenticated() const {
if (m_authenticated.has_value()) {
return m_authenticated.value();
}
return false;
}
} // namespace methods

View File

@@ -0,0 +1,48 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#ifndef METHODS_API_HPP
#define METHODS_API_HPP
#include <optional>
#include <string>
#include "../../data/DataStore.hpp"
using namespace data;
namespace RPCDataTypes = types::json_rpc_api;
namespace methods {
static const std::string METHOD_API_HELLO = "API.Hello";
/// This class includes all methods of the API namespace.
/// It contains the data object and the methods to access it.
class Api {
public:
// Constructor and Destructor
Api() = delete;
explicit Api(DataStoreCharger& dataobj) : m_dataobj(dataobj), m_authentication_required(false){};
~Api() = default;
// Methods
RPCDataTypes::HelloResObj hello();
void set_authentication_required(bool required);
bool is_authentication_required() const;
void set_api_version(const std::string& version);
const std::string& get_api_version() const;
void set_authenticated(bool authenticated);
bool is_authenticated() const;
private:
DataStoreCharger& m_dataobj;
bool m_authentication_required;
// optional
std::optional<bool> m_authenticated;
std::string m_api_version;
};
} // namespace methods
#endif // METHODS_API_HPP

View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#include <string>
#include "ChargePoint.hpp"
namespace methods {
RPCDataTypes::ChargePointGetEVSEInfosResObj ChargePoint::getEVSEInfos() {
RPCDataTypes::ChargePointGetEVSEInfosResObj res{};
// Iterate over all EVSEs and add the EVSEInfo objects to the response
for (const auto& evse : m_dataobj.evses) {
if (const auto _data = evse->evseinfo.get_data(); _data.has_value()) {
res.infos.push_back(_data.value());
}
}
// Error handling
if (res.infos.empty()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorNoDataAvailable;
} else {
res.error = RPCDataTypes::ResponseErrorEnum::NoError;
}
return res;
}
RPCDataTypes::ChargePointGetActiveErrorsResObj ChargePoint::getActiveErrors() {
RPCDataTypes::ChargePointGetActiveErrorsResObj res{};
res.active_errors = m_dataobj.chargererrors.get_data().value_or(std::vector<RPCDataTypes::ErrorObj>{});
res.error = RPCDataTypes::ResponseErrorEnum::NoError;
return res;
}
} // namespace methods

View File

@@ -0,0 +1,37 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#ifndef METHODS_CHARGEPOINT_HPP
#define METHODS_CHARGEPOINT_HPP
#include "../../data/DataStore.hpp"
using namespace data;
namespace RPCDataTypes = types::json_rpc_api;
namespace methods {
static const std::string METHOD_CHARGEPOINT_GET_EVSE_INFOS = "ChargePoint.GetEVSEInfos";
static const std::string METHOD_CHARGEPOINT_GET_ACTIVE_ERRORS = "ChargePoint.GetActiveErrors";
/// This class includes all methods of the ChargePoint namespace.
/// It contains the data object and the methods to access it.
class ChargePoint {
public:
// Constructor and Destructor
ChargePoint() = delete;
explicit ChargePoint(DataStoreCharger& dataobj) : m_dataobj(dataobj){};
~ChargePoint() = default;
// Methods
RPCDataTypes::ChargePointGetEVSEInfosResObj getEVSEInfos();
RPCDataTypes::ChargePointGetActiveErrorsResObj getActiveErrors();
private:
DataStoreCharger& m_dataobj;
};
} // namespace methods
#endif // METHODS_CHARGEPOINT_HPP

View File

@@ -0,0 +1,206 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#include "Evse.hpp"
namespace methods {
RPCDataTypes::EVSEGetInfoResObj Evse::get_info(const int32_t evse_index) {
RPCDataTypes::EVSEGetInfoResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
const auto data = evse->evseinfo.get_data();
if (not data.has_value()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorNoDataAvailable;
return res;
}
res.info = data.value();
res.error = RPCDataTypes::ResponseErrorEnum::NoError;
return res;
}
RPCDataTypes::EVSEGetStatusResObj Evse::get_status(const int32_t evse_index) {
RPCDataTypes::EVSEGetStatusResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
const auto data = evse->evsestatus.get_data();
if (not data.has_value()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorNoDataAvailable;
return res;
}
res.status = data.value();
res.error = RPCDataTypes::ResponseErrorEnum::NoError;
return res;
}
RPCDataTypes::EVSEGetHardwareCapabilitiesResObj Evse::get_hardware_capabilities(const int32_t evse_index) {
RPCDataTypes::EVSEGetHardwareCapabilitiesResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
const auto data = evse->hardwarecapabilities.get_data();
if (not data.has_value()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorNoDataAvailable;
return res;
}
res.hardware_capabilities = data.value();
return res;
}
RPCDataTypes::ErrorResObj Evse::set_charging_allowed(const int32_t evse_index, bool charging_allowed) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
return m_request_handler_ptr->set_charging_allowed(evse_index, charging_allowed);
}
RPCDataTypes::EVSEGetMeterDataResObj Evse::get_meter_data(const int32_t evse_index) {
RPCDataTypes::EVSEGetMeterDataResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
const auto data = evse->meterdata.get_data();
if (not data.has_value()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorNoDataAvailable;
return res;
}
res.meter_data = data.value();
return res;
}
RPCDataTypes::ErrorResObj Evse::set_ac_charging(const int32_t evse_index, bool charging_allowed, float max_current,
std::optional<int> phase_count) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
return m_request_handler_ptr->set_ac_charging(evse_index, charging_allowed, max_current, phase_count);
}
RPCDataTypes::ErrorResObj Evse::set_ac_charging_current(const int32_t evse_index, float max_current) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
return m_request_handler_ptr->set_ac_charging_current(evse_index, max_current);
}
RPCDataTypes::ErrorResObj Evse::set_ac_charging_phase_count(const int32_t evse_index, int phase_count) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
// Check if the requested phase count is equal to the current active phase count
// If so, we can return a success response without making any changes. Phase switching is not
// necessary in this case.
auto evse_status = evse->evsestatus.get_data();
if (evse_status.has_value() && evse_status.value().ac_charge_status.has_value()) {
if (evse_status.value().ac_charge_status.value().evse_active_phase_count == phase_count) {
res.error = RPCDataTypes::ResponseErrorEnum::NoError;
return res;
}
}
// If phase switching must be performed and the hardware capabilities do not allow it
// we return an error response.
auto hardwarecapabilities = evse->hardwarecapabilities.get_data();
if (hardwarecapabilities.has_value() && hardwarecapabilities.value().phase_switch_during_charging == false) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorOperationNotSupported;
return res;
}
// Check if the requested phase count is within the allowed range
if ((hardwarecapabilities.has_value() && phase_count < hardwarecapabilities.value().min_phase_count_export) ||
phase_count > hardwarecapabilities.value().max_phase_count_export) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorOutOfRange;
return res;
}
// Check if phases are 1 or 3, otherwise return an error
if (phase_count != 1 && phase_count != 3) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidParameter;
return res;
}
return m_request_handler_ptr->set_ac_charging_phase_count(evse_index, phase_count);
}
RPCDataTypes::ErrorResObj Evse::set_dc_charging(const int32_t evse_index, bool charging_allowed, float max_power) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
return m_request_handler_ptr->set_dc_charging(evse_index, charging_allowed, max_power);
}
RPCDataTypes::ErrorResObj Evse::set_dc_charging_power(const int32_t evse_index, float max_power) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
return m_request_handler_ptr->set_dc_charging_power(evse_index, max_power);
}
RPCDataTypes::ErrorResObj Evse::enable_connector(const int32_t evse_index, int connector_index, bool enable,
int priority) {
RPCDataTypes::ErrorResObj res{};
const auto* evse = m_dataobj.get_evse_store(evse_index);
if (!evse) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidEVSEIndex;
return res;
}
// Iterate through the connectors to find the one with the given ID
const auto connectors = evse->evseinfo.get_available_connectors();
auto it = std::find_if(connectors.begin(), connectors.end(),
[connector_index](const auto& connector) { return connector.index == connector_index; });
// If not found, return an error
if (it == connectors.end()) {
res.error = RPCDataTypes::ResponseErrorEnum::ErrorInvalidConnectorIndex;
return res;
}
return m_request_handler_ptr->enable_connector(evse_index, connector_index, enable, priority);
}
} // namespace methods

View File

@@ -0,0 +1,65 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright chargebyte GmbH and Contributors to EVerest
#ifndef METHODS_EVSE_HPP
#define METHODS_EVSE_HPP
#include <optional>
#include "../../data/DataStore.hpp"
#include "../../rpc/RequestHandlerInterface.hpp"
namespace RPCDataTypes = types::json_rpc_api;
namespace methods {
static const std::string METHOD_EVSE_GET_INFO = "EVSE.GetInfo";
static const std::string METHOD_EVSE_GET_STATUS = "EVSE.GetStatus";
static const std::string METHOD_EVSE_GET_HARDWARE_CAPABILITIES = "EVSE.GetHardwareCapabilities";
static const std::string METHOD_EVSE_SET_CHARGING_ALLOWED = "EVSE.SetChargingAllowed";
static const std::string METHOD_EVSE_GET_METER_DATA = "EVSE.GetMeterData";
static const std::string METHOD_EVSE_SET_AC_CHARGING = "EVSE.SetACCharging";
static const std::string METHOD_EVSE_SET_AC_CHARGING_CURRENT = "EVSE.SetACChargingCurrent";
static const std::string METHOD_EVSE_SET_AC_CHARGING_PHASE_COUNT = "EVSE.SetACChargingPhaseCount";
static const std::string METHOD_EVSE_SET_DC_CHARGING = "EVSE.SetDCCharging";
static const std::string METHOD_EVSE_SET_DC_CHARGING_POWER = "EVSE.SetDCChargingPower";
static const std::string METHOD_EVSE_ENABLE_CONNECTOR = "EVSE.EnableConnector";
/// This class includes all methods of the EVSE namespace.
/// It contains the data object and the methods to access it.
class Evse {
public:
// Constructor and Destructor
// Deleting the default constructor to ensure the class is always initialized with a DataStoreCharger object
Evse() = delete;
Evse(data::DataStoreCharger& dataobj, std::unique_ptr<request_interface::RequestHandlerInterface> req_handler) :
m_dataobj(dataobj), m_request_handler_ptr(std::move(req_handler)) {
}
~Evse() = default;
// Methods
RPCDataTypes::EVSEGetInfoResObj get_info(const int32_t evse_index);
RPCDataTypes::EVSEGetStatusResObj get_status(const int32_t evse_index);
RPCDataTypes::EVSEGetHardwareCapabilitiesResObj get_hardware_capabilities(const int32_t evse_index);
RPCDataTypes::ErrorResObj set_charging_allowed(const int32_t evse_index, bool charging_allowed);
RPCDataTypes::EVSEGetMeterDataResObj get_meter_data(const int32_t evse_index);
RPCDataTypes::ErrorResObj set_ac_charging(const int32_t evse_index, bool charging_allowed, float max_current,
std::optional<int> phase_count);
RPCDataTypes::ErrorResObj set_ac_charging_current(const int32_t evse_index, float max_current);
RPCDataTypes::ErrorResObj set_ac_charging_phase_count(const int32_t evse_index, int phase_count);
RPCDataTypes::ErrorResObj set_dc_charging(const int32_t evse_index, bool charging_allowed, float max_power);
RPCDataTypes::ErrorResObj set_dc_charging_power(const int32_t evse_index, float max_power);
RPCDataTypes::ErrorResObj enable_connector(const int32_t evse_index, int connector_id, bool enable, int priority);
private:
// Reference to the DataStoreCharger object that holds and manages EVSE-related data.
// This object is used to retrieve and update information about EVSEs, such as their status,
// hardware capabilities, and meter data, ensuring consistent access to the underlying data store.
data::DataStoreCharger& m_dataobj;
// Reference to the RequestHandlerInterface object for handling requests
std::unique_ptr<request_interface::RequestHandlerInterface> m_request_handler_ptr;
};
} // namespace methods
#endif // METHODS_EVSE_HPP