diff --git a/lib/include/srslte/interfaces/enb_command_interface.h b/lib/include/srslte/interfaces/enb_command_interface.h index e30182465..acf1a0865 100644 --- a/lib/include/srslte/interfaces/enb_command_interface.h +++ b/lib/include/srslte/interfaces/enb_command_interface.h @@ -30,10 +30,10 @@ class enb_command_interface public: /** * Sets the relative gain of a cell from it's index (following rr.conf) order. - * @param cell_idx Provides a cell index + * @param cell_id Provides a cell identifier * @param gain Relative gain */ - virtual void cmd_cell_gain(uint32_t cell_idx, float gain) = 0; + virtual void cmd_cell_gain(uint32_t cell_id, float gain) = 0; }; } // namespace srsenb diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 99e56db08..c3f767e93 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -131,7 +131,7 @@ public: bool get_metrics(enb_metrics_t* m) override; // eNodeB command interface - void cmd_cell_gain(uint32_t cell_idx, float gain) override; + void cmd_cell_gain(uint32_t cell_id, float gain) override; private: const static int ENB_POOL_SIZE = 1024 * 10; diff --git a/srsenb/hdr/phy/phy.h b/srsenb/hdr/phy/phy.h index 2ee849d17..bd38549bb 100644 --- a/srsenb/hdr/phy/phy.h +++ b/srsenb/hdr/phy/phy.h @@ -68,7 +68,7 @@ public: void get_metrics(phy_metrics_t metrics[ENB_METRICS_MAX_USERS]) override; - void cmd_cell_gain(uint32_t cell_idx, float gain_db) override; + void cmd_cell_gain(uint32_t cell_id, float gain_db) override; void radio_overflow() override{}; void radio_failure() override{}; diff --git a/srsenb/hdr/phy/phy_common.h b/srsenb/hdr/phy/phy_common.h index b68e87a80..cc766b095 100644 --- a/srsenb/hdr/phy/phy_common.h +++ b/srsenb/hdr/phy/phy_common.h @@ -137,11 +137,18 @@ public: return c; }; - void set_cell_gain(uint32_t cc_idx, float gain_db) + void set_cell_gain(uint32_t cell_id, float gain_db) { - if (cc_idx < cell_list.size()) { - cell_list.at(cc_idx).gain_db = gain_db; + auto it = + std::find_if(cell_list.begin(), cell_list.end(), [cell_id](phy_cell_cfg_t& x) { return x.cell_id == cell_id; }); + + // Check if the cell was found; + if (it == cell_list.end()) { + srslte::console("cell ID %d not found\n", cell_id); + return; } + + it->gain_db = gain_db; } float get_cell_gain(uint32_t cc_idx) diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index ad7b12761..1dbcd0733 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -209,9 +209,9 @@ bool enb::get_metrics(enb_metrics_t* m) return true; } -void enb::cmd_cell_gain(uint32_t cell_idx, float gain) +void enb::cmd_cell_gain(uint32_t cell_id, float gain) { - phy->cmd_cell_gain(cell_idx, gain); + phy->cmd_cell_gain(cell_id, gain); } srslte::LOG_LEVEL_ENUM enb::level(std::string l) diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 8d5a5f399..7bff78df5 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -427,16 +427,16 @@ static void* input_loop(metrics_stdout* metrics, srsenb::enb_command_interface* raise(SIGTERM); } else if (cmd[0] == "cell_gain") { if (cmd.size() != 3) { - cout << "Usage: " << cmd[0] << " [cell index] [gain in dB]" << endl; + cout << "Usage: " << cmd[0] << " [cell identifier] [gain in dB]" << endl; continue; } // Parse command arguments - uint32_t cell_idx = srslte::string_cast(cmd[1]); + uint32_t cell_id = srslte::string_cast(cmd[1]); float gain_db = srslte::string_cast(cmd[2]); // Set cell gain - control->cmd_cell_gain(cell_idx, gain_db); + control->cmd_cell_gain(cell_id, gain_db); } else { cout << "Available commands: " << endl; cout << " t: starts console trace" << endl; diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index c41a2ce16..2422a64c0 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -220,9 +220,9 @@ void phy::get_metrics(phy_metrics_t metrics[ENB_METRICS_MAX_USERS]) } } -void phy::cmd_cell_gain(uint32_t cc_idx, float gain_db) +void phy::cmd_cell_gain(uint32_t cell_id, float gain_db) { - workers_common.set_cell_gain(cc_idx, gain_db); + workers_common.set_cell_gain(cell_id, gain_db); } /***** RRC->PHY interface **********/