From 3555a021f148182d9b4a8b1a2898ba608b22d9d8 Mon Sep 17 00:00:00 2001
From: Nick Ho <nick133371@gmail.com>
Date: Tue, 12 Dec 2017 02:56:42 -0800
Subject: [PATCH] Debug with Scheduler

---
 openair2/LAYER2/MAC/config_NB_IoT.c           | 4 ++--
 openair2/LAYER2/MAC/defs_NB_IoT.h             | 2 +-
 openair2/LAYER2/MAC/eNB_scheduler_RA_NB_IoT.c | 2 ++
 openair2/LAYER2/MAC/proto_NB_IoT.h            | 2 +-
 openair2/LAYER2/MAC/schedule_tool_NB_IoT.c    | 3 +--
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/openair2/LAYER2/MAC/config_NB_IoT.c b/openair2/LAYER2/MAC/config_NB_IoT.c
index 789533550a..062f830187 100644
--- a/openair2/LAYER2/MAC/config_NB_IoT.c
+++ b/openair2/LAYER2/MAC/config_NB_IoT.c
@@ -72,7 +72,7 @@ int32_t get_uldl_offset_NB_IoT(int eutra_band) {
   return(-eutra_bandtable[eutra_band].dl_min + eutra_bandtable[eutra_band].ul_min);
 }
 
-uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl) {
+uint32_t to_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl) {
 
   uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq/100000;
 
@@ -198,7 +198,7 @@ void config_mib_fapi_NB_IoT(
      * 1) takes a random number from the offset of category NB1 and NB2 based on the operating mode (we assume always the usage of anchor carrier)
      * 2)evaluate the EARFCN value based on the corresponding formula
      */
-    config_INFO->cfg->nfapi_config.earfcn.value = to_earfcn(eutra_band,dl_CarrierFreq, m_dl);
+    config_INFO->cfg->nfapi_config.earfcn.value = to_earfcn_NB_IoT(eutra_band,dl_CarrierFreq, m_dl);
 
 }
 
diff --git a/openair2/LAYER2/MAC/defs_NB_IoT.h b/openair2/LAYER2/MAC/defs_NB_IoT.h
index 8d713da8b2..27b2e1c115 100644
--- a/openair2/LAYER2/MAC/defs_NB_IoT.h
+++ b/openair2/LAYER2/MAC/defs_NB_IoT.h
@@ -233,7 +233,7 @@ typedef struct{
 typedef struct {
 
   /// DCI template and MAC connection parameters for UEs
-  UE_TEMPLATE_NB_IoT UE_template_NB_IoT[NUMBER_OF_UE_MAX_NB_IoT];
+  UE_TEMPLATE_NB_IoT UE_template_NB_IoT[MAX_NUMBER_OF_UE_MAX_NB_IoT];
 
   /// NPDCCH Period and searching space info
   NPDCCH_config_dedicated_NB_IoT_t NPDCCH_config_dedicated;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA_NB_IoT.c b/openair2/LAYER2/MAC/eNB_scheduler_RA_NB_IoT.c
index b3f61d2d85..ae9ab02103 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA_NB_IoT.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA_NB_IoT.c
@@ -480,6 +480,8 @@ void schedule_msg4_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst){
 	schedule_result_t *msg4_result;
 	schedule_result_t *harq_result;
 
+	msg4_node = (available_resource_DL_t *)0;
+
 	//print_available_resource_DL();
 
 	while((RA_TEMPLATE_NB_IoT *)0 != msg4_nodes){
diff --git a/openair2/LAYER2/MAC/proto_NB_IoT.h b/openair2/LAYER2/MAC/proto_NB_IoT.h
index 9f5edd21cb..351a2b4b55 100644
--- a/openair2/LAYER2/MAC/proto_NB_IoT.h
+++ b/openair2/LAYER2/MAC/proto_NB_IoT.h
@@ -97,7 +97,7 @@ void convert_system_number(uint32_t source_sf,uint32_t *hyperSF, uint32_t *frame
 
 uint32_t convert_system_number_sf(uint32_t hyperSF, uint32_t frame, uint32_t subframe);
 
-uint32_t to_earfcn(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl);
+uint32_t to_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_CarrierFreq, float m_dl);
 
 uint32_t from_earfcn_NB_IoT(int eutra_bandP,uint32_t dl_earfcn, float m_dl);
 
diff --git a/openair2/LAYER2/MAC/schedule_tool_NB_IoT.c b/openair2/LAYER2/MAC/schedule_tool_NB_IoT.c
index 4cb0c5d96c..6a00e32028 100644
--- a/openair2/LAYER2/MAC/schedule_tool_NB_IoT.c
+++ b/openair2/LAYER2/MAC/schedule_tool_NB_IoT.c
@@ -179,11 +179,10 @@ void Initialize_Resource(void){
 //	extend subframe align to si-period
 void extend_available_resource_DL(eNB_MAC_INST_NB_IoT *mac_inst, int max_subframe){	//	assume max_subframe is found.
     
-	available_resource_DL_t *pt, *new_node;
+	available_resource_DL_t *new_node;
 	//int temp;
 	uint32_t i, i_div_si_window;
 	//uint32_t si_period_div_window;
-	pt = available_resource_DL;
     
     printf("%d %d\n", max_subframe, mac_inst->schedule_subframe_DL);
     
-- 
2.26.2