Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate OCPP 2.1 public draft messages #845

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1abd2bb
Fix code generator to include manual fixes for 2.0.1 VariableAttribute
hikinggrass Oct 7, 2024
780572c
Fix code generator to remove superfluous ; after DateTime conversions
hikinggrass Oct 7, 2024
70e7dd7
Remove SecurityEvent enum from code generator since it is no enum any…
hikinggrass Oct 7, 2024
dd95a43
1.6: retrieveDateTime in SignedUpdateFirmware.firmware is not optional
hikinggrass Oct 7, 2024
a882867
WIP: generate 2.0.1 messages from 2.1 draft schemas
hikinggrass Oct 23, 2024
17b736e
Generate OCPP 2.1 messages from draft schemas with modified code gene…
hikinggrass Oct 23, 2024
0492085
Merge remote-tracking branch 'origin/main' into feature/ocpp2.1-publi…
hikinggrass Oct 23, 2024
59d1361
Fix compilation of smart charging tests
hikinggrass Oct 24, 2024
a3e730f
Attempt to fix unchecked optional access in calculate_composite_schedule
hikinggrass Oct 24, 2024
ab4f806
More fixes for smart charging tests
hikinggrass Oct 28, 2024
ce30fc5
Merge remote-tracking branch 'origin/main' into feature/ocpp2.1-publi…
hikinggrass Oct 28, 2024
cb9e57e
Additional fixes
hikinggrass Oct 28, 2024
ada40cb
ctest: output on failure
hikinggrass Oct 28, 2024
03e55cd
Fix composite schedule calculation
hikinggrass Oct 28, 2024
2f0d9f3
clang-format
hikinggrass Oct 28, 2024
a1cc575
Merge remote-tracking branch 'origin/main' into feature/ocpp2.1-publi…
hikinggrass Oct 30, 2024
5800478
Fix enum usage in tests for enums that turned into strings
hikinggrass Oct 30, 2024
4dfd843
FIXME: re-introduce default limit temporarily
hikinggrass Oct 30, 2024
b14ec4b
Merge remote-tracking branch 'origin/main' into feature/ocpp2.1-publi…
hikinggrass Oct 30, 2024
06b4919
Update tests/lib/ocpp/v201/test_profile.cpp
Pietfried Nov 14, 2024
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
2 changes: 1 addition & 1 deletion .ci/build-kit/install_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ ninja -j$(nproc) -C build install

trap "cp build/Testing/Temporary/LastTest.log /ext/ctest-report" EXIT

ninja -j$(nproc) -C build test
CTEST_OUTPUT_ON_FAILURE=1 ninja -j$(nproc) -C build test

# cmake -B build -G Ninja -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="./dist" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
2 changes: 1 addition & 1 deletion include/ocpp/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constexpr float DEFAULT_LIMIT_WATTS = 33120.0;
constexpr std::int32_t DEFAULT_AND_MAX_NUMBER_PHASES = 3;
constexpr float LOW_VOLTAGE = 230;

constexpr float NO_LIMIT_SPECIFIED = -1.0;
// constexpr float NO_LIMIT_SPECIFIED = -1.0;
constexpr std::int32_t NO_START_PERIOD = -1;
constexpr std::int32_t EVSEID_NOT_SET = -1;

Expand Down
11 changes: 5 additions & 6 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class ChargePointInterface {
/// \param certificate
/// \param ocsp_request_data
/// \return AuthorizeResponse containing the result of the validation
virtual AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
virtual AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<10000>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) = 0;

/// \brief Event handler that can be called to trigger a NotifyEvent.req with the given \p events
Expand Down Expand Up @@ -640,7 +640,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
void notify_report_req(const int request_id, const std::vector<ReportData>& report_data);

// Functional Block C: Authorization
AuthorizeResponse authorize_req(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
AuthorizeResponse authorize_req(const IdToken id_token, const std::optional<CiString<10000>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data);

// Functional Block G: Availability
Expand All @@ -665,9 +665,8 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
const bool initiated_by_trigger_message = false);

// Functional Block K: Smart Charging
void report_charging_profile_req(const int32_t request_id, const int32_t evse_id,
const ChargingLimitSourceEnum source, const std::vector<ChargingProfile>& profiles,
const bool tbc);
void report_charging_profile_req(const int32_t request_id, const int32_t evse_id, const CiString<20> source,
const std::vector<ChargingProfile>& profiles, const bool tbc);
void report_charging_profile_req(const ReportChargingProfilesRequest& req);

