diff --git a/lib/include/srsran/interfaces/ue_phy_interfaces.h b/lib/include/srsran/interfaces/ue_phy_interfaces.h index 878eb79ee..58786eb0b 100644 --- a/lib/include/srsran/interfaces/ue_phy_interfaces.h +++ b/lib/include/srsran/interfaces/ue_phy_interfaces.h @@ -36,6 +36,7 @@ struct phy_args_t { std::map ul_earfcn_map; // Map linking DL EARFCN and UL EARFCN int force_N_id_2 = -1; // Cell identity within the identity group (PSS) to filter. + int force_N_id_1 = -1; // Cell identity group (SSS) to filter. float dl_freq = -1.0f; float ul_freq = -1.0f; diff --git a/srsue/hdr/phy/search.h b/srsue/hdr/phy/search.h index 77af489cd..9c3216562 100644 --- a/srsue/hdr/phy/search.h +++ b/srsue/hdr/phy/search.h @@ -36,7 +36,7 @@ public: explicit search(srslog::basic_logger& logger) : logger(logger) {} ~search(); - void init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent, int force_N_id_2_); + void init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent, int force_N_id_2_, int force_N_id_1_); void reset(); float get_last_cfo(); void set_agc_enable(bool enable); @@ -50,6 +50,7 @@ private: srsran_ue_cellsearch_t cs = {}; srsran_ue_mib_sync_t ue_mib_sync = {}; int force_N_id_2 = 0; + int force_N_id_1 = 0; }; }; // namespace srsue diff --git a/srsue/src/main.cc b/srsue/src/main.cc index a559490cf..495d49777 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -409,6 +409,10 @@ static int parse_args(all_args_t* args, int argc, char* argv[]) bpo::value(&args->phy.force_N_id_2)->default_value(-1), "Force using a specific PSS (set to -1 to allow all PSSs).") + ("phy.force_N_id_1", + bpo::value(&args->phy.force_N_id_1)->default_value(-1), + "Force using a specific SSS (set to -1 to allow all SSSs).") + // PHY NR args ("phy.nr.store_pdsch_ko", bpo::value(&args->phy.nr_store_pdsch_ko)->default_value(false), diff --git a/srsue/src/phy/search.cc b/srsue/src/phy/search.cc index fc94da9bd..6138483a9 100644 --- a/srsue/src/phy/search.cc +++ b/srsue/src/phy/search.cc @@ -46,7 +46,7 @@ search::~search() srsran_ue_cellsearch_free(&cs); } -void search::init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent, int force_N_id_2_) +void search::init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search_callback* parent, int force_N_id_2_, int force_N_id_1_) { p = parent; @@ -65,6 +65,7 @@ void search::init(srsran::rf_buffer_t& buffer_, uint32_t nof_rx_channels, search p->set_ue_sync_opts(&cs.ue_sync, 0); force_N_id_2 = force_N_id_2_; + force_N_id_1 = force_N_id_1_; } void search::set_cp_en(bool enable) @@ -125,6 +126,21 @@ search::ret_code search::run(srsran_cell_t* cell_, std::array= 0 && force_N_id_1 < SRSRAN_NOF_NID_1) { + bool N_id_1_found = false; + for (uint32_t N_id_2 = 0; N_id_2 < SRSRAN_NOF_NID_2; N_id_2++) { + if (found_cells[N_id_2].cell_id / SRSRAN_NOF_NID_2 == (uint32_t)force_N_id_1) { + N_id_1_found = true; + max_peak_cell = N_id_2; + } + } + if (!N_id_1_found) { + Info("SYNC: Could not find any cell in this SSS"); + return CELL_NOT_FOUND; + } + } + // Save result new_cell.id = found_cells[max_peak_cell].cell_id; new_cell.cp = found_cells[max_peak_cell].cp; diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index c0c468f47..3440f66ad 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -82,7 +82,7 @@ void sync::init(srsran::radio_interface_phy* _radio, } // Initialize cell searcher - search_p.init(sf_buffer, nof_rf_channels, this, worker_com->args->force_N_id_2); + search_p.init(sf_buffer, nof_rf_channels, this, worker_com->args->force_N_id_2, worker_com->args->force_N_id_1); search_p.set_cp_en(worker_com->args->detect_cp); // Initialize SFN synchronizer, it uses only pcell buffer sfn_p.init(&ue_sync, worker_com->args, sf_buffer, sf_buffer.size()); diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 67ad68634..59f36dacd 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -343,6 +343,9 @@ enable = false # nof_in_sync_events: Number of PHY in-sync events before sending an in-sync event to RRC # nof_out_of_sync_events: Number of PHY out-sync events before sending an out-sync event to RRC # +# force_N_id_2: Force using a specific PSS (set to -1 to allow all PSSs). +# force_N_id_1: Force using a specific SSS (set to -1 to allow all SSSs). +# ##################################################################### [phy] #rx_gain_offset = 62 @@ -374,6 +377,9 @@ enable = false #nof_in_sync_events = 10 #nof_out_of_sync_events = 20 +#force_N_id_2 = 1 +#force_N_id_1 = 10 + ##################################################################### # PHY NR specific configuration options #