Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
if (unpackResult == asn1::SRSASN_SUCCESS)
{
int msgTypeValue =
dlsch_msg.msg.type().value;
// printf("dlsch_msg.msg.type().value=%d\n", msgTypeValue);
if (msgTypeValue == 0)
{
if (dlsch_msg.msg.c1().type().value
== asn1::rrc::bcch_dl_sch_msg_type_c::c1_c_::types::sib_type1)
{
// printf("Accessing
dlsch_msg.msg.c1().sib_type1()\n");
asn1::rrc::sib_type1_s *sib1 = &dlsch_msg.msg.c1().sib_type1();
// printf("Accessing
sib1->cell_access_related_info.plmn_id_list[0].plmn_id\n");
asn1::rrc::plmn_id_s plmn =
sib1->cell_access_related_info.plmn_id_list[0].plmn_id;
std::string plmn_string =
srslte::plmn_id_to_string(plmn);
uint16_t mcc;
uint16_t mnc;
// If we were using C++11 we
could just use stoi
mcc =
atoi(plmn_string.substr(0, 3).c_str());
mnc =
atoi(plmn_string.substr(3, plmn_string.length() - 3).c_str());
// srslte::bytes_to_mcc(&plmn.mcc[0], &mcc);
// srslte::bytes_to_mnc(&plmn.mnc[0], &mnc, plmn.mnc.size());
www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 1/3
5/21/2020 [srslte-users] unpack sib1 in examples/cell_measurement.c
printf("MCC=%d, MNC=%d\n", mcc,
mnc);
if ((mnc != 0) && (mcc != 0))
{
// go_exit = true;
state = MEASURE;
}
}
}
}
//state = MEASURE;
In my case I wanted the MCC and MNC codes. The string conversion is
clumsy, and as you can see by the commented lines, I had tried to use
the bytes_to_mcc() functions directly, but that didn't work, and I don't
know why. I tried to debug the code in Eclipse, and while I could debug
it and see the class/structure data, I still didn't understand why those
functions didn't work. I had way bigger fish to fry, so I left the code
alone since at least it worked. You should be able to extend it to get
the other elements contained in SIB1.
www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 2/3
5/21/2020 [srslte-users] unpack sib1 in examples/cell_measurement.c
www.softwareradiosystems.com/pipermail/srslte-users/2019-April/002465.html 3/3