now the phy controller handles the scenario where the phy cell selection failed to be initialized

This commit is contained in:
Francisco Paisana 2020-10-16 11:11:35 +01:00
parent 7e60d8aae5
commit 665b3996bb
4 changed files with 40 additions and 8 deletions

View File

@ -67,7 +67,7 @@ public:
class phy_dummy_interface : public phy_interface_rrc_lte
{
bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx = 0) override { return true; }
bool set_config(srslte::phy_cfg_t config, uint32_t cc_idx) override { return true; }
bool set_scell(srslte_cell_t cell_info, uint32_t cc_idx, uint32_t earfcn) override { return true; }
void set_config_tdd(srslte_tdd_config_t& tdd_config) override {}
void set_config_mbsfn_sib2(srslte::mbsfn_sf_cfg_t* cfg_list, uint32_t nof_cfgs) override {}

View File

@ -117,7 +117,8 @@ public:
row< wait_csel_res, unknown_st, cell_sel_res >,
// +----------------+---------------+--------------+------------------+----------------------+
row< wait_in_sync, in_sync_st, in_sync_ev, &c::set_success >,
row< wait_in_sync, unknown_st, timeout_ev >
row< wait_in_sync, unknown_st, timeout_ev >,
to_state< unknown_st, srslte::failure_ev >
// +----------------+---------------+--------------+------------------+----------------------+
>;
// clang-format on
@ -129,7 +130,7 @@ public:
private:
phy_interface_rrc_lte* phy = nullptr;
srslte::task_sched_handle task_sched;
srslte::event_observer<bool> cell_selection_once_observer;
srslte::event_observer<bool> cell_selection_notifier;
std::function<void(uint32_t, uint32_t, bool)> cell_selection_always_observer;
srslte::event_dispatcher<cell_srch_res> cell_search_observers;
uint32_t nof_pending_configs = 0;

View File

@ -109,7 +109,7 @@ bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event
log_h->warning("Failed to launch cell selection. Current state: %s\n", current_state_name().c_str());
return false;
}
cell_selection_once_observer = std::move(observer);
cell_selection_notifier = std::move(observer);
return true;
}
@ -129,7 +129,9 @@ void phy_controller::selecting_cell::enter(phy_controller* f, const cell_sel_cmd
csel_res.result = false;
fsmInfo("Starting for pci=%d, earfcn=%d\n", target_cell.pci, target_cell.earfcn);
f->phy->cell_select(target_cell);
if (not f->phy->cell_select(target_cell)) {
trigger(srslte::failure_ev{});
}
}
void phy_controller::selecting_cell::exit(phy_controller* f)
@ -147,7 +149,7 @@ void phy_controller::selecting_cell::exit(phy_controller* f)
if (f->cell_selection_always_observer) {
f->cell_selection_always_observer(target_cell.earfcn, target_cell.pci, result);
}
f->task_sched.defer_task([f, result]() { f->cell_selection_once_observer(result); });
f->task_sched.defer_task([f, result]() { f->cell_selection_notifier(result); });
}
void phy_controller::selecting_cell::wait_in_sync::enter(selecting_cell* f)

View File

@ -25,6 +25,8 @@
namespace srsue {
srslte::log_ref test_log{"TEST"};
struct cell_search_result_test {
cell_search_result_test(phy_controller* phy_ctrl_) : phy_ctrl(phy_ctrl_) {}
@ -72,7 +74,6 @@ struct cell_select_result_test {
int test_phy_ctrl_fsm()
{
srslte::log_ref test_log{"TEST"};
srslte::task_scheduler task_sched;
phy_dummy_interface phy;
phy_controller phy_ctrl{&phy, &task_sched};
@ -167,10 +168,36 @@ int test_phy_ctrl_fsm()
task_sched.run_pending_tasks();
TESTASSERT(csel_tester.result == 0);
test_log->info("Finished RRC PHY controller test successfully\n");
phy_ctrl.start_cell_select(found_cell, csel_tester);
return SRSLTE_SUCCESS;
}
class phy_test_dummy : public phy_dummy_interface
{
public:
bool success_on_cell_select_init = true;
bool cell_select(phy_cell_t cell) override { return success_on_cell_select_init; }
};
/// TEST: Check if controller handles the case when PHY fails to init cell selection
int test_phy_cell_select_init_error_handling()
{
srslte::task_scheduler task_sched;
phy_test_dummy phy;
phy_controller phy_ctrl{&phy, &task_sched};
phy_cell_t found_cell{};
found_cell.pci = 1;
found_cell.earfcn = 2;
int test_result = -1;
phy.success_on_cell_select_init = false;
phy_ctrl.start_cell_select(found_cell, [&test_result](bool csel_result) { test_result = csel_result ? 1 : 0; });
return test_result == 0;
}
} // namespace srsue
int main()
@ -178,4 +205,6 @@ int main()
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSLTE_SUCCESS);
TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSLTE_SUCCESS);
srsue::test_log->info("Finished RRC PHY controller test successfully\n");
}