/** * * \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/ul_dcch_msg.h" #include "srslte/asn1/rrc_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/interfaces/rrc_interface_types.h" #include #define TESTASSERT(cond) \ { \ if (!(cond)) { \ std::cout << "[" << __FUNCTION__ << "][Line " << __LINE__ << "]: FAIL at " << (#cond) << std::endl; \ return -1; \ } \ } using namespace asn1; using namespace asn1::rrc; int meas_obj_test() { uint8_t rrc_msg[] = { 0x08, 0x10, 0x49, 0x3C, 0x0D, 0x97, 0x89, 0x83, 0xC0, 0x84, 0x20, 0x82, 0x08, 0x21, 0x00, 0x01, 0xBC, 0x48}; uint32_t rrc_msg_len = sizeof(rrc_msg); // 0810493C0D978983C084208208210001BC48 cbit_ref bref(&rrc_msg[0], sizeof(rrc_msg)); ul_dcch_msg_s ul_dcch_msg; ul_dcch_msg.unpack(bref); TESTASSERT(ul_dcch_msg.msg.type() == ul_dcch_msg_type_c::types::c1); TESTASSERT(ul_dcch_msg.msg.c1().type() == ul_dcch_msg_type_c::c1_c_::types::meas_report); meas_report_s* rep = &ul_dcch_msg.msg.c1().meas_report(); TESTASSERT(rep->crit_exts.type() == meas_report_s::crit_exts_c_::types::c1); TESTASSERT(rep->crit_exts.c1().type() == meas_report_s::crit_exts_c_::c1_c_::types::meas_report_r8); TESTASSERT(not rep->crit_exts.c1().meas_report_r8().non_crit_ext_present); meas_results_s* meas = &rep->crit_exts.c1().meas_report_r8().meas_results; TESTASSERT(not meas->ext); TESTASSERT(meas->meas_id == 1); TESTASSERT(meas->meas_result_pcell.rsrp_result == 73); TESTASSERT(meas->meas_result_pcell.rsrq_result == 15); TESTASSERT(meas->meas_result_neigh_cells_present); TESTASSERT(meas->meas_result_neigh_cells.type() == meas_results_s::meas_result_neigh_cells_c_::types::meas_result_list_eutra); meas_result_list_eutra_l& meas_list = meas->meas_result_neigh_cells.meas_result_list_eutra(); TESTASSERT(meas_list.size() == 1); TESTASSERT(meas_list[0].pci == 357); TESTASSERT(meas_list[0].cgi_info_present); TESTASSERT(meas_list[0].cgi_info.plmn_id_list_present); TESTASSERT(meas_list[0].cgi_info.cell_global_id.plmn_id.mcc_present); srslte::plmn_id_t plmn = srslte::make_plmn_id_t(meas_list[0].cgi_info.cell_global_id.plmn_id); TESTASSERT(plmn.to_string() == "89878"); TESTASSERT(meas_list[0].cgi_info.cell_global_id.cell_id.to_number() == 0x1084104); TESTASSERT(meas_list[0].cgi_info.tac.to_number() == 0x1042); TESTASSERT(meas_list[0].cgi_info.plmn_id_list.size() == 1); TESTASSERT(not meas_list[0].cgi_info.plmn_id_list[0].mcc_present); TESTASSERT(not meas_list[0].meas_result.ext); TESTASSERT(meas_list[0].meas_result.rsrp_result_present); TESTASSERT(meas_list[0].meas_result.rsrp_result == 60); TESTASSERT(meas_list[0].meas_result.rsrq_result_present); TESTASSERT(meas_list[0].meas_result.rsrq_result == 18); uint8_t rrc_msg2[rrc_msg_len]; bzero(rrc_msg2, rrc_msg_len); bit_ref bref2(&rrc_msg2[0], sizeof(rrc_msg2)); ul_dcch_msg.pack(bref2); TESTASSERT(bref.distance() == bref2.distance()); TESTASSERT(memcmp(rrc_msg2, rrc_msg, rrc_msg_len) == 0); return 0; } int main(int argc, char** argv) { auto& asn1_logger = srslog::fetch_basic_logger("ASN1", false); asn1_logger.set_level(srslog::basic_levels::debug); asn1_logger.set_hex_dump_max_size(-1); srslog::init(); TESTASSERT(meas_obj_test() == 0); return 0; }