From 2a464131213ac8eb5f98fbbc6ea4445b1afc127e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 30 Jan 2020 21:01:14 +0100 Subject: [PATCH] during cell search don't configure found cell as serving cell this fixes an issue in which, during cell search, the sync code itself would set the serving cell whenever it found a new cell. instead, only report the found cell to RRC and keep the sample rate at 1.92 MHz. RRC may select a new serving cell and then tell PHY to camp on it. --- lib/src/phy/ue/ue_sync.c | 1 - srsue/src/phy/sync.cc | 34 +++++---------------------- srsue/src/stack/rrc/rrc_procedures.cc | 9 +++++-- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/lib/src/phy/ue/ue_sync.c b/lib/src/phy/ue/ue_sync.c index d21dc00b0..4b1347ae4 100644 --- a/lib/src/phy/ue/ue_sync.c +++ b/lib/src/phy/ue/ue_sync.c @@ -759,7 +759,6 @@ int srslte_ue_sync_zerocopy(srslte_ue_sync_t* q, cf_t* input_buffer[SRSLTE_MAX_P n = srslte_sync_find(&q->sfind, input_buffer[0], 0, &q->peak_idx); switch (n) { case SRSLTE_SYNC_ERROR: - ret = SRSLTE_ERROR; ERROR("Error finding correlation peak (%d)\n", ret); return SRSLTE_ERROR; case SRSLTE_SYNC_FOUND: diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 990cc92f2..9f22585de 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -231,30 +231,12 @@ phy_interface_rrc_lte::cell_search_ret_t sync::cell_search(phy_interface_rrc_lte // Check return state switch (cell_search_ret) { case search::CELL_FOUND: - // If a cell is found, configure it, synchronize and measure it - if (set_cell()) { - - // Reconfigure first intra-frequency measurement - intra_freq_meas[0]->set_primary_cell(current_earfcn, cell); - - Info("Cell Search: Setting sampling rate and synchronizing SFN...\n"); - set_sampling_rate(); - phy_state.run_sfn_sync(); - - if (phy_state.is_camping()) { - log_h->info("Cell Search: Sync OK. Camping on cell PCI=%d\n", cell.id); - if (found_cell) { - found_cell->earfcn = current_earfcn; - found_cell->pci = cell.id; - } - ret.found = phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND; - } else { - log_h->info("Cell Search: Could not synchronize with cell\n"); - ret.found = phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND; - } - } else { - Error("Cell Search: Setting cell PCI=%d, nof_prb=%d\n", cell.id, cell.nof_prb); + log_h->info("Cell Search: Found cell with PCI=%d with %d PRB\n", cell.id, cell.nof_prb); + if (found_cell) { + found_cell->earfcn = current_earfcn; + found_cell->pci = cell.id; } + ret.found = phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND; break; case search::CELL_NOT_FOUND: Info("Cell Search: No cell found in this frequency\n"); @@ -294,7 +276,7 @@ bool sync::cell_select(phy_interface_rrc_lte::phy_cell_t* new_cell) Info("Cell Select: Starting cell resynchronization\n"); } else { if (!srslte_cellid_isvalid(new_cell->pci)) { - log_h->error("Cell Select: Invalid cell_id=%d\n", cell.id); + log_h->error("Cell Select: Invalid cell_id=%d\n", new_cell->pci); return ret; } Info("Cell Select: Starting cell selection for PCI=%d, EARFCN=%d\n", new_cell->pci, new_cell->earfcn); @@ -317,14 +299,11 @@ bool sync::cell_select(phy_interface_rrc_lte::phy_cell_t* new_cell) /* Reconfigure cell if necessary */ if (new_cell) { - if (new_cell->pci != cell.id) { - Info("Cell Select: Reconfiguring cell ID\n"); cell.id = new_cell->pci; if (!set_cell()) { Error("Cell Select: Reconfiguring cell\n"); return ret; } - } /* Select new frequency if necessary */ if ((int)new_cell->earfcn != current_earfcn) { @@ -821,7 +800,6 @@ void sync::set_ue_sync_opts(srslte_ue_sync_t* q, float cfo) bool sync::set_cell() { - if (!phy_state.is_idle()) { Warning("Can not change Cell while not in IDLE\n"); return false; diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 317441ff3..941579f8c 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -79,6 +79,12 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_interface_rrc_ rrc_ptr->set_serving_cell(new_cell, false); + // set new serving cell in PHY + if (not rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) { + Error("Couldn't select new serving cell\n"); + return proc_outcome_t::error; + } + if (not rrc_ptr->phy->cell_is_camping()) { Warning("Could not camp on found cell.\n"); return proc_outcome_t::error; @@ -111,9 +117,8 @@ proc_outcome_t rrc::cell_search_proc::react(const cell_search_event_t& event) Info("PHY cell search completed.\n"); // Transition to SI Acquire or finish switch (search_result.cs_ret.found) { - case phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND: { + case phy_interface_rrc_lte::cell_search_ret_t::CELL_FOUND: return handle_cell_found(search_result.found_cell); - } case phy_interface_rrc_lte::cell_search_ret_t::CELL_NOT_FOUND: rrc_ptr->phy_sync_state = phy_unknown_sync; Info("No cells found.\n");