From fb84abece3df291f424f5502474468dc4b0cd695 Mon Sep 17 00:00:00 2001
From: Nick Ho <nick133371@gmail.com>
Date: Sat, 10 Feb 2018 07:19:45 -0800
Subject: [PATCH] Modify do sib 1 nb-iot

---
 openair2/LAYER2/MAC/config_NB_IoT.c          | 17 ++----------
 openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c | 28 ++++++++------------
 openair2/RRC/LITE/rrc_eNB.c                  |  2 ++
 3 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/openair2/LAYER2/MAC/config_NB_IoT.c b/openair2/LAYER2/MAC/config_NB_IoT.c
index 236a988c5a..57163f8e1e 100644
--- a/openair2/LAYER2/MAC/config_NB_IoT.c
+++ b/openair2/LAYER2/MAC/config_NB_IoT.c
@@ -431,28 +431,15 @@ void rrc_mac_config_req_NB_IoT(
         mac_config->sib1_NB_IoT_sched_config.starting_rf = (intptr_t)(sib1_NB_IoT->si_RadioFrameOffset_r13);
         mac_config->si_window_length = sib1_NB_IoT->si_WindowLength_r13;
 
-        SchedulingInfo_NB_r13_t *scheduling_info_list;
-
 
         ///OAI only supports SIB2/3-NB for the sibs
-        if ( sib1_NB_IoT->schedulingInfoList_r13.list.array[0] != NULL){ 
-            scheduling_info_list = sib1_NB_IoT->schedulingInfoList_r13.list.array[0];
-
-            mac_config->sibs_NB_IoT_sched[0].si_periodicity =   scheduling_info_list->si_Periodicity_r13 ;
-            //printf("Pass first SIBs Asn, SI P:%d\n",mac_config->sibs_NB_IoT_sched[0].si_periodicity);
-            mac_config->sibs_NB_IoT_sched[0].si_repetition_pattern =  scheduling_info_list->si_RepetitionPattern_r13 ;
-            mac_config->sibs_NB_IoT_sched[0].sib_mapping_info =   scheduling_info_list->sib_MappingInfo_r13.list.array[0][0];
-            mac_config->sibs_NB_IoT_sched[0].si_tb =      scheduling_info_list->si_TB_r13  ;
-          
-        } else { //set this value for now to be test further
 
             mac_config->sibs_NB_IoT_sched[0].si_periodicity =   si_Periodicity_rf4096 ;
             mac_config->sibs_NB_IoT_sched[0].si_repetition_pattern =  si_RepetitionPattern_every2ndRF;
      
             mac_config->sibs_NB_IoT_sched[0].sib_mapping_info =   sib3_v;
             mac_config->sibs_NB_IoT_sched[0].si_tb =      si_TB_680;
-        }
-
+        /*
         /// Thiese value is setting for different SIB set
        if ( sib1_NB_IoT->schedulingInfoList_r13.list.array[1] != NULL) {
             scheduling_info_list = sib1_NB_IoT->schedulingInfoList_r13.list.array[1];
@@ -482,13 +469,13 @@ void rrc_mac_config_req_NB_IoT(
         mac_config->sibs_NB_IoT_sched[3].sib_mapping_info = 0x0;
         mac_config->sibs_NB_IoT_sched[4].sib_mapping_info = 0x0;
         mac_config->sibs_NB_IoT_sched[5].sib_mapping_info = 0x0;
+        */
 
     }else{
          LOG_E(MAC,"sib1_NB_IoT is NULL\n"); 
     }
 
 
