added a callback that always gets triggered when the phy cell selection completes. This callback checks if cell selection failed, and if so, sets the rsrp of the selected cell to -infinity

This commit is contained in:
Francisco Paisana 2020-09-22 10:24:51 +02:00
parent 0b127fa8c7
commit 7f8af023b8
6 changed files with 37 additions and 17 deletions

View File

@ -52,7 +52,9 @@ public:
struct in_sync_ev {};
struct out_sync_ev {};
explicit phy_controller(phy_interface_rrc_lte* phy_, srslte::task_sched_handle task_sched_);
explicit phy_controller(phy_interface_rrc_lte* phy_,
srslte::task_sched_handle task_sched_,
std::function<void(uint32_t, uint32_t, bool)> on_cell_selection = {});
// PHY procedures interfaces
bool start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer<bool> observer);
@ -114,10 +116,11 @@ public:
};
private:
phy_interface_rrc_lte* phy = nullptr;
srslte::task_sched_handle task_sched;
srslte::event_observer<bool> cell_selection_observer;
srslte::event_dispatcher<cell_srch_res> cell_search_observers;
phy_interface_rrc_lte* phy = nullptr;
srslte::task_sched_handle task_sched;
srslte::event_observer<bool> cell_selection_once_observer;
std::function<void(uint32_t, uint32_t, bool)> cell_selection_always_observer;
srslte::event_dispatcher<cell_srch_res> cell_search_observers;
protected:
state_list<unknown_st, in_sync_st, out_sync_st, searching_cell, selecting_cell> states{this,

View File

@ -189,6 +189,7 @@ public:
cell_t& operator[](size_t idx) { return *neighbour_cells[idx]; }
const cell_t& operator[](size_t idx) const { return *neighbour_cells[idx]; }
cell_t& at(size_t idx) { return *neighbour_cells.at(idx); }
cell_t* find_cell(uint32_t earfcn, uint32_t pci);
// serving cell handling
int set_serving_cell(phy_interface_rrc_lte::phy_cell_t phy_cell, bool discard_serving);

View File

@ -30,10 +30,13 @@ std::string to_string(const phy_interface_rrc_lte::phy_cell_t& cell)
return buffer;
}
phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_, srslte::task_sched_handle task_sched_) :
phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_,
srslte::task_sched_handle task_sched_,
std::function<void(uint32_t, uint32_t, bool)> on_cell_selection) :
base_t(srslte::log_ref{"RRC"}),
phy(phy_),
task_sched(task_sched_)
task_sched(task_sched_),
cell_selection_always_observer(std::move(on_cell_selection))
{}
void phy_controller::in_sync()
@ -56,7 +59,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_observer = std::move(observer);
cell_selection_once_observer = std::move(observer);
return true;
}
@ -96,7 +99,8 @@ void phy_controller::selecting_cell::exit(phy_controller* f)
// Signal result back to FSM that called cell selection
bool result = csel_res.result;
f->task_sched.defer_task([f, result]() { f->cell_selection_observer(result); });
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); });
}
void phy_controller::selecting_cell::wait_in_sync::enter(selecting_cell* f)

View File

@ -116,7 +116,15 @@ void rrc::init(phy_interface_rrc_lte* phy_,
args = args_;
phy_ctrl.reset(new phy_controller{phy, task_sched});
auto on_every_cell_selection = [this](uint32_t earfcn, uint32_t pci, bool csel_result) {
if (not csel_result) {
cell_t* c = meas_cells.find_cell(earfcn, pci);
if (c != nullptr) {
c->set_rsrp(-INFINITY);
}
}
};
phy_ctrl.reset(new phy_controller{phy, task_sched, on_every_cell_selection});
state = RRC_STATE_IDLE;
plmn_is_selected = false;

View File

@ -329,6 +329,14 @@ bool meas_cell_list::has_neighbour_cell(uint32_t earfcn, uint32_t pci) const
return get_neighbour_cell_handle(earfcn, pci) != nullptr;
}
cell_t* meas_cell_list::find_cell(uint32_t earfcn, uint32_t pci)
{
if (serving_cell().phy_cell.pci == pci and serving_cell().phy_cell.earfcn == earfcn) {
return &serving_cell();
}
return get_neighbour_cell_handle(earfcn, pci);
}
int meas_cell_list::set_serving_cell(phy_interface_rrc_lte::phy_cell_t phy_cell, bool discard_serving)
{
// don't update neighbor cell list unless serving cell changes

View File

@ -1358,13 +1358,9 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc
: rrc_ptr->meas_cells.serving_cell().get_earfcn();
// Target cell shall be either serving cell (intra-cell HO) or neighbour cell
if (rrc_ptr->has_neighbour_cell(target_earfcn, mob_ctrl_info->target_pci)) {
// target cell is neighbour cell
target_cell =
rrc_ptr->meas_cells.get_neighbour_cell_handle(target_earfcn, recfg_r8.mob_ctrl_info.target_pci)->phy_cell;
} else if (recfg_r8.mob_ctrl_info.target_pci == rrc_ptr->meas_cells.serving_cell().get_pci()) {
// intra-cell HO, target cell is current serving cell
target_cell = rrc_ptr->get_serving_cell()->phy_cell;
cell_t* cell_to_ho = rrc_ptr->meas_cells.find_cell(target_earfcn, mob_ctrl_info->target_pci);
if (cell_to_ho != nullptr) {
target_cell = cell_to_ho->phy_cell;
} else {
rrc_ptr->rrc_log->console("Received HO command to unknown PCI=%d\n", mob_ctrl_info->target_pci);
Error("Could not find target cell earfcn=%d, pci=%d\n",