Initial gnb emulator

master
Xavier Arteaga 3 years ago committed by Ismael Gomez
parent b1bcc1a8c0
commit 47b857db25

@ -39,7 +39,10 @@ public:
bool init(const args_t& args);
int set_ul_grant(std::array<uint8_t, 27> packed_ul_grant, uint16_t rnti, srsran_rnti_type_t rnti_type) override
int set_ul_grant(uint32_t rar_slot_idx,
std::array<uint8_t, SRSRAN_RAR_UL_GRANT_NBITS> packed_ul_grant,
uint16_t rnti,
srsran_rnti_type_t rnti_type) override
{
return 0;
}

@ -114,7 +114,18 @@ void sync_sa::run_state_idle()
radio.rx_now(rf_buffer, ts);
}
void sync_sa::run_state_cell_search() {}
void sync_sa::run_state_cell_search()
{
// Run Searcher
if (not searcher.run()) {
logger.error("Failed to run searcher. Transitioning to IDLE...");
// Transition to IDLE if fails to run
state_mutex.lock();
next_state = STATE_IDLE;
state_mutex.unlock();
}
}
void sync_sa::run_thread()
{

@ -17,25 +17,75 @@ struct test_args_t {};
class gnb_emulator : public srsran::radio_interface_phy
{
private:
// srsran_ssb_t ssb = {};
const uint32_t BUFFER_SIZE_SF = 10;
const std::string LOGNAME = "RF";
uint32_t sf_len = 0;
srsran_ssb_t ssb = {};
srsran_ringbuffer_t ringbuffer = {};
cf_t* buffer = nullptr;
srslog::basic_logger& logger;
public:
struct args_t {
double srate_hz;
double srate_hz;
srsran_carrier_nr_t carrier;
srsran_subcarrier_spacing_t ssb_scs;
srsran_ssb_patern_t ssb_pattern;
srsran_ssb_patern_t ssb_periodicity_ms;
srsran_duplex_config_nr_t duplex;
};
gnb_emulator() {}
gnb_emulator(const args_t& args) : logger(srslog::fetch_basic_logger(LOGNAME))
{
sf_len = args.srate_hz / 1000;
srsran_ssb_args_t ssb_args = {};
ssb_args.enable_encode = true;
srsran_assert(srsran_ssb_init(&ssb, &ssb_args) == SRSRAN_SUCCESS, "SSB initialisation failed");
srsran_ssb_cfg_t ssb_cfg = {};
ssb_cfg.srate_hz = args.srate_hz;
ssb_cfg.center_freq_hz = args.carrier.dl_center_frequency_hz;
ssb_cfg.ssb_freq_hz = args.carrier.ssb_center_freq_hz;
ssb_cfg.scs = args.ssb_scs;
ssb_cfg.pattern = args.ssb_pattern;
ssb_cfg.duplex_mode = args.duplex.mode;
ssb_cfg.periodicity_ms = args.ssb_periodicity_ms;
srsran_assert(srsran_ssb_set_cfg(&ssb, &ssb_cfg) == SRSRAN_SUCCESS, "SSB set config failed");
srsran_assert(srsran_ringbuffer_init(&ringbuffer, sizeof(cf_t) * BUFFER_SIZE_SF * sf_len),
"Ringbuffer initialisation failed");
buffer = srsran_vec_cf_malloc(sf_len);
}
~gnb_emulator()
{
srsran_ssb_free(&ssb);
srsran_ringbuffer_free(&ringbuffer);
}
void tx_end() override {}
bool tx(srsran::rf_buffer_interface& buffer, const srsran::rf_timestamp_interface& tx_time) override { return false; }
bool rx_now(srsran::rf_buffer_interface& buffer, srsran::rf_timestamp_interface& rxd_time) override { return false; }
void set_tx_freq(const uint32_t& carrier_idx, const double& freq) override {}
void set_rx_freq(const uint32_t& carrier_idx, const double& freq) override {}
void release_freq(const uint32_t& carrier_idx) override {}
void set_tx_gain(const float& gain) override {}
void set_rx_gain_th(const float& gain) override {}
void set_rx_gain(const float& gain) override {}
void set_tx_srate(const double& srate) override {}
void set_rx_srate(const double& srate) override {}
void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override {}
bool rx_now(srsran::rf_buffer_interface& buffer, srsran::rf_timestamp_interface& rxd_time) override
{
uint32_t nbytes = sizeof(cf_t) * buffer.get_nof_samples();
// As long as there are not enough samples
while (srsran_ringbuffer_status(&ringbuffer) < nbytes) {
if (srsran_ringbuffer_write(&ringbuffer, ) < SRSRAN_SUCCESS) {
logger return false;
}
}
return true;
}
void set_tx_freq(const uint32_t& carrier_idx, const double& freq) override {}
void set_rx_freq(const uint32_t& carrier_idx, const double& freq) override {}
void release_freq(const uint32_t& carrier_idx) override {}
void set_tx_gain(const float& gain) override {}
void set_rx_gain_th(const float& gain) override {}
void set_rx_gain(const float& gain) override {}
void set_tx_srate(const double& srate) override {}
void set_rx_srate(const double& srate) override {}
void set_channel_rx_offset(uint32_t ch, int32_t offset_samples) override {}
double get_freq_offset() override { return 0; }
float get_rx_gain() override { return 0; }
bool is_continuous_tx() override { return false; }

Loading…
Cancel
Save