// Functional Block N: Diagnostics
Expand Down Expand Up @@ -898,7 +897,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa

std::optional<std::string> get_evse_transaction_id(int32_t evse_id) override;

AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<10000>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) override;

void on_event(const std::vector<EventData>& events) override;
Expand Down
4 changes: 2 additions & 2 deletions include/ocpp/v201/charge_point_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ struct Callbacks {
/// \return True if evse is reserved for the given id token / group id token, false if it is reserved for another
/// one.
///
std::function<bool(const int32_t evse_id, const CiString<36> idToken,
const std::optional<CiString<36>> groupIdToken)>
std::function<bool(const int32_t evse_id, const CiString<255> idToken,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't really a backwards-compatible change in the 2.1 schemas. Changes like this happened in a few different messages/types and need case-by-case handling. Either by adding additional conversion functions or different message generation for 2.0.1 and 2.1

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be ok to accept larger tokens here. This is only an issue if e.g. OCTT tests for OCPP2.0.1 if we accept larger tokens.

const std::optional<CiString<255>> groupIdToken)>
is_reservation_for_token_callback;
std::function<UpdateFirmwareResponse(const UpdateFirmwareRequest& request)> update_firmware_request_callback;
// callback to be called when a variable has been changed by the CSMS
Expand Down
3 changes: 2 additions & 1 deletion include/ocpp/v201/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace v201 {

/// \brief OCPP 2.0.1 defines this as 5600 but it can be set to a higher value, which we do here, if it's reported via
/// the device model, which we do as well
constexpr std::size_t ISO15118_GET_EV_CERTIFICATE_EXI_RESPONSE_SIZE = 7500;
/// 17000 is the vminimum alue from OCPP 2.1
constexpr std::size_t ISO15118_GET_EV_CERTIFICATE_EXI_RESPONSE_SIZE = 17000;

} // namespace v201
} // namespace ocpp
4 changes: 2 additions & 2 deletions include/ocpp/v201/database_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DatabaseHandler : public common::DatabaseHandlerCommon {
/// \brief Inserts or updates the given \p profile to CHARGING_PROFILES table
void insert_or_update_charging_profile(
const int evse_id, const v201::ChargingProfile& profile,
const ChargingLimitSourceEnum charging_limit_source = ChargingLimitSourceEnum::CSO);
const CiString<20> charging_limit_source = ChargingLimitSourceEnumStringType::CSO);

