diff --git a/srsue/test/ttcn3/hdr/ttcn3_helpers.h b/srsue/test/ttcn3/hdr/ttcn3_helpers.h index d1785f2cf..a4d7ba4c7 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_helpers.h +++ b/srsue/test/ttcn3/hdr/ttcn3_helpers.h @@ -407,6 +407,77 @@ public: return config_flag.GetBool(); } + static std::string + get_rrc_pdu_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srslte::unique_byte_buffer_t pdubuf) + { + Document resp; + resp.SetObject(); + + // Create members of common object + + // CellId + Value cell(cell_.c_str(), resp.GetAllocator()); + + // RoutingInfo + Value radiobearer_id(kObjectType); + radiobearer_id.AddMember("Srb", lcid, resp.GetAllocator()); + Value routing_info(kObjectType); + routing_info.AddMember("RadioBearerId", radiobearer_id, resp.GetAllocator()); + + // TimingInfo + // SFN + uint32_t sfn = tti / 10; + Value sfn_key(kObjectType); + sfn_key.AddMember("Number", sfn, resp.GetAllocator()); + + // Actual subframe index + uint32_t sf_idx = tti % 10; + Value sf_idx_key(kObjectType); + sf_idx_key.AddMember("Number", sf_idx, resp.GetAllocator()); + + // Put it all together + Value subframe_key(kObjectType); + subframe_key.AddMember("SFN", sfn_key, resp.GetAllocator()); + subframe_key.AddMember("Subframe", sf_idx_key, resp.GetAllocator()); + + Value timing_info(kObjectType); + timing_info.AddMember("SubFrame", subframe_key, resp.GetAllocator()); + + // Status + Value status(kObjectType); + status.AddMember("Ok", true, resp.GetAllocator()); + + // Now, create the common object itself and add members + Value common(kObjectType); + common.AddMember("CellId", cell, resp.GetAllocator()); + common.AddMember("RoutingInfo", routing_info, resp.GetAllocator()); + common.AddMember("TimingInfo", timing_info, resp.GetAllocator()); + common.AddMember("Status", status, resp.GetAllocator()); + + resp.AddMember("Common", common, resp.GetAllocator()); + + // Add RRC PDU + std::string hexpdu = asn1::octstring_to_string(pdubuf->msg, pdubuf->N_bytes); + Value pdu(hexpdu.c_str(), resp.GetAllocator()); + + Value rrcpdu(kObjectType); + if (lcid == 0) { + rrcpdu.AddMember("Ccch", pdu, resp.GetAllocator()); + } else { + rrcpdu.AddMember("Dcch", pdu, resp.GetAllocator()); + } + + resp.AddMember("RrcPdu", rrcpdu, resp.GetAllocator()); + + // JSON-ize + StringBuffer buffer; + Writer writer(buffer); + resp.Accept(writer); + + // Return as std::string + return std::string(buffer.GetString()); + } + static std::string get_drb_common_ind_for_pdu(uint32_t tti, uint32_t lcid, const std::string cell_, srslte::unique_byte_buffer_t drbpdu) { diff --git a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h index 0a83ff219..73c2d7717 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h +++ b/srsue/test/ttcn3/hdr/ttcn3_srb_interface.h @@ -49,11 +49,12 @@ public: return port_listen(); } - void tx(unique_byte_buffer_t pdu) + void tx(std::string out) { if (initialized) { - log->info_hex(pdu->msg, pdu->N_bytes, "Sending %d B to Titan\n", pdu->N_bytes); - send(pdu->msg, pdu->N_bytes); + log->info_hex( + reinterpret_cast(out.c_str()), out.length(), "Sending %ld B to Titan\n", out.length()); + send(reinterpret_cast(out.c_str()), out.length()); } else { log->error("Trying to transmit but port not connected.\n"); } diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index 720a4b260..3d1a972d5 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -1025,23 +1025,9 @@ void ttcn3_syssim::write_pdu(uint32_t lcid, unique_byte_buffer_t pdu) // push content to Titan if (lcid <= 2) { - // check cell ID - if (cells[pcell_idx]->cell.id > 256) { - log->error("Cell ID too large to fit in single byte.\n"); - return; - } + std::string out = ttcn3_helpers::get_rrc_pdu_ind_for_pdu(tti, lcid, cells[pcell_idx]->name, std::move(pdu)); - // We don't handle RRC, prepend LCID - pdu->msg--; - *pdu->msg = lcid; - pdu->N_bytes++; - - // prepend pcell PCID - pdu->msg--; - *pdu->msg = static_cast(cells[pcell_idx]->cell.id); - pdu->N_bytes++; - - srb.tx(std::move(pdu)); + srb.tx(out); } else { std::string out = ttcn3_helpers::get_drb_common_ind_for_pdu(tti, lcid, cells[pcell_idx]->name, std::move(pdu)); log->error("DRB send:\n%s", out.c_str());