From a0f2d4815e013c70b428da5597b58fd18aa5b89d Mon Sep 17 00:00:00 2001
From: "islam.galal" <igalal.ext@orange.com>
Date: Wed, 16 Aug 2017 16:17:40 +0200
Subject: [PATCH] eMTC modem receives SIB1 & SIB23 successfully

---
 openair2/ENB_APP/enb_config.c                 |  2 +-
 openair2/RRC/LITE/MESSAGES/asn1_msg.c         | 32 +++++++++++++++----
 .../CONF/enb.band13.tm1.50PRB.emtc.conf       | 22 +++++++------
 3 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 325dfceda78..26c0f51214e 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -4063,7 +4063,7 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) {
                   RRC_CONFIGURATION_REQ(msg_p).si_HoppingConfigCommon_r13[j] = si_HoppingConfigCommon_r13;
                   RRC_CONFIGURATION_REQ(msg_p).startSymbolBR_r13[j] = startSymbolBR_r13;
 
-                  if (config_setting_lookup_int(setting_br13, ENB_CONFIG_STRING_Q_QUALMINRSRQ_CE, &si_ValidityTime_r13))
+                  if (config_setting_lookup_int(setting_br13, ENB_CONFIG_STRING_SI_VALIDITYTIME, &si_ValidityTime_r13))
                   {
                     RRC_CONFIGURATION_REQ(msg_p).si_ValidityTime_r13[j] = calloc(1, sizeof(long));
                     *RRC_CONFIGURATION_REQ(msg_p).si_ValidityTime_r13[j] = si_ValidityTime_r13;
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
index f339c4182d2..af2292d132f 100755
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
@@ -608,10 +608,15 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
               else
               {
                   sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->present
-                        = SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13_PR_subframePattern10_r13;
+                        = SystemInformationBlockType1_v1310_IEs__bandwidthReducedAccessRelatedInfo_r13__fdd_DownlinkOrTddSubframeBitmapBR_r13_PR_subframePattern40_r13;
 
                   sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf = calloc(5, sizeof(uint8_t));
-                  memmove(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf, &configuration->fdd_DownlinkOrTddSubframeBitmapBR_val_r13[CC_id], 5 * sizeof(uint8_t));
+//                  memmove(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf, &configuration->fdd_DownlinkOrTddSubframeBitmapBR_val_r13[CC_id], 5 * sizeof(uint8_t));
+                  int bm_index;
+                  for (bm_index = 0; bm_index < 5; bm_index++)
+                  {
+                      sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.buf[bm_index] = 0xFF;
+                  }
                   sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.size = 5;
                   sib1_1310->bandwidthReducedAccessRelatedInfo_r13->fdd_DownlinkOrTddSubframeBitmapBR_r13->choice.subframePattern40_r13.bits_unused = 0;
               }
@@ -647,6 +652,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,
               sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = calloc(1, sizeof(long));
               memset(sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13, 0, sizeof(long));
               *sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13 = *configuration->si_ValidityTime_r13[CC_id];
+              printf("[DEBUGGING][KOGO]: si_validity time = %d\n", *sib1_1310->bandwidthReducedAccessRelatedInfo_r13->si_ValidityTime_r13);
           }
           else
           {
@@ -1783,16 +1789,16 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
   (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL;
 
-  (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch=NULL;
-  (*sib3)->cellReselectionServingFreqInfo.threshServingLow=31;
-  (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority=7;
+  (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch        = NULL;
+  (*sib3)->cellReselectionServingFreqInfo.threshServingLow        = 0;
+  (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch        = 0;
+  (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority = 7;
 
   (*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70;
   (*sib3)->intraFreqCellReselectionInfo.p_Max = NULL;
   (*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch));
   *(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31;
   (*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth));
-
   *(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth = AllowedMeasBandwidth_mbw6;
 
   (*sib3)->intraFreqCellReselectionInfo.presenceAntennaPort1 = 0;
@@ -1800,9 +1806,21 @@ uint8_t do_SIB23(uint8_t Mod_id,
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.size = 1;
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf[0] = 1;
   (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.bits_unused = 6;
-  (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 1;
+  (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 2;
   (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA_SF = (struct SpeedStateScaleFactors *)NULL;
 
+  (*sib3)->ext1 = CALLOC(1, sizeof(struct SystemInformationBlockType3__ext1));
+  (*sib3)->ext1->s_IntraSearch_v920 = CALLOC(1, sizeof(struct SystemInformationBlockType3__ext1__s_IntraSearch_v920));
+  (*sib3)->ext1->s_IntraSearch_v920->s_IntraSearchP_r9 = 31; // FIXME
+  (*sib3)->ext1->s_IntraSearch_v920->s_IntraSearchQ_r9 = 4;
+
+  (*sib3)->ext4 = CALLOC(1, sizeof(struct SystemInformationBlockType3__ext4));
+  (*sib3)->ext4->cellSelectionInfoCE_r13 = CALLOC(1, sizeof(CellSelectionInfoCE_r13_t));
+  (*sib3)->ext4->cellSelectionInfoCE_r13->q_RxLevMinCE_r13 = -70;
+  (*sib3)->ext4->cellSelectionInfoCE_r13->q_QualMinRSRQ_CE_r13 = NULL;
+  (*sib3)->ext4->t_ReselectionEUTRA_CE_r13 = CALLOC(1, sizeof(T_ReselectionEUTRA_CE_r13_t));
+  *(*sib3)->ext4->t_ReselectionEUTRA_CE_r13 = 2;
+
   // SIB13
   // fill in all elements of SIB13 if present
 #if defined(Rel10) || defined(Rel14)
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf
index 6b5e62f2c7f..7baa08b3bee 100755
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band13.tm1.50PRB.emtc.conf
@@ -109,12 +109,16 @@ eNBs =
       # BR Parameters
       br_parameters : 
       {
+
+          fdd_DownlinkOrTddSubframeBitmapBR_r13 = "subframePattern40-r13"; 
+          fdd_DownlinkOrTddSubframeBitmapBR_val_r13 = 0xFFFFFFFFFF;
+
           #SIB1
           schedulingInfoSIB1_BR_r13                   = 4;
-          hyperSFN_r13                                = 0;
+          #hyperSFN_r13                                = 0;
           #eDRX_Allowed_r13                           = 0;
           cellSelectionInfoCE_r13                     = "ENABLE";
-          q_RxLevMinCE_r13                            = -50;
+          q_RxLevMinCE_r13                            = -70;
           #q_QualMinRSRQ_CE_r13                       = ;
           bandwidthReducedAccessRelatedInfo_r13       = "ENABLE"   
           scheduling_info_br =
@@ -129,12 +133,12 @@ eNBs =
           startSymbolBR_r13                           = 3;
           si_HoppingConfigCommon_r13                  = 1; # Note: 1==OFF !
           si_ValidityTime_r13                         = 0;
-          system_info_value_tag_SI = 
-          (
-              {
-                  systemInfoValueTagSi_r13 = 0;
-              }
-          );
+          #system_info_value_tag_SI = 
+          #(
+          #    {
+          #        systemInfoValueTagSi_r13 = 0;
+          #    }
+          #);
           freqHoppingParametersDL_r13                 = "DISABLE"
           mpdcch_pdsch_HoppingNB_r13                  = 0;
           interval_DLHoppingConfigCommonModeA_r13     = "interval-FDD-r13"
@@ -196,7 +200,7 @@ eNBs =
           {
               paging_narrowbands_r13          = 1;
               mpdcch_numrepetition_paging_r13 = 0;
-              nb_v1310                        = 2;
+              #nb_v1310                        = 2;
           }
 
 
-- 
GitLab