rrc_nr: add basic interface for NAS

master
Andre Puschmann 3 years ago
parent a15962c817
commit ccd4334672

@ -121,8 +121,6 @@ public:
void set_sib3(const asn1::rrc_nr::sib3_s& sib3_);
const asn1::rrc_nr::sib1_s* sib1ptr() const { return has_sib1() ? &sib1 : nullptr; }
const asn1::rrc_nr::sib2_s* sib2ptr() const { return has_sib2() ? &sib2 : nullptr; }
const asn1::rrc_nr::sib3_s* sib3ptr() const { return has_sib3() ? &sib3 : nullptr; }
uint32_t get_cell_id() const { return (uint32_t)0xFFFF; } // TODO find the correct sib
@ -131,11 +129,7 @@ public:
std::string to_string() const;
bool has_mcch = false;
asn1::rrc_nr::sib1_s sib1 = {};
asn1::rrc_nr::sib2_s sib2 = {};
asn1::rrc_nr::sib3_s sib3 = {};
asn1::rrc::mcch_msg_s mcch = {};
};
class meas_cell_eutra : public meas_cell

@ -13,6 +13,7 @@
#ifndef SRSUE_RRC_NR_H
#define SRSUE_RRC_NR_H
#include "../rrc/rrc_cell.h"
#include "rrc_nr_config.h"
#include "srsran/adt/circular_map.h"
#include "srsran/asn1/rrc_nr.h"
@ -40,6 +41,7 @@ class rrc_nr final : public rrc_interface_phy_nr,
public rrc_interface_rlc,
public rrc_interface_mac,
public rrc_nr_interface_rrc,
public rrc_nr_interface_nas_5g,
public srsran::timer_callback
{
public:
@ -101,6 +103,13 @@ public:
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
void notify_pdcp_integrity_error(uint32_t lcid) final;
// NAS interface
int write_sdu(srsran::unique_byte_buffer_t sdu);
bool is_connected();
int connection_request(srsran::nr_establishment_cause_t cause, srsran::unique_byte_buffer_t sdu);
uint16_t get_mcc();
uint16_t get_mnc();
// RRC (LTE) interface
int get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps);
int get_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps);
@ -122,6 +131,9 @@ public:
void set_phy_config_complete(bool status) final;
private:
// senders
void send_ul_info_transfer(srsran::unique_byte_buffer_t nas_msg);
srsran::task_sched_handle task_sched;
struct cmd_msg_t {
enum { PDU, PCCH, PDU_MCH, RLF, PDU_BCCH_DLSCH, STOP } command;
@ -145,6 +157,8 @@ private:
usim_interface_rrc_nr* usim = nullptr;
stack_interface_rrc* stack = nullptr;
meas_cell_list<meas_cell_nr> meas_cells;
const uint32_t sim_measurement_timer_duration_ms = 250;
uint32_t sim_measurement_carrier_freq_r15;
srsran::timer_handler::unique_timer sim_measurement_timer;
@ -157,8 +171,7 @@ private:
RRC_NR_STATE_N_ITEMS,
};
const static char* rrc_nr_state_text[RRC_NR_STATE_N_ITEMS];
// rrc_nr_state_t state = RRC_NR_STATE_IDLE;
rrc_nr_state_t state = RRC_NR_STATE_IDLE;
// Stores the state of the PHy configuration setting
enum {

@ -171,6 +171,41 @@ uint16_t meas_cell_eutra::get_mnc() const
return 0;
}
uint16_t meas_cell_nr::get_mcc() const
{
uint16_t mcc = 0;
if (has_valid_sib1) {
if (sib1.cell_access_related_info.plmn_id_list.size() > 0) {
// PLMN ID list is nested twice
if (sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list.size() > 0) {
if (sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0].mcc_present) {
if (srsran::bytes_to_mcc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0].mcc[0], &mcc)) {
// successfully read MCC
}
}
}
}
}
return mcc;
}
uint16_t meas_cell_nr::get_mnc() const
{
uint16_t mnc = 0;
if (has_valid_sib1) {
if (sib1.cell_access_related_info.plmn_id_list.size() > 0) {
if (sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list.size() > 0) {
if (srsran::bytes_to_mnc(&sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0].mnc[0],
&mnc,
sib1.cell_access_related_info.plmn_id_list[0].plmn_id_list[0].mnc.size())) {
// successfully read MNC
}
}
}
}
return mnc;
}
/*********************************************
* Neighbour Cell List
********************************************/

@ -8,6 +8,5 @@
add_subdirectory(test)
set(SOURCES rrc_nr.cc)
add_library(srsue_rrc_nr STATIC ${SOURCES})
set(SOURCES rrc_nr.cc ../rrc/rrc_cell.cc)
add_library(srsue_rrc_nr STATIC ${SOURCES})

@ -31,7 +31,7 @@ namespace srsue {
const char* rrc_nr::rrc_nr_state_text[] = {"IDLE", "CONNECTED", "CONNECTED-INACTIVE"};
rrc_nr::rrc_nr(srsran::task_sched_handle task_sched_) :
logger(srslog::fetch_basic_logger("RRC-NR")), task_sched(task_sched_), conn_recfg_proc(this)
logger(srslog::fetch_basic_logger("RRC-NR")), task_sched(task_sched_), conn_recfg_proc(this), meas_cells(task_sched_)
{}
rrc_nr::~rrc_nr() = default;
@ -209,6 +209,44 @@ void rrc_nr::write_pdu_pcch(srsran::unique_byte_buffer_t pdu) {}
void rrc_nr::write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) {}
void rrc_nr::notify_pdcp_integrity_error(uint32_t lcid) {}
// NAS interface
int rrc_nr::write_sdu(srsran::unique_byte_buffer_t sdu)
{
if (state == RRC_NR_STATE_IDLE) {
logger.warning("Received ULInformationTransfer SDU when in IDLE");
return SRSRAN_ERROR;
}
send_ul_info_transfer(std::move(sdu));
return SRSRAN_SUCCESS;
}
bool rrc_nr::is_connected()
{
return false;
}
int rrc_nr::connection_request(srsran::nr_establishment_cause_t cause, srsran::unique_byte_buffer_t sdu)
{
return SRSRAN_SUCCESS;
}
uint16_t rrc_nr::get_mcc()
{
return meas_cells.serving_cell().get_mcc();
}
uint16_t rrc_nr::get_mnc()
{
return meas_cells.serving_cell().get_mnc();
}
// Senders
void rrc_nr::send_ul_info_transfer(unique_byte_buffer_t nas_msg)
{
logger.warning("%s not implemented yet.", __FUNCTION__);
}
// EUTRA-RRC interface
int rrc_nr::get_eutra_nr_capabilities(srsran::byte_buffer_t* eutra_nr_caps_pdu)
{
struct ue_mrdc_cap_s mrdc_cap;

@ -7,4 +7,4 @@
#
add_executable(ue_rrc_nr_test ue_rrc_nr_test.cc)
target_link_libraries(ue_rrc_nr_test srsue_rrc_nr srsue_upper srsran_common srsran_pdcp srsran_phy rrc_asn1 rrc_nr_asn1)
target_link_libraries(ue_rrc_nr_test srsue_rrc srsue_rrc_nr srsue_upper srsran_common srsran_pdcp srsran_phy rrc_asn1 rrc_nr_asn1)
Loading…
Cancel
Save