-
     if (radioResourceConfigCommon!=NULL) {
 
         //if(cfg == NULL) LOG_E(MAC, "rrc_mac_config_req_eNB_NB_IoT: trying to configure PHY but no config.request message in config_INFO is allocated\n");
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c b/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c
index b13a3b021a..f4dfd2c0ba 100644
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg_NB_IoT.c
@@ -177,8 +177,8 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
 
   PLMN_IdentityInfo_NB_r13_t PLMN_identity_info_NB_IoT;
   MCC_MNC_Digit_t dummy_mcc[3],dummy_mnc[3];
-  SchedulingInfo_NB_r13_t *schedulingInfo_NB_IoT;
-  SIB_Type_NB_r13_t *sib_type_NB_IoT;
+  SchedulingInfo_NB_r13_t schedulingInfo_NB_IoT;
+  SIB_Type_NB_r13_t sib_type_NB_IoT;
 
 
   long* attachWithoutPDN_Connectivity = NULL;
@@ -192,7 +192,9 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
   memset(bcch_message,0,sizeof(BCCH_DL_SCH_Message_NB_t));
   bcch_message->message.present = BCCH_DL_SCH_MessageType_NB_PR_c1;
   bcch_message->message.choice.c1.present = BCCH_DL_SCH_MessageType_NB__c1_PR_systemInformationBlockType1_r13;
-
+  
+  memset(&schedulingInfo_NB_IoT,0,sizeof(SchedulingInfo_NB_r13_t));
+  memset(&sib_type_NB_IoT,0,sizeof(SIB_Type_NB_r13_t));
   //allocation
   *sib1_NB_IoT = &bcch_message->message.choice.c1.choice.systemInformationBlockType1_r13;
 
@@ -342,22 +344,14 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
    *nrs_CRS_PowerOffset= 0;
    (*sib1_NB_IoT)->nrs_CRS_PowerOffset_r13 = nrs_CRS_PowerOffset;
 
-   schedulingInfo_NB_IoT = (SchedulingInfo_NB_r13_t*) malloc (3*sizeof(SchedulingInfo_NB_r13_t));
-   sib_type_NB_IoT = (SIB_Type_NB_r13_t *) malloc (3*sizeof(SIB_Type_NB_r13_t));
 
-  memset(&schedulingInfo_NB_IoT[0],0,sizeof(SchedulingInfo_NB_r13_t));
-  memset(&schedulingInfo_NB_IoT[1],0,sizeof(SchedulingInfo_NB_r13_t));
-  memset(&schedulingInfo_NB_IoT[2],0,sizeof(SchedulingInfo_NB_r13_t));    
-  memset(&sib_type_NB_IoT[0],0,sizeof(SIB_Type_NB_r13_t));
-  memset(&sib_type_NB_IoT[1],0,sizeof(SIB_Type_NB_r13_t));
-  memset(&sib_type_NB_IoT[2],0,sizeof(SIB_Type_NB_r13_t));
 
 
   // Now, follow the scheduler SIB configuration
   // There is only one sib2+sib3 common setting
-  schedulingInfo_NB_IoT[0].si_Periodicity_r13=SchedulingInfo_NB_r13__si_Periodicity_r13_rf4096;
-  schedulingInfo_NB_IoT[0].si_RepetitionPattern_r13=SchedulingInfo_NB_r13__si_RepetitionPattern_r13_every2ndRF; //This Indicates the starting radio frames within the SI window used for SI message transmission.
-  schedulingInfo_NB_IoT[0].si_TB_r13= SchedulingInfo_NB_r13__si_TB_r13_b680;//208 bits
+  schedulingInfo_NB_IoT.si_Periodicity_r13=SchedulingInfo_NB_r13__si_Periodicity_r13_rf4096;
+  schedulingInfo_NB_IoT.si_RepetitionPattern_r13=SchedulingInfo_NB_r13__si_RepetitionPattern_r13_every2ndRF; //This Indicates the starting radio frames within the SI window used for SI message transmission.
+  schedulingInfo_NB_IoT.si_TB_r13= SchedulingInfo_NB_r13__si_TB_r13_b680;//208 bits
   
 
   // This is for SIB2/3
@@ -365,10 +359,10 @@ uint8_t do_SIB1_NB_IoT(uint8_t Mod_id, int CC_id,
     *  in the first SystemInformation message
     * listed in the schedulingInfoList list.
     * */
-  sib_type_NB_IoT[0]=SIB_Type_NB_r13_sibType3_NB_r13;
+  sib_type_NB_IoT=SIB_Type_NB_r13_sibType3_NB_r13;
 
-  ASN_SEQUENCE_ADD(&schedulingInfo_NB_IoT[0].sib_MappingInfo_r13.list,&sib_type_NB_IoT[0]);
-  ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->schedulingInfoList_r13.list,&schedulingInfo_NB_IoT[0]);
+  ASN_SEQUENCE_ADD(&schedulingInfo_NB_IoT.sib_MappingInfo_r13.list,&sib_type_NB_IoT);
+  ASN_SEQUENCE_ADD(&(*sib1_NB_IoT)->schedulingInfoList_r13.list,&schedulingInfo_NB_IoT);
 
   //printf("[ASN Debug] SI P: %ld\n",(*sib1_NB_IoT)->schedulingInfoList_r13.list.array[0]->si_Periodicity_r13);
 
diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c
index 17f8703f66..e8ce96c6cf 100644
--- a/openair2/RRC/LITE/rrc_eNB.c
+++ b/openair2/RRC/LITE/rrc_eNB.c
@@ -232,6 +232,8 @@ void init_testing_NB_IoT(uint8_t Mod_id, int CC_id, rrc_eNB_carrier_data_NB_IoT_
                                   0,
                                   0
                                   );
+
+      LOG_I(MAC,"testing_NB_IoT config done\n");
   } else {
       LOG_E(RRC, " init_SI: FATAL, no memory for SIB23_NB_IoT allocated\n");
     //exit here
-- 
2.26.2