-
Notifications
You must be signed in to change notification settings - Fork 74
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 TC_SECC_CMN_VTB_CmSlacParm_004/5/6 #928
base: main
Are you sure you want to change the base?
Changes from 1 commit
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 |
---|---|---|
|
@@ -72,7 +72,8 @@ FSMSimpleState::CallbackReturnType MatchingState::callback() { | |
|
||
if (!seen_slac_parm_req) { | ||
if (now_tp >= timeout_slac_parm_req) { | ||
return Event::RETRY_MATCHING; | ||
ctx.log_info("CM_SLAC_PARM_REQ timed out -> FAILED"); | ||
return Event::FAILED; | ||
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 change should not be necessary for the tests 4/5/6 to succeed, because it still won't sent any confirm message. |
||
} | ||
|
||
call_back_ms = remaining_milliseconds(timeout_slac_parm_req, now_tp); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#include <slac/fsm/evse/states/others.hpp> | ||
|
||
#include <cstring> | ||
#include <optional> | ||
#include <string_view> | ||
|
||
#include <slac/fsm/evse/states/matching.hpp> | ||
|
@@ -76,7 +77,7 @@ bool ResetState::handle_slac_message(slac::messages::HomeplugMessage& message) { | |
const auto mmtype = message.get_mmtype(); | ||
if (mmtype != (slac::defs::MMTYPE_CM_SET_KEY | slac::defs::MMTYPE_MODE_CNF)) { | ||
// unexpected message | ||
// FIXME (aw): need to also deal with CM_VALIDATE.REQ | ||
// FIXME (aw): need to also deal with CM_VALIDATE.REQ. It is optional in the standard. | ||
ctx.log_info("Received non-expected SLAC message of type " + format_mmtype(mmtype)); | ||
return false; | ||
} else { | ||
|
@@ -163,17 +164,75 @@ FSMSimpleState::HandleEventReturnType IdleState::handle_event(AllocatorType& sa, | |
} | ||
} | ||
|
||
static std::optional<bool> check_link_status_cnf(const slac::fsm::evse::ModemVendor modem_vendor, | ||
slac::messages::HomeplugMessage& message) { | ||
const auto mmtype = message.get_mmtype(); | ||
if (modem_vendor == ModemVendor::Qualcomm && | ||
mmtype == (slac::defs::qualcomm::MMTYPE_LINK_STATUS | slac::defs::MMTYPE_MODE_CNF)) { | ||
const auto success = message.get_payload<slac::messages::qualcomm::link_status_cnf>().link_status == 0x01; | ||
return {success}; | ||
|
||
} else if (modem_vendor == ModemVendor::Lumissil && | ||
mmtype == (slac::defs::lumissil::MMTYPE_NSCM_GET_D_LINK_STATUS | slac::defs::MMTYPE_MODE_CNF)) { | ||
const auto success = | ||
message.get_payload<slac::messages::lumissil::nscm_get_d_link_status_cnf>().link_status == 0x01; | ||
return {success}; | ||
} | ||
return {}; | ||
} | ||
|
||
static bool send_link_status_req(slac::fsm::evse::Context& ctx) { | ||
if (ctx.modem_vendor == ModemVendor::Qualcomm) { | ||
slac::messages::qualcomm::link_status_req link_status_req; | ||
ctx.send_slac_message(ctx.slac_config.plc_peer_mac, link_status_req); | ||
return true; | ||
} else if (ctx.modem_vendor == ModemVendor::Lumissil) { | ||
slac::messages::lumissil::nscm_get_d_link_status_req link_status_req; | ||
ctx.send_slac_message(ctx.slac_config.plc_peer_mac, link_status_req); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
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. would drop the |
||
} | ||
|
||
void MatchedState::enter() { | ||
ctx.signal_state("MATCHED"); | ||
ctx.signal_dlink_ready(true); | ||
ctx.log_info("Entered Matched state"); | ||
} | ||
|
||
FSMSimpleState::HandleEventReturnType MatchedState::handle_event(AllocatorType& sa, Event ev) { | ||
if (ev == Event::RESET) { | ||
if (ev == Event::SLAC_MESSAGE) { | ||
auto link_ok = check_link_status_cnf(ctx.modem_vendor, ctx.slac_message_payload); | ||
if (link_ok.has_value()) { | ||
if (link_ok.value()) { | ||
return sa.PASS_ON; | ||
} else { | ||
ctx.log_info("Connection lost in matched state"); | ||
ctx.signal_error_routine_request(); | ||
return sa.PASS_ON; | ||
} | ||
} | ||
} else if (ev == Event::RESET) { | ||
return sa.create_simple<ResetState>(ctx); | ||
} | ||
return sa.PASS_ON; | ||
} | ||
|
||
FSMSimpleState::CallbackReturnType MatchedState::callback() { | ||
const auto& cfg = ctx.slac_config; | ||
|
||
if (not ctx.slac_config.link_status.do_detect) { | ||
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. Why not using |
||
return {}; | ||
} | ||
|
||
if (not link_status_req_sent) { | ||
link_status_req_sent = send_link_status_req(ctx); | ||
return cfg.link_status.poll_in_matched_state_ms; | ||
} else { | ||
return sa.PASS_ON; | ||
// Link is confirmed not up yet, query again | ||
link_status_req_sent = false; | ||
return cfg.link_status.poll_in_matched_state_ms; | ||
} | ||
} | ||
|
||
|
@@ -182,7 +241,9 @@ void MatchedState::leave() { | |
} | ||
|
||
void FailedState::enter() { | ||
ctx.signal_error_routine_request(); | ||
if (ctx.slac_config.ac_mode_five_percent) { | ||
ctx.signal_error_routine_request(); | ||
} | ||
ctx.log_info("Entered Failed state"); | ||
} | ||
|
||
|
@@ -210,6 +271,8 @@ FSMSimpleState::HandleEventReturnType WaitForLinkState::handle_event(AllocatorTy | |
ctx.log_info("Link could not be established, resetting..."); | ||
// Notify higher layers to on CP signal | ||
return sa.create_simple<FailedState>(ctx); | ||
} else if (ev == Event::RESET) { | ||
return sa.create_simple<ResetState>(ctx); | ||
} else { | ||
return sa.PASS_ON; | ||
} | ||
|
@@ -218,19 +281,7 @@ FSMSimpleState::HandleEventReturnType WaitForLinkState::handle_event(AllocatorTy | |
FSMSimpleState::CallbackReturnType WaitForLinkState::callback() { | ||
const auto& cfg = ctx.slac_config; | ||
if (not link_status_req_sent) { | ||
|
||
if (ctx.modem_vendor == ModemVendor::Qualcomm) { | ||
slac::messages::qualcomm::link_status_req link_status_req; | ||
ctx.send_slac_message(cfg.plc_peer_mac, link_status_req); | ||
link_status_req_sent = true; | ||
} else if (ctx.modem_vendor == ModemVendor::Lumissil) { | ||
slac::messages::lumissil::nscm_get_d_link_status_req link_status_req; | ||
ctx.send_slac_message(cfg.plc_peer_mac, link_status_req); | ||
link_status_req_sent = true; | ||
} else { | ||
ctx.log_info("Link detection not supported on this chip"); | ||
} | ||
|
||
link_status_req_sent = send_link_status_req(ctx); | ||
return cfg.link_status.retry_ms; | ||
} else { | ||
// Did we timeout? | ||
|
@@ -246,22 +297,19 @@ FSMSimpleState::CallbackReturnType WaitForLinkState::callback() { | |
bool WaitForLinkState::handle_slac_message(slac::messages::HomeplugMessage& message) { | ||
const auto mmtype = message.get_mmtype(); | ||
|
||
if (ctx.modem_vendor == ModemVendor::Qualcomm && | ||
mmtype == (slac::defs::qualcomm::MMTYPE_LINK_STATUS | slac::defs::MMTYPE_MODE_CNF)) { | ||
const auto success = message.get_payload<slac::messages::qualcomm::link_status_cnf>().link_status == 0x01; | ||
return success; | ||
auto link_ok = check_link_status_cnf(ctx.modem_vendor, message); | ||
|
||
} else if (ctx.modem_vendor == ModemVendor::Lumissil && | ||
mmtype == (slac::defs::lumissil::MMTYPE_NSCM_GET_D_LINK_STATUS | slac::defs::MMTYPE_MODE_CNF)) { | ||
const auto success = | ||
message.get_payload<slac::messages::lumissil::nscm_get_d_link_status_cnf>().link_status == 0x01; | ||
return success; | ||
if (link_ok.has_value() and link_ok.value()) { | ||
return true; | ||
} | ||
|
||
} else { | ||
// unexpected message | ||
ctx.log_info("Received non-expected SLAC message of type " + format_mmtype(mmtype)); | ||
if (mmtype == (slac::defs::MMTYPE_CM_SLAC_MATCH | slac::defs::MMTYPE_MODE_REQ)) { | ||
// EV retries MATCH_REQ, so we send the CNF again | ||
ctx.log_info("Received CM_SLAC_MATCH.REQ retry from EV, sending out CM_SLAC_MATCH.CNF again."); | ||
ctx.send_slac_message(message.get_src_mac(), ctx.match_cnf_message); | ||
return false; | ||
} | ||
return false; | ||
} | ||
|
||
FSMSimpleState::HandleEventReturnType InitState::handle_event(AllocatorType& sa, Event ev) { | ||
|
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.
This doesn't really belong here, as it is shared information only between Matching and WaitForLink state. Matching state should keep it for itself and pass it to WaitForLink state with
create_simple<WaitForLink>(ctx, std::move(match_cnf_message))
. You would need to modify the constructor of WaitForLink state.