Skip to content
This repository was archived by the owner on Sep 7, 2020. It is now read-only.

Commit 786bbd6

Browse files
agent: backhaul_manager: add READY_FOR_MASTER_DISCOVERY state
https://jira.prplfoundation.org/browse/PPM-143 Add READY_FOR_MASTER_DISCOVERY state to backhaul_manager state machine. In certification mode the agent state machine should stop before the MASTER_DISCOVERY state and wait for dev_set_config (wired backhaul) or start_wps_registration (wireless backhaul). In non-certification mode this state has no meaning, the state will change to MASTER_DISCOVERY on the next tick of backhaul_manager_thread. Signed-off-by: Vitalii Komisarenko <vitalii.komisarenko@gmail.com>
1 parent 6c9f9d1 commit 786bbd6

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

agent/src/beerocks/slave/agent_ucc_listener.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ std::string agent_ucc_listener::fill_version_reply_string()
6161
*/
6262
void agent_ucc_listener::clear_configuration()
6363
{
64-
m_in_reset = true;
65-
m_reset_completed = false;
64+
m_in_reset = true;
65+
m_reset_completed = false;
66+
m_received_dev_set_config = false;
6667

6768
auto timeout =
6869
std::chrono::steady_clock::now() + std::chrono::seconds(UCC_REPLY_COMPLETE_TIMEOUT_SEC);
@@ -221,6 +222,7 @@ bool agent_ucc_listener::handle_dev_set_config(std::unordered_map<std::string, s
221222

222223
// Signal to backhaul that it can continue onboarding.
223224
m_in_reset = false;
225+
m_received_dev_set_config = true;
224226
return true;
225227
}
226228

agent/src/beerocks/slave/agent_ucc_listener.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class agent_ucc_listener : public beerocks_ucc_listener {
5252
* again. This function allows the backhaul to signal that it has reached that state.
5353
*/
5454
void reset_completed() { m_reset_completed = true; }
55+
56+
bool has_received_dev_set_config() { return m_received_dev_set_config; }
57+
5558
std::string get_selected_backhaul();
5659
void update_vaps_list(std::string ruid, beerocks_message::sVapsList &vaps);
5760

@@ -73,8 +76,9 @@ class agent_ucc_listener : public beerocks_ucc_listener {
7376
const std::string &m_bridge_iface;
7477
std::string m_bridge_mac;
7578

76-
bool m_in_reset = false;
77-
bool m_reset_completed = false;
79+
bool m_in_reset = false;
80+
bool m_reset_completed = false;
81+
bool m_received_dev_set_config = false;
7882
std::string m_selected_backhaul; // "ETH" or "<RUID of the selected radio>"
7983

8084
std::mutex mutex;

agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select)
841841
// Ignore 'selected_backhaul' since this case is not covered by certification flows
842842
if (db->device_conf.local_controller && db->device_conf.local_gw) {
843843
LOG(DEBUG) << "local controller && local gw";
844-
FSM_MOVE_STATE(MASTER_DISCOVERY);
844+
FSM_MOVE_STATE(READY_FOR_MASTER_DISCOVERY);
845845
db->backhaul.connection_type = AgentDB::sBackhaul::eConnectionType::Invalid;
846846
db->backhaul.selected_iface_name.clear();
847847
} else { // link establish
@@ -897,13 +897,36 @@ bool backhaul_manager::backhaul_fsm_main(bool &skip_select)
897897
if (db->backhaul.connection_type == AgentDB::sBackhaul::eConnectionType::Wireless) {
898898
FSM_MOVE_STATE(INIT_HAL);
899899
} else { // EType::Wired
900-
FSM_MOVE_STATE(MASTER_DISCOVERY);
900+
FSM_MOVE_STATE(READY_FOR_MASTER_DISCOVERY);
901901
}
902902

903903
skip_select = true;
904904
}
905905
break;
906906
}
907+
case EState::READY_FOR_MASTER_DISCOVERY: {
908+
auto certification_mode = bpl::cfg_get_certification_mode();
909+
if (certification_mode < 0) {
910+
LOG(ERROR) << "Failed reading certification_mode: " << certification_mode;
911+
return false;
912+
}
913+
// In certification mode we want to wait till dev_set_config is received (wired backhaul)
914+
// or start_wps_registration (wireless backhaul).
915+
// Otherwise switch to MASTER_DISCOVERY
916+
if (!certification_mode) {
917+
FSM_MOVE_STATE(MASTER_DISCOVERY);
918+
}
919+
920+
if (!m_agent_ucc_listener) {
921+
LOG(ERROR) << "m_agent_ucc_listener == nullptr";
922+
return false;
923+
}
924+
925+
if (m_agent_ucc_listener->has_received_dev_set_config()) {
926+
FSM_MOVE_STATE(MASTER_DISCOVERY);
927+
}
928+
break;
929+
}
907930
case EState::MASTER_DISCOVERY: {
908931

909932
auto db = AgentDB ::get();

agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ class backhaul_manager : public btl::transport_socket_thread {
559559
STATE(WIRELESS_WAIT_FOR_RECONNECT) \
560560
STATE(_WIRELESS_END_) \
561561
\
562+
STATE(READY_FOR_MASTER_DISCOVERY) \
562563
STATE(MASTER_DISCOVERY) \
563564
STATE(SEND_AUTOCONFIG_SEARCH_MESSAGE) \
564565
STATE(WAIT_FOR_AUTOCONFIG_RESPONSE_MESSAGE) \

0 commit comments

Comments
 (0)