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

Fix potential crashes and fix TxProfile during transaction #299

Merged
merged 3 commits into from
Dec 11, 2023

Conversation

hikinggrass
Copy link
Contributor

No description provided.

This was a bit too strict since it does reject some valid charging profiles (like TxProfiles that omit the transaction id)

Signed-off-by: Kai-Uwe Hermann <[email protected]>
@hikinggrass hikinggrass changed the title WIP: fix potential crashes Fix potential crashes and fix TxProfile during transaction Dec 11, 2023
@hikinggrass hikinggrass marked this pull request as ready for review December 11, 2023 16:40
Copy link
Contributor

@corneliusclaussen corneliusclaussen left a comment

Choose a reason for hiding this comment

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

Looks good!

@corneliusclaussen corneliusclaussen merged commit aba6f3b into main Dec 11, 2023
@corneliusclaussen corneliusclaussen deleted the kh-fix-potential-crashes branch December 11, 2023 16:49
couryrr-afs pushed a commit to US-JOET/libocpp that referenced this pull request Dec 18, 2023
* Smart charging: set ignore_no_transaction in validate_profile call
This was a bit too strict since it does reject some valid charging profiles (like TxProfiles that omit the transaction id)
* Log an error if attempting to stop a transaction that is unknown to libocpp
* Check if websocket is nullptr in authorize_id_token

Signed-off-by: Kai-Uwe Hermann <[email protected]>
@@ -1865,7 +1865,7 @@ void ChargePointImpl::handleSetChargingProfileRequest(ocpp::Call<SetChargingProf
<< call.msg.csChargingProfiles.chargingProfilePurpose;
response.status = ChargingProfileStatus::Rejected;
} else if (this->smart_charging_handler->validate_profile(
profile, connector_id, false, this->configuration->getChargeProfileMaxStackLevel(),
profile, connector_id, true, this->configuration->getChargeProfileMaxStackLevel(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This allows TxProfile(s) without a transaction_id, which I consider invalid for a SetChargingProfile.req .
The purpose of the ignore_no_transaction flag was to allow ChargingProfiles as part of RemoteStartTransaction.req messages, because in that case no transaction is active yet: https://github.com/EVerest/libocpp/blob/main/lib/ocpp/v16/charge_point_impl.cpp#L1606

Can you ellaborate why this had to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a part of the OCPP 1.6 spec that unfortunately leaves room for interpretation. Maybe we should keep this behavior behind an additional configuration key though.

The relevant section in the 1.6 spec (page 54 in edition 2 FINAL, 2017-09-28):

To prevent mismatch between transactions and a TxProfile, The Central System SHALL include the transactionId in a SetChargingProfile.req if the profile applies to a specific transaction.

If the CSMS just wants to limit a connector during a transaction (just for this transaction) but doesn't care about the specific transaction, at least in my interpretation, it is valid to not include the transaction id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants