You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srsRAN_4G/lib/src/asn1/rrc_nr_utils.cc

79 lines
2.4 KiB
C++

/**
*
* \section COPYRIGHT
*
* Copyright 2013-2020 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srslte/asn1/rrc_nr_utils.h"
#include "srslte/asn1/rrc_nr.h"
#include "srslte/config.h"
#include <algorithm>
namespace srslte {
/***************************
* PLMN ID
**************************/
bool plmn_is_valid(const asn1::rrc_nr::plmn_id_s& asn1_type)
{
return asn1_type.mcc_present and (asn1_type.mnc.size() == 3 or asn1_type.mnc.size() == 2);
}
plmn_id_t make_plmn_id_t(const asn1::rrc_nr::plmn_id_s& asn1_type)
{
if (not plmn_is_valid(asn1_type)) {
return {};
}
plmn_id_t plmn;
std::copy(&asn1_type.mcc[0], &asn1_type.mcc[3], &plmn.mcc[0]);
plmn.nof_mnc_digits = asn1_type.mnc.size();
std::copy(&asn1_type.mnc[0], &asn1_type.mnc[plmn.nof_mnc_digits], &plmn.mnc[0]);
return plmn;
}
void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg)
{
asn1_type->mcc_present = true;
std::copy(&cfg.mcc[0], &cfg.mcc[3], &asn1_type->mcc[0]);
asn1_type->mnc.resize(cfg.nof_mnc_digits);
std::copy(&cfg.mnc[0], &cfg.mnc[cfg.nof_mnc_digits], &asn1_type->mnc[0]);
}
} // namespace srslte
namespace srsenb {
int set_sched_cell_cfg_sib1(srsenb::sched_interface::cell_cfg_t* sched_cfg, const asn1::rrc_nr::sib1_s& sib1)
{
bzero(sched_cfg, sizeof(srsenb::sched_interface::cell_cfg_t));
// set SIB1 and SIB2+ period
sched_cfg->sibs[0].period_rf = 16; // SIB1 is always 16 rf
for (uint32_t i = 0; i < sib1.si_sched_info.sched_info_list.size(); i++) {
sched_cfg->sibs[i + 1].period_rf = sib1.si_sched_info.sched_info_list[i].si_periodicity.to_number();
}
// si-WindowLength
sched_cfg->si_window_ms = sib1.si_sched_info.si_win_len.to_number();
// setup PRACH
if (not sib1.si_sched_info.si_request_cfg.rach_occasions_si_present) {
asn1::log_error("Expected RA Resp Win present\n");
return SRSLTE_ERROR;
}
sched_cfg->prach_rar_window = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.ra_resp_win.to_number();
sched_cfg->prach_freq_offset = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.msg1_freq_start;
sched_cfg->maxharq_msg3tx = sib1.si_sched_info.si_request_cfg.rach_occasions_si.rach_cfg_si.preamb_trans_max;
return SRSLTE_SUCCESS;
}
} // namespace srsenb