From 848496bb0fd3644935f10c6a15ff9444c46a9e77 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 8 Dec 2020 11:30:41 +0100 Subject: [PATCH] Moved get_earfcn to srslte get_carrier_freq func --- lib/include/srslte/asn1/rrc_utils.h | 5 +++++ lib/src/asn1/rrc_utils.cc | 11 +++++++++++ srsenb/hdr/stack/rrc/ue_meas_cfg.h | 1 - srsenb/src/stack/rrc/ue_meas_cfg.cc | 15 ++++----------- srsenb/test/upper/rrc_meascfg_test.cc | 9 ++++++--- srsue/hdr/stack/rrc/rrc_meas.h | 1 - srsue/src/stack/rrc/rrc_meas.cc | 12 +----------- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/include/srslte/asn1/rrc_utils.h b/lib/include/srslte/asn1/rrc_utils.h index a3a7b9a34..bd11ae1d8 100644 --- a/lib/include/srslte/asn1/rrc_utils.h +++ b/lib/include/srslte/asn1/rrc_utils.h @@ -122,6 +122,11 @@ void set_phy_cfg_t_common_pwr_ctrl(phy_cfg_t* cfg, const asn1::rrc::ul_pwr_ctrl_ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mod_r10_s& asn1_type); void set_phy_cfg_t_enable_64qam(phy_cfg_t* cfg, const bool enabled); +/*************************** + * Measurements + **************************/ +int get_carrier_freq(const asn1::rrc::meas_obj_to_add_mod_s& obj); + /*************************** * EUTRA UE Capabilities **************************/ diff --git a/lib/src/asn1/rrc_utils.cc b/lib/src/asn1/rrc_utils.cc index fdf659f54..0c5b03614 100644 --- a/lib/src/asn1/rrc_utils.cc +++ b/lib/src/asn1/rrc_utils.cc @@ -820,6 +820,17 @@ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mo } } +/*************************** + * Measurements + **************************/ +int get_carrier_freq(const asn1::rrc::meas_obj_to_add_mod_s& obj) +{ + if (obj.meas_obj.type().value != meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_eutra) { + return -1; + } + return obj.meas_obj.meas_obj_eutra().carrier_freq; +} + /* * UE Capabilities parser */ diff --git a/srsenb/hdr/stack/rrc/ue_meas_cfg.h b/srsenb/hdr/stack/rrc/ue_meas_cfg.h index 52dfe5803..d30f28210 100644 --- a/srsenb/hdr/stack/rrc/ue_meas_cfg.h +++ b/srsenb/hdr/stack/rrc/ue_meas_cfg.h @@ -30,7 +30,6 @@ using report_cfg_list = asn1::rrc::report_cfg_to_add_mod_list_l; using meas_id_t = asn1::rrc::meas_id_to_add_mod_s; using meas_id_list = asn1::rrc::meas_id_to_add_mod_list_l; -int get_earfcn(const meas_obj_t& obj); bool is_same_earfcn(const meas_obj_t& lhs, const meas_obj_t& rhs); /// Find MeasObj with same earfcn. Assumes ordered list diff --git a/srsenb/src/stack/rrc/ue_meas_cfg.cc b/srsenb/src/stack/rrc/ue_meas_cfg.cc index a5bf5fe62..7fe29fc12 100644 --- a/srsenb/src/stack/rrc/ue_meas_cfg.cc +++ b/srsenb/src/stack/rrc/ue_meas_cfg.cc @@ -22,30 +22,23 @@ namespace srsenb { * measObjToAddMod **********************************/ -int get_earfcn(const meas_obj_t& obj) -{ - if (obj.meas_obj.type().value != meas_obj_t::meas_obj_c_::types_opts::meas_obj_eutra) { - return -1; - } - return obj.meas_obj.meas_obj_eutra().carrier_freq; -} bool is_same_earfcn(const meas_obj_t& lhs, const meas_obj_t& rhs) { - int freq1 = get_earfcn(lhs); - int freq2 = get_earfcn(rhs); + int freq1 = srslte::get_carrier_freq(lhs); + int freq2 = srslte::get_carrier_freq(rhs); return freq1 != -1 and freq1 == freq2; } meas_obj_t* find_meas_obj(meas_obj_to_add_mod_list_l& l, uint32_t earfcn) { - auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == get_earfcn(obj); }; + auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srslte::get_carrier_freq(obj); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); return it == l.end() ? nullptr : &(*it); } const meas_obj_t* find_meas_obj(const meas_obj_to_add_mod_list_l& l, uint32_t earfcn) { - auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == get_earfcn(obj); }; + auto same_earfcn = [earfcn](const meas_obj_t& obj) { return (int)earfcn == srslte::get_carrier_freq(obj); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); return it == l.end() ? nullptr : &(*it); } diff --git a/srsenb/test/upper/rrc_meascfg_test.cc b/srsenb/test/upper/rrc_meascfg_test.cc index e422bf476..61392b8d7 100644 --- a/srsenb/test/upper/rrc_meascfg_test.cc +++ b/srsenb/test/upper/rrc_meascfg_test.cc @@ -12,10 +12,11 @@ #include "srsenb/hdr/enb.h" #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" +#include "srslte/asn1/rrc_utils.h" #include "srslte/common/test_common.h" #include "srslte/interfaces/enb_rrc_interface_types.h" -#include "test_helpers.h" #include "srslte/rrc/rrc_cfg_utils.h" +#include "test_helpers.h" using namespace asn1::rrc; @@ -309,8 +310,10 @@ int test_minimize_meascfg_reordering() // TEST1: Ensure consistent order of measObjects based on DL-EARFCN TESTASSERT(mcfg1.meas_obj_to_add_mod_list_present and mcfg2.meas_obj_to_add_mod_list_present); TESTASSERT(mcfg1.meas_obj_to_add_mod_list.size() == mcfg2.meas_obj_to_add_mod_list.size()); - TESTASSERT(get_earfcn(mcfg1.meas_obj_to_add_mod_list[0]) == get_earfcn(mcfg2.meas_obj_to_add_mod_list[0])); - TESTASSERT(get_earfcn(mcfg1.meas_obj_to_add_mod_list[1]) == get_earfcn(mcfg2.meas_obj_to_add_mod_list[1])); + TESTASSERT(srslte::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[0]) == + srslte::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[0])); + TESTASSERT(srslte::get_carrier_freq(mcfg1.meas_obj_to_add_mod_list[1]) == + srslte::get_carrier_freq(mcfg2.meas_obj_to_add_mod_list[1])); TESTASSERT(std::is_sorted( mcfg1.meas_obj_to_add_mod_list.begin(), mcfg1.meas_obj_to_add_mod_list.end(), srslte::rrc_obj_id_cmp{})); TESTASSERT(std::is_sorted( diff --git a/srsue/hdr/stack/rrc/rrc_meas.h b/srsue/hdr/stack/rrc/rrc_meas.h index 2d7ba5d70..95343ce6b 100644 --- a/srsue/hdr/stack/rrc/rrc_meas.h +++ b/srsue/hdr/stack/rrc/rrc_meas.h @@ -29,7 +29,6 @@ using namespace asn1::rrc; typedef std::vector cell_triggered_t; // TODO make this agnostic with srsenb -int get_carrier_freq(const meas_obj_to_add_mod_s& obj); meas_obj_to_add_mod_s* find_meas_obj_map(std::map& l, uint32_t earfcn); // RRC Measurements class diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index 45086ab80..ced9413ac 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -27,20 +27,10 @@ using namespace asn1::rrc; namespace srsue { - -int get_carrier_freq(const meas_obj_to_add_mod_s& obj) -{ - if (obj.meas_obj.type().value != meas_obj_to_add_mod_s::meas_obj_c_::types_opts::meas_obj_eutra) { - return -1; - } - return obj.meas_obj.meas_obj_eutra().carrier_freq; -} - - meas_obj_to_add_mod_s* find_meas_obj_map(std::map& l, uint32_t earfcn) { auto same_earfcn = [earfcn](const std::pair& c) { - return (int)earfcn == get_carrier_freq(c.second); + return (int)earfcn == srslte::get_carrier_freq(c.second); }; auto it = std::find_if(l.begin(), l.end(), same_earfcn); if (it == l.end()) {