-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feature/pnc related #44
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ namespace feedback { | |
|
||
enum class Signal { | ||
REQUIRE_AUTH_EIM, | ||
REQUIRE_AUTH_PNC, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we should send also the contract cert chain from the AuthorizationReq message as well. But only once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not have to be part of this PR, but will be added when PnC is fully implemented. |
||
START_CABLE_CHECK, | ||
SETUP_FINISHED, | ||
CHARGE_LOOP_STARTED, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,16 @@ | |
|
||
namespace iso15118::d20::state { | ||
|
||
namespace { | ||
auto required_auth_signal(const message_20::AuthorizationSetupResponse& res) { | ||
using Signal = session::feedback::Signal; | ||
return (std::holds_alternative<message_20::AuthorizationSetupResponse::PnC_ASResAuthorizationMode>( | ||
res.authorization_mode)) | ||
? Signal::REQUIRE_AUTH_PNC | ||
: Signal::REQUIRE_AUTH_EIM; | ||
} | ||
} // namespace | ||
|
||
message_20::AuthorizationSetupResponse | ||
handle_request(const message_20::AuthorizationSetupRequest& req, d20::Session& session, bool cert_install_service, | ||
const std::vector<message_20::Authorization>& authorization_services) { | ||
|
@@ -40,6 +50,7 @@ handle_request(const message_20::AuthorizationSetupRequest& req, d20::Session& s | |
auto& pnc_auth_mode = | ||
res.authorization_mode.emplace<message_20::AuthorizationSetupResponse::PnC_ASResAuthorizationMode>(); | ||
|
||
// FIXME (aw): refactor to utilities | ||
std::random_device rd; | ||
std::mt19937 generator(rd()); | ||
std::uniform_int_distribution<uint8_t> distribution(0x00, 0xff); | ||
|
@@ -77,8 +88,7 @@ FsmSimpleState::HandleEventReturnType AuthorizationSetup::handle_event(Allocator | |
return sa.PASS_ON; | ||
} | ||
|
||
// Todo(sl): PnC is currently not supported | ||
ctx.feedback.signal(session::feedback::Signal::REQUIRE_AUTH_EIM); | ||
ctx.feedback.signal(required_auth_signal(res)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should move this feedback.signal call to the authorization state. Only in the authorization state is it clear whether the car is requesting PnC or EIM. |
||
|
||
return sa.create_simple<Authorization>(ctx); | ||
} else if (const auto req = variant->get_if<message_20::SessionStopRequest>()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,43 +22,18 @@ using Dynamic_BPT_DC_Res = message_20::DC_ChargeLoopResponse::BPT_Dynamic_DC_CLR | |
|
||
template <typename In, typename Out> void convert(Out& out, const In& in); | ||
|
||
template <> void convert(Scheduled_DC_Res& out, const d20::DcTransferLimits& in) { | ||
template <typename Out> void convert(Out& out, const d20::DcTransferLimits& in) { | ||
out.max_charge_power = in.charge_limits.power.max; | ||
out.min_charge_power = in.charge_limits.power.min; | ||
out.max_charge_current = in.charge_limits.current.max; | ||
out.max_voltage = in.voltage.max; | ||
} | ||
|
||
template <> void convert(Scheduled_BPT_DC_Res& out, const d20::DcTransferLimits& in) { | ||
out.max_charge_power = in.charge_limits.power.max; | ||
out.min_charge_power = in.charge_limits.power.min; | ||
out.max_charge_current = in.charge_limits.current.max; | ||
out.max_voltage = in.voltage.max; | ||
out.min_voltage = in.voltage.min; | ||
|
||
if (in.discharge_limits.has_value()) { | ||
auto& discharge_limits = in.discharge_limits.value(); | ||
out.max_discharge_power = discharge_limits.power.max; | ||
out.min_discharge_power = discharge_limits.power.min; | ||
out.max_discharge_current = discharge_limits.current.max; | ||
} | ||
} | ||
|
||
template <> void convert(Dynamic_DC_Res& out, const d20::DcTransferLimits& in) { | ||
out.max_charge_power = in.charge_limits.power.max; | ||
out.min_charge_power = in.charge_limits.power.min; | ||
out.max_charge_current = in.charge_limits.current.max; | ||
out.max_voltage = in.voltage.max; | ||
} | ||
|
||
template <> void convert(Dynamic_BPT_DC_Res& out, const d20::DcTransferLimits& in) { | ||
out.max_charge_power = in.charge_limits.power.max; | ||
out.min_charge_power = in.charge_limits.power.min; | ||
out.max_charge_current = in.charge_limits.current.max; | ||
out.max_voltage = in.voltage.max; | ||
out.min_voltage = in.voltage.min; | ||
if constexpr (std::is_same_v<Out, Scheduled_BPT_DC_Res> || std::is_same_v<Out, Dynamic_BPT_DC_Res>) { | ||
out.min_voltage = in.voltage.min; | ||
|
||
if (in.discharge_limits.has_value()) { | ||
if (not in.discharge_limits) { | ||
return; | ||
} | ||
auto& discharge_limits = in.discharge_limits.value(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
out.max_discharge_power = discharge_limits.power.max; | ||
out.min_discharge_power = discharge_limits.power.min; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should start to use
std::array
instead of a c buffer.I am fine with increasing the buffer size to 4096. I think that's more of an experience value. 4096 should be enough for now.