From 31f1516d748b61c5350768ec4337585cf80fab79 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Mon, 18 May 2020 16:40:27 +0200 Subject: [PATCH] Use callback to establish connection before sending PDUs in TestmodeB --- srsue/hdr/stack/ue_stack_lte.h | 2 +- srsue/test/ttcn3/hdr/ttcn3_ue.h | 2 ++ srsue/test/ttcn3/src/ttcn3_ue.cc | 27 ++++++++++++++++++++------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 8f311c8ba..d98b287d4 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -72,7 +72,7 @@ public: void stop() final; bool get_metrics(stack_metrics_t* metrics) final; - bool is_rrc_connected(); + bool is_rrc_connected() { return rrc.is_connected(); }; // RRC interface for PHY void in_sync() final; diff --git a/srsue/test/ttcn3/hdr/ttcn3_ue.h b/srsue/test/ttcn3/hdr/ttcn3_ue.h index 621e01641..7e57fc766 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ue.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ue.h @@ -70,6 +70,8 @@ public: void timer_expired(uint32_t timeout_id); + void send_queued_data(); + void loop_back_pdu_with_tft(uint32_t input_lcid, srslte::unique_byte_buffer_t pdu); private: diff --git a/srsue/test/ttcn3/src/ttcn3_ue.cc b/srsue/test/ttcn3/src/ttcn3_ue.cc index 447c5e781..45913c982 100644 --- a/srsue/test/ttcn3/src/ttcn3_ue.cc +++ b/srsue/test/ttcn3/src/ttcn3_ue.cc @@ -226,13 +226,26 @@ void ttcn3_ue::timer_expired(uint32_t timeout_id) { if (timeout_id == pdu_delay_timer.id()) { log.info("Testmode B PDU delay timer expired\n"); - for (auto& bearer_pdu_queue : pdu_queue) { - log.info("Delivering %zd buffered PDUs for LCID=%d\n", bearer_pdu_queue.second.size(), bearer_pdu_queue.first); - while (not bearer_pdu_queue.second.empty()) { - srslte::unique_byte_buffer_t pdu; - bearer_pdu_queue.second.try_pop(&pdu); - loop_back_pdu_with_tft(bearer_pdu_queue.first, std::move(pdu)); - } + send_queued_data(); + } +} +void ttcn3_ue::send_queued_data() +{ + if (!stack->is_rrc_connected()) { + log.info("RRC not connected, requesting NAS attach\n"); + if (not stack->switch_on()) { + log.warning("Could not reestablish the connection\n"); + } + stack->defer_callback(500, [&]() { send_queued_data(); }); + return; + } + + for (auto& bearer_pdu_queue : pdu_queue) { + log.info("Delivering %zd buffered PDUs for LCID=%d\n", bearer_pdu_queue.second.size(), bearer_pdu_queue.first); + while (not bearer_pdu_queue.second.empty()) { + srslte::unique_byte_buffer_t pdu; + bearer_pdu_queue.second.try_pop(&pdu); + loop_back_pdu_with_tft(bearer_pdu_queue.first, std::move(pdu)); } } }