/// \brief Deletes the profile with the given \p profile_id
bool delete_charging_profile(const int profile_id);
Expand Down Expand Up @@ -210,7 +210,7 @@ class DatabaseHandler : public common::DatabaseHandlerCommon {
/// \brief Retrieves all ChargingProfiles grouped by EVSE ID
virtual std::map<int32_t, std::vector<v201::ChargingProfile>> get_all_charging_profiles_group_by_evse();

ChargingLimitSourceEnum get_charging_limit_source_for_profile(const int profile_id);
CiString<20> get_charging_limit_source_for_profile(const int profile_id);

std::unique_ptr<common::SQLiteStatementInterface> new_statement(const std::string& sql);
};
Expand Down
5 changes: 4 additions & 1 deletion include/ocpp/v201/messages/Authorize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace v201 {
struct AuthorizeRequest : public ocpp::Message {
IdToken idToken;
std::optional<CustomData> customData;
std::optional<CiString<5500>> certificate;
std::optional<CiString<10000>> certificate;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could probably be reported via FieldLength variable for the AuthorizeRequest.certificate instance which should make this change backwards-compatible with 2.0.1

std::optional<std::vector<OCSPRequestData>> iso15118CertificateHashData;

/// \brief Provides the type of this Authorize message as a human readable string
Expand All @@ -42,6 +42,9 @@ struct AuthorizeResponse : public ocpp::Message {
IdTokenInfo idTokenInfo;
std::optional<CustomData> customData;
std::optional<AuthorizeCertificateStatusEnum> certificateStatus;
std::optional<std::vector<EnergyTransferModeEnum>> allowedEnergyTransfer;
std::optional<Tariff> tariff;
std::optional<TransactionLimit> transactionLimit;

/// \brief Provides the type of this AuthorizeResponse message as a human readable string
/// \returns the message type as a human readable string
Expand Down
3 changes: 1 addition & 2 deletions include/ocpp/v201/messages/ClearedChargingLimit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
#include <optional>

#include <ocpp/common/types.hpp>
#include <ocpp/v201/ocpp_enums.hpp>
#include <ocpp/v201/ocpp_types.hpp>

namespace ocpp {
namespace v201 {

/// \brief Contains a OCPP ClearedChargingLimit message
struct ClearedChargingLimitRequest : public ocpp::Message {
ChargingLimitSourceEnum chargingLimitSource;
CiString<20> chargingLimitSource;
std::optional<CustomData> customData;
std::optional<int32_t> evseId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct FirmwareStatusNotificationRequest : public ocpp::Message {
FirmwareStatusEnum status;
std::optional<CustomData> customData;
std::optional<int32_t> requestId;
std::optional<StatusInfo> statusInfo;

/// \brief Provides the type of this FirmwareStatusNotification message as a human readable string
/// \returns the message type as a human readable string
Expand Down
5 changes: 4 additions & 1 deletion include/ocpp/v201/messages/Get15118EVCertificate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace v201 {
struct Get15118EVCertificateRequest : public ocpp::Message {
CiString<50> iso15118SchemaVersion;
CertificateActionEnum action;
CiString<5600> exiRequest;
CiString<11000> exiRequest;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a FieldLength variable for Get15118EVCertificateRequest.exiRequest should make this backwards-compatible with 2.0.1

std::optional<CustomData> customData;
std::optional<int32_t> maximumContractCertificateChains;
std::optional<std::vector<CiString<255>>> prioritizedEMAIDs;

/// \brief Provides the type of this Get15118EVCertificate message as a human readable string
/// \returns the message type as a human readable string
Expand All @@ -44,6 +46,7 @@ struct Get15118EVCertificateResponse : public ocpp::Message {
CiString<ISO15118_GET_EV_CERTIFICATE_EXI_RESPONSE_SIZE> exiResponse;
std::optional<CustomData> customData;
std::optional<StatusInfo> statusInfo;
std::optional<int32_t> remainingContracts;

/// \brief Provides the type of this Get15118EVCertificateResponse message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/messages/GetCertificateStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct GetCertificateStatusResponse : public ocpp::Message {
GetCertificateStatusEnum status;
std::optional<CustomData> customData;
std::optional<StatusInfo> statusInfo;
std::optional<CiString<5500>> ocspResult;
std::optional<CiString<18000>> ocspResult;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a FieldLength variable for GetCertificateStatusResponse.ocspResult should make this backwards-compatible with 2.0.1


/// \brief Provides the type of this GetCertificateStatusResponse message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/messages/InstallCertificate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace v201 {
/// \brief Contains a OCPP InstallCertificate message
struct InstallCertificateRequest : public ocpp::Message {
InstallCertificateUseEnum certificateType;
CiString<5500> certificate;
CiString<10000> certificate;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a FieldLength variable for InstallCertificateRequest.certificate should make this backwards-compatible with 2.0.1

std::optional<CustomData> customData;

/// \brief Provides the type of this InstallCertificate message as a human readable string
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v201/messages/LogStatusNotification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct LogStatusNotificationRequest : public ocpp::Message {
UploadLogStatusEnum status;
std::optional<CustomData> customData;
std::optional<int32_t> requestId;
std::optional<StatusInfo> statusInfo;

/// \brief Provides the type of this LogStatusNotification message as a human readable string
/// \returns the message type as a human readable string
Expand Down
3 changes: 2 additions & 1 deletion include/ocpp/v201/messages/NotifyEVChargingNeeds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ namespace v201 {

/// \brief Contains a OCPP NotifyEVChargingNeeds message
struct NotifyEVChargingNeedsRequest : public ocpp::Message {
ChargingNeeds chargingNeeds;
int32_t evseId;
ChargingNeeds chargingNeeds;
std::optional<CustomData> customData;
std::optional<int32_t> maxScheduleTuples;
std::optional<ocpp::DateTime> timestamp;

/// \brief Provides the type of this NotifyEVChargingNeeds message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 2 additions & 0 deletions include/ocpp/v201/messages/NotifyEVChargingSchedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct NotifyEVChargingScheduleRequest : public ocpp::Message {
ChargingSchedule chargingSchedule;
int32_t evseId;
std::optional<CustomData> customData;
std::optional<int32_t> selectedScheduleTupleId;
std::optional<bool> powerToleranceAcceptance;

/// \brief Provides the type of this NotifyEVChargingSchedule message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/messages/PublishFirmware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace v201 {

/// \brief Contains a OCPP PublishFirmware message
struct PublishFirmwareRequest : public ocpp::Message {
CiString<512> location;
CiString<2000> location;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a FieldLength variable for PublishFirmwareRequest.location should make this backwards-compatible with 2.0.1

CiString<32> checksum;
int32_t requestId;
std::optional<CustomData> customData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ namespace v201 {
struct PublishFirmwareStatusNotificationRequest : public ocpp::Message {
PublishFirmwareStatusEnum status;
std::optional<CustomData> customData;
std::optional<std::vector<CiString<512>>> location;
std::optional<std::vector<CiString<2000>>> location;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a FieldLength variable for PublishFirmwareStatusNotificationRequest.location should make this backwards-compatible with 2.0.1

std::optional<int32_t> requestId;
std::optional<StatusInfo> statusInfo;

/// \brief Provides the type of this PublishFirmwareStatusNotification message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/messages/ReportChargingProfiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace v201 {
/// \brief Contains a OCPP ReportChargingProfiles message
struct ReportChargingProfilesRequest : public ocpp::Message {
int32_t requestId;
ChargingLimitSourceEnum chargingLimitSource;
CiString<20> chargingLimitSource;
std::vector<ChargingProfile> chargingProfile;
int32_t evseId;
std::optional<CustomData> customData;
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v201/messages/RequestStartTransaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct RequestStartTransactionRequest : public ocpp::Message {
std::optional<int32_t> evseId;
std::optional<IdToken> groupIdToken;
std::optional<ChargingProfile> chargingProfile;
std::optional<TransactionLimit> transactionLimit;

/// \brief Provides the type of this StartTransaction message as a human readable string
/// \returns the message type as a human readable string
Expand Down
2 changes: 1 addition & 1 deletion include/ocpp/v201/messages/ReserveNow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ReserveNowRequest : public ocpp::Message {
ocpp::DateTime expiryDateTime;
IdToken idToken;
std::optional<CustomData> customData;
std::optional<ConnectorEnum> connectorType;
std::optional<CiString<20>> connectorType;
std::optional<int32_t> evseId;
std::optional<IdToken> groupIdToken;

Expand Down
7 changes: 6 additions & 1 deletion include/ocpp/v201/messages/TransactionEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ struct TransactionEventRequest : public ocpp::Message {
int32_t seqNo;
Transaction transactionInfo;
std::optional<CustomData> customData;
std::optional<CostDetails> costDetails;
std::optional<std::vector<MeterValue>> meterValue;
std::optional<bool> offline;
std::optional<int32_t> numberOfPhasesUsed;
std::optional<int32_t> cableMaxCurrent;
std::optional<float> cableMaxCurrent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't strictly backwards compatible with 2.0.1 and probably needs additional handling

Copy link
Contributor

Choose a reason for hiding this comment

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

This change doesnt seem to make a lot of sense. In transaction_event_req we could continue to use an int and make an implicit cast to float

We should make sure that the float is serialized to an int in 2.0.1 when transmitting to the CSMS.

std::optional<int32_t> reservationId;
std::optional<PreconditioningStatusEnum> preconditioningStatus;
std::optional<bool> evseSleep;
std::optional<EVSE> evse;
std::optional<IdToken> idToken;

Expand All @@ -52,7 +55,9 @@ struct TransactionEventResponse : public ocpp::Message {
std::optional<float> totalCost;
std::optional<int32_t> chargingPriority;
std::optional<IdTokenInfo> idTokenInfo;
std::optional<TransactionLimit> transactionLimit;
std::optional<MessageContent> updatedPersonalMessage;
std::optional<std::vector<MessageContent>> updatedPersonalMessageExtra;

/// \brief Provides the type of this TransactionEventResponse message as a human readable string
/// \returns the message type as a human readable string
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v201/messages/TriggerMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct TriggerMessageRequest : public ocpp::Message {
MessageTriggerEnum requestedMessage;
std::optional<CustomData> customData;
std::optional<EVSE> evse;
std::optional<CiString<50>> customTrigger;

/// \brief Provides the type of this TriggerMessage message as a human readable string
/// \returns the message type as a human readable string
Expand Down
Loading
Loading