From 10dec919ce087f4f42936f4b26808f58afa0bb36 Mon Sep 17 00:00:00 2001
From: Melissa Elkadi <melissa@episci.com>
Date: Thu, 4 Nov 2021 11:11:13 -0700
Subject: [PATCH] Temp fix to try to get CBRA procdeure complete

Need to review this with Raymond.
---
 openair2/RRC/NR_UE/rrc_UE.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index 99bd7ff091..13cb2b7f78 100644
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -1762,8 +1762,13 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB
  //-----------------------------------------------------------------------------
  void nr_rrc_ue_generate_RRCSetupRequest(module_id_t module_id, const uint8_t gNB_index) {
    uint8_t i=0,rv[6];
-
-   if(get_softmodem_params()->sa) {
+   /* TODO: Melissa, this is not a proper fix. The NAS layer should be
+      getting intialized and then the substate will not crash when AMF_MODE_ENABLED
+      is equal to 1. However, as a side note, when we keep the code below,
+      once the CBRA procedure is finished, the NAS layer is ran and the AMF_MODE_ENABLED
+      is switched to one and the substate assertion in the nr_rrc_set_sub_state()
+      does not happen. So show this to Raymond and maybe its okay? */
+   if(get_softmodem_params()->sa && !get_softmodem_params()->emulate_l2) {
      AMF_MODE_ENABLED = 1;
    }
    if(NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size ==0) {
-- 
2.26.2