diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 65ec9f9c2..559bb4ba3 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -28,8 +28,8 @@ #ifndef SRSLTE_UE_INTERFACES_H #define SRSLTE_UE_INTERFACES_H -#include #include +#include #include "rrc_interface_types.h" #include "srslte/asn1/liblte_mme.h" @@ -142,9 +142,9 @@ public: uint32_t pci; } phy_meas_t; - virtual void in_sync() = 0; - virtual void out_of_sync() = 0; - virtual void new_cell_meas(std::vector& meas) = 0; + virtual void in_sync() = 0; + virtual void out_of_sync() = 0; + virtual void new_cell_meas(const std::vector& meas) = 0; }; // RRC interface for NAS @@ -227,25 +227,25 @@ public: class pdcp_interface_rrc { public: - virtual void reestablish() = 0; - virtual void reestablish(uint32_t lcid) = 0; - virtual void reset() = 0; - virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking) = 0; - virtual void add_bearer(uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; - virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; + virtual void reestablish() = 0; + virtual void reestablish(uint32_t lcid) = 0; + virtual void reset() = 0; + virtual void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking) = 0; + virtual void add_bearer(uint32_t lcid, srslte::pdcp_config_t cnfg) = 0; + virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; virtual void config_security(uint32_t lcid, uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; virtual void config_security_all(uint8_t* k_rrc_enc_, uint8_t* k_rrc_int_, uint8_t* k_up_enc_, srslte::CIPHERING_ALGORITHM_ID_ENUM cipher_algo_, - srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; - virtual void enable_integrity(uint32_t lcid) = 0; - virtual void enable_encryption(uint32_t lcid) = 0; + srslte::INTEGRITY_ALGORITHM_ID_ENUM integ_algo_) = 0; + virtual void enable_integrity(uint32_t lcid) = 0; + virtual void enable_encryption(uint32_t lcid) = 0; }; // PDCP interface for RLC @@ -601,8 +601,8 @@ public: virtual void set_config_mbsfn_mcch(const srslte::mcch_msg_t& mcch) = 0; /* Measurements interface */ - virtual void set_cells_to_meas(uint32_t earfcn, std::set& pci) = 0; - virtual void meas_stop() = 0; + virtual void set_cells_to_meas(uint32_t earfcn, const std::set& pci) = 0; + virtual void meas_stop() = 0; typedef struct { enum { CELL_FOUND = 0, CELL_NOT_FOUND, ERROR } found; diff --git a/lib/src/phy/ch_estimation/chest_dl.c b/lib/src/phy/ch_estimation/chest_dl.c index ea3d64b1c..69a53a0f7 100644 --- a/lib/src/phy/ch_estimation/chest_dl.c +++ b/lib/src/phy/ch_estimation/chest_dl.c @@ -815,7 +815,7 @@ static float get_rsrp_port(srslte_chest_dl_t* q, uint32_t port) return sum; } -static float get_rsrp_neigbhour_port(srslte_chest_dl_t* q, uint32_t port) +static float get_rsrp_neighbour_port(srslte_chest_dl_t* q, uint32_t port) { float sum = 0.0f; for (int j = 0; j < q->cell.nof_ports; ++j) { @@ -855,7 +855,7 @@ static float get_rsrp_neighbour(srslte_chest_dl_t* q) { float max = -1e9; for (int i = 0; i < q->nof_rx_antennas; ++i) { - float v = get_rsrp_neigbhour_port(q, i); + float v = get_rsrp_neighbour_port(q, i); if (v > max) { max = v; } diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index f5d886828..d1c1561e0 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -929,7 +929,11 @@ static void ulsch_interleave(uint8_t* g_bits, uint8_t* ri_present) { if (N_pusch_symbs == 0 || Qm == 0 || H_prime_total == 0 || H_prime_total < N_pusch_symbs) { - ERROR("Invalid input: N_pusch_symbs=%d, Qm=%d, H_prime_total=%d, N_pusch_symbs=%d\n", N_pusch_symbs, Qm, H_prime_total, N_pusch_symbs); + ERROR("Invalid input: N_pusch_symbs=%d, Qm=%d, H_prime_total=%d, N_pusch_symbs=%d\n", + N_pusch_symbs, + Qm, + H_prime_total, + N_pusch_symbs); return; } @@ -1247,7 +1251,7 @@ int srslte_ulsch_encode(srslte_sch_t* q, srslte_bit_pack_vector(q->temp_g_bits, g_bits, Q_prime_cqi * Qm); // Reset the buffer because will be reused in ulsch_interleave - bzero(q->temp_g_bits, sizeof(uint8_t) * SRSLTE_MIN(Q_prime_cqi * Qm, SCH_MAX_G_BITS)); + bzero(q->temp_g_bits, Q_prime_cqi * Qm); } e_offset += Q_prime_cqi * Qm; @@ -1323,4 +1327,4 @@ void srslte_sl_ulsch_deinterleave(int16_t* q_bits, uint32_t* inteleaver_lut) { ulsch_deinterleave(q_bits, Qm, H_prime_total, N_pusch_symbs, g_bits, NULL, 0, NULL, inteleaver_lut); -} \ No newline at end of file +} diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index 4f7f53b9c..8546b3e10 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -72,7 +72,7 @@ public: cell_search_ret_t cell_search(phy_cell_t* cell) final; bool cell_select(phy_cell_t* cell) final; - void set_cells_to_meas(uint32_t earfcn, std::set& pci) final; + void set_cells_to_meas(uint32_t earfcn, const std::set& pci) final; void meas_stop() final; // also MAC interface @@ -132,7 +132,7 @@ private: std::mutex config_mutex; std::condition_variable config_cond; bool is_configured = false; - uint32_t nof_workers = 0; + uint32_t nof_workers = 0; const static int SF_RECV_THREAD_PRIO = 1; const static int WORKERS_THREAD_PRIO = 2; diff --git a/srsue/hdr/phy/phy_metrics.h b/srsue/hdr/phy/phy_metrics.h index bdf499f35..817619266 100644 --- a/srsue/hdr/phy/phy_metrics.h +++ b/srsue/hdr/phy/phy_metrics.h @@ -22,7 +22,7 @@ #ifndef SRSUE_PHY_METRICS_H #define SRSUE_PHY_METRICS_H -#include "srslte/phy/common/phy_common.h" +#include "srslte/srslte.h" namespace srsue { diff --git a/srsue/hdr/phy/scell/intra_measure.h b/srsue/hdr/phy/scell/intra_measure.h index d02fc254e..1b92423c3 100644 --- a/srsue/hdr/phy/scell/intra_measure.h +++ b/srsue/hdr/phy/scell/intra_measure.h @@ -37,16 +37,20 @@ class intra_measure : public thread public: intra_measure(); ~intra_measure(); - void init(phy_common* common, rrc_interface_phy_lte* rrc, srslte::log* log_h); - void stop(); - void set_primary_cell(uint32_t earfcn, srslte_cell_t cell); - void set_cells_to_meas(std::set& pci); + void init(phy_common* common, rrc_interface_phy_lte* rrc, srslte::log* log_h); + void stop(); + void set_primary_cell(uint32_t earfcn, srslte_cell_t cell); + void set_cells_to_meas(const std::set& pci); void meas_stop(); - void write(uint32_t tti, cf_t* data, uint32_t nsamples); + void write(uint32_t tti, cf_t* data, uint32_t nsamples); uint32_t get_earfcn() { return current_earfcn; }; + void wait_meas() + { // Only used by scell_search_test + meas_sync.wait(); + } private: - void run_thread(); + void run_thread() override; const static int INTRA_FREQ_MEAS_PRIO = DEFAULT_PRIORITY + 5; scell_recv scell = {}; @@ -60,6 +64,7 @@ private: std::mutex active_pci_mutex = {}; srslte::tti_sync_cv tti_sync; + srslte::tti_sync_cv meas_sync; // Only used by scell_search_test cf_t* search_buffer = nullptr; diff --git a/srsue/hdr/phy/sync.h b/srsue/hdr/phy/sync.h index ad90fb526..3f99c275e 100644 --- a/srsue/hdr/phy/sync.h +++ b/srsue/hdr/phy/sync.h @@ -70,7 +70,7 @@ public: bool cell_is_camping(); // RRC interface for controlling the neighbour cell measurement - void set_cells_to_meas(uint32_t earfcn, std::set& pci); + void set_cells_to_meas(uint32_t earfcn, const std::set& pci); void set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, srslte_cell_t cell_); void meas_stop(); @@ -170,8 +170,8 @@ private: bool running = false; // Objects for internal use - search search_p; - sfn_sync sfn_p; + search search_p; + sfn_sync sfn_p; std::vector > intra_freq_meas; uint32_t current_sflen = 0; @@ -349,7 +349,7 @@ private: srslte_timestamp_t radio_ts = {}; std::array mib; - uint32_t nof_workers = 0; + uint32_t nof_workers = 0; float ul_dl_factor = NAN; int current_earfcn = 0; diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 0409d9ce9..9e9b34cbd 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -246,7 +246,7 @@ public: return 0; } - std::string print() + std::string to_string() { char buf[256]; snprintf(buf, @@ -334,7 +334,7 @@ public: // PHY interface void in_sync() final; void out_of_sync() final; - void new_cell_meas(std::vector& meas); + void new_cell_meas(const std::vector& meas); // MAC interface void ho_ra_completed(bool ra_successful); @@ -425,9 +425,9 @@ private: std::map drbs; // RRC constants and timers - srslte::timer_handler* timers = nullptr; - uint32_t n310_cnt, N310 = 0; - uint32_t n311_cnt, N311 = 0; + srslte::timer_handler* timers = nullptr; + uint32_t n310_cnt = 0, N310 = 0; + uint32_t n311_cnt = 0, N311 = 0; srslte::timer_handler::unique_timer t300, t301, t302, t310, t311, t304; // Radio bearers @@ -466,16 +466,16 @@ private: unique_cell_t serving_cell = nullptr; void set_serving_cell(uint32_t cell_idx); - unique_cell_t remove_neighbour_cell(const uint32_t earfcn, const uint32_t pci); - cell_t* get_neighbour_cell_handle(const uint32_t earfcn, const uint32_t pci); - int find_neighbour_cell(uint32_t earfcn, uint32_t pci); + unique_cell_t remove_neighbour_cell(const uint32_t earfcn, const uint32_t pci); + cell_t* get_neighbour_cell_handle(const uint32_t earfcn, const uint32_t pci); + int find_neighbour_cell(uint32_t earfcn, uint32_t pci); bool add_neighbour_cell(phy_meas_t meas); - bool add_neighbour_cell(unique_cell_t new_cell); + bool add_neighbour_cell(unique_cell_t new_cell); void log_neighbour_cells(); - void sort_neighbour_cells(); - void clean_neighbours(); - void delete_last_neighbour(); - std::string print_neighbour_cells(); + void sort_neighbour_cells(); + void clean_neighbours(); + void delete_last_neighbour(); + std::string print_neighbour_cells(); std::set get_neighbour_pcis(uint32_t earfcn); bool initiated = false; @@ -490,7 +490,7 @@ private: // Measurements private subclass class rrc_meas; - rrc_meas* measurements; + std::unique_ptr measurements; // Interface from rrc_meas void send_srb1_msg(const asn1::rrc::ul_dcch_msg_s& msg); @@ -500,7 +500,7 @@ private: cell_t* get_serving_cell(); void process_cell_meas(); - void process_new_cell_meas(std::vector& meas); + void process_new_cell_meas(const std::vector& meas); srslte::block_queue > cell_meas_q; // Cell selection/reselection functions/variables diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 273c4f4a8..7dce4a9ed 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -77,7 +77,7 @@ public: // RRC interface for PHY void in_sync() final; void out_of_sync() final; - void new_cell_meas(std::vector& meas) { rrc.new_cell_meas(meas); } + void new_cell_meas(const std::vector& meas) override { rrc.new_cell_meas(meas); } // MAC Interface for PHY uint16_t get_dl_sched_rnti(uint32_t tti) { return mac.get_dl_sched_rnti(tti); } diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 1a4e5ac11..eea54f863 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -315,7 +315,7 @@ void phy::configure_prach_params() } } -void phy::set_cells_to_meas(uint32_t earfcn, std::set& pci) +void phy::set_cells_to_meas(uint32_t earfcn, const std::set& pci) { sfsync.set_cells_to_meas(earfcn, pci); } diff --git a/srsue/src/phy/scell/intra_measure.cc b/srsue/src/phy/scell/intra_measure.cc index 8d8e11590..fdf2c68f8 100644 --- a/srsue/src/phy/scell/intra_measure.cc +++ b/srsue/src/phy/scell/intra_measure.cc @@ -97,7 +97,7 @@ void intra_measure::meas_stop() } } -void intra_measure::set_cells_to_meas(std::set& pci) +void intra_measure::set_cells_to_meas(const std::set& pci) { active_pci_mutex.lock(); active_pci = pci; @@ -159,7 +159,7 @@ void intra_measure::run_thread() receiving = false; - std::vector neigbhour_cells = {}; + std::vector neighbour_cells = {}; // Use Cell Reference signal to measure cells in the time domain for all known active PCI for (auto id : cells_to_measure) { @@ -180,7 +180,7 @@ void intra_measure::run_thread() m.earfcn = current_earfcn; m.rsrp = refsignal_dl_sync.rsrp_dBfs - common->rx_gain_offset; m.rsrq = refsignal_dl_sync.rsrq_dB; - neigbhour_cells.push_back(m); + neighbour_cells.push_back(m); Info("INTRA: Found neighbour cell: EARFCN=%d, PCI=%03d, RSRP=%5.1f dBm, RSRQ=%5.1f, peak_idx=%5d, " "CFO=%+.1fHz\n", @@ -194,9 +194,11 @@ void intra_measure::run_thread() } // Send measurements to RRC - if (neigbhour_cells.size() > 0) { - rrc->new_cell_meas(neigbhour_cells); + if (not neighbour_cells.empty()) { + rrc->new_cell_meas(neighbour_cells); } + + meas_sync.increase(); } } } diff --git a/srsue/src/phy/sync.cc b/srsue/src/phy/sync.cc index 77cbbc403..990cc92f2 100644 --- a/srsue/src/phy/sync.cc +++ b/srsue/src/phy/sync.cc @@ -386,7 +386,7 @@ bool sync::cell_is_camping() void sync::run_thread() { - sf_worker* worker = nullptr; + sf_worker* worker = nullptr; cf_t* buffer[SRSLTE_MAX_RADIOS][SRSLTE_MAX_PORTS] = {}; srslte_cell_t temp_cell = {}; @@ -482,9 +482,9 @@ void sync::run_thread() // Force decode MIB if required if (force_camping_sfn_sync) { - uint32_t _tti = 0; - temp_cell = cell; - sync::sfn_sync::ret_code ret = sfn_p.decode_mib(&temp_cell, &_tti, buffer[0], mib); + uint32_t _tti = 0; + temp_cell = cell; + sync::sfn_sync::ret_code ret = sfn_p.decode_mib(&temp_cell, &_tti, buffer[0], mib); if (ret == sfn_sync::SFN_FOUND) { // Force tti tti = _tti; @@ -1291,7 +1291,7 @@ void sync::set_inter_frequency_measurement(uint32_t cc_idx, uint32_t earfcn_, sr intra_freq_meas[cc_idx]->set_primary_cell(earfcn_, cell_); } } -void sync::set_cells_to_meas(uint32_t earfcn_, std::set& pci) +void sync::set_cells_to_meas(uint32_t earfcn_, const std::set& pci) { bool found = false; for (size_t i = 0; i < intra_freq_meas.size() and not found; i++) { diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index bdb5c8b25..0a4e18ca0 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -67,13 +67,10 @@ rrc::rrc(srslte::log* rrc_log_) : connection_reest(this), serving_cell(unique_cell_t(new cell_t())) { - measurements = new rrc_meas(rrc_log); + measurements = std::unique_ptr(new rrc_meas(rrc_log)); } -rrc::~rrc() -{ - delete measurements; -} +rrc::~rrc() = default; template void rrc::log_rrc_message(const std::string source, @@ -361,7 +358,7 @@ void rrc::set_ue_identity(srslte::s_tmsi_t s_tmsi) /* This function is called from a PHY worker thus must return very quickly. * Queue the values of the measurements and process them from the RRC thread */ -void rrc::new_cell_meas(std::vector& meas) +void rrc::new_cell_meas(const std::vector& meas) { cell_meas_q.push(meas); } @@ -379,7 +376,7 @@ void rrc::process_cell_meas() } } -void rrc::process_new_cell_meas(std::vector& meas) +void rrc::process_new_cell_meas(const std::vector& meas) { bool neighbour_added = false; rrc_log->debug("MEAS: Processing measurement of %lu cells\n", meas.size()); @@ -540,7 +537,7 @@ void rrc::delete_last_neighbour() { if (not neighbour_cells.empty()) { auto& it = neighbour_cells.back(); - rrc_log->debug("Delete cell earfcn=%d, pci=%d from neighbor list.\n", (*it).get_earfcn(), (*it).get_pci()); + rrc_log->debug("Delete cell %s from neighbor list.\n", (*it).to_string().c_str()); neighbour_cells.pop_back(); } } @@ -567,19 +564,9 @@ void rrc::log_neighbour_cells() if (not neighbour_cells.empty()) { char ordered[512] = {}; int n = 0; - n += snprintf(ordered, - 512, - "[earfcn=%d, pci=%d, rsrp=%.2f", - neighbour_cells[0]->get_earfcn(), - neighbour_cells[0]->phy_cell.pci, - neighbour_cells[0]->get_rsrp()); + n += snprintf(ordered, 512, "[%s", neighbour_cells[0]->to_string().c_str()); for (uint32_t i = 1; i < neighbour_cells.size(); i++) { - int m = snprintf(&ordered[n], - 512 - n, - " | earfcn=%d, pci=%d, rsrp=%.2f", - neighbour_cells[i]->get_earfcn(), - neighbour_cells[i]->get_pci(), - neighbour_cells[i]->get_rsrp()); + int m = snprintf(&ordered[n], 512 - n, " | %s", neighbour_cells[i]->to_string().c_str()); n += m; } rrc_log->info("Neighbours: %s]\n", ordered); @@ -603,27 +590,33 @@ bool rrc::add_neighbour_cell(unique_cell_t new_cell) bool ret = false; // Make sure cell is valid if (!new_cell->is_valid()) { - rrc_log->error( - "Trying to add cell EARFCN=%d, PCI=%d but is not valid", new_cell->get_earfcn(), new_cell->get_pci()); + rrc_log->error("Trying to add cell %s but is not valid", new_cell->to_string().c_str()); return ret; } - // First make sure it doesn't exist - if (has_neighbour_cell(new_cell->get_earfcn(), new_cell->get_pci())) { - rrc_log->warning( - "Trying to add cell EARFCN=%d, PCI=%d but already exists", new_cell->get_earfcn(), new_cell->get_pci()); - return ret; - } - if (neighbour_cells.size() < NOF_NEIGHBOUR_CELLS) { - ret = true; - } else if (new_cell->greater(neighbour_cells.back().get())) { - // delete last neighbour cell - delete_last_neighbour(); + // If cell exists, update RSRP value + cell_t* existing_cell = get_neighbour_cell_handle(new_cell->get_earfcn(), new_cell->get_pci()); + if (existing_cell != nullptr) { + if (std::isnormal(new_cell.get()->get_rsrp())) { + existing_cell->set_rsrp(new_cell.get()->get_rsrp()); + } ret = true; + } else { + // If doesn't exists, add it if there is enough space + if (neighbour_cells.size() < NOF_NEIGHBOUR_CELLS) { + ret = true; + // If there isn't space, keep the strongest only + } else if (new_cell->greater(neighbour_cells.back().get())) { + // delete last neighbour cell + delete_last_neighbour(); + ret = true; + } } if (ret) { rrc_log->info( - "Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->print().c_str(), neighbour_cells.size() + 1); + "Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->to_string().c_str(), neighbour_cells.size() + 1); neighbour_cells.push_back(std::move(new_cell)); + } else { + rrc_log->warning("Could not add cell %s: no space in neighbours\n", new_cell->to_string().c_str()); } sort_neighbour_cells(); @@ -679,9 +672,9 @@ std::string rrc::print_neighbour_cells() std::string s; s.reserve(256); for (auto it = neighbour_cells.begin(); it != neighbour_cells.end() - 1; ++it) { - s += (*it)->print() + ", "; + s += (*it)->to_string() + ", "; } - s += neighbour_cells.back()->print(); + s += neighbour_cells.back()->to_string(); return s; } @@ -707,8 +700,8 @@ std::set rrc::get_neighbour_pcis(uint32_t earfcn) *******************************************************************************/ std::string rrc::print_mbms() { - mcch_msg_type_c msg = serving_cell->mcch.msg; - std::stringstream ss; + mcch_msg_type_c msg = serving_cell->mcch.msg; + std::stringstream ss; for (uint32_t i = 0; i < msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9.size(); i++) { ss << "PMCH: " << i << std::endl; pmch_info_r9_s* pmch = &msg.c1().mbsfn_area_cfg_r9().pmch_info_list_r9[i]; @@ -1071,8 +1064,8 @@ bool rrc::ho_prepare() cell_t* target_cell = get_neighbour_cell_handle(target_earfcn, mob_ctrl_info->target_pci); if (!phy->cell_select(&target_cell->phy_cell)) { rrc_log->error("Could not synchronize with target cell %s. Removing cell and trying to return to source %s\n", - target_cell->print().c_str(), - serving_cell->print().c_str()); + target_cell->to_string().c_str(), + serving_cell->to_string().c_str()); // Remove cell from list to avoid cell re-selection, picking the same cell target_cell->set_rsrp(-INFINITY); @@ -1440,9 +1433,10 @@ cell_t* rrc::get_serving_cell() *******************************************************************************/ void rrc::write_pdu_bcch_bch(unique_byte_buffer_t pdu) { - bcch_bch_msg_s bch_msg; - asn1::cbit_ref bch_bref(pdu->msg, pdu->N_bytes); - asn1::SRSASN_CODE err = bch_msg.unpack(bch_bref); + bcch_bch_msg_s bch_msg; + asn1::cbit_ref bch_bref(pdu->msg, pdu->N_bytes); + asn1::SRSASN_CODE err = bch_msg.unpack(bch_bref); + if (err != asn1::SRSASN_SUCCESS) { rrc_log->error("Could not unpack BCCH-BCH message.\n"); return; @@ -1468,8 +1462,8 @@ void rrc::parse_pdu_bcch_dlsch(unique_byte_buffer_t pdu) bcch_dl_sch_msg_s dlsch_msg; asn1::cbit_ref dlsch_bref(pdu->msg, pdu->N_bytes); + asn1::SRSASN_CODE err = dlsch_msg.unpack(dlsch_bref); - asn1::SRSASN_CODE err = dlsch_msg.unpack(dlsch_bref); if (err != asn1::SRSASN_SUCCESS or dlsch_msg.msg.type().value != bcch_dl_sch_msg_type_c::types_opts::c1) { rrc_log->error("Could not unpack BCCH DL-SCH message.\n"); return; @@ -1970,8 +1964,8 @@ void rrc::handle_ue_capability_enquiry(const ue_cap_enquiry_s& enquiry) { rrc_log->debug("Preparing UE Capability Info\n"); - ul_dcch_msg_s ul_dcch_msg; - ue_cap_info_r8_ies_s* info = &ul_dcch_msg.msg.set_c1().set_ue_cap_info().crit_exts.set_c1().set_ue_cap_info_r8(); + ul_dcch_msg_s ul_dcch_msg; + ue_cap_info_r8_ies_s* info = &ul_dcch_msg.msg.set_c1().set_ue_cap_info().crit_exts.set_c1().set_ue_cap_info_r8(); ul_dcch_msg.msg.c1().ue_cap_info().rrc_transaction_id = transaction_id; // resize container to fit all requested RATs diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 35cace5a5..30b0ed2cf 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -73,8 +73,8 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_interface_rrc_ // Create a cell with NaN RSRP. Will be updated by new_phy_meas() during SIB search. if (not rrc_ptr->add_neighbour_cell(unique_cell_t(new cell_t(new_cell)))) { - Info("No more space for neighbour cells\n"); - return proc_outcome_t::success; + Error("Could not add new found cell\n"); + return proc_outcome_t::error; } rrc_ptr->set_serving_cell(new_cell, false); @@ -346,7 +346,7 @@ proc_outcome_t rrc::cell_selection_proc::init() proc_outcome_t rrc::cell_selection_proc::step_cell_selection() { - Info("Current serving cell: %s\n", rrc_ptr->serving_cell->print().c_str()); + Info("Current serving cell: %s\n", rrc_ptr->serving_cell->to_string().c_str()); // Neighbour cells are sorted in descending order of RSRP for (; neigh_index < rrc_ptr->neighbour_cells.size(); ++neigh_index) { @@ -361,7 +361,7 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_selection() // Try to select Cell rrc_ptr->set_serving_cell(rrc_ptr->neighbour_cells.at(neigh_index)->phy_cell, discard_serving); discard_serving = false; - Info("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str()); + Info("Selected cell: %s\n", rrc_ptr->serving_cell->to_string().c_str()); /* BLOCKING CALL */ if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) { @@ -379,7 +379,7 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_selection() } if (rrc_ptr->phy_sync_state == phy_in_sync && rrc_ptr->cell_selection_criteria(rrc_ptr->serving_cell->get_rsrp())) { if (not rrc_ptr->phy->cell_is_camping()) { - Info("Serving cell %s is in-sync but not camping. Selecting it...\n", rrc_ptr->serving_cell->print().c_str()); + Info("Serving cell %s is in-sync but not camping. Selecting it...\n", rrc_ptr->serving_cell->to_string().c_str()); /* BLOCKING CALL */ if (rrc_ptr->phy->cell_select(&rrc_ptr->serving_cell->phy_cell)) { @@ -447,7 +447,7 @@ proc_outcome_t rrc::cell_selection_proc::step_cell_config() return proc_outcome_t::yield; } if (serv_cell_cfg_fut.is_success()) { - rrc_ptr->rrc_log->console("Selected cell: %s\n", rrc_ptr->serving_cell->print().c_str()); + rrc_ptr->rrc_log->console("Selected cell: %s\n", rrc_ptr->serving_cell->to_string().c_str()); Info("All SIBs of serving cell obtained successfully\n"); cs_result = cs_result_t::changed_cell; return proc_outcome_t::success; diff --git a/srsue/test/phy/scell_search_test.cc b/srsue/test/phy/scell_search_test.cc index 0963aa212..caa4135f6 100644 --- a/srsue/test/phy/scell_search_test.cc +++ b/srsue/test/phy/scell_search_test.cc @@ -240,7 +240,7 @@ public: void in_sync() override {} void out_of_sync() override {} - void new_cell_meas(std::vector& meas) override + void new_cell_meas(const std::vector& meas) override { for (auto& m : meas) { uint32_t pci = m.pci; diff --git a/srsue/test/phy/ue_phy_test.cc b/srsue/test/phy/ue_phy_test.cc index d5c3d3de1..68aeba4a3 100644 --- a/srsue/test/phy/ue_phy_test.cc +++ b/srsue/test/phy/ue_phy_test.cc @@ -85,7 +85,7 @@ private: void in_sync() override { notify_in_sync(); } void out_of_sync() override { notify_out_of_sync(); } - void new_cell_meas(std::vector& meas) override + void new_cell_meas(const std::vector& meas) override { for (auto& m : meas) { notify_new_phy_meas(); @@ -307,16 +307,16 @@ private: std::unique_lock lock(mutex); return srslte_convert_amplitude_to_dB(rx_gain); } - double get_freq_offset() override { return 0; } - double get_tx_freq(const uint32_t& radio_idx) override { return tx_freq; } - double get_rx_freq(const uint32_t& radio_idx) override { return rx_freq; } - float get_max_tx_power() override { return 0; } - float get_tx_gain_offset() override { return 0; } - float get_rx_gain_offset() override { return 0; } - bool is_continuous_tx() override { return false; } - bool get_is_start_of_burst(const uint32_t& radio_idx) override { return false; } - bool is_init() override { return false; } - void reset() override {} + double get_freq_offset() override { return 0; } + double get_tx_freq(const uint32_t& radio_idx) override { return tx_freq; } + double get_rx_freq(const uint32_t& radio_idx) override { return rx_freq; } + float get_max_tx_power() override { return 0; } + float get_tx_gain_offset() override { return 0; } + float get_rx_gain_offset() override { return 0; } + bool is_continuous_tx() override { return false; } + bool get_is_start_of_burst(const uint32_t& radio_idx) override { return false; } + bool is_init() override { return false; } + void reset() override {} srslte_rf_info_t* get_info(const uint32_t& radio_idx) override { return &rf_info; } }; @@ -465,11 +465,11 @@ public: int main(int argc, char** argv) { - int ret = SRSLTE_SUCCESS; - const uint32_t default_timeout = 60000; // 1 minute + int ret = SRSLTE_SUCCESS; + const uint32_t default_timeout = 60000; // 1 minute // Define Cell - srslte_cell_t cell = {.nof_prb = 6, + srslte_cell_t cell = {.nof_prb = 6, .nof_ports = 1, .id = 1, .cp = SRSLTE_CP_NORM, diff --git a/srsue/test/upper/rrc_meas_test.cc b/srsue/test/upper/rrc_meas_test.cc index ccea390a9..659c069f5 100644 --- a/srsue/test/upper/rrc_meas_test.cc +++ b/srsue/test/upper/rrc_meas_test.cc @@ -58,7 +58,7 @@ public: void reset() override {} void enable_pregen_signals(bool enable) override {} - void set_cells_to_meas(uint32_t earfcn, std::set& pci) override + void set_cells_to_meas(uint32_t earfcn, const std::set& pci) override { freqs_started.insert(earfcn); cells_started[earfcn] = pci; @@ -117,7 +117,7 @@ public: pdcp_test(srslte::log* log_, srslte::timer_handler* t) : srslte::pdcp(t, log_) {} void write_sdu(uint32_t lcid, srslte::unique_byte_buffer_t sdu, bool blocking = false) override { - ul_dcch_msg_s ul_dcch_msg; + ul_dcch_msg_s ul_dcch_msg; asn1::cbit_ref bref(sdu->msg, sdu->N_bytes); if (ul_dcch_msg.unpack(bref) != asn1::SRSASN_SUCCESS or ul_dcch_msg.msg.type().value != ul_dcch_msg_type_c::types_opts::c1) { @@ -488,7 +488,7 @@ int meas_obj_test() TESTASSERT(rrctest.phytest.meas_cell_started(2, 23)); // was added TESTASSERT(rrctest.phytest.meas_cell_started(2, 24)); // was added - log1.info("Test7: PHY finds new neigbhours in frequency 1 and 2, check RRC instructs to search them\n"); + log1.info("Test7: PHY finds new neighbours in frequency 1 and 2, check RRC instructs to search them\n"); std::vector phy_meas = {}; phy_meas.push_back({0, 0, 1, 31}); phy_meas.push_back({-1, 0, 1, 32});